Esempio n. 1
0
        EmitScope scope; // New scope for the block

        internal override void Walk(EmitContext ec)
        {
            if (ec.Resolving)
            {
                scope = ec.CreateBlockScope("block");
            }

            ec.PushScope(scope);

            if (ec.Emitting)
            {
                ec.EmitScopeInitializer();
            }

            // The parser should produce a more comfortable format for this
            if (var is RNDAsgn)
            {
                RNDefn.WalkArg(ec, 0, var.vid);
            }
            else
            {
                RNArray args = var != null ? (RNArray)((RNMAsgn)var).head : null;

                int i = 0;
                for (RNode n = args; n != null;)
                {
                    RNDAsgn a = (RNDAsgn)n.head;
                    RNDefn.WalkArg(ec, i, a.vid);
                    n = n.next;
                    i++;
                }
            }

            body.Walk(ec);

            if (ec.Emitting)
            {
                Type t = ec.CloseScope(scope);

                RNCall call = (RNCall)iter;
                call.block = t;

                call.Walk(ec);
            }
            else
            {
                ec.PopScope(scope);

                iter.Walk(ec);
            }
        }
Esempio n. 2
0
        EmitScope scope; // New scope for the block
        
        internal override void Walk(EmitContext ec)
        {
            if(ec.Resolving) {
                scope = ec.CreateBlockScope("block");
            }

            ec.PushScope(scope);

            if(ec.Emitting)
                ec.EmitScopeInitializer();
            
            // The parser should produce a more comfortable format for this
            if(var is RNDAsgn) {
                RNDefn.WalkArg(ec, 0, var.vid);
            } else {
                RNArray args = var != null ? (RNArray)((RNMAsgn)var).head : null;
            
                int i = 0;
                for(RNode n = args; n != null; ) {
                    RNDAsgn a = (RNDAsgn)n.head;
                    RNDefn.WalkArg(ec, i, a.vid);
                    n = n.next;
                    i++;
                }
            }
            
            body.Walk(ec);
            
            if(ec.Emitting) {
                Type t = ec.CloseScope(scope);

                RNCall call = (RNCall)iter;
                call.block = t;

                call.Walk(ec);
            } else {
                ec.PopScope(scope);

                iter.Walk(ec);
            }
        }