public override void Accept (ForeachStatement foreachStmt)
		{
			IodineLabel foreachLabel = methodBuilder.CreateLabel ();
			IodineLabel breakLabel = methodBuilder.CreateLabel ();
			breakLabels.Push (breakLabel);
			continueLabels.Push (foreachLabel);
			foreachStmt.Iterator.Visit (this);
			int tmp = methodBuilder.CreateTemporary (); 
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.Dup);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.StoreLocal, tmp);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.IterReset);
			methodBuilder.MarkLabelPosition (foreachLabel);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.LoadLocal, tmp);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.IterMoveNext);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.JumpIfFalse,
				breakLabel);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.LoadLocal, tmp);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.IterGetNext);
			methodBuilder.EmitInstruction (foreachStmt.Iterator.Location, Opcode.StoreLocal,
				symbolTable.GetSymbol
				(foreachStmt.Item).Index);
			foreachStmt.Body.Visit (this);
			methodBuilder.EmitInstruction (foreachStmt.Body.Location, Opcode.Jump, foreachLabel);
			methodBuilder.MarkLabelPosition (breakLabel);
			breakLabels.Pop ();
			continueLabels.Pop ();
		}
Example #2
0
 public void Accept(ForeachStatement foreachStmt)
 {
     foreachStmt.Visit (functionCompiler);
 }
Example #3
0
		public override void Accept (ForeachStatement foreachStmt)
		{
			errorLog.AddError (ErrorType.ParserError, foreachStmt.Location,
				"statement can not exist inside pattern!");
		}
 public virtual void Accept(ForeachStatement foreachStmt)
 {
 }
Example #5
0
 public void Accept(ForeachStatement foreachStmt)
 {
     symbolTable.AddSymbol (foreachStmt.Item);
     foreachStmt.Iterator.Visit (this);
     foreachStmt.Body.Visit (this);
 }
Example #6
0
 public void Accept(ForeachStatement foreachStmt)
 {
     errorLog.AddError (ErrorType.ParserError, foreachStmt.Location,
         "Statement not allowed outside function body!");
 }