Example #1
0
 private static AstNode ParseTernaryIfElse(TokenStream stream)
 {
     AstNode expr = ParsePipeline (stream);
     while (stream.Accept (TokenClass.Keyword, "when")) {
         AstNode condition = ParseExpression (stream);
         stream.Expect (TokenClass.Keyword, "else");
         AstNode altValue = ParseTernaryIfElse (stream);
         expr = new TernaryExpression (expr.Location, condition, expr, altValue);
     }
     return expr;
 }
		public override void Accept (TernaryExpression ifExpr)
		{
			IodineLabel elseLabel = methodBuilder.CreateLabel ();
			IodineLabel endLabel = methodBuilder.CreateLabel ();
			ifExpr.Condition.Visit (this);
			methodBuilder.EmitInstruction (ifExpr.Expression.Location, Opcode.JumpIfFalse, elseLabel);
			ifExpr.Expression.Visit (this);
			methodBuilder.EmitInstruction (ifExpr.ElseExpression.Location, Opcode.Jump, endLabel);
			methodBuilder.MarkLabelPosition (elseLabel);
			ifExpr.ElseExpression.Visit (this);
			methodBuilder.MarkLabelPosition (endLabel);
		}
Example #3
0
 public void Accept(TernaryExpression ifExpr)
 {
     ifExpr.Visit (functionCompiler);
 }
Example #4
0
		public override void Accept (TernaryExpression ifExpr)
		{
			errorLog.AddError (ErrorType.ParserError, ifExpr.Location,
				"Expression can not exist inside pattern!");
		}
 public virtual void Accept(TernaryExpression ifExpr)
 {
 }
Example #6
0
 public void Accept(TernaryExpression ifExpr)
 {
     ifExpr.VisitChildren (this);
 }