void gentrace(compile_t* c, LLVMValueRef ctx, LLVMValueRef value, ast_t* type) { switch(trace_type(type)) { case TRACE_NONE: assert(0); return; case TRACE_PRIMITIVE: return; case TRACE_MAYBE: trace_maybe(c, ctx, value, type); return; case TRACE_ACTOR: trace_actor(c, ctx, value); return; case TRACE_KNOWN_VAL: trace_known(c, ctx, value, type, true); return; case TRACE_UNKNOWN_VAL: trace_unknown(c, ctx, value, true); return; case TRACE_KNOWN: trace_known(c, ctx, value, type, false); return; case TRACE_UNKNOWN: trace_unknown(c, ctx, value, false); return; case TRACE_TAG: trace_tag(c, ctx, value); return; case TRACE_TAG_OR_ACTOR: trace_tag_or_actor(c, ctx, value); return; case TRACE_DYNAMIC: { LLVMBasicBlockRef next_block = codegen_block(c, ""); trace_dynamic(c, ctx, value, type, type, NULL, next_block); LLVMBuildBr(c->builder, next_block); LLVMPositionBuilderAtEnd(c->builder, next_block); return; } case TRACE_TUPLE: trace_tuple(c, ctx, value, type); return; } }
bool gentrace(compile_t* c, LLVMValueRef ctx, LLVMValueRef value, ast_t* type) { bool tag = trace_as_tag(c, value, type); switch(ast_id(type)) { case TK_UNIONTYPE: case TK_ISECTTYPE: { if(tag) trace_tag_or_actor(c, ctx, value); else trace_unknown(c, ctx, value); return true; } case TK_TUPLETYPE: return trace_tuple(c, ctx, value, type); case TK_NOMINAL: { switch(ast_id((ast_t*)ast_data(type))) { case TK_INTERFACE: case TK_TRAIT: if(tag) trace_tag_or_actor(c, ctx, value); else trace_unknown(c, ctx, value); return true; case TK_PRIMITIVE: // Do nothing. return false; case TK_STRUCT: case TK_CLASS: if(tag) { if(is_maybe(type)) trace_maybe(c, ctx, value, type, true); else trace_tag(c, ctx, value); return true; } if(is_maybe(type)) { trace_maybe(c, ctx, value, type, false); return true; } return trace_known(c, ctx, value, type); case TK_ACTOR: trace_actor(c, ctx, value); return true; default: {} } break; } default: {} } assert(0); return false; }