コード例 #1
0
ファイル: ForStatement.cs プロジェクト: wowngasb/CLanguage
        protected override void DoEmit(EmitContext ec)
        {
            ec.BeginBlock(InitBlock);
            foreach (var s in InitBlock.InitStatements)
            {
                s.Emit(ec);
            }
            foreach (var s in InitBlock.Statements)
            {
                s.Emit(ec);
            }

            var endLabel = ec.DefineLabel();

            var contLabel = ec.DefineLabel();

            ec.EmitLabel(contLabel);
            ContinueExpression.Emit(ec);
            ec.EmitCastToBoolean(ContinueExpression.GetEvaluatedCType(ec));
            ec.Emit(OpCode.BranchIfFalse, endLabel);

            LoopBody.Emit(ec);

            if (NextExpression != null)
            {
                NextExpression.Emit(ec);
                ec.Emit(OpCode.Pop);
            }
            ec.Emit(OpCode.Jump, contLabel);

            ec.EmitLabel(endLabel);

            ec.EndBlock();
        }
コード例 #2
0
        protected override void DoEmit(EmitContext initialContext)
        {
            initialContext.BeginBlock(InitBlock);
            foreach (var s in InitBlock.InitStatements)
            {
                s.Emit(initialContext);
            }
            foreach (var s in InitBlock.Statements)
            {
                s.Emit(initialContext);
            }

            var nextLabel = initialContext.DefineLabel();
            var endLabel  = initialContext.DefineLabel();

            var ec = initialContext.PushLoop(breakLabel: endLabel, continueLabel: nextLabel);

            //
            // Test the condition:
            //   If succeeded then execute the loop body
            //   If failed, goto END
            //
            var conditionLabel = ec.DefineLabel();

            ec.EmitLabel(conditionLabel);
            ContinueExpression.Emit(ec);
            ec.EmitCastToBoolean(ContinueExpression.GetEvaluatedCType(ec));
            ec.Emit(OpCode.BranchIfFalse, endLabel);

            //
            // Fall through to the loop body
            //
            LoopBody.Emit(ec);

            //
            // Fall through to the NEXT label
            //   Run the incrementer
            //   Loop back to the condition
            //
            ec.EmitLabel(nextLabel);
            if (NextExpression != null)
            {
                NextExpression.Emit(ec);
                ec.Emit(OpCode.Pop);
            }
            ec.Emit(OpCode.Jump, conditionLabel);

            //
            // Arrive here when the condition fails
            //
            ec.EmitLabel(endLabel);

            ec.EndBlock();
        }
コード例 #3
0
        public static ContinueExpression Create(
            AphidExpressionContext context_aphidExpressionContext,
            int value_i,
            int value_i1
            )
        {
            ContinueExpression continueExpression
                = new ContinueExpression(context_aphidExpressionContext);

            ((AphidExpression)continueExpression).Index  = value_i;
            ((AphidExpression)continueExpression).Length = value_i1;
            return(continueExpression);

            // TODO: Edit factory method of ContinueExpression
            // This method should be able to configure the object in all possible ways.
            // Add as many parameters as needed,
            // and assign their values to each field by using the API.
        }
コード例 #4
0
ファイル: ForStatement.cs プロジェクト: arlm/CLanguage
        protected override void DoEmit(EmitContext ec)
        {
            InitBlock.Emit(ec);

            var endLabel = ec.DefineLabel();

            var contLabel = ec.DefineLabel();

            ec.EmitLabel(contLabel);
            ContinueExpression.Emit(ec);
            ec.EmitCastToBoolean(ContinueExpression.GetEvaluatedCType(ec));
            ec.Emit(OpCode.BranchIfFalse, endLabel);

            LoopBody.Emit(ec);
            NextExpression.Emit(ec);
            ec.Emit(OpCode.Pop);
            ec.Emit(OpCode.Jump, contLabel);

            ec.EmitLabel(endLabel);
        }
コード例 #5
0
        public static void RegisterAll()
        {
            BreakExpression.Register();
            ContinueExpression.Register();
            ReturnFunctionExpression.Register();
            AbsFunction.Register();
            ExecuteFile.Register();
            PowFunction.Register();
            ProductFunction.Register();
            HelpFunction.Register();
            SqrtFunction.Register();
            SumDeepFunction.Register();
            SumFunction.Register();
            LengthFunction.Register();

            ConsoleObject.Register();
            TrigonometryObject.Register();
            ThisConstant.Register();

            BooleanValue.Register();
            ComplexValue.Register();
            DecimalValue.Register();
            NullValue.Register();
        }
コード例 #6
0
ファイル: ExpressionVisitor.cs プロジェクト: xserve98/Mond
 public virtual T Visit(ContinueExpression expression)
 {
     return(default(T));
 }
コード例 #7
0
 public virtual Expression Visit(ContinueExpression expression)
 {
     return(expression);
 }
コード例 #8
0
 public int Visit(ContinueExpression expression)
 {
     _writer.Write("continue");
     return(0);
 }
コード例 #9
0
 public static Result Run(ContinueExpression block, Scope scope)
 {
     throw new ContinueException(Interpreters.Execute(block.CountOfLoops, scope).ResultValue.GetLongValue().Clamp(1, 1000));
 }