예제 #1
0
파일: codegen.cs 프로젝트: retahc/old-code
        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);
            }
        }
예제 #2
0
파일: codegen.cs 프로젝트: retahc/old-code
        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);
            }
        }
예제 #3
0
파일: codegen.cs 프로젝트: emtees/old-code
        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);
            }
        }
예제 #4
0
파일: codegen.cs 프로젝트: emtees/old-code
        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);
            }
        }