public ILCompilationUnit BuildAst( ControlFlowGraph graph, IFrameLayout frameLayout, VMConstants constants) { var result = BuildBasicAst(graph, frameLayout); OnInitialAstBuilt(result); ApplyTransformations(result, constants); return(result); }
public ILCompilationUnit(ControlFlowGraph controlFlowGraph, IFrameLayout frameLayout) { ControlFlowGraph = controlFlowGraph ?? throw new ArgumentNullException(nameof(controlFlowGraph)); FrameLayout = frameLayout; DominatorInfo = new DominatorInfo(controlFlowGraph.Entrypoint); DominatorTree = DominatorInfo.ToDominatorTree(); for (int i = 0; i < frameLayout.Parameters.Count; i++) { var parameter = new ILParameter("arg_" + i, i); Parameters.Add(parameter); _variables.Add(parameter.Name, parameter); } }
public ILCompilationUnit BuildAst( ControlFlowGraph graph, IFrameLayout frameLayout, VMConstants constants) { Logger.Debug(Tag, "Building initial IL-AST..."); var result = BuildBasicAst(graph, frameLayout); OnInitialAstBuilt(result); Logger.Debug(Tag, "Applying IL-AST transforms..."); ApplyTransformations(result, constants); return(result); }
private ILCompilationUnit BuildBasicAst(ControlFlowGraph graph, IFrameLayout frameLayout) { var result = new ILCompilationUnit(graph, frameLayout); // Introduce variables: Logger.Debug2(Tag, "Determining variables..."); var resultVariables = DetermineVariables(result); // Build AST blocks. Logger.Debug2(Tag, "Building AST blocks..."); BuildAstBlocks(result, resultVariables); Logger.Debug2(Tag, "Marking expressions affecting flags..."); var marker = new FlagDataSourceMarker(); result.AcceptVisitor(marker); return(result); }
private static MethodSignature CreateMethodSignature(DevirtualisationContext context, IFrameLayout layout) { var methodSignature = new MethodSignature(layout.ReturnType ?? context.TargetImage.TypeSystem.Object); // Add parameters. for (int i = 0; i < layout.Parameters.Count; i++) { methodSignature.Parameters.Add( new ParameterSignature(layout.Parameters[i].Type ?? context.TargetImage.TypeSystem.Object)); } methodSignature.HasThis = layout.HasThis; return(methodSignature); }
private static MethodSignature CreateMethodSignature(DevirtualisationContext context, IFrameLayout layout) { var flags = layout.HasThis ? CallingConventionAttributes.HasThis : 0; var returnType = layout.ReturnType ?? context.TargetModule.CorLibTypeFactory.Object; var parameterTypes = new List <TypeSignature>(); // Add parameters. for (int i = 0; i < layout.Parameters.Count; i++) { parameterTypes.Add(layout.Parameters[i].Type ?? context.TargetModule.CorLibTypeFactory.Object); } return(new MethodSignature(flags, returnType, parameterTypes)); }