protected override Expression RewriteSet(AssignmentExtensionExpression node) { GlobalVariableExpression lvalue = (GlobalVariableExpression)node.Expression; return(AstUtils.Convert( Expression.Assign( MapToExpression(lvalue), AstUtils.Convert(Visit(node.Value), typeof(object)) ), node.Type )); }
private Expression Rewrite(AssignmentExtensionExpression node) { Expression lvalue = node.Expression; GlobalVariableExpression global = lvalue as GlobalVariableExpression; if (global != null) { return(RewriteSet(node)); } return(node); }
protected override Expression RewriteSet(AssignmentExtensionExpression node) { GlobalVariableExpression lvalue = (GlobalVariableExpression)node.Expression; EnsureUniqueName(lvalue); return(AstUtils.Convert( Expression.Call( typeof(ScriptingRuntimeHelpers).GetMethod(lvalue.IsLocal ? "SetName" : "SetGlobalName"), new Expression[] { Context, AstUtils.Constant(SymbolTable.StringToId(lvalue.Name)), Visit(node.Value) } ), node.Type )); }
protected override Expression VisitExtension(Expression node) { if (node is YieldExpression || node is GeneratorExpression || node is FinallyFlowControlExpression) { // These should be rewritten last, when doing finaly compilation // for now, just walk them so we can find other nodes return(base.VisitExtension(node)); } GlobalVariableExpression global = node as GlobalVariableExpression; if (global != null) { return(RewriteGet(global)); } CodeContextExpression cc = node as CodeContextExpression; if (cc != null) { return(_context); } CodeContextScopeExpression ccs = node as CodeContextScopeExpression; if (ccs != null) { return(Rewrite(ccs)); } AssignmentExtensionExpression aee = node as AssignmentExtensionExpression; if (aee != null) { return(Rewrite(aee)); } // Must remove extension nodes because they could contain // one of the above node types. See, e.g. DeleteUnboundExpression return(Visit(node.ReduceExtensions())); }
protected abstract Expression RewriteSet(AssignmentExtensionExpression node);