public void Generate(AssemblyLoader assemblyLoader, CodeGenerator codeGenerator) { MethodBodyLoader bodyLoader = new MethodBodyLoader(assemblyLoader, codeGenerator); BlockRegion baseRegion = bodyLoader.LoadBody(this, _body); LLVMTypeRef type = GetMethodType(codeGenerator); LLVMValueRef function = codeGenerator.GetFunction(MangledName, type); LLVM.SetLinkage(function, LLVMLinkage.LLVMExternalLinkage); FunctionGenerator functionGenerator = new FunctionGenerator(codeGenerator, this, function); functionGenerator.CreateBlock("entry", null); functionGenerator.Locals = new LLVMValueRef[_body.Variables.Count]; foreach (VariableDefinition variable in _body.Variables) { string name = "local_" + (string.IsNullOrEmpty(variable.Name) ? variable.Index.ToString() : variable.Name); LLVMTypeRef localType = assemblyLoader.ResolveType(variable.VariableType).GetStackType() .GetType(codeGenerator); functionGenerator.Locals[variable.Index] = LLVM.BuildAlloca(codeGenerator.Builder, localType, name); } foreach (Block block in bodyLoader.Blocks) { functionGenerator.CreateBlock(block, codeGenerator); } baseRegion.Generate(codeGenerator, functionGenerator); functionGenerator.SelectBlock("entry"); functionGenerator.Branch(bodyLoader.GetFirstBlock(), null); }
public Block(string name, BlockRegion region) { Name = name; Region = region; CallingBlocks = new List <Block>(); }
public CatchCase(IType type, BlockRegion region) { CatchType = type; Region = region; }
public Zone(BlockRegion parentRegion) { ParentRegion = parentRegion; }