Esempio n. 1
0
        /// <summary>
        /// Creates a prototype for this function, overriding
        /// any existing prototype property value. Creates arguments.
        /// </summary>
        public Prototype CreatePrototype()
        {
            // Default the return type to void.
            ITypeEmitter returnType = PrimitiveTypeFactory.Void();

            // Create a new prototype instance.
            this.Prototype = new Prototype(NameRegister.GetAnonymous(), null, returnType);

            // Create formal arguments after assigning prototype to avoid infinite loop.
            FormalArgs args = this.CreateArgs();

            // Assign the formal arguments.
            this.Prototype.Args = args;

            // Return the prototype.
            return(this.Prototype);
        }
Esempio n. 2
0
        public Expr Parse(ParserContext context)
        {
            // Create a lambda expression.
            LambdaExpr lambda = new LambdaExpr();

            // Parse the formal arguments.
            FormalArgs args = new FormalArgsParser().Parse(context);

            // Assign the parsed arguments to the lambda.
            lambda.Args = args;

            // Create the type buffer, defaulting to void.
            ITypeEmitter type = PrimitiveTypeFactory.Void();

            // Return type is explicitly specified, parse and use it instead of the default.
            if (context.Stream.Current.Type == TokenType.SymbolColon)
            {
                // Ensure current type is symbol colon.
                context.Stream.EnsureCurrent(TokenType.SymbolColon);

                // Skip symbol colon token.
                context.Stream.Skip();

                // Parse the return type.
                type = new TypeParser().Parse(context);
            }

            // Assign the parsed type to the return type.
            lambda.ReturnType = type;

            // Ensure current token is symbol arrow.
            context.Stream.EnsureCurrent(TokenType.SymbolArrow);

            // Skip arrow symbol token.
            context.Stream.Skip();

            // Parse the body block.
            Block body = new BlockParser().Parse(context);

            // Assign the block to the lambda.
            lambda.Body = body;

            // Return the resulting expression.
            return(lambda);
        }
Esempio n. 3
0
 public Prototype(string name, FormalArgs args, ITypeEmitter returnType)
 {
     this.SetName(name);
     this.Args       = args;
     this.ReturnType = returnType;
 }
Esempio n. 4
0
 public ArrayExpr(ITypeEmitter type, Expr[] values)
 {
     this.Type   = type;
     this.Values = values;
 }
 public JsonRpcDescriptionProvider(IMethodMatcher methodMatcher, ITypeEmitter typeEmitter, IOptions <JsonRpcOptions> options)
 {
     this.methodMatcher = methodMatcher;
     this.typeEmitter   = typeEmitter;
     this.options       = options.Value;
 }
Esempio n. 6
0
 public ArrayExprParser(ITypeEmitter type)
 {
     this.type = type;
 }
Esempio n. 7
0
 public TypeFactory(ITypeEmitter emitter)
 {
     _emitter = emitter;
 }