예제 #1
0
        public override void Generate(ModuleContext context)
        {
            context.BeginLoop();
            var bindIndex = new BindExpression(indexExp, beginExp);

            bindIndex.Generate(context);
            context.Add(new ByteCode {
                opCode = ByteCode.OpCode.Clear
            });
            var beginLabel = new LabelExpression(context.NewUID(), indexExp.debugInfo);

            beginLabel.Generate(context);
            var jumpBegin = new LuaLabel(context.vm, beginLabel.value, beginLabel.index);

            condExp.Generate(context);
            var endLabel = new LabelExpression(context.NewUID(), indexExp.debugInfo);
            var jumpEnd  = new LuaLabel(context.vm, endLabel.value, endLabel.index);

            context.Add(new ByteCode {
                opCode = ByteCode.OpCode.JumpIf, opArg = jumpEnd
            });
            context.Add(new ByteCode {
                opCode = ByteCode.OpCode.Clear
            });
            moduleExp.Generate(context);
            changeExp.Generate(context);
            context.Add(new ByteCode {
                opCode = ByteCode.OpCode.Jump, opArg = jumpBegin
            });
            endLabel.Generate(context);
            jumpEnd.index = endLabel.index;
            context.EndLoop(jumpEnd);
        }
예제 #2
0
        public override void Generate(ModuleContext context)
        {
            var jumpEnd = new LuaLabel(context.vm, null, 0);

            context.OnBreak(jumpEnd);
            context.Add(new ByteCode {
                opCode = ByteCode.OpCode.Jump, opArg = jumpEnd
            });
        }
예제 #3
0
        public void EndLoop(LuaLabel endLabel)
        {
            var queue = breakStack.Pop();

            while (queue.Count > 0)
            {
                var item = queue.Dequeue();
                item.value = endLabel.value;
                item.index = endLabel.index;
            }
        }
예제 #4
0
        public override void Generate(ModuleContext context)
        {
            condExp.Generate(context);
            var endLabel = new LabelExpression(context.NewUID(), condExp.debugInfo);
            var jumpEnd  = new LuaLabel(context.vm, endLabel.value, endLabel.index);

            context.Add(new ByteCode {
                opCode = ByteCode.OpCode.JumpNot, opArg = jumpEnd
            });
            moduleExp.Generate(context);
            endLabel.Generate(context);
            jumpEnd.index = endLabel.index;
        }
예제 #5
0
 public void Jump(LuaLabel label)
 {
     position = label.index;
 }
예제 #6
0
 public void OnBreak(LuaLabel label)
 {
     breakStack.Peek().Enqueue(label);
 }