Esempio n. 1
0
    // TODO: Add vardecl to while loop?
    //  It's pretty dumb but C++ allows it =/

    protected void ExecuteWhileStmt(AstWhileStmt stmt)
    {
        if (HadErrorOrReturn())
        {
            return;
        }

        while (!m_runtimeError)
        {
            m_blockexitk = BLOCKEXITK.Normal;

            object conditionVal = EvaluateExpr(stmt.m_condition);

            if (!IsTruthy(conditionVal))
            {
                break;
            }

            ExecuteStmt(stmt.m_body);

            if (m_blockexitk == BLOCKEXITK.Break)
            {
                break;
            }
        }
    }
Esempio n. 2
0
    protected void ExecuteForStmt(AstForStmt stmt)
    {
        if (HadErrorOrReturn())
        {
            return;
        }

        // NOTE (andrews) This pushes an environment before opening the scope, which is where any declared iterator lives

        bool isEnvPushed = false;

        if (stmt.m_preDecl != null)
        {
            Debug.Assert(stmt.m_preExpr == null);

            PushEnvironment();
            isEnvPushed = true;

            ExecuteVarDeclStmt(stmt.m_preDecl);
        }
        else if (stmt.m_preExpr != null)
        {
            EvaluateExpr(stmt.m_preExpr);
        }

        while (!m_runtimeError)
        {
            m_blockexitk = BLOCKEXITK.Normal;

            object conditionVal = true;

            if (stmt.m_condition != null)
            {
                conditionVal = EvaluateExpr(stmt.m_condition);

                if (!IsTruthy(conditionVal))
                {
                    break;
                }
            }

            ExecuteStmt(stmt.m_body);

            if (m_blockexitk == BLOCKEXITK.Break)
            {
                break;
            }

            if (stmt.m_post != null)
            {
                EvaluateExpr(stmt.m_post);
            }
        }

        if (isEnvPushed)
        {
            PopEnvironment();
        }
    }
Esempio n. 3
0
 protected void ExecuteContinueStmt(AstContinueStmt stmt)
 {
     if (HadErrorOrReturn())
     {
         return;
     }
     m_blockexitk = BLOCKEXITK.Continue;
 }
Esempio n. 4
0
 protected void ExecuteBreakStmt(AstBreakStmt stmt)
 {
     if (HadErrorOrReturn())
     {
         return;
     }
     m_blockexitk = BLOCKEXITK.Break;
 }