예제 #1
0
파일: codegen.cs 프로젝트: retahc/old-code
        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);
            }
        }
예제 #2
0
파일: codegen.cs 프로젝트: retahc/old-code
        internal override void Walk(EmitContext ec)
        {
            if (ec.Resolving)
            {
                cond.Walk(ec);
                body.Walk(ec);
                if (nd_else != null)
                {
                    nd_else.Walk(ec);
                }
            }
            if (ec.Emitting)
            {
                Label else_label = ec.DefineLabel();
                Label end_label  = ec.DefineLabel();

                cond.Walk(ec);
                ec.EmitBranchIfFalse(else_label);

                // TODO rearrange the body and else clause in this case
                if (body != null)
                {
                    body.Walk(ec);
                    ec.EmitDiscard();
                }

                if (nd_else != null)
                {
                    ec.EmitBranch(end_label);
                }

                ec.MarkLabel(else_label);

                if (nd_else != null)
                {
                    nd_else.Walk(ec);
                    ec.EmitDiscard();
                }

                ec.MarkLabel(end_label);

                ec.EmitNull();
            }
        }
예제 #3
0
파일: codegen.cs 프로젝트: emtees/old-code
        internal override void Walk(EmitContext ec)
        {
            if(ec.Resolving) {
                cond.Walk(ec);
                body.Walk(ec);
            }
            
            if(ec.Emitting) {
                Label end_label = ec.DefineLabel();
                Label start_label = ec.DefineLabel();
                
                ec.MarkLabel(start_label);
                cond.Walk(ec);

                if(this is RNUntil)
                    ec.EmitBranchIfTrue(end_label);
                else
                    ec.EmitBranchIfFalse(end_label);

                body.Walk(ec);
                // TODO return value in local
                ec.EmitDiscard();
                ec.EmitBranch(start_label);

                ec.MarkLabel(end_label);
                
                ec.EmitNull();
            }
        }
예제 #4
0
파일: codegen.cs 프로젝트: emtees/old-code
        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);
            }
        }
예제 #5
0
파일: codegen.cs 프로젝트: emtees/old-code
        internal override void Walk(EmitContext ec)
        {
            if(ec.Resolving) {
                cond.Walk(ec);
                body.Walk(ec);
                if(nd_else != null)
                    nd_else.Walk(ec);
            }
            if(ec.Emitting) {
                Label else_label = ec.DefineLabel();
                Label end_label = ec.DefineLabel();
                
                cond.Walk(ec);
                ec.EmitBranchIfFalse(else_label);

                // TODO rearrange the body and else clause in this case
                if(body != null) {
                    body.Walk(ec);
                    ec.EmitDiscard();
                }
                
                if(nd_else != null) {
                    ec.EmitBranch(end_label);
                }
                    
                ec.MarkLabel(else_label);

                if(nd_else != null) {
                    nd_else.Walk(ec);
                    ec.EmitDiscard();
                }

                ec.MarkLabel(end_label);

                ec.EmitNull();
            }
        }