private static void Conditional(Compiler c, bool allowAssignment) { // Ignore newline after '?'. c.IgnoreNewlines(); // Jump to the else branch if the condition is false. int ifJump = c.EmitJump(Instruction.JumpIf); // Compile the then branch. c.ParsePrecedence(allowAssignment, Precedence.Ternary); c.Consume(TokenType.Colon, "Expect ':' after then branch of conditional operator."); c.IgnoreNewlines(); // Jump over the else branch when the if branch is taken. int elseJump = c.EmitJump(Instruction.Jump); // Compile the else branch. c.PatchJump(ifJump); c.ParsePrecedence(allowAssignment, Precedence.Assignment); // Patch the jump over the else. c.PatchJump(elseJump); }
private static void and_(Compiler c, bool allowAssignment) { c.IgnoreNewlines(); // Skip the right argument if the left is false. int jump = c.EmitJump(Instruction.And); c.ParsePrecedence(false, Precedence.LogicalAnd); c.PatchJump(jump); }