示例#1
0
 private static AstNode ParseIf(TokenStream stream)
 {
     IfStatement ifStmt = new IfStatement (stream.Location);
     stream.Expect (TokenClass.Keyword, "if");
     stream.Expect (TokenClass.OpenParan);
     ifStmt.Add (ParseExpression (stream));
     stream.Expect (TokenClass.CloseParan);
     ifStmt.Add (ParseStatement (stream));
     if (stream.Accept (TokenClass.Keyword, "else")) {
         ifStmt.Add (ParseStatement (stream));
     } else {
         ifStmt.Add (new CodeBlock (stream.Location));
     }
     return ifStmt;
 }
示例#2
0
 public void Accept(IfStatement ifStmt)
 {
     ifStmt.Visit (functionCompiler);
 }
示例#3
0
		public override void Accept (IfStatement ifStmt)
		{
			IodineLabel elseLabel = methodBuilder.CreateLabel ();
			IodineLabel endLabel = methodBuilder.CreateLabel ();
			ifStmt.Condition.Visit (this);
			methodBuilder.EmitInstruction (ifStmt.Body.Location, Opcode.JumpIfFalse, elseLabel);
			ifStmt.Body.Visit (this);
			methodBuilder.EmitInstruction (ifStmt.ElseBody.Location, Opcode.Jump, endLabel);
			methodBuilder.MarkLabelPosition (elseLabel);
			ifStmt.ElseBody.Visit (this);
			methodBuilder.MarkLabelPosition (endLabel);
		}
示例#4
0
		public override void Accept (IfStatement ifStmt)
		{
			errorLog.AddError (ErrorType.ParserError, ifStmt.Location,
				"statement can not exist inside pattern!");
		}
示例#5
0
 public virtual void Accept(IfStatement ifStmt)
 {
 }
示例#6
0
 public void Accept(IfStatement ifStmt)
 {
     ifStmt.VisitChildren (this);
 }
示例#7
0
 public void Accept(IfStatement ifStmt)
 {
     errorLog.AddError (ErrorType.ParserError, ifStmt.Location,
         "Statement not allowed outside function body!");
 }
示例#8
0
 public void Accept(IfStatement ifStmt)
 {
 }