static void or_(Compiler c, bool allowAssignment) { c.IgnoreNewlines(); // Skip the right argument if the left is true. int jump = c.EmitJump(Instruction.OR); c.ParsePrecedence(false, Precedence.LogicalOr); c.PatchJump(jump); }
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.JUMP_IF); // 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.PREC_LOGICAL_AND); c.PatchJump(jump); }