/// <summary> /// Get a symbol representing a function that takes an unsigned integer /// parameter. /// </summary> /// <param name="unit">Module calling the function.</param> /// <param name="assembly">Name of the assembly.</param> /// <param name="type">Name of the class.</param> /// <param name="method">Name of the function.</param> /// <returns>FunctionSymbol representing the function.</returns> private static Phx.Symbols.FunctionSymbol GetFunctionSymbol(Phx.PEModuleUnit unit, string assembly, string type, string method) { // Look the function up in the cache Phx.Symbols.FunctionSymbol functionSymbol = null; if (FunctionSymbols.TryGetValue(unit, out functionSymbol) && functionSymbol != null) { return(functionSymbol); } // Create symbols for the assemblies and types Phx.Symbols.AssemblySymbol assemblySymbol = GetAssemblySymbol(unit, assembly); Phx.Symbols.MsilTypeSymbol typeSymbol = GetTypeSymbol(unit, type, assemblySymbol); // Build a symbol reference Phx.Types.FunctionTypeBuilder builder = Phx.Types.FunctionTypeBuilder.New(unit.TypeTable); builder.Begin(); builder.CallingConventionKind = Phx.Types.CallingConventionKind.ClrCall; builder.AppendReturnParameter(unit.TypeTable.VoidType); builder.AppendParameter(unit.TypeTable.UInt32Type); // Create the function symbol Phx.Name name = Phx.Name.New(unit.Lifetime, method); functionSymbol = Phx.Symbols.FunctionSymbol.New(unit.SymbolTable, 0, name, builder.GetFunctionType(), Phx.Symbols.Visibility.GlobalReference); typeSymbol.InsertInLexicalScope(functionSymbol, name); // Create a type Phx.Types.AggregateType aggregate = Phx.Types.AggregateType.NewDynamicSize(unit.TypeTable, typeSymbol); aggregate.IsDefinition = false; aggregate.AppendMethodSymbol(functionSymbol); // Cache the function FunctionSymbols[unit] = functionSymbol; return(functionSymbol); }