Example #1
0
        private void ProcessLocalDeclarationStatement(ILocalDeclarationStatement pStatement)
        {
            if (mCurrentBlock.Terminated)
            {
                mCurrentBlock = CreateBlock(CreateLabel());
            }

            if (pStatement.InitialValue == null)
            {
                return;
            }
            HLLocation locationLocalVariable = HLLocalLocation.Create(HLDomain.GetLocal(pStatement.LocalVariable));
            HLLocation locationInitialValue  = ProcessExpression(pStatement.InitialValue);

            mCurrentBlock.EmitAssignment(locationLocalVariable, locationInitialValue);
        }
Example #2
0
        private HLLocation ProcessConditionalExpression(IConditional pExpression)
        {
            HLLocation         locationCondition = ProcessExpression(pExpression.Condition);
            HLInstructionBlock blockParent       = mCurrentBlock;

            HLLocation locationResult = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type)));

            HLInstructionBlock blockTrueStart = CreateBlock(CreateLabel());

            mCurrentBlock = blockTrueStart;
            HLLocation locationTrue = ProcessExpression(pExpression.ResultIfTrue);

            mCurrentBlock.EmitAssignment(locationResult, locationTrue);
            HLInstructionBlock blockTrueEnd = mCurrentBlock;

            HLInstructionBlock blockFalseStart = CreateBlock(CreateLabel());

            mCurrentBlock = blockFalseStart;
            HLLocation locationFalse = ProcessExpression(pExpression.ResultIfFalse);

            mCurrentBlock.EmitAssignment(locationResult, locationFalse);
            HLInstructionBlock blockFalseEnd = mCurrentBlock;

            blockParent.EmitBranch(locationCondition, blockTrueStart.StartLabel, blockFalseStart.StartLabel);

            mCurrentBlock = CreateBlock(CreateLabel());
            blockTrueEnd.Terminate(mCurrentBlock.StartLabel);
            blockFalseEnd.Terminate(mCurrentBlock.StartLabel);

            return(locationResult);
        }
Example #3
0
        private HLLocation ProcessConditionalExpression(IConditional pExpression)
        {
            HLLocation locationCondition = ProcessExpression(pExpression.Condition);
            HLInstructionBlock blockParent = mCurrentBlock;

            HLLocation locationResult = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type)));

            HLInstructionBlock blockTrueStart = CreateBlock(CreateLabel());
            mCurrentBlock = blockTrueStart;
            HLLocation locationTrue = ProcessExpression(pExpression.ResultIfTrue);
            mCurrentBlock.EmitAssignment(locationResult, locationTrue);
            HLInstructionBlock blockTrueEnd = mCurrentBlock;

            HLInstructionBlock blockFalseStart = CreateBlock(CreateLabel());
            mCurrentBlock = blockFalseStart;
            HLLocation locationFalse = ProcessExpression(pExpression.ResultIfFalse);
            mCurrentBlock.EmitAssignment(locationResult, locationFalse);
            HLInstructionBlock blockFalseEnd = mCurrentBlock;

            blockParent.EmitBranch(locationCondition, blockTrueStart.StartLabel, blockFalseStart.StartLabel);

            mCurrentBlock = CreateBlock(CreateLabel());
            blockTrueEnd.Terminate(mCurrentBlock.StartLabel);
            blockFalseEnd.Terminate(mCurrentBlock.StartLabel);

            return locationResult;
        }