private void DefineFunctionBody(FunctionDefinition node, Function function, LexicalScope topScope) { // Create the top basic block. BasicBlock topBlock = CreateBasicBlock(); topBlock.SetName("top"); builder.SetBlock(topBlock); // Prepare returning. PrepareReturning(node, function, topScope); // Store the arguments into local variables. FunctionPrototype prototype = node.GetPrototype(); AstNode argument = prototype.GetArguments(); byte index = 0; while(argument != null) { FunctionArgument argNode = (FunctionArgument) argument; LocalVariable argVar = argNode.GetVariable(); if(argVar != null && !argVar.IsPseudoScope()) { // Load the argument. builder.CreateLoadArg(index); // Store it into the local. builder.CreateStoreLocal(argVar); } // Process the next argument. argument = argument.GetNext(); index++; } // Generate constructor initialization. if(function.IsConstructor()) { Method ctor = (Method)function; ConstructorInitializer ctorInit = prototype.GetConstructorInitializer(); if(ctorInit != null) ctorInit.Accept(this); else CreateImplicitBaseConstructor(node, ctor); // Initialize some field. if(ctor.IsCtorLeaf()) { Structure building = (Structure)ctor.GetParentScope(); GenerateFieldInitializations(node, building); } } else if(function.IsStaticConstructor()) { // Generate static field initialization. Scope parent = function.GetParentScope(); Structure pbuilding = parent as Structure; if(pbuilding != null) GenerateStaticFieldInitializations(node, function, pbuilding); } // Visit his children. VisitList(node.GetChildren()); // Finish return. FinishReturn(node, function); }