Creates the scope creator used by this pass. If not in validity check mode, use a {@link
RedeclarationCheckHandler} to check var redeclarations.
965225
private Es6SyntacticScopeCreator createScopeCreator() {
    if (validityCheck) {
      return new Es6SyntacticScopeCreator(compiler);
    } else {
      dupHandler = new RedeclarationCheckHandler();
      return new Es6SyntacticScopeCreator(compiler, dupHandler);
    }
  }
916036
protected final MethodSpec newGetter(Strength strength, TypeName varType,
      String varName, Visibility visibility) {
    MethodSpec.Builder getter = MethodSpec.methodBuilder("get" + capitalize(varName))
        .addModifiers(context.publicFinalModifiers())
        .returns(varType);
    String type;
    if (varType.isPrimitive()) {
      type = varType.equals(TypeName.INT) ? "Int" : "Long";
    } else {
      type = "Object";
    }
    if (strength == Strength.STRONG) {
      if (visibility.isRelaxed) {
        if (varType.isPrimitive()) {
          getter.addStatement("return $T.UNSAFE.get$N(this, $N)",
              UNSAFE_ACCESS, type, offsetName(varName));
        } else {
          getter.addStatement("return ($T) $T.UNSAFE.get$N(this, $N)",
              varType, UNSAFE_ACCESS, type, offsetName(varName));
        }
      } else {
        getter.addStatement("return $N", varName);
      }
    } else {
      if (visibility.isRelaxed) {
        getter.addStatement("return (($T<$T>) $T.UNSAFE.get$N(this, $N)).get()",
            Reference.class, varType, UNSAFE_ACCESS, type, offsetName(varName));
      } else {
        getter.addStatement("return $N.get()", varName);
      }
    }
    return getter.build();
  }
203469
public MethodType<MethodPermissionType<T>> getOrCreateMethod()
   {
      List<Node> nodeList = childNode.get("method");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new MethodTypeImpl<MethodPermissionType<T>>(this, "method", childNode, nodeList.get(0));
      }
      return createMethod();
   }
1324010
public static VarBinding create( IVarDef varDef, VarValueDef valueDef)
    {
    VarBinding binding = 
      valueDef.isNA()
      ? new VarNaBinding( varDef.getPathName(), varDef.getType())
      : new VarBinding( varDef.getPathName(), varDef.getType(), valueDef.getName());

    binding.setValueValid( valueDef.isValid());
    binding.setVarDef( varDef);

    return binding;
    }
1121283
private LocalVariableDefinition constructUnionInstance(MethodDefinition read)
    {
        LocalVariableDefinition instance = read.addLocalVariable(structType, "instance");

        // create the new instance (or builder)
        if (metadata.getBuilderClass() == null) {
            read.newObject(structType).dup();
        }
        else {
            read.newObject(metadata.getBuilderClass()).dup();
        }

        // switch (fieldId)
        read.loadVariable("fieldId");

        List<CaseStatement> cases = new ArrayList<>();
        for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
            if (field.getConstructorInjection().isPresent()) {
                cases.add(caseStatement(field.getId(), field.getName() + "-id-field"));
            }
        }
        read.switchStatement("no-field-ctor", cases);

        for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
            if (field.getConstructorInjection().isPresent()) {
                // case fieldId:
                read.visitLabel(field.getName() + "-id-field");

                // Load the read value
                read.loadVariable("f_" + field.getName());
                read.invokeConstructor(field.getConstructorInjection().get().getConstructor())
                        .storeVariable(instance)
                        .gotoLabel("instance-ok");
            }
        }

        read.visitLabel("no-field-ctor");

        // No args c'tor present.
        if (metadata.getConstructorInjection().isPresent()) {
            ThriftConstructorInjection constructor = metadata.getConstructorInjection().get();
            // invoke constructor
            read.invokeConstructor(constructor.getConstructor())
                    .storeVariable(instance);
        }
        else {
            read.pop() // get rid of the half-constructed element
                    .loadConstant(metadata.getStructClass())
                    .loadVariable("fieldId")
                    .invokeStatic(SwiftBytecodeHelper.NO_CONSTRUCTOR_FOUND)
                    .throwException();
        }
        read.visitLabel("instance-ok");

        return instance;
    }
45767
public static <IN, OUT> OUT create(IN obj, Creator<IN, OUT> creator) {
        return obj == null ? null : creator.create(obj);
    }
571135
public static <Q> LocklessLazyVar<Q> make( final LazyVarInit<Q> closure ) {
    return new LocklessLazyVar<Q>(){
      protected Q init()
      {
        return closure.init();
      }
    };
  }
229395
public boolean createChildScope(String name) {
        // quick lookup by name
        log.debug("createChildScope: {}", name);
        if (children.hasName(name)) {
            log.debug("Scope: {} already exists, children: {}", name, children.getNames());
        } else {
            return addChildScope(new Builder(this, ScopeType.ROOM, name, false).build());
        }
        return false;
    }
1066874
static ExpressionToSoyValueProviderCompiler create(
      TemplateVariableManager varManager,
      ExpressionCompiler exprCompiler,
      TemplateParameterLookup variables) {
    return new ExpressionToSoyValueProviderCompiler(varManager, exprCompiler, variables);
  }
1044363
public void makeScope(IScope scope) {
        log.debug("makeScope: {}", scope);
        String path = scope.getContextPath();
        WebSocketScope wsScope = null;
        if (!scopes.containsKey(path)) {
            // add the name to the collection (no '/' prefix)
            activeRooms.add(scope.getName());
            // new websocket scope for the server scope
            wsScope = new WebSocketScope();
            wsScope.setPath(path);
            wsScope.setScope(scope);
            notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
            addWebSocketScope(wsScope);
            log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
        } else {
            log.debug("Scope already exists: {}", path);
        }
    }
885532
@VisibleForTesting
  TypedScope createInitialScope(Node root) {
    checkArgument(root.isRoot(), root);

    NodeTraversal.traverse(
        compiler,
        root,
        new IdentifyGlobalEnumsAndTypedefsAsNonNullable(typeRegistry, codingConvention));

    TypedScope s = TypedScope.createGlobalScope(root);
    declareNativeFunctionType(s, ARRAY_FUNCTION_TYPE);
    declareNativeFunctionType(s, BOOLEAN_OBJECT_FUNCTION_TYPE);
    declareNativeFunctionType(s, DATE_FUNCTION_TYPE);
    declareNativeFunctionType(s, FUNCTION_FUNCTION_TYPE);
    declareNativeFunctionType(s, GENERATOR_FUNCTION_TYPE);
    declareNativeFunctionType(s, ITERABLE_FUNCTION_TYPE);
    declareNativeFunctionType(s, ITERATOR_FUNCTION_TYPE);
    declareNativeFunctionType(s, NUMBER_OBJECT_FUNCTION_TYPE);
    declareNativeFunctionType(s, OBJECT_FUNCTION_TYPE);
    declareNativeFunctionType(s, REGEXP_FUNCTION_TYPE);
    declareNativeFunctionType(s, STRING_OBJECT_FUNCTION_TYPE);
    declareNativeValueType(s, "undefined", VOID_TYPE);

    gatherAllProvides(root);

    return s;
  }
808926
private E createUsingConstructor() throws CheckedAnalysisException {
        Constructor<E> constructor;
        try {
            constructor = databaseClass.getConstructor(new Class[0]);
        } catch (NoSuchMethodException e) {
            return null;
        }

        try {
            return constructor.newInstance(new Object[0]);
        } catch (InstantiationException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        } catch (IllegalAccessException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        } catch (InvocationTargetException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        }
    }
460651
public TypeUsage.Builder nullableScope(QualifiedName scope) {
    if (scope != null) {
      return scope(scope);
    } else {
      return clearScope();
    }
  }
259764
public void pushVariableScope(VariableScope el) {
        pushState();
        scope = el;
        superBlockNamedLabels = new HashMap(superBlockNamedLabels);
        superBlockNamedLabels.putAll(currentBlockNamedLabels);
        currentBlockNamedLabels = new HashMap();
    }
520825
private LocalVariableScope calculateScope(LocalVariableScopeData scope) {
		final TryCatchBlockLabels enclosingTry = getEnclosingTry(scope);
		final Label start = scope.labels.start;
		final Label end = getTryFixedEndLabel(scope, enclosingTry);
		
		int startIndex = getIndex(start);
		int endIndex = getIndex(end);
		
		LocalVariableScopeData.LineNumbers scopeWithLineNumbers = getLineNumbers(scope, enclosingTry, start, end);
		
		return new LocalVariableScope(scope.var, scope.name, VariableType.getByDesc(scope.desc), scopeWithLineNumbers.startLine, scopeWithLineNumbers.endLine, startIndex, endIndex, getVarReferencesBeforeStart(scope));
	}
429788
protected void setVariable(String variableName, Object value, ExecutionEntity sourceExecution, boolean fetchAllVariables) {

    if (fetchAllVariables == true) {

      // If it's in the cache, it's more recent
      if (usedVariablesCache.containsKey(variableName)) {
        updateVariableInstance(usedVariablesCache.get(variableName), value, sourceExecution);
      }

      // If the variable exists on this scope, replace it
      if (hasVariableLocal(variableName)) {
        setVariableLocal(variableName, value, sourceExecution, true);
        return;
      }

      // Otherwise, go up the hierarchy (we're trying to put it as high as possible)
      VariableScopeImpl parentVariableScope = getParentVariableScope();
      if (parentVariableScope != null) {
        if (sourceExecution == null) {
          parentVariableScope.setVariable(variableName, value);
        } else {
          parentVariableScope.setVariable(variableName, value, sourceExecution, true);
        }
        return;
      }

      // We're as high as possible and the variable doesn't exist yet, so
      // we're creating it
      if (sourceExecution != null) {
        createVariableLocal(variableName, value, sourceExecution);
      } else {
        createVariableLocal(variableName, value);
      }

    } else {

      // Check local cache first
      if (usedVariablesCache.containsKey(variableName)) {

        updateVariableInstance(usedVariablesCache.get(variableName), value, sourceExecution);

      } else if (variableInstances != null && variableInstances.containsKey(variableName)) {

        updateVariableInstance(variableInstances.get(variableName), value, sourceExecution);

      } else {

        // Not in local cache, check if defined on this scope
        // Create it if it doesn't exist yet
        VariableInstanceEntity variable = getSpecificVariable(variableName);
        if (variable != null) {
          updateVariableInstance(variable, value, sourceExecution);
          usedVariablesCache.put(variableName, variable);
        } else {

          VariableScopeImpl parent = getParentVariableScope();
          if (parent != null) {
            if (sourceExecution == null) {
              parent.setVariable(variableName, value, fetchAllVariables);
            } else {
              parent.setVariable(variableName, value, sourceExecution, fetchAllVariables);
            }

            return;
          }

          variable = createVariableInstance(variableName, value, sourceExecution);
          usedVariablesCache.put(variableName, variable);

        }

      }

    }

  }
1015172
private MethodSpec makeSetValue() {
    MethodSpec.Builder setter = MethodSpec.methodBuilder("setValue")
        .addModifiers(context.publicFinalModifiers())
        .addParameter(vTypeVar, "value")
        .addParameter(vRefQueueType, "referenceQueue");

    if (isStrongValues()) {
      setter.addStatement("$T.UNSAFE.putObject(this, $N, $N)",
          UNSAFE_ACCESS, offsetName("value"), "value");
    } else {
      setter.addStatement("(($T<V>) getValueReference()).clear()", Reference.class);
      setter.addStatement("$T.UNSAFE.putObject(this, $N, new $T($L, $N, referenceQueue))",
          UNSAFE_ACCESS, offsetName("value"), valueReferenceType(), "getKeyReference()", "value");
    }

    return setter.build();
  }