internal override void Walk(EmitContext ec) { if (ec.Emitting) { ec.EmitGetGlobal(ec.id2name(vid)); } }
internal override void Walk(EmitContext ec) { val.Walk(ec); if (ec.Emitting) { ec.EmitDup(); ec.EmitSetGlobal(ec.id2name(vid)); } }
internal override void Walk(EmitContext ec) { string name = ec.id2name(mid); if (ec.Resolving) { scope = ec.CreateMethodScope(name); } ec.PushScope(scope); if (ec.Emitting) { ec.EmitScopeInitializer(); } RNScope sc = (RNScope)defn; RNode n = sc.next; RNArgs args = (RNArgs)n.head; RNode body = n.next; int argc = args.cnt; for (int i = 0; i < argc; i++) { // First two locals in table are $~ and $_ uint vid = sc.tbl[i + 2]; WalkArg(ec, i, vid); } // Methods can have no body if (body != null) { body.Walk(ec); } if (ec.Emitting) { Type t = ec.CloseScope(scope); ec.EmitDefine(name, t); ec.EmitNil(); // Return value } else { ec.PopScope(scope); } }
private Variable GetAndCreateVariable(uint vid, bool create) { Variable v = vars[vid] as Variable; if (v == null) { if (IsBlock) { Variable dv = GetMethodScope().vars[vid] as Variable; if (dv != null) { if (create) { dv.IsDynamic = true; dv.closure_slot = GetMethodScope().CreateClosureSlot(); } else if (!dv.IsDynamic) { throw new Exception("bug: missing dynamic data for dynamic var: " + context.id2name(vid)); } return(dv); } } if (create) { v = new Variable(); vars[vid] = v; return(v); } else { throw new Exception("Local not found: " + context.id2name(vid)); } } return(v); }
internal override void Walk(EmitContext ec) { string name = ec.id2name(mid); if(ec.Resolving) { scope = ec.CreateMethodScope(name); } ec.PushScope(scope); if(ec.Emitting) ec.EmitScopeInitializer(); RNScope sc = (RNScope)defn; RNode n = sc.next; RNArgs args = (RNArgs)n.head; RNode body = n.next; int argc = args.cnt; for(int i = 0; i < argc; i++) { // First two locals in table are $~ and $_ uint vid = sc.tbl[i + 2]; WalkArg(ec, i, vid); } // Methods can have no body if(body != null) body.Walk(ec); if(ec.Emitting) { Type t = ec.CloseScope(scope); ec.EmitDefine(name, t); ec.EmitNil(); // Return value } else { ec.PopScope(scope); } }
internal override void Walk(EmitContext ec) { if(ec.Emitting) ec.EmitGetGlobal(ec.id2name(vid)); }
internal override void Walk(EmitContext ec) { val.Walk(ec); if(ec.Emitting) { ec.EmitDup(); ec.EmitSetGlobal(ec.id2name(vid)); } }