Beispiel #1
0
        internal void AddScopeBody(CodeGenContext context)
        {
            returnTemp = context.CreateLocal("returnTemp", PrimitiveType.Object);

            context.labels = new Labels();
            context.labels.Redo = context.NewLabel();
            context.labels.Return = context.NewLabel();

            // try { ... }
            context.StartBlock(Clause.Try);
            {
                if (BEGIN != null)
                    BEGIN.GenCode(context);

                context.CodeLabel(context.labels.Redo);

                if (body != null)
                {
                    body.GenCode(context);

                    if (context.Reachable())
                        context.stloc(returnTemp);
                }

                context.Goto(context.labels.Return);
            }
            PERWAPI.TryBlock tryBlock = context.EndTryBlock();        

            CatchReturnException(context, tryBlock);

            // ReturnLabel:
            //    return returnTemp;
            context.CodeLabel(context.labels.Return);
            context.newEndPoint(location);
            if (context.Method.GetRetType() != PERWAPI.PrimitiveType.Void)
                context.ldloc(returnTemp);
            context.ret();

            context.ReleaseLocal(returnTemp, true);
        }