Beispiel #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);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
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);
            }
        }