/*public void Bind() * { * throw new NotImplementedException(); * }*/ public SLE.LambdaExpression BindAndTransform(MJCP.Expression expression, MJCP.BindingInfo bindingInfo) { Init(); //TODO test to know the internal of this and know the use of bindinginfo builder.Body = SLE.Expression.Block(Generate(expression)); return(builder.MakeLambda()); }
public ObjectLiteralElement(Expression Name, Expression Value, TextPoint ColonLocation, TextPoint CommaLocation) { this.Name = Name; this.Value = Value; this.ColonLocation = ColonLocation; this.CommaLocation = CommaLocation; }
public ForInStatement(Statement.Operation Opcode, Expression Collection, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint In, TextPoint LeftParen, TextPoint RightParen) :base(Opcode, Body, Location, LeftParen, RightParen) { this.Collection = Collection; this.HeaderLocation = HeaderLocation; this.In = In; }
public DoStatement(Statement Body, Expression Condition, TextSpan Location, TextSpan HeaderLocation, TextPoint While, TextPoint LeftParen, TextPoint RightParen) :base(Operation.Do, Body, Location, LeftParen, RightParen) { this.While = While; this.Condition = Condition; this.HeaderLocation = HeaderLocation; }
public BinaryOperatorExpression(Expression Left, Expression Right, Expression.Operation Opcode, TextSpan Location, TextPoint OperatorLocation) : base(Opcode,Location) { this.Left = Left; this.Right = Right; this.operatorLocation = OperatorLocation; }
public SubscriptExpression(Expression Base, Expression Subscript, TextSpan Location, TextPoint LeftBracketLocation) : base(Operation.Subscript, Location) { this.Base = Base; this.Subscript = Subscript; this.LeftBracketLocation = LeftBracketLocation; }
public DeclarationForInStatement(VariableDeclaration Item, Expression Collection, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint In, TextPoint LeftParen, TextPoint RightParen) :base(Operation.DeclarationForIn,Collection,Body,Location,HeaderLocation,In,LeftParen,RightParen) { this.Item = Item; this.In = In; this.LeftParen = LeftParen; this.RightParen = RightParen; }
public QualifiedExpression(Expression Base, Identifier Qualifier, TextSpan Location, TextPoint DotLocation, TextPoint QualifierLocation) :base(Operation.Qualified, Location) { this.Base = Base; this.Qualifier = Qualifier; this.DotLocation = DotLocation; this.QualifierLocation = QualifierLocation; }
public TernaryOperatorExpression(Expression First, Expression Second, Expression Third, Expression.Operation opcode, TextSpan Location, TextPoint FirstOperatorLocation, TextPoint SecondOperatorLocation) :base(opcode,Location) { this.First = First; this.Second = Second; this.Third = Third; this.FirstOperatorLocation = FirstOperatorLocation; this.SecondOperatorLocation = SecondOperatorLocation; }
public WithStatement(Expression Scope, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint LeftParen, TextPoint RightParen) :base(Operation.With,Location) { this.LeftParen = LeftParen; this.RightParen = RightParen; this.Body = Body; this.HeaderLocation = HeaderLocation; this.Scope = Scope; }
public ForStatement(Statement.Operation Opcode, Expression Condition, Expression Increment, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint FirstSemicolon, TextPoint SecondSemicolon, TextPoint LeftParen, TextPoint RightParen) :base(Opcode,Body,Location,LeftParen,RightParen) { this.Condition = Condition; this.Increment = Increment; this.HeaderLocation = HeaderLocation; this.FirstSemicolon= FirstSemicolon; this.SecondSemicolon = SecondSemicolon; }
public SwitchStatement(Expression Value, DList<CaseClause, SwitchStatement> Cases, TextSpan Location, TextSpan HeaderLocation, TextPoint LeftParen, TextPoint RightParen, TextPoint LeftBrace) :base(Operation.Switch,Location) { this.Value = Value; this.Cases = Cases; this.HeaderLocation = HeaderLocation; this.LeftParen = LeftParen; this.RightParen = RightParen; this.LeftBrace = LeftBrace; }
public IfStatement (Expression Condition, Statement IfBody, Statement ElseBody, TextSpan Location, TextSpan HeaderLocation, TextPoint LeftParen, TextPoint RightParen, TextPoint Else) : base (Operation.If, Location) { this.Condition = Condition; this.IfBody = IfBody; this.ElseBody = ElseBody; this.HeaderLocation = HeaderLocation; this.LeftParen = LeftParen; this.RightParen = RightParen; this.Else = Else; }
public void GenerateSyntaxError () { MJCP.Expression input = new MJCP.Expression (MJCP.Expression.Operation.SyntaxError, new TextSpan (0,0,0,0,0,0)); gen.SetGlobals (new MSIA.CodeBlock ("", new List<MSIA.Parameter> (0), new MSIA.EmptyStatement ())); Assert.IsNull (gen.Generate (input), "#1"); }
public void Generatethis () { MJCP.Expression input = new MJCP.Expression (MJCP.Expression.Operation.@this, new TextSpan (0,0,0,0,0,0)); gen.SetGlobals (new MSIA.CodeBlock ("", new List<MSIA.Parameter> (0), new MSIA.EmptyStatement ())); MSIA.Expression exp = gen.Generate (input); Assert.IsInstanceOfType (typeof (MSIA.MethodCallExpression), exp, "#1"); //here strange so must detect that there is no parent function Assert.AreEqual ("GetGlobalObject", ((MSIA.MethodCallExpression)exp).Method.Name, "#2"); Assert.IsNull ( ((MSIA.MethodCallExpression)exp).Instance, "#3"); Assert.AreEqual (1,((MSIA.MethodCallExpression)exp).Arguments.Count, "#4"); Assert.IsInstanceOfType (typeof (MSIA.CodeContextExpression), ((MSIA.MethodCallExpression)exp).Arguments[0], "#5"); // 2cd pass with a parent function to have a real this Parser parser = new Parser ("function foo () { var bar; this.bar=5;}".ToCharArray ()); List<Comment> comms = new List<Comment> (); input = parser.ParseExpression (ref comms); gen.SetGlobals (new MSIA.CodeBlock ("", new List<MSIA.Parameter> (0), new MSIA.EmptyStatement ())); exp = gen.Generate (input); IList<MSIA.Statement> statements = ((MSIA.BlockStatement)((MSIA.CodeBlockExpression)((MSIA.MethodCallExpression)((MSIA.BoundAssignment)exp).Value).Arguments[3]).Block.Body).Statements; exp = ((MSIA.ExpressionStatement)statements[0]).Expression;//the this Assert.IsInstanceOfType (typeof (MSIA.BoundAssignment), exp, "#6"); //((MSIA.BoundAssignment)exp).Reference.Name. //maptable. }
public ExpressionListElement(Expression Value, TextPoint CommaLocation) { this.Value = Value; this.CommaLocation = CommaLocation; }
private Expression ParseLeftHandSideExpression () { Token start = current; Expression expr; switch (current.Kind) { //primary expression case Token.Type.@this: expr = new Expression (Expression.Operation.@this, new TextSpan (current, current)); break; case Token.Type.Identifier: expr = new IdentifierExpression ((current as IdentifierToken).Spelling, new TextSpan (current, current)); break; case Token.Type.@null: expr = new NullExpression (new TextSpan (current, current)); break; case Token.Type.@true: expr = new Expression (Expression.Operation.@true, new TextSpan (current, current)); break; case Token.Type.@false: expr = new Expression (Expression.Operation.@false, new TextSpan (current, current)); break; case Token.Type.NumericLiteral: expr = new NumericLiteralExpression (((NumericLiteralToken)current).Spelling, new TextSpan (current, current)); break; case Token.Type.OctalIntegerLiteral: expr = new OctalLiteralExpression (((OctalIntegerLiteralToken)current).Value, new TextSpan (current, current)); break; case Token.Type.HexIntegerLiteral: expr = new HexLiteralExpression (((HexIntegerLiteralToken)current).Value, new TextSpan (current, current)); break; case Token.Type.StringLiteral: expr = new StringLiteralExpression ((current as StringLiteralToken).Value, (current as StringLiteralToken).Spelling, new TextSpan (current, current)); break; case Token.Type.LeftBracket: expr = ParseArrayLiteral (); break; case Token.Type.LeftBrace: expr = ParseObjectLiteral (); break; case Token.Type.LeftParenthesis: Next (); expr = new UnaryOperatorExpression(ParseExpression (), Expression.Operation.Parenthesized, new TextSpan(current,current)); CheckSyntaxExpected (Token.Type.RightParenthesis); break; //end primary case Token.Type.function: expr = new FunctionExpression (ParseFunctionDefinition ()); break; case Token.Type.@new: Next (); Expression target = ParseExpression (); ArgumentList arguments; if (current.Kind == Token.Type.LeftParenthesis) { arguments = this.ParseArgumentList (); } else { arguments = new ArgumentList (new List<ExpressionListElement> (), new TextSpan (start, current)); } expr = new InvocationExpression (target, arguments,Expression.Operation.@new, new TextSpan(start,current)); break; default: SyntaxError.Add ("Expression start with a strange token :" + current.Kind.ToString ()); return new Expression (Expression.Operation.SyntaxError, new TextSpan (start, current)); } Next (); // to go ahead for other part return ParseRightExpression (expr); }
public ExpressionForInStatement(Expression Item, Expression Collection, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint In, TextPoint LeftParen, TextPoint RightParen) : base(Operation.ExpressionFor, Collection, Body, Location, HeaderLocation, In, LeftParen, RightParen) { this.Item = Item; }
public UnaryOperatorExpression(Expression Operand, Expression.Operation Opcode, TextSpan Location) :base(Opcode, Location) { this.Operand = Operand; }
public ValueCaseClause(Expression Value, DList<Statement, CaseClause> Children, TextSpan Location, TextSpan HeaderLocation, TextPoint Colon) :base(Children, Location, HeaderLocation, Colon) { this.Value = Value; }
public ExpressionForStatement(Expression Initial, Expression Condition, Expression Increment, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint FirstSemicolon, TextPoint SecondSemicolon, TextPoint LeftParen, TextPoint RightParen) :base(Operation.ExpressionFor, Condition, Increment, Body, Location, HeaderLocation, FirstSemicolon, SecondSemicolon, LeftParen, RightParen) { this.Initial = Initial; }
public WhileStatement(Expression Condition, Statement Body, TextSpan Location, TextSpan HeaderLocation, TextPoint LeftParen, TextPoint RightParen) :base(Operation.While, Body, Location, LeftParen, RightParen) { this.HeaderLocation = HeaderLocation; this.Condition = Condition; }
//not in ecma but more clean to cut it from left hand side expr //group some of member expression and call expression private Expression ParseRightExpression (Expression expr) { Token start = current; while(true) { switch (current.Kind) { case Token.Type.LeftParenthesis: ArgumentList argumentList = ParseArgumentList (); expr = new InvocationExpression (expr, argumentList, Expression.Operation.Invocation, new TextSpan (start, current)); Next (); break; case Token.Type.LeftBracket: Next (); Expression subscript = ParseExpression (); CheckSyntaxExpected (Token.Type.RightBracket); expr = new SubscriptExpression (expr, subscript, new TextSpan (start, current), new TextPoint (start.StartPosition)); Next (); break; case Token.Type.Dot: Next (); Identifier id = null; if (CheckSyntaxExpected (Token.Type.Identifier)) id = ((IdentifierToken)current).Spelling; expr = new QualifiedExpression (expr, id, new TextSpan (start, current), new TextPoint (start.StartPosition), new TextPoint (current.StartPosition)); Next (); break; default: return expr; } } }
public ReturnOrThrowStatement(Statement.Operation Opcode, Expression Value, TextSpan Location) : base(Opcode, Location) { this.Value = Value; }
public InitializerVariableDeclaration(Identifier Name, Expression Initializer, TextSpan Location, TextPoint Equal) : base(Name, Location) { this.Initializer = Initializer; this.Equal = Equal; }
public ExpressionStatement(Expression Expression, TextSpan Location) :base(Operation.Expression, Location) { this.Expression = Expression; }
public InvocationExpression(Expression Target, ArgumentList Arguments, Expression.Operation Opcode, TextSpan Location) : base(Opcode, Location) { this.Target = Target; this.Arguments = Arguments; }