Пример #1
0
		protected override void TranslateForLoop(List<string> output, ForLoop exec)
		{
			this.Translate(output, exec.Init);
			output.Add(this.CurrentTabIndention);
			output.Add(this.Shorten("while ("));
			this.TranslateExpression(output, exec.Condition);
			if (this.isEgyptian)
			{
				output.Add(this.Shorten(") {") + this.NL);
			}
			else
			{
				output.Add(")");
				output.Add(this.NL);
				output.Add(this.CurrentTabIndention);
				output.Add("{");
				output.Add(this.NL);
			}
			this.CurrentIndention++;
			this.Translate(output, exec.Code);
			this.Translate(output, exec.Step);
			this.CurrentIndention--;
			output.Add(this.CurrentTabIndention);
			output.Add("}" + this.NL);
		}
Пример #2
0
		private void CompileForLoop(Parser parser, ByteBuffer buffer, ForLoop forLoop)
		{
			this.Compile(parser, buffer, forLoop.Init);

			ByteBuffer codeBuffer = new ByteBuffer();
			this.Compile(parser, codeBuffer, forLoop.Code);
			codeBuffer.ResolveContinues(true); // resolve continues as jump-to-end before you add the step instructions.
			this.Compile(parser, codeBuffer, forLoop.Step);

			ByteBuffer forBuffer = new ByteBuffer();
			this.CompileExpression(parser, forBuffer, forLoop.Condition, true);
			forBuffer.Add(forLoop.Condition.FirstToken, OpCode.JUMP_IF_FALSE, codeBuffer.Size + 1); // +1 to go past the jump I'm about to add.

			forBuffer.Concat(codeBuffer);
			forBuffer.Add(null, OpCode.JUMP, -forBuffer.Size - 1);

			forBuffer.ResolveBreaks();

			buffer.Concat(forBuffer);
		}
Пример #3
0
		protected abstract void TranslateForLoop(List<string> output, ForLoop forLoop);