Exemple #1
0
 public abstract void Visit(PrimitiveExpression expression);
Exemple #2
0
        public override void Visit(PrimitiveExpression expression)
        {
            this.writer.Write(string.Format("var _primitive = primitives.primitive{0}(self", expression.Number));

            foreach (var parameter in this.CurrentMethod.ParameterNames)
            {
                this.writer.Write(", ");
                this.writer.Write(parameter);
            }

            this.writer.WriteLine(");");
            this.writer.WriteLine("if (_primitive) return _primitive.value;");
        }
Exemple #3
0
 public override void Visit(PrimitiveExpression expression)
 {
     if (!string.IsNullOrEmpty(expression.Module))
         this.block.CompileByteCode(ByteCode.NamedPrimitive, this.block.CompileConstant(expression.Name), this.block.CompileConstant(expression.Module));
     else
         this.block.CompileByteCode(ByteCode.Primitive, (byte)expression.Number);
 }
Exemple #4
0
        private IExpression ParsePrimitive()
        {
            this.ParseToken(TokenType.Name, "primitive:");
            int number;
            string name;
            string module;
            IExpression primitive = null;

            Token token = this.NextToken();

            if (token.Type == TokenType.Integer)
            {
                number = Convert.ToInt32(token.Value, CultureInfo.InvariantCulture);
                string error = null;
                if (this.TryParseToken(TokenType.Name, "error:"))
                    error = this.ParseName();
                primitive = new PrimitiveExpression(number, error);
            }
            else if (token.Type == TokenType.String)
            {
                name = token.Value;
                this.ParseToken(TokenType.Name, "module:");
                module = this.ParseString();
                primitive = new PrimitiveExpression(name, module);
            }
            else
                throw new ParserException("String or Number expected in Primitive");

            this.ParseToken(TokenType.Operator, ">");

            return primitive;
        }