コード例 #1
0
        protected Delegate primitiveFunctionFor(List <KeywordMessageArgument> arguments)
        {
            ParseTreeNode node;
            var           argNames = argNamesFromPrimitiveSpecArgumentList(
                arguments,
                (errorMessage, span)
                => compiler.handlePrimitiveSpeficationError(errorMessage, span));
            ESSymbol            primName   = symbolRegistry.symbolFor(argNames[0]);
            String              domainName = argNames[1];
            PrimitiveDomainType domain     = (PrimitiveDomainType)ushort.MaxValue;         // On account of typical statically-typed compiler stupidity.

            try {
                domain = (PrimitiveDomainType)Enum.Parse(typeof(PrimitiveDomainType), domainName);
            } catch {
                Context.markAsUncompilable();
                node = arguments[1];
                compiler.handlePrimitiveSpeficationError(
                    "Unknown primitive domain <" + domainName + ">.",
                    node.Span);
            }
            Delegate function;

            if (!objectSpace.getPrimitiveFunction(domain, primName, out function))
            {
                Context.markAsUncompilable();
                node = arguments[0];
                compiler.handlePrimitiveSpeficationError(
                    "No primitive named <" + primName.PrimitiveValue + "> is defined in the primitive domain <" + domainName + ">.",
                    node.Span);
            }
            return(function);
        }