Exemple #1
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);
            }
        }
Exemple #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);
            }
        }