// File: /workspace/github_c_makefile_star2_O0/atomlang[P]atomlang/src/pk_compiler.c
// Function: eatString
static void eatString(Compiler* compiler, bool single_quote) {
  pkByteBuffer buff;
  pkByteBufferInit(&buff);

  char quote = (single_quote) ? '\'' : '"';

  while (true) {
    char c = eatChar(compiler);

    if (c == quote) break;

    if (c == '\0') {
      lexError(compiler, "Non terminated string.");

      // Null byte is required by TK_EOF.
      compiler->current_char--;
      break;
    }

    if (c == '\\') {
      switch (eatChar(compiler)) {
        case '"':  pkByteBufferWrite(&buff, compiler->vm, '"'); break;
        case '\'': pkByteBufferWrite(&buff, compiler->vm, '\''); break;
        case '\\': pkByteBufferWrite(&buff, compiler->vm, '\\'); break;
        case 'n':  pkByteBufferWrite(&buff, compiler->vm, '\n'); break;
        case 'r':  pkByteBufferWrite(&buff, compiler->vm, '\r'); break;
        case 't':  pkByteBufferWrite(&buff, compiler->vm, '\t'); break;

        default:
          lexError(compiler, "Error: invalid escape character");
          break;
      }
    } else {
      pkByteBufferWrite(&buff, compiler->vm, c);
    }
  }

  // '\0' will be added by varNewSring();
  Var string = VAR_OBJ(newStringLength(compiler->vm, (const char*)buff.data,
                       (uint32_t)buff.count));

  pkByteBufferClear(&buff, compiler->vm);

  setNextValueToken(compiler, TK_STRING, string);
}

// Assembly:
subq $0x38, %rsp
movb %sil, %al
movq %rdi, 0x30(%rsp)
andb $0x1, %al
movb %al, 0x2f(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x30d0
movb 0x2f(%rsp), %dl
movl $0x22, %eax
movl $0x27, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movb %al, 0x17(%rsp)
movq 0x30(%rsp), %rdi
callq 0x187c0
movb %al, 0x16(%rsp)
movsbl 0x16(%rsp), %eax
movsbl 0x17(%rsp), %ecx
cmpl %ecx, %eax
jne 0x18e95
jmp 0x18ff6
movsbl 0x16(%rsp), %eax
cmpl $0x0, %eax
jne 0x18ec8
movq 0x30(%rsp), %rdi
leaq 0x12751(%rip), %rsi     # 0x2b5fc
movb $0x0, %al
callq 0x19190
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0x18ff6
movsbl 0x16(%rsp), %eax
cmpl $0x5c, %eax
jne 0x18fda
movq 0x30(%rsp), %rdi
callq 0x187c0
movsbl %al, %eax
movl %eax, 0x4(%rsp)
subl $0x22, %eax
je 0x18f2c
jmp 0x18eee
movl 0x4(%rsp), %eax
subl $0x27, %eax
je 0x18f48
jmp 0x18ef9
movl 0x4(%rsp), %eax
subl $0x5c, %eax
je 0x18f61
jmp 0x18f04
movl 0x4(%rsp), %eax
subl $0x6e, %eax
je 0x18f7a
jmp 0x18f0f
movl 0x4(%rsp), %eax
subl $0x72, %eax
je 0x18f93
jmp 0x18f1a
movl 0x4(%rsp), %eax
subl $0x74, %eax
je 0x18fac
jmp 0x18fc5
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movl $0x22, %edx
callq 0x3270
jmp 0x18fd8
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movl $0x27, %edx
callq 0x3270
jmp 0x18fd8
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movl $0x5c, %edx
callq 0x3270
jmp 0x18fd8
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movl $0xa, %edx
callq 0x3270
jmp 0x18fd8
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movl $0xd, %edx
callq 0x3270
jmp 0x18fd8
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movl $0x9, %edx
callq 0x3270
jmp 0x18fd8
movq 0x30(%rsp), %rdi
leaq 0x12642(%rip), %rsi     # 0x2b613
movb $0x0, %al
callq 0x19190
jmp 0x18ff1
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
movzbl 0x16(%rsp), %edx
callq 0x3270
jmp 0x18e74
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x18(%rsp), %rsi
movl 0x20(%rsp), %edx
callq 0x2760
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
orq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %rdi
callq 0x3100
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rdx
movl $0x49, %esi
callq 0x192b0
addq $0x38, %rsp
retq
nopl (%rax)