Example #1
0
 public override void TypeCheck()
 {
     TryStmts.TypeCheck();
     if (CatchStmts != null)
     {
         CatchStmts.TypeCheck();
     }
     if (FinallyStmts != null)
     {
         FinallyStmts.TypeCheck();
     }
 }
Example #2
0
        public override bool ResolveNames(LexicalScope scope)
        {
            var  newScope    = getNewScope(scope, null);
            bool loopResolve = TryStmts.ResolveNames(newScope);

            if (CatchStmts != null)
            {
                loopResolve = loopResolve & CatchStmts.ResolveNames(newScope);
            }
            if (FinallyStmts != null)
            {
                loopResolve = loopResolve & FinallyStmts.ResolveNames(newScope);
            }
            return(loopResolve);
        }
Example #3
0
        public override void GenCode(StringBuilder sb)
        {
            cg.emit(sb, "\t.try\n");
            cg.emit(sb, "\t{{\n");
            int tryLabel = LastLabel++;

            if (CatchStmts != null && FinallyStmts != null)
            {
                int tryLabel2 = LastLabel++;
                cg.emit(sb, "\t.try\n");
                cg.emit(sb, "\t{{\n");
                TryStmts.GenCode(sb);
                cg.emit(sb, "\tleave.s\tL{0}\n", tryLabel2);
                cg.emit(sb, "\t}}\n");
                cg.emit(sb, "\tcatch [mscorlib]System.Object \n");
                cg.emit(sb, "\t{{\n");
                CatchStmts.GenCode(sb);
                cg.emit(sb, "\tleave.s\tL{0}\n", tryLabel2);
                cg.emit(sb, "\t}}\n");
                cg.emit(sb, "L{0}:\n", tryLabel2);
            }
            else
            {
                TryStmts.GenCode(sb);
            }
            cg.emit(sb, "\tleave.s\tL{0}\n", tryLabel);
            cg.emit(sb, "\t}}\n");

            if (FinallyStmts != null)
            {
                cg.emit(sb, "\tfinally\n");
                cg.emit(sb, "\t{{\n");
                FinallyStmts.GenCode(sb);
                cg.emit(sb, "\tendfinally\n");
                cg.emit(sb, "\t}}\n");
            }
            else
            {
                cg.emit(sb, "\tcatch [mscorlib]System.Object \n");
                cg.emit(sb, "\t{{\n");
                CatchStmts.GenCode(sb);
                cg.emit(sb, "\tleave.s\tL{0}\n", tryLabel);
                cg.emit(sb, "\t}}\n");
            }
            cg.emit(sb, "L{0}:\n", tryLabel);
        }