示例#1
0
        private void writeIf(IfBlock block)
        {
            string cond;

            if (block.logic == null)
            {
                writeStatements(block.source);

                DJumpCondition jcc = (DJumpCondition)block.source.nodes.last;

                if (block.invert)
                {
                    if (jcc.getOperand(0).type == NodeType.Unary &&
                        ((DUnary)jcc.getOperand(0)).spop == SPOpcode.not)
                    {
                        cond = buildExpression(jcc.getOperand(0).getOperand(0));
                    }
                    else if (jcc.getOperand(0).type == NodeType.Load)
                    {
                        cond = "!" + buildExpression(jcc.getOperand(0));
                    }
                    else
                    {
                        cond = "!(" + buildExpression(jcc.getOperand(0)) + ")";
                    }
                }
                else
                {
                    cond = buildExpression(jcc.getOperand(0));
                }
            }
            else
            {
                cond = buildLogicChain(block.logic);
                Debug.Assert(!block.invert);
            }

            outputLine("if (" + cond + ")");
            outputLine("{");
            increaseIndent();
            writeBlock(block.trueArm);
            decreaseIndent();
            if (block.falseArm != null &&
                BlockAnalysis.GetEmptyTarget(block.falseArm.source) == null)
            {
                outputLine("}");
                outputLine("else");
                outputLine("{");
                increaseIndent();
                writeBlock(block.falseArm);
                decreaseIndent();
            }
            outputLine("}");
            if (block.join != null)
            {
                writeBlock(block.join);
            }
        }
示例#2
0
        private void writeIf(IfBlock block)
        {
            string cond;
            if (block.logic == null)
            {
                writeStatements(block.source);

                DJumpCondition jcc = (DJumpCondition)block.source.nodes.last;

                if (block.invert)
                {
                    if (jcc.getOperand(0).type == NodeType.Unary &&
                        ((DUnary)jcc.getOperand(0)).spop == SPOpcode.not)
                    {
                        cond = buildExpression(jcc.getOperand(0).getOperand(0));
                    }
                    else if (jcc.getOperand(0).type == NodeType.Load)
                    {
                        cond = "!" + buildExpression(jcc.getOperand(0));
                    }
                    else
                    {
                        cond = "!(" + buildExpression(jcc.getOperand(0)) + ")";
                    }
                }
                else
                {
                    cond = buildExpression(jcc.getOperand(0));
                }
            }
            else
            {
                cond = buildLogicChain(block.logic);
                Debug.Assert(!block.invert);
            }

            outputLine("if (" + cond + ")");
            outputLine("{");
            increaseIndent();
            writeBlock(block.trueArm);
            decreaseIndent();
            if (block.falseArm != null &&
                BlockAnalysis.GetEmptyTarget(block.falseArm.source) == null)
            {
                outputLine("}");
                outputLine("else");
                outputLine("{");
                increaseIndent();
                writeBlock(block.falseArm);
                decreaseIndent();
            }
            outputLine("}");
            if (block.join != null)
                writeBlock(block.join);
        }