Consider a scope and its parents reliable if the vast majority of its
bindings were successfully mapped to generated scope bindings.
343001
function isReliableScope(scope: OriginalScope): boolean {
  let totalBindings = 0;
  let unknownBindings = 0;

  for (let s = scope; s; s = s.parent) {
    const vars = (s.bindings && s.bindings.variables) || {};
    for (const key of Object.keys(vars)) {
      const binding = vars[key];

      totalBindings += 1;
      if (
        binding.value &&
        typeof binding.value === "object" &&
        (binding.value.type === "unscoped" || binding.value.type === "unmapped")
      ) {
        unknownBindings += 1;
      }
    }
  }

  // As determined by fair dice roll.
  return totalBindings === 0 || unknownBindings / totalBindings < 0.25;
}
922919
protected static boolean isLegacyBehaviorRequired(ActivityExecution scopeExecution) {
    // legacy behavior is turned off: the current activity was parsed as scope.
    // now we need to check whether a scope execution was correctly created for the
    // event subprocess.

    // first create the mapping:
    Map<ScopeImpl, PvmExecutionImpl> activityExecutionMapping = scopeExecution.createActivityExecutionMapping();
    // if the scope execution for the current activity is the same as for the parent scope
    // -> we need to perform legacy behavior
    PvmScope activity = scopeExecution.getActivity();
    if (!activity.isScope()) {
      activity = activity.getFlowScope();
    }
    return activityExecutionMapping.get(activity) == activityExecutionMapping.get(activity.getFlowScope());
  }
1175445
def has_scope(context=None):
    '''
    
    '''
    if not booted(context):
        return False
    _sd_version = version(context)
    if _sd_version is None:
        return False
    return _sd_version >= 205
502292
function isDefinedInNestedScope(path, outermostScopeUid) {
  return path.findParent(
    parent =>
      parent.scope.hasOwnBinding(path.node.name) &&
      parent.scope.uid > outermostScopeUid
  );
}
670320
public boolean isContainedBy(@Nonnull PermissionScope s) {
        for (PermissionScope c : scopes) {
            if (c.isContainedBy(s))
                return true;
        }
        return false;
    }
960672
function ensureEvaluated(module, seen, loader) {
      if (module.evaluated || !module.dependencies)
        return;

      seen.push(module);

      var deps = module.dependencies;
      var err;

      for (var i = 0, l = deps.length; i < l; i++) {
        var dep = deps[i];
        if (indexOf.call(seen, dep) == -1) {
          err = ensureEvaluated(dep, seen, loader);
          // stop on error, see https://bugs.ecmascript.org/show_bug.cgi?id=2996
          if (err)
            return err + '\n  in module ' + dep.name;
        }
      }

      if (module.failed)
        return new Error('Module failed execution.');

      if (module.evaluated)
        return;

      module.evaluated = true;
      err = doExecute(module);
      if (err)
        module.failed = true;
      
      // spec variation
      // we don't create a new module here because it was created and ammended
      // we just disable further extensions instead
      if (Object.preventExtensions)
        Object.preventExtensions(module.module);

      module.execute = undefined;
      return err;
    }
1016340
public boolean isUnary() {
		Variable oneVar = this.scope[0];
		for (int i = 1; i < this.scope.length; i++) {
			if (!this.scope[i].equals(oneVar)) return false;
		}
		return true;
	}
1270728
function validateScopeValues(scope, pageCount) {
                // Block where the page is larger than the pageCount
                if (scope.page > pageCount) {
                    scope.page = pageCount;
                }

                // Block where the page is less than 0
                if (scope.page <= 0) {
                    scope.page = 1;
                }

                // Block where adjacent value is 0 or below
                if (scope.adjacent <= 0) {
                    scope.adjacent = 2;
                }

                // Hide from page if we have 1 or less pages
                // if directed to hide empty
                if (pageCount <= 1) {
                    scope.Hide = scope.hideIfEmpty;
                }
            }
157497
private boolean makeComplete( TestCaseDef testCase, VarTupleSet tuples, List<VarDef> vars)
    {
    boolean complete;

    // Test case still missing a required property?
    if( testCase.isSatisfied())
      {
      // No, complete bindings for remaining variables
      complete = completeSatisfied( testCase, tuples, vars);
      }
    else
      {
      // Yes, find tuples that contain satisfying bindings.
      int prevBindings = testCase.getBindingCount();
      Iterator<Tuple> satisfyingTuples = getSatisfyingTuples( testCase, tuples);
      for( complete = false;

           satisfyingTuples.hasNext()
             && !(
               // Does this tuple lead to satisfaction of all current test case conditions?
               makeSatisfied( testCase, tuples, satisfyingTuples.next())

               // Can we complete bindings for remaining variables?
               && (complete = completeSatisfied( testCase, tuples, vars)));

           // No, try next tuple
           testCase.revertBindings( prevBindings));
      }

    return complete;
    }
40702
private boolean verifyDefine(NodeTraversal t, Node parent, Node methodName, Node args) {
    // Calls to goog.define must be in the global hoist scope.  This is copied from
    // validate(Un)aliasablePrimitiveCall.
    // TODO(sdh): loosen this restriction if the results are assigned?
    if (!compiler.getOptions().shouldPreserveGoogModule() && !t.inGlobalHoistScope()) {
      compiler.report(JSError.make(methodName.getParent(), INVALID_CLOSURE_CALL_SCOPE_ERROR));
      return false;
    }

    // It is an error for goog.define to show up anywhere except on its own or immediately after =.
    if (parent.isAssign() && parent.getParent().isExprResult()) {
      parent = parent.getParent();
    } else if (parent.isName() && NodeUtil.isNameDeclaration(parent.getParent())) {
      parent = parent.getParent();
    } else if (!parent.isExprResult()) {
      compiler.report(JSError.make(methodName.getParent(), INVALID_CLOSURE_CALL_SCOPE_ERROR));
      return false;
    }

    // Verify first arg
    Node arg = args;
    if (!verifyNotNull(methodName, arg) || !verifyOfType(methodName, arg, Token.STRING)) {
      return false;
    }

    // Verify second arg
    arg = arg.getNext();
    if (!args.isFromExterns()
        && (!verifyNotNull(methodName, arg) || !verifyIsLast(methodName, arg))) {
      return false;
    }

    String name = args.getString();
    if (!NodeUtil.isValidQualifiedName(
        compiler.getOptions().getLanguageIn().toFeatureSet(), name)) {
      compiler.report(JSError.make(args, INVALID_DEFINE_NAME_ERROR, name));
      return false;
    }

    JSDocInfo info = (parent.isExprResult() ? parent.getFirstChild() : parent).getJSDocInfo();
    if (info == null || !info.isDefine()) {
      compiler.report(JSError.make(parent, MISSING_DEFINE_ANNOTATION));
      return false;
    }
    return true;
  }
6253
function evaluateState(state, instance, message) {
    var result = false;
    // delegate to child regions first if a non-continuation
    if (message !== state) {
        state.regions.every(function (region) {
            var currentState = instance.getLastKnownState(region);
            if (currentState && evaluateState(currentState, instance, message)) {
                result = true;
                return isActive(state, instance); // NOTE: this just controls the every loop; also isActive is a litte costly so using sparingly
            }
            return true; // NOTE: this just controls the every loop
        });
    }
    // if a transition occured in a child region, check for completions
    if (result) {
        if ((message !== state) && isComplete(state, instance)) {
            evaluateState(state, instance, state);
        }
    }
    else {
        // otherwise look for a transition from this state
        var transitions = state.outgoing.filter(function (transition) { return transition.guard(message, instance); });
        if (transitions.length === 1) {
            // execute if a single transition was found
            result = traverse(transitions[0], instance, message);
        }
        else if (transitions.length > 1) {
            // error if multiple transitions evaluated true
            exports.console.error(state + ": multiple outbound transitions evaluated true for message " + message);
        }
    }
    return result;
}
252691
def could_scope_out(self):
        
        return not self.waiting_for or \
               isinstance(self.waiting_for, callable.EndOfStory) or \
               self.is_breaking_a_loop()
308466
def trust(self, scope, vk):
        """"""
        self.data['verifiers'].append({'scope': scope, 'vk': vk})
        return self
221378
protected function hasListifyScopeChanged()
    {
        $scope = $this->normalizeListifyScope($this->getScopeName(), true);

        if ($scope instanceof BelongsTo) {
            // for BelongsTo scopes, use a cleaner way to check for differences
            $foreignKey = $scope->getForeignKeyName();
            return (Arr::get($this->getOriginal(), $foreignKey) != $this->getAttribute($foreignKey));
        }

        if (null === $this->stringScopeValue && ! $this->stringScopeNullExplicitlySet) {

            // if the known previous scope is null, make sure this isn't the result of a
            // variable scope that returned null - if that is the case, the scope has changed
            if (null !== $scope && $this->hasVariableListifyScope()) {
                
                $this->swapChangedAttributes();
                $previousScope = $this->normalizeListifyScope($this->getScopeName());
                $this->swapChangedAttributes();
                
                if (null === $previousScope) return true;
            }

            $this->stringScopeValue = $scope;
            $this->stringScopeNullExplicitlySet = (null === $scope);
            return false;
        }

        return ($scope != $this->stringScopeValue);
    }
262318
function() {
		var lastScope;

		// find the first reference scope
		var templateContext = this.getScope(function(scope) {
			lastScope = scope;
			return scope._context instanceof TemplateContext;
		});

		// if there is no reference scope, add one as the root
		if(!templateContext) {
			templateContext = new Scope(new TemplateContext());

			// add templateContext to root of the scope chain so it
			// can be found using `getScope` next time it is looked up
			lastScope._parent = templateContext;
		}
		return templateContext;
	}
537519
function Scope(node, parent, scope, state) {
    // check if this scope has a local binding that will shadow the rest parameter
    if (!scope.bindingIdentifierEquals(state.name, state.outerBinding)) {
      this.skip();
    }
  }
1214752
function safeEval(src, parentContext){
  var tree = prepareAst(src)
  var context = Object.create(parentContext || {})
  return finalValue(evaluateAst(tree, context))
}