| author | |
| committer | |
| log | 1f48b626a1cef1168d23654f5a9f21ed2196738e |
| tree | 697d703a204b26c2cb34b494a7ab53d75785f936 |
| parent | 673d638070452d86543c6bb47879e83adcfa73a1 |
4 files changed, 8 insertions(+), 15 deletions(-)
example/hello_world/hello.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ export executable "hello"; |
| 2 | 2 | |
| 3 | 3 | use "std.zig"; |
| 4 | 4 | |
| 5 | export fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { | |
| 5 | pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 { | |
| 6 | 6 | // TODO implicit coercion from array to string |
| 7 | 7 | print_str("Hello, world!\n" as string); |
| 8 | 8 | return 0; |
src/analyze.cpp+1-1| ... | ... | @@ -315,7 +315,7 @@ static void preview_function_declarations(CodeGen *g, ImportTableEntry *import, |
| 315 | 315 | auto entry = import->fn_table.maybe_get(proto_name); |
| 316 | 316 | bool skip = false; |
| 317 | 317 | bool is_internal = (proto_node->data.fn_proto.visib_mod != FnProtoVisibModExport); |
| 318 | bool is_pub = (proto_node->data.fn_proto.visib_mod == FnProtoVisibModPub); | |
| 318 | bool is_pub = (proto_node->data.fn_proto.visib_mod != FnProtoVisibModPrivate); | |
| 319 | 319 | if (entry) { |
| 320 | 320 | add_node_error(g, node, |
| 321 | 321 | buf_sprintf("redefinition of '%s'", buf_ptr(proto_name))); |
src/codegen.cpp+1-1| ... | ... | @@ -1611,7 +1611,7 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *src_dirname, Buf *src |
| 1611 | 1611 | assert(proto_node->type == NodeTypeFnProto); |
| 1612 | 1612 | Buf *proto_name = &proto_node->data.fn_proto.name; |
| 1613 | 1613 | |
| 1614 | bool is_exported = (proto_node->data.fn_proto.visib_mod == FnProtoVisibModExport); | |
| 1614 | bool is_exported = (proto_node->data.fn_proto.visib_mod != FnProtoVisibModPrivate); | |
| 1615 | 1615 | |
| 1616 | 1616 | if (buf_eql_str(proto_name, "main") && is_exported) { |
| 1617 | 1617 | g->insert_bootstrap_code = true; |
std/bootstrap.zig+5-12| ... | ... | @@ -1,16 +1,9 @@ |
| 1 | use "std.zig"; | |
| 1 | 2 | |
| 2 | // TODO conditionally compile this differently for non-ELF | |
| 3 | 3 | #attribute("naked") |
| 4 | 4 | export fn _start() -> unreachable { |
| 5 | // TODO conditionally compile this differently for other architectures and other OSes | |
| 6 | asm volatile (" | |
| 7 | mov (%%rsp), %%rdi // first parameter is argc | |
| 8 | lea 0x8(%%rsp), %%rsi // second parameter is argv | |
| 9 | lea 0x10(%%rsp,%%rdi,8), %%rdx // third paremeter is env | |
| 10 | callq main | |
| 11 | mov %%rax, %%rdi // return value is the parameter to exit syscall | |
| 12 | mov $60, %%rax // 60 is exit syscall number | |
| 13 | syscall | |
| 14 | "); | |
| 15 | unreachable | |
| 5 | const argc = asm("mov (%%rsp), %[argc]" : [argc] "=r" (return isize)); | |
| 6 | const argv = asm("lea 0x8(%%rsp), %[argv]" : [argv] "=r" (return &&u8)); | |
| 7 | const env = asm("lea 0x10(%%rsp,%%rdi,8), %[env]" : [env] "=r" (return &&u8)); | |
| 8 | exit(main(argc, argv, env)) | |
| 16 | 9 | } |