Core: Change lookup rules, 2x speedup
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
call "..\misc\compile_setup.bat"
|
call "..\misc\compile_setup.bat"
|
||||||
|
|
||||||
rem bld --dont_compile_core
|
bld --dont_compile_core
|
||||||
cd build
|
cd build
|
||||||
core_main.exe rtsgame/main.core
|
core_main.exe rtsgame/main.core
|
||||||
bld --dont_compile_core --link=vendor/raylib/windows/raylibdll.lib
|
bld --dont_compile_core --link=vendor/raylib/windows/raylibdll.lib
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ VariadicArguments :: (string: *char, args: []Any): Any
|
|||||||
|
|
||||||
AnyArguments :: (values: []Any)
|
AnyArguments :: (values: []Any)
|
||||||
for values
|
for values
|
||||||
Assert(it.type == S64)
|
Assert(it.type == int)
|
||||||
Assert(*(values[0].data->*S64) == 10)
|
Assert(*(values[0].data->*int) == 10)
|
||||||
Assert(*(values[1].data->*S64) == 20)
|
Assert(*(values[1].data->*int) == 20)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C++ version 0.4 char* style "itoa":
|
* C++ version 0.4 char* style "itoa":
|
||||||
* Written by Lukás Chmela
|
* Written by Lukás Chmela
|
||||||
* Released under GPLv3.
|
* Released under GPLv3.
|
||||||
*/
|
*/
|
||||||
IntegerToString :: (value: S64, result: *U8, base: S64): *U8
|
IntegerToString :: (value: int, result: *U8, base: int): *U8
|
||||||
// check that the base if valid
|
// check that the base if valid
|
||||||
if (base < 2) || (base > 36)
|
if (base < 2) || (base > 36)
|
||||||
*result = 0 // '
|
*result = 0 // '
|
||||||
@@ -22,7 +22,7 @@ IntegerToString :: (value: S64, result: *U8, base: S64): *U8
|
|||||||
ptr := result
|
ptr := result
|
||||||
ptr1 := result
|
ptr1 := result
|
||||||
tmp_char: U8
|
tmp_char: U8
|
||||||
tmp_value: S64
|
tmp_value: int
|
||||||
|
|
||||||
for value != 0
|
for value != 0
|
||||||
tmp_value = value
|
tmp_value = value
|
||||||
@@ -63,8 +63,8 @@ FormatString :: (buffer: *U8, buffer_len: U64, string: String, args: []Any)
|
|||||||
Assert(arg_counter < Len(args), "Passed too many [%] to the string formating function")
|
Assert(arg_counter < Len(args), "Passed too many [%] to the string formating function")
|
||||||
arg := args[arg_counter++]
|
arg := args[arg_counter++]
|
||||||
|
|
||||||
if arg.type == S64
|
if arg.type == int
|
||||||
value := *(arg.data->*S64)
|
value := *(arg.data->*int)
|
||||||
itoa_buff: [64]U8
|
itoa_buff: [64]U8
|
||||||
p := IntegerToString(value, &itoa_buff[0], 10)
|
p := IntegerToString(value, &itoa_buff[0], 10)
|
||||||
|
|
||||||
@@ -81,15 +81,15 @@ main :: (): int
|
|||||||
values := []Any{a, b}
|
values := []Any{a, b}
|
||||||
|
|
||||||
for values
|
for values
|
||||||
Assert(it.type == S64)
|
Assert(it.type == int)
|
||||||
AnyArguments({a,b})
|
AnyArguments({a,b})
|
||||||
c := VariadicArguments("Test", args = {a+b,b})
|
c := VariadicArguments("Test", args = {a+b,b})
|
||||||
Assert(*(c.data->*S64) == 30)
|
Assert(*(c.data->*int) == 30)
|
||||||
d := VariadicArguments("Test", {b,a})
|
d := VariadicArguments("Test", {b,a})
|
||||||
Assert(*(d.data->*S64) == b)
|
Assert(*(d.data->*int) == b)
|
||||||
|
|
||||||
Assert(*(values[0].data->*S64) == 10)
|
Assert(*(values[0].data->*int) == 10)
|
||||||
Assert(*(values[1].data->*S64) == 20)
|
Assert(*(values[1].data->*int) == 20)
|
||||||
|
|
||||||
buf: [128]U8
|
buf: [128]U8
|
||||||
FormatString(&buf[0], Len(buf), "Test % %", {32, 156})
|
FormatString(&buf[0], Len(buf), "Test % %", {32, 156})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
/*@feature_idea: labeled block
|
/*@language_todo: labeled block
|
||||||
|
|
||||||
It acts just like a scope in C.
|
It acts just like a scope in C.
|
||||||
BUT it can be turned into a goto label by adding another semicolon
|
BUT it can be turned into a goto label by adding another semicolon
|
||||||
@@ -18,9 +18,11 @@ thing := 1
|
|||||||
thing2 := thing
|
thing2 := thing
|
||||||
|
|
||||||
:goto_block: for
|
:goto_block: for
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
@language_todo: Bring back named loads
|
||||||
|
A :: #load "array.core"
|
||||||
|
|
||||||
|
|
||||||
@reproduction:
|
@reproduction:
|
||||||
This kills the compiler due to referencing slice data
|
This kills the compiler due to referencing slice data
|
||||||
|
|
||||||
@@ -131,6 +133,7 @@ main :: (): int
|
|||||||
target_color.a = 255/2
|
target_color.a = 255/2
|
||||||
|
|
||||||
for !WindowShouldClose()
|
for !WindowShouldClose()
|
||||||
|
|
||||||
WinX = GetScreenWidth()
|
WinX = GetScreenWidth()
|
||||||
WinY = GetScreenHeight()
|
WinY = GetScreenHeight()
|
||||||
MouseX = GetMouseX()
|
MouseX = GetMouseX()
|
||||||
|
|||||||
@@ -420,7 +420,10 @@ GetTypeInfo :: (type: Type): *Type_Info
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Ast_Scope *scope = ast_decl_scope(&pctx->null_token, pctx->perm, get(&module->all_loaded_files, 0));
|
Ast_File *file = get(&module->all_loaded_files, 0);
|
||||||
|
Ast_Scope *scope = ast_decl_scope(&pctx->null_token, pctx->perm, file);
|
||||||
|
scope->parent_scope = file;
|
||||||
|
scope->module = module;
|
||||||
Ast_Decl *decl = ast_namespace(&pctx->null_token, scope, pctx->intern("Const"_s));
|
Ast_Decl *decl = ast_namespace(&pctx->null_token, scope, pctx->intern("Const"_s));
|
||||||
decl->state = DECL_RESOLVED;
|
decl->state = DECL_RESOLVED;
|
||||||
|
|
||||||
|
|||||||
@@ -539,24 +539,31 @@ resolve_name(Ast_Scope *scope, Token *pos, Intern_String name, Search_Flag searc
|
|||||||
Scoped_Arena scratch(pctx->scratch);
|
Scoped_Arena scratch(pctx->scratch);
|
||||||
Scope_Search search = make_scope_search(scratch.arena, scope, name);
|
Scope_Search search = make_scope_search(scratch.arena, scope, name);
|
||||||
search.search_only_current_scope = search_flags & SEARCH_ONLY_CURRENT_SCOPE;
|
search.search_only_current_scope = search_flags & SEARCH_ONLY_CURRENT_SCOPE;
|
||||||
|
search.exit_on_find = true; // @test(asd): not sure if this change will be ok, 2x typecheck speedup though
|
||||||
scope_search(&search);
|
scope_search(&search);
|
||||||
|
|
||||||
if (search.results.len == 0) {
|
if (search.results.len == 0) {
|
||||||
compiler_error(pos, "Unidentified name [%s]", name.str);
|
compiler_error(pos, "Unidentified name [%s]", name.str);
|
||||||
}
|
}
|
||||||
if (search.results.len > 1) {
|
|
||||||
if (is_flag_set(search.results[0]->flags, AST_OPERATOR_OVERLOAD)) {
|
if (is_flag_set(search.results[0]->flags, AST_OPERATOR_OVERLOAD)) {
|
||||||
if (is_flag_set(search_flags, RESOLVE_NAME_MAKE_SURE_OPERATOR_OVERLOAD_IS_NOT_EVER_CALLED)) {
|
compiler_error(pos, "Internal compiler error: resolve_name got an overload");
|
||||||
compiler_error(pos, "Internal compiler error: somehow we found %Q which is an operator to be also an identifier and we started resolving it using resolve_name", name);
|
|
||||||
}
|
|
||||||
For(search.results) {
|
|
||||||
resolve_decl(it);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
compiler_error(pos, "Found multiple definitions of name [%s]", name.str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @test(asd): not sure if this change will be ok
|
||||||
|
// if (search.results.len > 1) {
|
||||||
|
// if (is_flag_set(search.results[0]->flags, AST_OPERATOR_OVERLOAD)) {
|
||||||
|
// if (is_flag_set(search_flags, RESOLVE_NAME_MAKE_SURE_OPERATOR_OVERLOAD_IS_NOT_EVER_CALLED)) {
|
||||||
|
// compiler_error(pos, "Internal compiler error: somehow we found %Q which is an operator to be also an identifier and we started resolving it using resolve_name", name);
|
||||||
|
// }
|
||||||
|
// For(search.results) {
|
||||||
|
// resolve_decl(it);
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// compiler_error(pos, "Found multiple definitions of name [%s]", name.str);
|
||||||
|
// }
|
||||||
|
|
||||||
Ast_Decl *decl = *search.results.data;
|
Ast_Decl *decl = *search.results.data;
|
||||||
resolve_decl(decl);
|
resolve_decl(decl);
|
||||||
return decl;
|
return decl;
|
||||||
@@ -605,7 +612,7 @@ insert_into_scope(Ast_Scope *scope, Ast_Decl *decl) {
|
|||||||
// as such we probably don't want to call any resolve stuff here
|
// as such we probably don't want to call any resolve stuff here
|
||||||
Scoped_Arena scratch(pctx->scratch);
|
Scoped_Arena scratch(pctx->scratch);
|
||||||
Scope_Search search = make_scope_search(scratch.arena, scope, decl->name);
|
Scope_Search search = make_scope_search(scratch.arena, scope, decl->name);
|
||||||
search.search_only_current_scope = true;
|
// search.search_only_current_scope = true;
|
||||||
scope_search(&search);
|
scope_search(&search);
|
||||||
if (search.results.len != 0) {
|
if (search.results.len != 0) {
|
||||||
if (!is_flag_set(decl->flags, AST_OPERATOR_OVERLOAD)) {
|
if (!is_flag_set(decl->flags, AST_OPERATOR_OVERLOAD)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user