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); }
internal void Process() { if (Definition.IsExternal) { return; } ISourceMethodBody sourceMethodBody = null; if (Definition.Body is ISourceMethodBody) { sourceMethodBody = (ISourceMethodBody)Definition.Body; } else { sourceMethodBody = Decompiler.GetCodeModelFromMetadataModel(HLDomain.Host, Definition.Body, null); } mCurrentBlock = CreateBlock(CreateLabel()); ProcessStatement(sourceMethodBody.Block); mCurrentBlock.Terminate(null); List <string> buf = new List <string>(); foreach (HLInstructionBlock block in mBlocks) { foreach (HLInstruction instruction in block.Instructions) { buf.Add(instruction.ToString()); } } }
private void ProcessConditionalStatement(IConditionalStatement pStatement) { if (mCurrentBlock.Terminated) { mCurrentBlock = CreateBlock(CreateLabel()); } HLLocation locationCondition = ProcessExpression(pStatement.Condition); HLInstructionBlock blockParent = mCurrentBlock; HLInstructionBlock blockTrueStart = CreateBlock(CreateLabel()); mCurrentBlock = blockTrueStart; ProcessStatement(pStatement.TrueBranch); HLInstructionBlock blockTrueEnd = mCurrentBlock; HLInstructionBlock blockFalseStart = CreateBlock(CreateLabel()); mCurrentBlock = blockFalseStart; ProcessStatement(pStatement.FalseBranch); HLInstructionBlock blockFalseEnd = mCurrentBlock; blockParent.EmitBranch(locationCondition, blockTrueStart.StartLabel, blockFalseStart.StartLabel); if (!blockTrueEnd.Terminated || !blockFalseEnd.Terminated) { mCurrentBlock = CreateBlock(CreateLabel()); blockTrueEnd.Terminate(mCurrentBlock.StartLabel); blockFalseEnd.Terminate(mCurrentBlock.StartLabel); } }
private void ProcessLabeledStatement(ILabeledStatement pStatement) { HLLabel labelTarget = null; if (!mRemappedLabels.TryGetValue(pStatement.Label.Value, out labelTarget)) { labelTarget = CreateLabel(); mRemappedLabels.Add(pStatement.Label.Value, labelTarget); } mCurrentBlock.Terminate(labelTarget); mCurrentBlock = CreateBlock(labelTarget); ProcessStatement(pStatement.Statement); }
internal void Process() { if (Definition.IsExternal) return; ISourceMethodBody sourceMethodBody = null; if (Definition.Body is ISourceMethodBody) sourceMethodBody = (ISourceMethodBody)Definition.Body; else sourceMethodBody = Decompiler.GetCodeModelFromMetadataModel(HLDomain.Host, Definition.Body, null); mCurrentBlock = CreateBlock(CreateLabel()); ProcessStatement(sourceMethodBody.Block); mCurrentBlock.Terminate(null); List<string> buf = new List<string>(); foreach (HLInstructionBlock block in mBlocks) foreach (HLInstruction instruction in block.Instructions) buf.Add(instruction.ToString()); }