Compile DependencyInstance
325570
private function getInstanceCode(Instance $instance) : Code
    {
        $node = ($this->normalizer)($instance->value);

        return new Code(new Node\Stmt\Return_($node), false);
    }
363367
function preR3InjectableCompile(injectableType, options) {
    if (options && options.providedIn !== undefined && injectableType.ngInjectableDef === undefined) {
        injectableType.ngInjectableDef = defineInjectable({
            providedIn: options.providedIn,
            factory: convertInjectableProviderToFactory(injectableType, options),
        });
    }
}
1177183
void compileClass(Source javaSource, Source javaClass,
                    String sourcePath, boolean isMake)
    throws ClassNotFoundException
  {
    try {
      JavaCompilerUtil compiler = JavaCompilerUtil.create(getClassLoader());
      compiler.setClassDir(_classDir);
      compiler.setSourceDir(_sourceDir);
      if (_encoding != null)
        compiler.setEncoding(_encoding);
      compiler.setArgs(_args);
      compiler.setCompileParent(! isMake);
      compiler.setSourceExtension(_sourceExt);
      if (_compiler != null)
        compiler.setCompiler(_compiler);

      //LineMap lineMap = new LineMap(javaFile.getNativePath());
      // The context path is obvious from the browser url
      //lineMap.add(name.replace('.', '/') + _sourceExt, 1, 1);

      // Force this into a relative path so different compilers will work
      String prefix = _sourceDir.getPath();
      String full = javaSource.getPath();

      String source;
      if (full.startsWith(prefix)) {
        source = full.substring(prefix.length());
        if (source.startsWith("/"))
          source = source.substring(1);
      }
      else
        source = javaSource.getPath();

      /*
      if (javaSource.canRead() && javaClass.exists())
        javaClass.remove();
      */
          
      compiler.compileIfModified(source, null);
    } catch (Exception e) {
      //getClassLoader().addDependency(new Depend(javaSource));

      log.log(Level.FINEST, e.toString(), e);

      // Compile errors are wrapped in a special ClassNotFound class
      // so the server can give a nice error message
      throw new CompileClassNotFound(e);
    }
  }
167670
private function preparePrototypeBindingClosure($id, $blueprint, $dependencies): Closure
    {
        if ($blueprint instanceof ReflectionClass) {
            return $this->cache[$id] = function () use ($blueprint, $dependencies) {
                foreach ($dependencies as $key => $dependency) {
                    if ($dependency instanceof Closure) {
                        $dependencies[$key] = $dependency();
                    }
                }

                return $blueprint->newInstanceArgs($dependencies);
            };
        }
        if ($blueprint instanceof Closure) {
            return $this->cache[$id] = $blueprint;
        }

        return $this->cache[$id] = function () use ($blueprint) {
            return new $blueprint;
        };
    }
1294719
private Object getBindingObjectInstance(Context c, Hashtable<?, ?> envmt, String className, ResourceInfo resourceRefInfo, Reference bindingRef, InjectionBinding<?> binding) throws Exception {
        Object bindingObject = binding.getBindingObject();
        if (bindingObject instanceof Reference) {
            // Handle special Reference.
            Reference ref = (Reference) bindingObject;

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "ref=" + ref.getClass().getName() + ", factory=" + ref.getFactoryClassName());

            if (ref == bindingRef) {
                throw new InjectionException(Tr.formatMessage(tc, "INDIRECT_LOOKUP_LOOP_CWNEN1008E"));
            }

            // A resource-ref to a data-source.  Propagate resource-ref info.
            if (ref instanceof ResourceFactoryReference) {
                ResourceFactoryReference factoryRef = (ResourceFactoryReference) ref;
                ResourceFactory factory = factoryRef.getResourceFactory();

                return factory.createResource(resourceRefInfo);
            }

            // An indirect reference to another indirect reference (e.g.,
            // resource-ref to data-source override).  Propagate resource-ref
            // info if necessary.
            if (ref instanceof IndirectReference) {
                IndirectReference indirectRef = (IndirectReference) ref;
                String refBindingName = indirectRef.bindingName;

                // resource-ref1 -> resource-ref2 -> data-source should use
                // resource-ref2's info.

                String refClassName = ref.getClassName();
                if (refClassName == null) {
                    refClassName = className;
                }

                ResourceInfo refResourceRefInfo = indirectRef.resourceInfo;
                if (refResourceRefInfo == null) {
                    refResourceRefInfo = resourceRefInfo;
                }

                return getObjectInstance(c, envmt, refClassName, refBindingName, refResourceRefInfo, indirectRef);
            }
        }

        // We could return null and use InitialContext.lookup, but that will
        // eventually call InjectionBinding.getInjectionObject anyway (assuming
        // non-conflicting JavaColonNamingHelper), so we might as well just make
        // the call while we have the InjectionBinding.  This also allows
        // @Resource(lookup="java:...") to work even if JNDI is disabled.
        return binding.getInjectionObject();
    }
830262
function CompileModules(inputTree, options) {
    if (!(this instanceof CompileModules)) {
        return new CompileModules(inputTree, options);
    }

    options || (options = {});

    var formatter = options.formatter;

    if (!formatter) {
        formatter = transpiler.formatters.DEFAULT;
    }

    if (typeof formatter === 'string') {
        formatter = transpiler.formatters[formatter];
    }

    var resolverClasses = options.resolvers;

    if (!resolverClasses) {
        resolverClasses = [ FileResolver ];
    }

    this.inputTree       = inputTree;
    this.resolverClasses = resolverClasses;
    this.formatter       = formatter;
    this.output          = options.output || '.';
    this.basePath        = options.basePath;
    this.sourceRoot      = options.sourceRoot || '/';
    this.description     = options.description;

    this._cache = {};
}
629883
public static CompiledScript compile(ScriptEngine engine, String script) throws ScriptException {
		if (engine instanceof Compilable) {
			Compilable compEngine = (Compilable) engine;
			return compEngine.compile(script);
		}
		return null;
	}
938912
function getConstructorInterface(namespace, module) {

    var methods = [];


    // Add the main chainable type.

    var chainableGenerics = getChainableBaseGenerics(namespace.name)
    var chainableType = 'ChainableBase' + chainableGenerics;

    if (namespace.name !== 'Object') {
      chainableType += ' & Object.ChainableBase' + getChainableBaseGenerics('Object');
    }
    module.types.push({
      name: 'Chainable' + chainableGenerics,
      type: chainableType
    });


    // Set up constructor methods.

    var rawType = getRawType(namespace.name);

    var constructorMethod = {
      name: 'new',
      type: 'constructor',
      module: namespace.name,
      generics: getNamespaceBaseGenerics(namespace.name),
      returns: 'Chainable' + getChainableInstanceGenerics(namespace.name),
      params: [{
        name: 'raw',
        type: rawType
      }]
    };

    var createMethod = namespace.methods.find(function(method) {
      return method.name === 'create';
    });

    if (createMethod) {
      // If the namespace has a "create" method, then it will be mapped
      // to the chainable constructor, so accomodate for that here.
      constructorMethod.params = createMethod.params;
      constructorMethod.params[0].required = false;
    }

    var factoryMethod = clone(constructorMethod);
    factoryMethod.name = '';

    methods.push(constructorMethod);
    methods.push(factoryMethod);


    // Set up all remaining methods.

    namespace.methods.forEach(function(method) {
      var instanceParam = {
        name: 'instance',
        required: true,
        type: getInstanceParamType(method, rawType)
      };
      var method = clone(method);
      if (method.type === 'instance') {
        method.params.unshift(instanceParam);
        if (method.signatures) {
          method.signatures.forEach(function(signature) {
            signature.unshift(instanceParam);
          });
        }
        if (namespace.name === 'Array') {
          method.generics = ['T'];
        }
      }
      methods.push(method);
    });

    methods = buildMethods(methods, namespace, 'static');
    return getInterfaceSource('Constructor', methods.join('\n'), null, 'SugarNamespace');
  }
40636
function (options, callback) {
        options = extend({}, DEPENDENCY_WRITE_DEFAULTS, options)
        var json = require(options.jsonUri)

        // the JSON DSL has the option to have "/foo" in <moduleNameLeft>
        after.reduce(json, createFoldersIntoFilesIterator(options.uri), 
            {}, runDependencyMapper)

        function runDependencyMapper(err, data) {
            if (err) {
                return callback(err)
            }
            after.map(data, mapToDependencies, callback)
        }

        function mapToDependencies(dependencies, moduleName, callback) {
            if (isFile.test(moduleName)) {
                // the JSON DSL has the option to have "/foo" or ["/foo"]
                // in <moduleNameRight>.
                after.map(dependencies, createConvertToProxyNameIterator({
                    moduleName: moduleName,
                    uri: options.uri
                }), callback)
            }
        }
    }
1347050
public static void compile(Class<?> cls, File outputPath) {
        if (outputPath == null) {
            throw new NullPointerException("Param 'outputPath' is null.");
        }
        if (!outputPath.isDirectory()) {
            throw new RuntimeException("Param 'outputPath' value should be a path directory. path=" + outputPath);
        }

    }
629999
private static void addDependencyFactoryToContainer(Object dependencyFactory) {
        try {
            Class clazz = dependencyFactory.getClass();
            for (Field field : ReflectionHelper.getFields(clazz)) {
                if (field.isAnnotationPresent(Dependency.class)) {
                    qualifiers.clear();
                    for (Annotation annotation : field.getAnnotations()) {
                        if (annotation.annotationType().isAnnotationPresent(Qualifier.class)) {
                            qualifiers.add(annotation.annotationType().getCanonicalName());
                        }
                    }
                    dependencyContainer.add(DependencyIdentifier
                                    .getDependencyIdentifierForClass(field, qualifiers),
                            new DependencySource(DependencySource.DependencySourceType.FIELD,
                                    field,
                                    null,
                                    dependencyFactory,
                                    field.isAnnotationPresent(Singleton.class)));
                }
            }
            for (Method method : clazz.getMethods()) {
                if (method.isAnnotationPresent(Dependency.class)) {
                    qualifiers.clear();
                    for (Annotation annotation : method.getAnnotations()) {
                        if (annotation.annotationType().isAnnotationPresent(Qualifier.class)) {
                            qualifiers.add(annotation.annotationType().getCanonicalName());
                        }
                    }
                    dependencyContainer.add(DependencyIdentifier
                                    .getDependencyIdentifierForClass(method, qualifiers),
                            new DependencySource(DependencySource.DependencySourceType.METHOD,
                                    null,
                                    method,
                                    dependencyFactory,
                                    method.isAnnotationPresent(Singleton.class)));
                }
            }
        } catch (Exception e) {
            throw new AvicennaRuntimeException(e);
        }
    }
183310
@Requires({
    "sourceDependencyLoader != null",
    "type != null"
  })
  @Ensures({
    "importNames != null",
    "rootLineNumberIterator != null"
  })
  @SuppressWarnings("unchecked")
  protected void fetchSourceDependency() throws IOException {
    String fileName = type.getName().getBinaryName()
        + JavaUtils.SOURCE_DEPENDENCY_EXTENSION;
    InputStream in =
        sourceDependencyLoader.getResourceAsStream(fileName);
    if (in == null) {
      throw new FileNotFoundException();
    }
    ObjectInputStream oin = new ObjectInputStream(in);
    try {
      importNames = (Set<String>) oin.readObject();
      rootLineNumberIterator = ((List<Long>) oin.readObject()).iterator();
    } catch (ClassNotFoundException e) {
      throw new IOException(e);
    }
    oin.close();
  }
160440
private void generateInjectAdapter(TypeElement type, ExecutableElement constructor,
      List<Element> fields) throws IOException {
    String packageName = getPackage(type).getQualifiedName().toString();
    TypeMirror supertype = getApplicationSupertype(type);
    if (supertype != null) {
      supertype = processingEnv.getTypeUtils().erasure(supertype);
    }
    ClassName injectedClassName = ClassName.get(type);
    ClassName adapterClassName = adapterName(injectedClassName, INJECT_ADAPTER_SUFFIX);

    boolean isAbstract = type.getModifiers().contains(ABSTRACT);
    boolean injectMembers = !fields.isEmpty() || supertype != null;
    boolean disambiguateFields = !fields.isEmpty()
        && (constructor != null)
        && !constructor.getParameters().isEmpty();
    boolean dependent = injectMembers
        || ((constructor != null) && !constructor.getParameters().isEmpty());

    TypeSpec.Builder result = TypeSpec.classBuilder(adapterClassName.simpleName())
        .addOriginatingElement(type)
        .addModifiers(PUBLIC, FINAL)
        .superclass(ParameterizedTypeName.get(ClassName.get(Binding.class), injectedClassName))
        .addJavadoc("$L", bindingTypeDocs(injectableType(type.asType()), isAbstract,
            injectMembers, dependent).toString());

    for (Element field : fields) {
      result.addField(memberBindingField(disambiguateFields, field));
    }
    if (constructor != null) {
      for (VariableElement parameter : constructor.getParameters()) {
        result.addField(parameterBindingField(disambiguateFields, parameter));
      }
    }
    if (supertype != null) {
      result.addField(supertypeBindingField(supertype));
    }

    result.addMethod(writeInjectAdapterConstructor(constructor, type, injectedClassName));
    if (dependent) {
      result.addMethod(attachMethod(
          constructor, fields, disambiguateFields, injectedClassName, supertype, true));
      result.addMethod(getDependenciesMethod(
          constructor, fields, disambiguateFields, supertype, true));
    }
    if (constructor != null) {
      result.addMethod(
          getMethod(constructor, disambiguateFields, injectMembers, injectedClassName));
    }
    if (injectMembers) {
      result.addMethod(
          membersInjectMethod(fields, disambiguateFields, injectedClassName, supertype));
    }

    JavaFile javaFile = JavaFile.builder(packageName, result.build())
        .addFileComment(AdapterJavadocs.GENERATED_BY_DAGGER)
        .build();
    javaFile.writeTo(processingEnv.getFiler());
  }
230695
public static void addDependencyFactory(Class... dependencyFactoryClasses) {
        for (Class dependencyFactoryClass : dependencyFactoryClasses) {
            if (!dependencyFactoryClass.isAnnotationPresent(DependencyFactory.class)) {
                throw new AvicennaRuntimeException(
                        dependencyFactoryClass + " should be annotated with DependencyFactory.");
            }
            if (Avicenna.dependencyFactories.contains(dependencyFactoryClass)) {
                throw new AvicennaRuntimeException(
                        dependencyFactoryClass + " has already been added to container.");
            }
            try {
                addDependencyFactoryToContainer(dependencyFactoryClass.newInstance());
                Avicenna.dependencyFactories.add(dependencyFactoryClass);
            } catch (InstantiationException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
    }
401858
@Override
    public ObjectData compileObjectType(Set<String> filter, Boolean includeAllowableActions,
            ObjectInfoHandler objectInfos, boolean requiresObjectInfo) {

        try {
            ObjectDataImpl result = new ObjectDataImpl();
            ObjectInfoImpl objectInfo = new ObjectInfoImpl();

            PropertiesImpl properties = new PropertiesImpl();
            filter = filter == null ? null : new HashSet<>(filter);
            compileProperties(properties, filter, objectInfo);
            result.setProperties(properties);

            if (Boolean.TRUE.equals(includeAllowableActions)) {
                result.setAllowableActions(getAllowableActions());
            }

            if (requiresObjectInfo) {
                objectInfo.setObject(result);
                objectInfos.addObjectInfo(objectInfo);
            }

            return result;
        } catch (RepositoryException e) {
            throw new CmisRuntimeException(e.getMessage(), e);
        }
    }
1293962
public Output compile(FileContext context, ImportStack importStack) throws CompilationException {
    NativeFileContext nativeContext = convertToNativeContext(context, importStack);
    return compileFile(nativeContext);
  }
1071331
protected function loadDependencyInObject($object, $property, $dependencyName, $dependencyDefinition){
        $dependency= $this->loadDependency($dependencyName, $dependencyDefinition);
        $reflection= new Reflection($object);
        $reflection->setProperty($property, $dependency, TRUE);
    }