mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix issue #8 - https://github.com/gingerBill/Odin/issues/8
This commit is contained in:
+55
-79
@@ -1,85 +1,61 @@
|
|||||||
|
#import "atomic.odin";
|
||||||
#import "fmt.odin";
|
#import "fmt.odin";
|
||||||
|
#import "hash.odin";
|
||||||
|
#import "math.odin";
|
||||||
|
#import "mem.odin";
|
||||||
|
#import "opengl.odin";
|
||||||
#import "os.odin";
|
#import "os.odin";
|
||||||
|
#import win32 "sys/windows.odin";
|
||||||
|
#import "sync.odin";
|
||||||
|
#import "utf8.odin";
|
||||||
|
|
||||||
fgetc :: proc(fd : os.Handle) -> ?byte
|
T :: struct { x, y: int };
|
||||||
{
|
thread_local t: T;
|
||||||
c : [1]byte;
|
|
||||||
|
|
||||||
if bytes_read, _ := os.read(fd, c[:]); bytes_read == 0
|
main :: proc() {
|
||||||
{
|
immutable using t := T{123, 321};
|
||||||
return nil;
|
fmt.println(t);
|
||||||
}
|
|
||||||
|
|
||||||
return c[0];
|
|
||||||
|
// foo :: proc(x: ^i32) -> (int, int) {
|
||||||
|
// fmt.println("^int");
|
||||||
|
// return 123, int(x^);
|
||||||
|
// }
|
||||||
|
// foo :: proc(x: rawptr) {
|
||||||
|
// fmt.println("rawptr");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// THINGI :: 14451;
|
||||||
|
// THINGF :: 14451.1;
|
||||||
|
|
||||||
|
// a: i32 = 111111;
|
||||||
|
// b: f32;
|
||||||
|
// c: rawptr;
|
||||||
|
// fmt.println(foo(^a));
|
||||||
|
// foo(^b);
|
||||||
|
// foo(c);
|
||||||
|
// // foo(nil);
|
||||||
|
// atomic.store(^a, 1);
|
||||||
|
|
||||||
|
// foo :: proc() {
|
||||||
|
// fmt.printf("Zero args\n");
|
||||||
|
// }
|
||||||
|
// foo :: proc(i: int) {
|
||||||
|
// fmt.printf("int arg, i=%d\n", i);
|
||||||
|
// }
|
||||||
|
// foo :: proc(f: f64) {
|
||||||
|
// i := int(f);
|
||||||
|
// fmt.printf("f64 arg, f=%d\n", i);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foo();
|
||||||
|
// // foo(THINGI);
|
||||||
|
// foo(THINGF);
|
||||||
|
// foo(int(THINGI));
|
||||||
|
// fmt.println(THINGI);
|
||||||
|
// fmt.println(THINGF);
|
||||||
|
|
||||||
|
// f: proc();
|
||||||
|
// f = foo;
|
||||||
|
// f();
|
||||||
}
|
}
|
||||||
|
|
||||||
main :: proc ()
|
|
||||||
{
|
|
||||||
b := fgetc(os.stdin);
|
|
||||||
|
|
||||||
if bv, ok := b?; ok
|
|
||||||
{
|
|
||||||
fmt.println(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// #import "atomic.odin";
|
|
||||||
// #import "fmt.odin";
|
|
||||||
// #import "hash.odin";
|
|
||||||
// #import "math.odin";
|
|
||||||
// #import "mem.odin";
|
|
||||||
// #import "opengl.odin";
|
|
||||||
// #import "os.odin";
|
|
||||||
// #import win32 "sys/windows.odin";
|
|
||||||
// #import "sync.odin";
|
|
||||||
// #import "utf8.odin";
|
|
||||||
|
|
||||||
// T :: struct { x, y: int };
|
|
||||||
// thread_local t: T;
|
|
||||||
|
|
||||||
// main :: proc() {
|
|
||||||
// immutable using t := T{123, 321};
|
|
||||||
// fmt.println(t);
|
|
||||||
|
|
||||||
|
|
||||||
// // foo :: proc(x: ^i32) -> (int, int) {
|
|
||||||
// // fmt.println("^int");
|
|
||||||
// // return 123, int(x^);
|
|
||||||
// // }
|
|
||||||
// // foo :: proc(x: rawptr) {
|
|
||||||
// // fmt.println("rawptr");
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // THINGI :: 14451;
|
|
||||||
// // THINGF :: 14451.1;
|
|
||||||
|
|
||||||
// // a: i32 = 111111;
|
|
||||||
// // b: f32;
|
|
||||||
// // c: rawptr;
|
|
||||||
// // fmt.println(foo(^a));
|
|
||||||
// // foo(^b);
|
|
||||||
// // foo(c);
|
|
||||||
// // // foo(nil);
|
|
||||||
// // atomic.store(^a, 1);
|
|
||||||
|
|
||||||
// // foo :: proc() {
|
|
||||||
// // fmt.printf("Zero args\n");
|
|
||||||
// // }
|
|
||||||
// // foo :: proc(i: int) {
|
|
||||||
// // fmt.printf("int arg, i=%d\n", i);
|
|
||||||
// // }
|
|
||||||
// // foo :: proc(f: f64) {
|
|
||||||
// // i := int(f);
|
|
||||||
// // fmt.printf("f64 arg, f=%d\n", i);
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // foo();
|
|
||||||
// // // foo(THINGI);
|
|
||||||
// // foo(THINGF);
|
|
||||||
// // foo(int(THINGI));
|
|
||||||
// // fmt.println(THINGI);
|
|
||||||
// // fmt.println(THINGF);
|
|
||||||
|
|
||||||
// // f: proc();
|
|
||||||
// // f = foo;
|
|
||||||
// // f();
|
|
||||||
// }
|
|
||||||
|
|||||||
+3
-2
@@ -5,12 +5,13 @@ typedef enum AddressingMode {
|
|||||||
Addressing_Invalid,
|
Addressing_Invalid,
|
||||||
|
|
||||||
Addressing_NoValue,
|
Addressing_NoValue,
|
||||||
Addressing_Value,
|
Addressing_Value, // R-value
|
||||||
Addressing_Variable,
|
Addressing_Variable, // L-value
|
||||||
Addressing_Constant,
|
Addressing_Constant,
|
||||||
Addressing_Type,
|
Addressing_Type,
|
||||||
Addressing_Builtin,
|
Addressing_Builtin,
|
||||||
Addressing_Overload,
|
Addressing_Overload,
|
||||||
|
|
||||||
Addressing_Count,
|
Addressing_Count,
|
||||||
} AddressingMode;
|
} AddressingMode;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -141,7 +141,7 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) {
|
|||||||
i64 word_bits = 8*s.word_size;
|
i64 word_bits = 8*s.word_size;
|
||||||
GB_ASSERT_NOT_NULL(t);
|
GB_ASSERT_NOT_NULL(t);
|
||||||
t = default_type(t);
|
t = default_type(t);
|
||||||
// GB_ASSERT(is_type_typed(t));
|
GB_ASSERT(is_type_typed(t));
|
||||||
|
|
||||||
switch (t->kind) {
|
switch (t->kind) {
|
||||||
case Type_Basic:
|
case Type_Basic:
|
||||||
|
|||||||
+4
-4
@@ -202,7 +202,7 @@ int main(int argc, char **argv) {
|
|||||||
i32 exit_code = 0;
|
i32 exit_code = 0;
|
||||||
// For more passes arguments: http://llvm.org/docs/Passes.html
|
// For more passes arguments: http://llvm.org/docs/Passes.html
|
||||||
exit_code = win32_exec_command_line_app("llvm-opt", false,
|
exit_code = win32_exec_command_line_app("llvm-opt", false,
|
||||||
"%.*sbin/opt %s -o %.*s.bc "
|
"\"%.*sbin/opt\" \"%s\" -o \"%.*s\".bc "
|
||||||
"-mem2reg "
|
"-mem2reg "
|
||||||
"-memcpyopt "
|
"-memcpyopt "
|
||||||
"-die "
|
"-die "
|
||||||
@@ -220,7 +220,7 @@ int main(int argc, char **argv) {
|
|||||||
timings_start_section(&timings, str_lit("llvm-llc"));
|
timings_start_section(&timings, str_lit("llvm-llc"));
|
||||||
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
|
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
|
||||||
exit_code = win32_exec_command_line_app("llvm-llc", false,
|
exit_code = win32_exec_command_line_app("llvm-llc", false,
|
||||||
"%.*sbin/llc %.*s.bc -filetype=obj -O%d "
|
"\"%.*sbin/llc\" \"%.*s.bc\" -filetype=obj -O%d "
|
||||||
"%.*s "
|
"%.*s "
|
||||||
// "-debug-pass=Arguments "
|
// "-debug-pass=Arguments "
|
||||||
"",
|
"",
|
||||||
@@ -240,7 +240,7 @@ int main(int argc, char **argv) {
|
|||||||
for_array(i, checker.info.foreign_libraries) {
|
for_array(i, checker.info.foreign_libraries) {
|
||||||
String lib = checker.info.foreign_libraries.e[i];
|
String lib = checker.info.foreign_libraries.e[i];
|
||||||
isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf),
|
isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf),
|
||||||
" %.*s.lib", LIT(lib));
|
" \"%.*s.lib\"", LIT(lib));
|
||||||
lib_str = gb_string_appendc(lib_str, lib_str_buf);
|
lib_str = gb_string_appendc(lib_str, lib_str_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit_code = win32_exec_command_line_app("msvc-link", true,
|
exit_code = win32_exec_command_line_app("msvc-link", true,
|
||||||
"link %.*s.obj -OUT:%.*s.%s %s "
|
"link \"%.*s\".obj -OUT:\"%.*s.%s\" %s "
|
||||||
"/defaultlib:libcmt "
|
"/defaultlib:libcmt "
|
||||||
"/nologo /incremental:no /opt:ref /subsystem:CONSOLE "
|
"/nologo /incremental:no /opt:ref /subsystem:CONSOLE "
|
||||||
" %.*s "
|
" %.*s "
|
||||||
|
|||||||
Reference in New Issue
Block a user