public RloMethodBody(Compiler compiler, HighMethod method, MethodSpecTag methodSpec, TypeSpecClassTag thisType, bool isStruct, RloInstantiationParameters instParams, MethodInstantiationPath methodInstantiationPath) { m_instantiationPath = methodInstantiationPath; m_methodSpec = methodSpec; HighMethodBody methodBody = method.MethodBody; TagRepository tagRepo = compiler.TagRepository; // Validate locals uint numParamArgs = (uint)method.MethodSignature.ParamTypes.Length; if (method.IsStatic) { if (methodBody.InstanceLocal != null) throw new Exception("Instance local in static method"); } else { HighLocal thisLocal = methodBody.InstanceLocal; if (thisLocal == null) throw new Exception("Missing instance local in instance method"); HighLocal.ETypeOfType expectedTypeOfType = isStruct ? HighLocal.ETypeOfType.ByRef : HighLocal.ETypeOfType.Value; if (thisLocal.TypeOfType != expectedTypeOfType || thisLocal.Type.Instantiate(tagRepo, instParams.TypeParams, instParams.MethodParams) != thisType) throw new Exception("Invalid this type for method"); } if (numParamArgs != (uint)methodBody.Args.Length) throw new Exception("Mismatched argument count in method body and signature"); for (uint i = 0; i < numParamArgs; i++) { HighLocal bodyArg = methodBody.Args[i]; MethodSignatureParam methodSigParam = method.MethodSignature.ParamTypes[i]; MethodSignatureParamTypeOfType tot = methodSigParam.TypeOfType; HighLocal.ETypeOfType expectedTypeOfType; switch (tot.Value) { case MethodSignatureParamTypeOfType.Values.ByRef: expectedTypeOfType = HighLocal.ETypeOfType.ByRef; break; case MethodSignatureParamTypeOfType.Values.TypedByRef: expectedTypeOfType = HighLocal.ETypeOfType.TypedByRef; break; case MethodSignatureParamTypeOfType.Values.Value: expectedTypeOfType = HighLocal.ETypeOfType.Value; break; default: throw new ArgumentException(); } if (bodyArg.TypeOfType != expectedTypeOfType) throw new Exception("Method body arg doesn't match signature"); } HighLocal instanceLocal = methodBody.InstanceLocal; RloMethodConverter methodConverter = new RloMethodConverter(compiler.TagRepository, instParams, method.MethodSignature.RetType, instanceLocal, methodBody.Args, methodBody.Locals); RloRegionConverter regionConverter = new RloRegionConverter(methodConverter, methodBody.MainRegion, true); m_locals = methodConverter.Locals2; m_args = methodConverter.Args; m_instanceLocal = methodConverter.InstanceLocal; m_returnType = methodConverter.ReturnType; m_entryRegion = new HighRegion(regionConverter.EntryNode); m_methodSignature = method.MethodSignature; RloFindPredecessorsAndSuccessorsPass psPass = new RloFindPredecessorsAndSuccessorsPass(compiler, this); psPass.Run(); RloCanonicalizeSsaTypesPass cstPass = new RloCanonicalizeSsaTypesPass(compiler, this); cstPass.Run(); RloInitPass initPass = new RloInitPass(compiler, this, psPass); initPass.Run(); RloInitExceptionsPass exceptionInitPass = new RloInitExceptionsPass(compiler, this); exceptionInitPass.Run(); }
public RegionProcessor(RloInitExceptionsPass initPass, RegionStack regionStack, bool isTry, bool canReturnNothing) { m_initPass = initPass; m_isTry = isTry; m_alreadyQueuedNodes = new HashSet<HighCfgNode>(); m_queuedNodes = new Queue<HighCfgNode>(); m_canReturnNothing = canReturnNothing; if (regionStack != null) { m_regionStack = regionStack; if (m_isTry) m_exceptionNode = regionStack.ExceptionHandler; else { RegionStack parent = regionStack.Next; if (parent != null) m_exceptionNode = parent.ExceptionHandler; } HighTryFinallyRegion tryFinallyRegion = regionStack.EHCluster.ProtectedRegion as HighTryFinallyRegion; if (tryFinallyRegion != null && !m_isTry) m_finallyCleanupNode = GenerateFinallyCleanup(regionStack.EHCluster, tryFinallyRegion, regionStack.ExceptionHandler); } }