public override void SetChildrenScopes(KumaScope scope) { TryBlock.SetScope(scope); RescueBlocks.ForEach(block => block.SetScope(scope)); EnsureBlock.SetScope(scope); ElseBlock.SetScope(scope); }
private static dynamic InstanceEval(object self, string eval, KumaScope scope) { if (!(self is KumaInstance instance)) { return(null); } var xexpression = string.Format("{0};", eval); var res = KumaParser.Parse(xexpression); Expression block; if (res != null) { scope["self"] = scope["super"] = instance; scope["<kuma_context_invokemember>"] = true; string selfName; var selfScope = scope.SearchForObject(instance, out selfName); if (selfScope != null && selfName != null) { scope["<kuma_context_selfscope>"] = selfScope; scope["<kuma_context_selfname>"] = selfName; } block = KumaExpression.KumaBlock(res); // We want eval'd expressions to execute in the current scope, not its own child scopes. This ensures assignment evals work properly. ((BlockExpression)block).Scope = scope; ((BlockExpression)block).SetChildrenScopes(scope); } else { return(null); } var val = CompilerServices.CreateLambdaForExpression(block)(); return(val); }
public override void SetChildrenScopes(KumaScope scope) { Body.SetScope(scope); Init.SetScope(((KumaExpression)Body).Scope); Test.SetScope(((KumaExpression)Body).Scope); Step.SetScope(((KumaExpression)Body).Scope); }
public override void SetChildrenScopes(KumaScope scope) { foreach (var arg in Arguments) { arg.Value.SetScope(scope); } }
public override void SetChildrenScopes(KumaScope scope) { foreach (var expr in Body) { expr.SetScope(scope); } }
internal BlockExpression(List <Expression> body, KumaScope scope) { body.RemoveAll(e => e == null); Body = body; SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { foreach (var value in Values) { value.SetScope(scope); } }
private static void SetParentScopeIfBlock(this Expression expr, KumaScope scope) { if (expr is BlockExpression) { expr.SetParentScope(scope); } else if (expr is IScopeExpression) { (expr as IScopeExpression).SetScope(scope); } }
private static void SetParentScope(this Expression expr, KumaScope scope) { if (!(expr is BlockExpression block)) { return; } if (block.Scope == null) { block.Scope = new KumaScope(); } block.Scope.ParentScope = scope; }
public override void SetChildrenScopes(KumaScope scope) { LeftHandValues.ForEach(value => { if (value.Value is KumaExpression) { value.Value.SetScope(scope); } }); RightHandValues.ForEach(value => { if (value.Value is KumaExpression) { value.Value.SetScope(scope); } }); }
public override void SetChildrenScopes(KumaScope scope) { Test.SetScope(scope); if (DefaultBody != null) { DefaultBody.SetScope(scope); } foreach (var @case in Cases) { foreach (var test in @case.TestValues) { test.SetScope(scope); } @case.Body.SetScope(scope); } }
private static dynamic Eval(string eval, KumaScope scope) { var xexpression = string.Format("{0};", eval); var res = KumaParser.Parse(xexpression); Expression block; if (res != null) { block = KumaExpression.KumaBlock(res); // We want eval'd expressions to execute in the current scope, not its own child scopes. This ensures assignment evals work properly. ((BlockExpression)block).Scope = scope; ((BlockExpression)block).SetChildrenScopes(scope); } else { return(null); } var val = CompilerServices.CreateLambdaForExpression(block)(); return(val); }
private static dynamic ClassEval(object self, string eval, KumaScope scope) { KumaClass @class; var instance = self as KumaInstance; if (instance != null) { @class = instance.Class; } else { @class = self as KumaClass; } if (@class == null) { return(null); } var xexpression = string.Format("{0};", eval); var res = KumaParser.Parse(xexpression); return(res != null?RuntimeOperations.DefineCategory(@class, res.ToList(), scope) : null); }
public override void SetChildrenScopes(KumaScope scope) { LValue.SetScope(scope); Key.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Function.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Name.SetScope(scope); Contents.ForEach(content => content.SetScope(scope)); }
public override void SetChildrenScopes(KumaScope scope) { Start.SetScope(scope); End.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Body.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Test.SetScope(scope); IfTrue.SetScope(scope); IfFalse.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Enumerator.SetScope(scope); Body.SetScope(scope); }
public static void SetScope(this Expression expr, KumaScope scope) { expr.SetParentScopeIfBlock(scope); }
public static dynamic BoxNoCache(object obj, KumaScope scope = null) { return(KumaBoxedInstance.BoxNoCache(obj, scope ?? new KumaScope())); }
public override void SetChildrenScopes(KumaScope scope) { ExceptionObject.SetScope(scope); }
/// <summary> /// Called by SetScope to set the children scope on expressions. Should be overridden to tell the runtime which /// children should have scopes set. /// </summary> /// <param name="scope"></param> public virtual void SetChildrenScopes(KumaScope scope) { }
public override void SetChildrenScopes(KumaScope scope) { TargetType.SetScope(scope); Method.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { base.SetChildrenScopes(scope); Value.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Expression.SetScope(scope); }
public override void SetChildrenScopes(KumaScope scope) { Left.SetScope(scope); Right.SetScope(scope); }
/// <summary> /// Sets the scope used by this expression. /// </summary> /// <param name="scope">Scope for this expression</param> public void SetScope(KumaScope scope) { _scope = scope; SetChildrenScopes(scope); }