aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-26 16:00:39 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-26 16:00:39 -0700
commita73453a2680cdbe4decb946f5f8355e83b521aa2 (patch)
tree93922996fba980dc65d648f9dfae7ddc50fe0419 /src/codegen.cpp
parent5afe473a86c2fe32b6d7c472b71f88e70ac671c6 (diff)
downloadzig-a73453a2680cdbe4decb946f5f8355e83b521aa2.tar.gz
zig-a73453a2680cdbe4decb946f5f8355e83b521aa2.zip
add c_import top level decl
see #88
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 0c91f496db..98dbfd03e5 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -177,6 +177,9 @@ static LLVMValueRef gen_builtin_fn_call_expr(CodeGen *g, AstNode *node) {
switch (builtin_fn->id) {
case BuiltinFnIdInvalid:
case BuiltinFnIdTypeof:
+ case BuiltinFnIdCInclude:
+ case BuiltinFnIdCDefine:
+ case BuiltinFnIdCUndef:
zig_unreachable();
case BuiltinFnIdAddWithOverflow:
case BuiltinFnIdSubWithOverflow:
@@ -2250,7 +2253,8 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) {
case NodeTypeFnDecl:
case NodeTypeParamDecl:
case NodeTypeDirective:
- case NodeTypeUse:
+ case NodeTypeImport:
+ case NodeTypeCImport:
case NodeTypeStructDecl:
case NodeTypeStructField:
case NodeTypeStructValueField:
@@ -2930,6 +2934,9 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn_with_arg_count(g, BuiltinFnIdAddWithOverflow, "add_with_overflow", 4);
create_builtin_fn_with_arg_count(g, BuiltinFnIdSubWithOverflow, "sub_with_overflow", 4);
create_builtin_fn_with_arg_count(g, BuiltinFnIdMulWithOverflow, "mul_with_overflow", 4);
+ create_builtin_fn_with_arg_count(g, BuiltinFnIdCInclude, "c_include", 1);
+ create_builtin_fn_with_arg_count(g, BuiltinFnIdCDefine, "c_define", 2);
+ create_builtin_fn_with_arg_count(g, BuiltinFnIdCUndef, "c_undef", 1);
}
@@ -3138,8 +3145,8 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *abs_full_path,
}
}
}
- } else if (top_level_decl->type == NodeTypeUse) {
- Buf *import_target_path = &top_level_decl->data.use.path;
+ } else if (top_level_decl->type == NodeTypeImport) {
+ Buf *import_target_path = &top_level_decl->data.import.path;
Buf full_path = BUF_INIT;
Buf *import_code = buf_alloc();
bool found_it = false;
@@ -3163,7 +3170,7 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *abs_full_path,
auto entry = g->import_table.maybe_get(abs_full_path);
if (entry) {
found_it = true;
- top_level_decl->data.use.import = entry->value;
+ top_level_decl->data.import.import = entry->value;
} else {
if ((err = os_fetch_file_path(abs_full_path, import_code))) {
if (err == ErrorFileNotFound) {
@@ -3175,8 +3182,8 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *abs_full_path,
goto done_looking_at_imports;
}
}
- top_level_decl->data.use.import = codegen_add_code(g,
- abs_full_path, search_path, &top_level_decl->data.use.path, import_code);
+ top_level_decl->data.import.import = codegen_add_code(g,
+ abs_full_path, search_path, &top_level_decl->data.import.path, import_code);
found_it = true;
}
break;