Exemple #1
0
		private void CompileBooleanCombination(Parser parser, ByteBuffer buffer, BooleanCombination boolComb, bool outputUsed)
		{
			if (!outputUsed) throw new ParserException(boolComb.FirstToken, "Cannot have this expression here.");

			ByteBuffer rightBuffer = new ByteBuffer();
			Expression[] expressions = boolComb.Expressions;
			this.CompileExpression(parser, rightBuffer, expressions[expressions.Length - 1], true);
			for (int i = expressions.Length - 2; i >= 0; --i)
			{
				ByteBuffer leftBuffer = new ByteBuffer();
				this.CompileExpression(parser, leftBuffer, expressions[i], true);
				Token op = boolComb.Ops[i];
				if (op.Value == "&&")
				{
					leftBuffer.Add(op, OpCode.JUMP_IF_FALSE_NO_POP, rightBuffer.Size);
				}
				else
				{
					leftBuffer.Add(op, OpCode.JUMP_IF_TRUE_NO_POP, rightBuffer.Size);
				}
				leftBuffer.Concat(rightBuffer);
				rightBuffer = leftBuffer;
			}

			buffer.Concat(rightBuffer);
		}
Exemple #2
0
		protected override void TranslateBooleanCombination(List<string> output, BooleanCombination booleanCombination)
		{
			output.Add("(");
			this.TranslateExpression(output, booleanCombination.Expressions[0]);
			output.Add(")");

			for (int i = 0; i < booleanCombination.Ops.Length; ++i)
			{
				if (booleanCombination.Ops[i].Value == "&&")
				{
					output.Add(" and ");
				}
				else
				{
					output.Add(" or ");
				}

				output.Add("(");
				this.TranslateExpression(output, booleanCombination.Expressions[i + 1]);
				output.Add(")");
			}
		}
Exemple #3
0
		protected abstract void TranslateBooleanCombination(List<string> output, BooleanCombination booleanCombination);