private static dynamic InstanceEval(object self, string eval, NovaScope scope) { if (!(self is NovaInstance instance)) { return(null); } var xexpression = string.Format("{0};", eval); var res = NovaParser.Parse(xexpression); Expression block; if (res != null) { scope["self"] = scope["super"] = instance; scope["<nova_context_invokemember>"] = true; string selfName; var selfScope = scope.SearchForObject(instance, out selfName); if (selfScope != null && selfName != null) { scope["<nova_context_selfscope>"] = selfScope; scope["<nova_context_selfname>"] = selfName; } block = NovaExpression.NovaBlock(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(NovaScope scope) { Body.SetScope(scope); Init.SetScope(((NovaExpression)Body).Scope); Test.SetScope(((NovaExpression)Body).Scope); Step.SetScope(((NovaExpression)Body).Scope); }
internal BlockExpression(List <Expression> body, NovaScope scope) { body.RemoveAll(e => e == null); Body = body; SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { TryBlock.SetScope(scope); RescueBlocks.ForEach(block => block.SetScope(scope)); EnsureBlock.SetScope(scope); ElseBlock.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { foreach (var arg in Arguments) { arg.Value.SetScope(scope); } }
public override void SetChildrenScopes(NovaScope scope) { foreach (var expr in Body) { expr.SetScope(scope); } }
public override void SetChildrenScopes(NovaScope scope) { foreach (var value in Values) { value.SetScope(scope); } }
private static void SetParentScopeIfBlock(this Expression expr, NovaScope 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, NovaScope scope) { if (!(expr is BlockExpression block)) { return; } if (block.Scope == null) { block.Scope = new NovaScope(); } block.Scope.ParentScope = scope; }
public override void SetChildrenScopes(NovaScope scope) { LeftHandValues.ForEach(value => { if (value.Value is NovaExpression) { value.Value.SetScope(scope); } }); RightHandValues.ForEach(value => { if (value.Value is NovaExpression) { value.Value.SetScope(scope); } }); }
public override void SetChildrenScopes(NovaScope 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, NovaScope scope) { var xexpression = string.Format("{0};", eval); var res = NovaParser.Parse(xexpression); Expression block; if (res != null) { block = NovaExpression.NovaBlock(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, NovaScope scope) { NovaClass @class; var instance = self as NovaInstance; if (instance != null) { @class = instance.Class; } else { @class = self as NovaClass; } if (@class == null) { return(null); } var xexpression = string.Format("{0};", eval); var res = NovaParser.Parse(xexpression); return(res != null?RuntimeOperations.DefineCategory(@class, res.ToList(), scope) : null); }
public override void SetChildrenScopes(NovaScope scope) { Test.SetScope(scope); Body.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Expression.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Key.SetScope(scope); Value.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(NovaScope scope) { }
/// <summary> /// Sets the scope used by this expression. /// </summary> /// <param name="scope">Scope for this expression</param> public void SetScope(NovaScope scope) { _scope = scope; SetChildrenScopes(scope); }
public override void SetChildrenScopes(NovaScope scope) { ExceptionObject.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Left.SetScope(scope); Right.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Name.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Test.SetScope(scope); IfTrue.SetScope(scope); IfFalse.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { TargetType.SetScope(scope); Method.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Enumerator.SetScope(scope); Body.SetScope(scope); }
public override void SetChildrenScopes(NovaScope scope) { Function.SetScope(scope); }
public static void SetScope(this Expression expr, NovaScope scope) { expr.SetParentScopeIfBlock(scope); }
public override void SetChildrenScopes(NovaScope scope) { Contents.ForEach(content => content.SetScope(scope)); }
public static dynamic BoxNoCache(object obj, NovaScope scope = null) { return(NovaBoxedInstance.BoxNoCache(obj, scope ?? new NovaScope())); }