public Allocator(ExternMemory memory, IReadOnlyList <ExternFunction> functions) { _memory = memory ?? throw new ArgumentNullException(nameof(memory)); _malloc = functions .Where(f => f.Name == "__wbindgen_malloc") .SingleOrDefault() ?? throw new ArgumentException("Unable to resolve malloc function."); _free = functions .Where(f => f.Name == "__wbindgen_free") .SingleOrDefault() ?? throw new ArgumentException("Unable to resolve free function."); }
static Function MakeExternFunction(Module module, RheaParser.ExternFunctionDeclarationContext context) { var name = context.functionDeclaration().name().GetText(); var type = new Type(context.functionDeclaration().type().GetText()); var newFunction = new ExternFunction { Name = name, Type = type, Module = module, Parameters = context.functionDeclaration()._parameters.Select(p => new FunctionParameter { Context = p, Name = p.name().GetText(), Type = new Type(p.type().GetText()) }) }; return(newFunction); }
public static Type GetType(ExternFunction e) => e.DeclaringType ?? e.Function.DeclaringType !;