Skip to content

Commit

Permalink
v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Feb 9, 2018
1 parent 8f913c6 commit 54976c3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
45 changes: 43 additions & 2 deletions examples/demo.odin
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "core:types.odin"
import "core:utf16.odin"
import "core:utf8.odin"

// File scope `when` statements
when ODIN_OS == "windows" {
import "core:atomics.odin"
import "core:thread.odin"
Expand Down Expand Up @@ -643,6 +644,7 @@ array_programming :: proc() {
using println in import "core:fmt.odin"

using_in :: proc() {
fmt.println("# using in");
using print in fmt;

println("Hellope1");
Expand All @@ -660,7 +662,9 @@ using_in :: proc() {
println(f);
}

named_proc_parameters :: proc() {
named_proc_return_parameters :: proc() {
fmt.println("# named proc return parameters");

foo0 :: proc() -> int {
return 123;
}
Expand All @@ -681,6 +685,8 @@ named_proc_parameters :: proc() {


enum_export :: proc() {
fmt.println("# enum #export");

Foo :: enum #export {A, B, C};

f0 := A;
Expand All @@ -689,6 +695,40 @@ enum_export :: proc() {
fmt.println(f0, f1, f2);
}

explicit_procedure_overloading :: proc() {
fmt.println("# explicit procedure overloading");

add_ints :: proc(a, b: int) -> int {
x := a + b;
fmt.println("add_ints", x);
return x;
}
add_floats :: proc(a, b: f32) -> f32 {
x := a + b;
fmt.println("add_floats", x);
return x;
}
add_numbers :: proc(a: int, b: f32, c: u8) -> int {
x := int(a) + int(b) + int(c);
fmt.println("add_numbers", x);
return x;
}

add :: proc[add_ints, add_floats, add_numbers];

add(int(1), int(2));
add(f32(1), f32(2));
add(int(1), f32(2), u8(3));

add(1, 2); // untyped ints coerce to int tighter than f32
add(1.0, 2.0); // untyped floats coerce to f32 tighter than int
add(1, 2, 3); // three parameters

// Ambiguous answers
// add(1.0, 2);
// add(1, 2.0);
}

main :: proc() {
when false {
general_stuff();
Expand All @@ -698,7 +738,8 @@ main :: proc() {
threading_example();
array_programming();
using_in();
named_proc_parameters();
named_proc_return_parameters();
enum_export();
explicit_procedure_overloading();
}
}
2 changes: 1 addition & 1 deletion src/build_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ String get_fullpath_core(gbAllocator a, String path) {
}


String const ODIN_VERSION = str_lit("0.8.0-dev");
String const ODIN_VERSION = str_lit("0.8.0");
String cross_compile_target = str_lit("");
String cross_compile_lib_dir = str_lit("");

Expand Down
11 changes: 5 additions & 6 deletions src/check_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,6 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
}



struct TypeAndToken {
Type *type;
Token token;
};

void check_when_stmt(Checker *c, AstNodeWhenStmt *ws, u32 flags) {
Operand operand = {Addressing_Invalid};
check_expr(c, &operand, ws->cond);
Expand Down Expand Up @@ -634,6 +628,11 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) {
}
}

struct TypeAndToken {
Type *type;
Token token;
};

Map<TypeAndToken> seen = {}; // NOTE(bill): Multimap
map_init(&seen, heap_allocator());
defer (map_destroy(&seen));
Expand Down

0 comments on commit 54976c3

Please sign in to comment.