Fix assert; exporting rules

This commit is contained in:
Ginger Bill
2016-09-22 23:18:29 +01:00
parent 2e506b7e6e
commit ee0aa7b9de
5 changed files with 45 additions and 49 deletions

View File

@@ -4,7 +4,7 @@
set exe_name=odin.exe
:: Debug = 0, Release = 1
set release_mode=1
set release_mode=0
set compiler_flags= -nologo -Oi -TP -W4 -fp:fast -fp:except- -Gm- -MP -FC -GS- -EHsc- -GR-
@@ -46,10 +46,10 @@ rem pushd %build_dir%
del *.pdb > NUL 2> NUL
del *.ilk > NUL 2> NUL
rem cl %compiler_settings% "src\main.cpp" ^
rem /link %linker_settings% -OUT:%exe_name% ^
rem && odin run code/demo.odin
odin run code/demo.odin
cl %compiler_settings% "src\main.cpp" ^
/link %linker_settings% -OUT:%exe_name% ^
&& odin run code/demo.odin
rem odin run code/demo.odin
:do_not_compile_exe

View File

@@ -5,14 +5,13 @@
// #import "punity.odin" as pn
main :: proc() {
// struct_padding()
// bounds_checking()
// type_introspection()
// any_type()
// crazy_introspection()
// namespaces_and_files()
namespaces_and_files()
// miscellany()
// ht.run()
@@ -125,11 +124,11 @@ bounds_checking :: proc() {
// x[-1] = 0; // Compile Time
// x[4] = 0; // Compile Time
/*{
{
a, b := -1, 4;
x[a] = 0; // Runtime Time
x[b] = 0; // Runtime Time
}*/
// x[a] = 0; // Runtime Time
// x[b] = 0; // Runtime Time
}
// Works for arrays, strings, slices, and related procedures & operations
@@ -190,11 +189,9 @@ type_introspection :: proc() {
fmt.println()
fmt.print("Type of v1 is:\n\t", t1)
// fmt.fprint_type(os.stdout, t1)
fmt.println()
fmt.print("Type of v2 is:\n\t")
fmt.fprint_type(os.stdout, t2)
fmt.print("Type of v2 is:\n\t", t2)
fmt.println("\n")
fmt.println("t1 == t2:", t1 == t2)
@@ -205,9 +202,9 @@ type_introspection :: proc() {
any_type :: proc() {
a: any
x := 123
y := 6.28
z := "Yo-Yo Ma"
x: int = 123
y: f64 = 6.28
z: string = "Yo-Yo Ma"
// All types can be implicit cast to `any`
a = x
a = y
@@ -267,7 +264,7 @@ crazy_introspection :: proc() {
name := (fruit_ti as ^Type_Info.Named).name // Unsafe casts
info := type_info_base(fruit_ti) as ^Type_Info.Enum // Unsafe casts
fmt.printf("% :: enum % {", name, info.base);
fmt.printf("% :: enum % {\n", name, info.base);
for i := 0; i < info.values.count; i++ {
fmt.printf("\t%\t= %,\n", info.names[i], info.values[i])
}
@@ -293,6 +290,10 @@ crazy_introspection :: proc() {
// #import "test.odin"
namespaces_and_files :: proc() {
// test.thing()
// test.format.println()
// test.println()
/*
// Non-exporting import
#import "file.odin"

View File

@@ -1,4 +1,3 @@
#import "fmt.odin" as fmt
#foreign_system_library "Ws2_32"

View File

@@ -1,38 +1,36 @@
#import "fmt.odin"
/*#import "fmt.odin"
thing :: proc() {
fmt.println("Hello!")
fmt.println("Hello1!")
}*/
#import "fmt.odin" as format
thing :: proc() {
format.println("Hello2!")
}
/*
#import "fmt.odin" as fmt
/*#import "fmt.odin" as .
thing :: proc() {
fmt.println("Hello!")
println("Hello3!")
}
*/
/*#import "fmt.odin" as _
thing :: proc() {
// println("Hello4!")
}
*/
/*
#import "fmt.odin" as .
thing :: proc() {
println("Hello!")
}
*/
/*
#import "fmt.odin" as _
thing :: proc() {
// println("Hello!")
}
*/
/*
#load "fmt.odin"
thing :: proc() {
println("Hello!")
}
*/
println("Hello5!")
}*/

View File

@@ -2077,11 +2077,11 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node) {
check_entity_decl(c, entity, NULL, NULL);
}
GB_ASSERT(entity->type != NULL);
b32 is_not_exported = !((e->ImportName.scope == entity->scope) && !is_entity_exported(entity));
b32 is_not_exported = !is_entity_exported(entity);
if (is_not_exported) {
auto found = map_get(&e->ImportName.scope->implicit, hash_string(sel_name));
if (!found) {
if (!found && e->ImportName.scope != entity->scope) {
is_not_exported = false;
}
}
@@ -2437,9 +2437,7 @@ b32 check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id)
return false;
}
if (operand->mode != Addressing_Constant) {
operand->mode = Addressing_NoValue;
}
operand->mode = Addressing_NoValue;
break;
case BuiltinProc_panic: