Esempio n. 1
0
        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.");
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public static Type GetType(ExternFunction e) => e.DeclaringType ?? e.Function.DeclaringType !;