Allows evaluation of another rule while evaluating a rule.

    :param ctxt: The evaluation context for the rule.
    :param name: The name of the rule to evaluate.
437231
def rule(ctxt, name):
    

    # If the result of evaluation is in the rule cache, bypass
    # evaluation
    if name in ctxt.rule_cache:
        ctxt.stack.append(ctxt.rule_cache[name])
        return

    # Obtain the rule we're to evaluate
    try:
        rule = ctxt.policy[name]
    except KeyError:
        # Rule doesn't exist; log a message and assume False
        log = logging.getLogger('policies')
        log.warn("Request to evaluate non-existant rule %r "
                 "while evaluating rule %r" % (name, ctxt.name))
        ctxt.stack.append(False)
        ctxt.rule_cache[name] = False
        return

    # Evaluate the rule, stopping at the set_authz instruction
    with ctxt.push_rule(name):
        rule.instructions(ctxt, True)

    # Cache the result
    ctxt.rule_cache[name] = ctxt.stack[-1]
272691
def visitLexerAtom(self, ctx: jsgParser.LexerAtomContext):
        
        if ctx.LEXER_CHAR_SET() or ctx.ANY():
            self._rulePattern += str(ctx.getText())
        else:
            self.visitChildren(ctx)
167005
def invoke_function(self, ctx, name, arguments):
        
        from temba_expressions import EvaluationError, conversions

        # find function with given name
        func = self.get_function(name)
        if func is None:
            raise EvaluationError("Undefined function: %s" % name)

        args, varargs, defaults = self._get_arg_spec(func)

        call_args = []
        passed_args = list(arguments)

        for arg in args:
            if arg == 'ctx':
                call_args.append(ctx)
            elif passed_args:
                call_args.append(passed_args.pop(0))
            elif arg in defaults:
                call_args.append(defaults[arg])
            else:
                raise EvaluationError("Too few arguments provided for function %s" % name)

        if varargs is not None:
            call_args.extend(passed_args)
            passed_args = []

        # any unused arguments?
        if passed_args:
            raise EvaluationError("Too many arguments provided for function %s" % name)

        try:
            return func(*call_args)
        except Exception as e:
            pretty_args = []
            for arg in arguments:
                if isinstance(arg, str):
                    pretty = '"%s"' % arg
                else:
                    try:
                        pretty = conversions.to_string(arg, ctx)
                    except EvaluationError:
                        pretty = str(arg)
                pretty_args.append(pretty)

            raise EvaluationError("Error calling function %s with arguments %s" % (name, ', '.join(pretty_args)), e)
460446
function(context, name) {

                    var method = typeof name === "string" ? context[name] : name;

                    if (!isFunction(method)) {
                        method = context[method];
                    }

                    return function() {
                        context.called = name;
                        return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0)));
                    };
                }
1102223
def do_define(self, t):
        
        _, name, args, expansion = t
        try:
            expansion = int(expansion)
        except (TypeError, ValueError):
            pass
        if args:
            evaluator = FunctionEvaluator(name, args[1:-1], expansion)
            self.cpp_namespace[name] = evaluator
        else:
            self.cpp_namespace[name] = expansion
642548
def get_rule_id_from_name(self, name):
        
        results = self.client.call('SoftLayer_Virtual_PlacementGroup_Rule', 'getAllObjects')
        return [result['id'] for result in results if result['keyName'] == name.upper()]
964487
def add_context(self, name, context, prefix_char=None):
        
        if name in self.contexts:
            raise SuiteError("Context already in suite: %r" % name)
        if not context.success:
            raise SuiteError("Context is not resolved: %r" % name)

        self.contexts[name] = dict(name=name,
                                   context=context.copy(),
                                   tool_aliases={},
                                   hidden_tools=set(),
                                   priority=self._next_priority,
                                   prefix_char=prefix_char)
        self._flush_tools()
879962
def visitQualifier(self, ctx: ShExDocParser.QualifierContext):
        
        if ctx.includeSet():
            if self.shape.inherit is None:
                self.shape.inherit = []
            self.shape.inherit += [self.context.tripleexprlabel_to_iriref(tel)
                                   for tel in ctx.includeSet().tripleExpressionLabel()]
        elif ctx.extraPropertySet():
            if self.shape.extra is None:
                self.shape.extra = []
            self.shape.extra += [self.context.predicate_to_IRI(p) for p in ctx.extraPropertySet().predicate()]

        elif ctx.KW_CLOSED():
            self.shape.closed = True
378235
def _execute_rules(self, matches, context):
        
        if not self.disabled(context):
            rules = self.effective_rules(context)
            rules.execute_all_rules(matches, context)
1160942
def visitFunctionCall(self, ctx):
        
        func_name = ctx.fnname().getText()

        if ctx.parameters() is not None:
            parameters = self.visit(ctx.parameters())
        else:
            parameters = []

        return self._functions.invoke_function(self._eval_context, func_name, parameters)
134842
def select_by_name(self, name):
        
        for a, li, holder in self._tabs.values():
            if a.children['text'] == name:
                self._on_tab_pressed(a, li, holder)
                return
402747
function(name, context) {
      name = this.trim(name);

      // Checks whether a value is thruthy or false or 0
      function is_kinda_truthy(bool) {
        return bool === false || bool === 0 || bool;
      }

      var value;
      
      // check for dot notation eg. foo.bar
      if(name.match(/([a-z_]+)\./ig)){
        var childValue = this.walk_context(name, context);
        if(is_kinda_truthy(childValue)) {
          value = childValue;
        }
      }
      else{
        if(is_kinda_truthy(context[name])) {
          value = context[name];
        } else if(is_kinda_truthy(this.context[name])) {
          value = this.context[name];
        }
      }

      if(typeof value === "function") {
        return value.apply(context);
      }
      if(value !== undefined) {
        return value;
      }
      // silently ignore unkown variables
      return "";
    }
827706
@Override
	public Value evaluate(String line, Context ctxt) throws Exception
	{
		PExp expr = parseExpression(line, getDefaultName());
		PublicClassEnvironment globals = new PublicClassEnvironment(assistantFactory, classes, null);
		Environment env = new PrivateClassEnvironment(assistantFactory, defaultClass, globals);

		try
		{
			typeCheck(expr, env);
		} catch (VDMErrorsException e)
		{
			// We don't care... we just needed to type check it.
		}

		ctxt.threadState.init();
		try
		{
			return expr.apply(VdmRuntime.getExpressionEvaluator(), ctxt);
		} catch (Exception e)
		{
			throw e;
		}
	}
648424
def _try_compile(source, name):
    
    try:
        c = compile(source, name, 'eval')
    except SyntaxError:
        c = compile(source, name, 'exec')
    return c
1273146
public Rule getRule(String name) {
		Rule rule = rules.get(name);
		if (rule == null) {
			throw new FuzzerException(name + ": rule not found");
		}
		return rule;
	}
1026773
def init_rule(rule_name)
    rule_name.to_s[/^([^?!]*)([?!])?$/]
    rule_name = $1.to_sym
    option = $2
    match_rule = rules[rule_name]
    raise "no rule for #{rule_name}" unless match_rule

    self.parser = lambda {|parent_node| match_rule.parse(parent_node)}
    self.name ||= rule_name
    case option
    when "?"  then self.optional = true
    when "!"  then self.negative = true
    end
  end
578125
def set_rule_name(self, rule_name):
        
        if not self.aws.get('xray', None):
            self.aws['xray'] = {}
        self.aws['xray']['sampling_rule_name'] = rule_name