Commit cd18186715

kristopher tate <kt@connectfree.co.jp>
2018-07-27 12:18:29
src/codegen.cpp: base handle builtin on `@frameAddress()`;
Tracking Issue #1296 ;
1 parent a9ea22d
Changed files (1)
src/codegen.cpp
@@ -4146,6 +4146,15 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutable *executable
     return LLVMBuildCall(g->builder, get_frame_address_fn_val(g), &zero, 1, "");
 }
 
+static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutable *executable,
+        IrInstructionHandle *instruction)
+{
+    // @andrewrk, not sure what to place here ?
+    // `get_promise_frame_type` ?
+    LLVMValueRef handle = LLVMConstNull(g->builtin_types.entry_promise->type_ref);
+    return LLVMBuildRet(g->builder, handle);
+}
+
 static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp *instruction) {
     TypeTableEntry *int_type = instruction->result_ptr_type;
     assert(int_type->id == TypeTableEntryIdInt);
@@ -4910,6 +4919,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
             return ir_render_return_address(g, executable, (IrInstructionReturnAddress *)instruction);
         case IrInstructionIdFrameAddress:
             return ir_render_frame_address(g, executable, (IrInstructionFrameAddress *)instruction);
+        case IrInstructionIdHandle:
+            return ir_render_handle(g, executable, (IrInstructionHandle *)instruction);
         case IrInstructionIdOverflowOp:
             return ir_render_overflow_op(g, executable, (IrInstructionOverflowOp *)instruction);
         case IrInstructionIdTestErr:
@@ -6344,6 +6355,7 @@ static void define_builtin_fns(CodeGen *g) {
     create_builtin_fn(g, BuiltinFnIdBreakpoint, "breakpoint", 0);
     create_builtin_fn(g, BuiltinFnIdReturnAddress, "returnAddress", 0);
     create_builtin_fn(g, BuiltinFnIdFrameAddress, "frameAddress", 0);
+    create_builtin_fn(g, BuiltinFnIdHandle, "handle", 0);
     create_builtin_fn(g, BuiltinFnIdMemcpy, "memcpy", 3);
     create_builtin_fn(g, BuiltinFnIdMemset, "memset", 3);
     create_builtin_fn(g, BuiltinFnIdSizeof, "sizeOf", 1);