internal override void Walk(EmitContext ec) { if (ec.Emitting) { Label skip_label = ec.DefineLabel(); nd1st.Walk(ec); ec.EmitDup(); LocalBuilder first = ec.EmitStoreTemp(); ec.EmitBranchIfTrue(skip_label); nd2nd.Walk(ec); ec.EmitDup(); LocalBuilder second = ec.EmitStoreTemp(); ec.EmitBranchIfTrue(skip_label); ec.EmitLoadTemp(second); ec.EmitStoreTemp(first); ec.MarkLabel(skip_label); ec.EmitLoadTemp(first); } else { nd1st.Walk(ec); nd2nd.Walk(ec); } }
internal Type block; // Generated type of the block attached to the call // ( argsarr -- argsarr ) internal static void EmitStoreArg(EmitContext ec, int i, RNode val) { ec.EmitDup(); // arr ec.EmitInt(i); // idx val.Walk(ec); // val ec.EmitArrayStore(); }
internal override void Walk(EmitContext ec) { // Due to the slightly weird RNode inheritance hierarchy bool is_load = this is RNLVar || this is RNDVar; if (!(is_load || this is RNDAsgn || this is RNLAsgn)) { throw new NotSupportedException("bug: variable type not supported: " + this.GetType().Name); } if (ec.Resolving) { v = ec.scope.MarkVariable(vid); } if (!is_load) { val.Walk(ec); } if (ec.Emitting) { if (is_load) { Variable v = ec.scope.GetVariable(vid); ec.EmitLoadVar(v); } else { ec.EmitDup(); ec.EmitStoreVar(v); } } }
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) { if (ec.Emitting) { ec.EmitRArray(alen); } int i = 0; for (RNode n = this; n != null;) { if (n is RNArray) { if (n.head != null) { if (ec.Emitting) { ec.EmitDup(); ec.EmitInt(i); } n.head.Walk(ec); if (ec.Emitting) { ec.EmitRArraySet(); } } n = n.next; i++; } else { // n.Walk(ec); // break; throw new NotSupportedException("bug: array has tail of type " + n.GetType().Name); } } }
internal override void Walk(EmitContext ec) { // Due to the slightly weird RNode inheritance hierarchy bool is_load = this is RNLVar || this is RNDVar; if(!(is_load || this is RNDAsgn || this is RNLAsgn)) { throw new NotSupportedException("bug: variable type not supported: " + this.GetType().Name); } if(ec.Resolving) { v = ec.scope.MarkVariable(vid); } if(!is_load) val.Walk(ec); if(ec.Emitting) { if(is_load) { Variable v = ec.scope.GetVariable(vid); ec.EmitLoadVar(v); } else { ec.EmitDup(); ec.EmitStoreVar(v); } } }
internal Type block; // Generated type of the block attached to the call // ( argsarr -- argsarr ) internal static void EmitStoreArg(EmitContext ec, int i, RNode val) { ec.EmitDup(); // arr ec.EmitInt(i); // idx val.Walk(ec); // val ec.EmitArrayStore(); }
internal override void Walk(EmitContext ec) { if(ec.Emitting) { ec.EmitRArray(alen); } int i = 0; for(RNode n = this; n != null; ) { if(n is RNArray) { if(n.head != null) { if(ec.Emitting) { ec.EmitDup(); ec.EmitInt(i); } n.head.Walk(ec); if(ec.Emitting) { ec.EmitRArraySet(); } } n = n.next; i++; } else { // n.Walk(ec); // break; throw new NotSupportedException("bug: array has tail of type " + n.GetType().Name); } } }
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) { if(ec.Emitting) { Label skip_label = ec.DefineLabel(); nd1st.Walk(ec); ec.EmitDup(); LocalBuilder first = ec.EmitStoreTemp(); ec.EmitBranchIfTrue(skip_label); nd2nd.Walk(ec); ec.EmitDup(); LocalBuilder second = ec.EmitStoreTemp(); ec.EmitBranchIfTrue(skip_label); ec.EmitLoadTemp(second); ec.EmitStoreTemp(first); ec.MarkLabel(skip_label); ec.EmitLoadTemp(first); } else { nd1st.Walk(ec); nd2nd.Walk(ec); } }