public override Value Visit(RoutineDeclaration node) { ProceduralType functype = node.Type; TypeRef llvmfrettype = (node.IsFunction ? GetLLVMType(functype.funcret) : TypeRef.CreateVoid()); var @params = [email protected](); var args = @params.Select(a => GetLLVMType(a.type)); Function func = new Function(module, node.name, llvmfrettype, args.ToArray()); func.SetLinkage(LLVMLinkage.ExternalLinkage); // If F conflicted, there was already something named 'Name'. If it has a // body, don't allow redefinition or reextern. if (func.IsDuplicate()) { // Delete the one we just made and get the existing one. func.Delete(); func = module.GetFunction(node.name); } // Set names for all arguments. uint i = 0; foreach (var param in @params) { Value val = func.GetParameter(i++); val.Name = param.name; // calls llvm } valuemap.AddValue(node, func); return(func); }
public virtual T Visit(ProceduralType node) { Visit((TypeNode)node); traverse(node.@params); traverse(node.Directives); return(traverse(node.funcret)); }
public override bool Visit(CallableDeclaration node) { ProceduralType pp = node.type as ProceduralType; traverse(pp.funcret); string name = node.name as string; outputCode(name, false, false); outputCode("(", false, false); DeclarationList p = [email protected]; int i = 0; foreach (ParamDeclaration pd in p) { if (i > 0) { outputCode(", ", false, false); } traverse(pd); i++; } outputCode(")", false, true); traverse(node.Directives); return(true); }
public override bool Visit(ProceduralType node) { Visit((TypeNode)node); TraversePrint(node.@params); TraversePrint(node.funcret); TraversePrint(node.Directives); return(true); }
public override bool Visit(ProceduralType node) { traverse(node.funcret); outputCode("(*", false, false); traverse(node.@params); outputCode(")", false, false); return(true); }
public override bool Visit(MethodDefinition node) { if (node.IsFunction) { ProceduralType pp = node.type as ProceduralType; node.body.decls.Add(new VarDeclaration("result", pp.funcret)); } if (node.Type.funcret == null) { outputCode("void ", false, false); } else { traverse(node.Type.funcret); } String metid; /*if (node.Type.IsDestructor) * metid = "::~" + node.objname; * else if (node.Type.IsConstructor) * metid = "::" + node.objname; * else*/ metid = "::" + node.name; outputCode(node.objname + metid + "(", false, false); traverse(node.Type.@params); outputCode(")", false, true); outputCode("{", false, true); PushIdent(); if (node.Type.IsConstructor) { ProcessConstructor(node.body, node.Type); } else { traverse(node.body); } if (node.IsFunction) { builder.Remove(builder.Length - 3, 3); outputCode(" return result;", true, true); outputCode("}", true, true); } PopIdent(); outputCode("}", false, true); outputCode("", false, true); return(true); }
public override bool Visit(RoutineDefinition node) { if (node.IsFunction) { ProceduralType p = node.type as ProceduralType; node.body.decls.Add(new VarDeclaration("result", p.funcret)); } Visit((CallableDeclaration)node); traverse(node.body); if (node.IsFunction) { builder.Remove(builder.Length - 3, 3); outputCode(" return result;", true, true); outputCode("}", true, true); } outputCode("", false, true); return(true); }