Skip to content

Commit

Permalink
sync on 2024/11/18, rev 0cee6d005970bf5594bd2849bac9ed03ef6096fa
Browse files Browse the repository at this point in the history
  • Loading branch information
NicSavichev committed Nov 18, 2024
1 parent 4888824 commit 07358a8
Show file tree
Hide file tree
Showing 703 changed files with 90,613 additions and 29,323 deletions.
2 changes: 1 addition & 1 deletion DagorEngine.rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
74a089e04b4efe3b67b0d61cff4b7b6d10974174
0cee6d005970bf5594bd2849bac9ed03ef6096fa
5 changes: 5 additions & 0 deletions _docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@
max-width: 90%;
}

audio, canvas, video {
display: block;
margin: auto;
margin-bottom: 12px;
}


1 change: 1 addition & 0 deletions _docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'hoverxref.extension',
'versionwarning.extension',
'sphinx_copybutton',
'sphinxcontrib.video',
]

myst_enable_extensions = [
Expand Down
1 change: 1 addition & 0 deletions _docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sphinx-design==0.6.0
sphinx-hoverxref==1.4.0
sphinx-markdown-tables==0.0.17
sphinx-version-warning==1.1.2
sphinxcontrib-video==0.3.1

# Documentation theme

Expand Down
16 changes: 15 additions & 1 deletion prog/1stPartyLibs/daScript/daslib/async_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AsyncMacro : AstFunctionAnnotation
//! Generator yields bool if its a void function (coroutine), and yields the return type otherwise (async return).
//! async function can wait for another async function using await(<async fn call>).
//! use 'return false' to immediately return from the generator.
[unused_argument(group, args, errors)] def override apply(var func : FunctionPtr; var group : ModuleGroup; args : AnnotationArgumentList; var errors : das_string) : bool
[unused_argument(group, args)] def override apply(var func : FunctionPtr; var group : ModuleGroup; args : AnnotationArgumentList; var errors : das_string) : bool
if func.result.baseType == Type autoinfer
errors := "async function should have explicit return type"
return false
Expand Down Expand Up @@ -95,6 +95,20 @@ class AsyncMacro : AstFunctionAnnotation
$e(func.body)
return false

var ret = blk as ExprReturn
var gen = ret.subexpr as ExprMakeGenerator
for arg in func.arguments
if arg._type.baseType == Type.autoinfer
errors := "{errors}\nasync function argument '{arg.name}' should have explicit type"
return false

if !arg._type.canCopy
let capturesNum = length(gen._capture)
gen._capture.resize(capturesNum + 1)
gen._capture[capturesNum].name := arg.name
let mode = arg._type.canMove ? CaptureMode.capture_by_move : CaptureMode.capture_by_clone
gen._capture[capturesNum].mode = mode

blk.at := func.at
func.body |> move() <| blk
func.result |> move_new() <| qmacro_type(type<iterator<$t(retT)>>)
Expand Down
6 changes: 3 additions & 3 deletions prog/1stPartyLibs/daScript/daslib/macro_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class MacroVerifyMacro : AstFunctionAnnotation
[macro]
class CaptureBlock : AstVisitor
[[do_not_delete]] scope : table<Variable?>
[[do_not_delete]] capture : table<Variable?; ExprVar?>
[[do_not_delete]] captured : table<Variable?; ExprVar?>
def override preVisitExprVar(expr:smart_ptr<ExprVar>) : void
if !(expr.varFlags.local || expr.varFlags.argument || expr.varFlags._block)
return
let vptr = get_ptr(expr.variable)
if !(scope |> key_exists(vptr))
capture[vptr] = get_ptr(expr)
captured[vptr] = get_ptr(expr)
def override preVisitExprLetVariable(expr:smart_ptr<ExprLet>;arg:VariablePtr;lastArg:bool) : void
scope |> insert(get_ptr(arg))
def override preVisitExprForVariable(expr:smart_ptr<ExprFor>;svar:VariablePtr;last:bool) : void
Expand All @@ -59,7 +59,7 @@ def public capture_block(expr:ExpressionPtr) : array<CapturedVariable>
var astVisitor = new CaptureBlock()
var inscope adapter <- make_visitor(*astVisitor)
visit(expr, adapter)
var res <- [{for k,v in keys(astVisitor.capture),values(astVisitor.capture); [[CapturedVariable variable=k,expression=v]] }]
var res <- [{for k,v in keys(astVisitor.captured),values(astVisitor.captured); [[CapturedVariable variable=k,expression=v]] }]
unsafe
delete astVisitor
return <- res
Expand Down
12 changes: 6 additions & 6 deletions prog/1stPartyLibs/daScript/daslib/refactor.das
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ class ExtractMethodMacro : AstFunctionAnnotation
if !(call.arguments[0] is ExprConstString)
print("extract_method: first argument must be a string literal")
return false
var capture <- capture_block(call.arguments[1])
sort(capture) <| $ ( a,b ) => string(a.variable.name) < string(b.variable.name)
var captured <- capture_block(call.arguments[1])
sort(captured) <| $ ( a,b ) => string(a.variable.name) < string(b.variable.name)
var call_name = string((call.arguments[0] as ExprConstString).value)
let function_declaration = build_string <| $ ( writer )
writer |> write ( "def ")
writer |> write ( call_name )
if length(capture) != 0
if length(captured) != 0
writer |> write ( " ( " )
var first = true
for v in capture
for v in captured
if first
first = false
else
Expand All @@ -78,9 +78,9 @@ class ExtractMethodMacro : AstFunctionAnnotation
let call_expression = build_string <| $ ( writer )
writer |> write ( call_name )
writer |> write ( "(" )
if length(capture) != 0
if length(captured) != 0
var first = true
for v in capture
for v in captured
if first
first = false
else
Expand Down
4 changes: 3 additions & 1 deletion prog/1stPartyLibs/daScript/examples/profile/config.das
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let TEST_LUA = true
let TEST_LUA_JIT = true
let TEST_SQUIRREL = true
let TEST_CSHARP = true
let TEST_MONO_INTERPRETER = false

[no_jit,no_aot]
def cpp_label
Expand Down Expand Up @@ -117,7 +118,8 @@ def run_files ( tf:TestFile )
let cwd = getcwd()
chdir(monoRoot)
run_and_gun_silent("{monoCompiler} -optimize+ {monoRoot}/{tf.monoFile} -out:test.exe")
run_and_gun("MONO --interpreter","{monoRunner} --interpreter test.exe")
if TEST_MONO_INTERPRETER
run_and_gun("MONO --interpreter","{monoRunner} --interpreter test.exe")
run_and_gun("MONO","{monoRunner} test.exe")
if TEST_CSHARP && !empty(tf.dotNetFile)
let cscRoot = "{get_das_root()}/examples/profile/tests/cs"
Expand Down
43 changes: 22 additions & 21 deletions prog/1stPartyLibs/daScript/examples/profile/main.das
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ require rtti
require debugapi
require math

var HTML_TEST_MODE = false

var LOG_TEST_COMPILATION_TIME = false
var ENABLE_AOT = true
var ENABLE_JIT = true
Expand Down Expand Up @@ -64,8 +66,12 @@ def test_single_file ( fileName:string )
print("\n\n")

def run_dir ( appDir : string )
var once = false
dir(appDir) <| $ ( fileName )
if (!fileName |> starts_with("_")) && fileName |> ends_with(".das")
if HTML_TEST_MODE && once
return
once = true
let appfile = "{appDir}/{fileName}"
test_single_file(appfile)

Expand Down Expand Up @@ -102,44 +108,39 @@ def parse_short_profile_entry ( invocation:string; blk:block<(var res : ProfileE
return <- [[ProfileEntry category=category, time=time, count=int(count)]]

def make_table ( tablename:string; entries:array<ProfileEntry>; languages:table<string> )
var categories : table<string; double>
var categories : table<string; tuple<min:double;max:double>>
for e in entries
if languages |> key_exists(e.language)
if categories |> key_exists(e.category)
categories[e.category] = min(e.time, categories[e.category])
let [[tmin,tmax]] = categories[e.category]
categories[e.category] = ( min(e.time,tmin), max(e.time, tmax))
else
categories[e.category] = e.time
categories[e.category] = ( e.time, e.time )
var slanguages <- [{for l in keys(languages); l}]
slanguages |> sort
var scategories <- [{for c in keys(categories); c}]
scategories |> sort
print("<h2>{tablename}</h2>\n")
print("<table border=\"1\">\n")
print("<tr><th>Test</th>\n")
for l in slanguages
print("<th>{l}</th>")
print("</tr>\n")
print("\n<h2>{tablename}</h2>\n")
for c in scategories
var cattime : table<string; double>
for e in entries
if e.category==c
cattime[e.language] = e.time
print("<tr><td>{c}</td>\n")
print("<h3>{c}</h3>\n")
print("<table class=\"chart\" style=\"width: 600px;\">\n")
for l in slanguages
if cattime |> key_exists(l)
let time = cattime[l]
let mintime = categories[c]
let factor = time / mintime
let [[tmin,tmax]] = categories[c]
let minfactor = time / tmin
let maxfactor = time / tmax
let ts = fmt(":.4f", float(time))
let fs = fmt(":.2f", float(factor))
if int(factor*100.0lf) == 100
print("<td><b>{fs} ({ts})</b></td>")
else
print("<td>{fs} ({ts})</td>")
else
print("<td>N/A</td>")
print("</tr>\n")
print("</table>\n")
let fs = fmt(":.2f", float(minfactor))
let featured = int(minfactor*100.0lf) == 100
let tabclass = !featured ? "chart-bar" : "chart-bar featured"
let space = maxfactor*100.0lf // make it no less than 10%?
print("<tr><th>{l}</th><td><div class=\"{tabclass}\" style=\"width: {space}%;\">{ts}&nbsp ({fs})</div></td></tr>\n")
print("</table>\n")

def make_entries ( extra:string = "" )
let exe = get_command_line_arguments()[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ struct Data
b : string
arr : array<int>

[async] def timeout(time : float; var callback : lambda<void>): void
let start_time = get_clock()
while get_clock() - start_time < double(time)
await_next_frame()
invoke(callback)


[async] def get_plus_1(a : int) : int
log("get_plus_1 1\n")
await_next_frame() // frame pause
Expand Down Expand Up @@ -48,6 +55,8 @@ struct Data
yield true

[async] def getall() : void
log("timeout...\n")
await <| timeout(1.0, @() { log("timeout done\n"); })
var a = await <| get_plus_1(100)
debug(a, "1+100")
assert(a == 101)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
def operator :=(value : auto(T))
var res : T
res := value
return <-res

var
some_a <- [{ auto[] "test"}]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ namespace das {
template<> struct ToBasicType<long double> { enum { type = Type::tDouble }; };
template<> struct ToBasicType<wchar_t> { enum { type = Type::tUInt16 }; };
#endif
#if !defined(_MSC_VER) && !defined(__APPLE__) && defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffffULL
#if !defined(_MSC_VER) && !defined(__APPLE__) && !defined(_EMSCRIPTEN_VER) && defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffffULL
template<> struct ToBasicType<long long int> { enum { type = Type::tInt64 }; };
template<> struct ToBasicType<unsigned long long int> { enum { type = Type::tUInt64 }; };
#endif
Expand Down
21 changes: 21 additions & 0 deletions prog/1stPartyLibs/daScript/include/daScript/daScriptC.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ typedef struct dasNode das_node;
typedef struct dasStructure das_structure;
typedef struct dasEnumeration das_enumeration;

typedef struct {
float x, y, z, w;
} vec4f_unaligned;

typedef vec4f (das_interop_function) ( das_context * ctx, das_node * node, vec4f * arguments );

typedef void (das_interop_function_unaligned) ( das_context * ctx, das_node * node, vec4f_unaligned * arguments, vec4f_unaligned * result );

void das_initialize();
void das_shutdown();

Expand Down Expand Up @@ -94,6 +100,7 @@ das_context * das_context_make ( int stackSize );
void das_context_release ( das_context * context );
das_function * das_context_find_function ( das_context * context, char * name );
vec4f das_context_eval_with_catch ( das_context * context, das_function * fun, vec4f * arguments );
void das_context_eval_with_catch_unaligned ( das_context * context, das_function * fun, vec4f_unaligned * arguments, int narguments, vec4f_unaligned * result );
char * das_context_get_exception ( das_context * context );

das_structure * das_structure_make ( das_module_group * lib, const char * name, const char * cppname, int sz, int al );
Expand All @@ -104,6 +111,7 @@ void das_enumeration_add_value ( das_enumeration * enu, const char * name, const

das_module * das_module_create ( char * name );
void das_module_bind_interop_function ( das_module * mod, das_module_group * lib, das_interop_function * fun, char * name, char * cppName, uint32_t sideffects, char* args );
void das_module_bind_interop_function_unaligned ( das_module * mod, das_module_group * lib, das_interop_function_unaligned * fun, char * name, char * cppName, uint32_t sideffects, char* args );
void das_module_bind_alias ( das_module * mod, das_module_group * lib, char * aname, char * tname );
void das_module_bind_structure ( das_module * mod, das_structure * st );
void das_module_bind_enumeration ( das_module * mod, das_enumeration * en );
Expand All @@ -114,13 +122,26 @@ double das_argument_double ( vec4f arg );
char * das_argument_string ( vec4f arg );
void * das_argument_ptr ( vec4f arg );

int das_argument_int_unaligned ( vec4f_unaligned * arg );
float das_argument_float_unaligned ( vec4f_unaligned * arg );
double das_argument_double_unaligned ( vec4f_unaligned * arg );
char * das_argument_string_unaligned ( vec4f_unaligned * arg );
void * das_argument_ptr_unaligned ( vec4f_unaligned * arg );

vec4f das_result_void ();
vec4f das_result_int ( int r );
vec4f das_result_float ( float r );
vec4f das_result_double ( double r );
vec4f das_result_string ( char * r );
vec4f das_result_ptr ( void * r );

void das_result_void_unaligned ( vec4f_unaligned * result );
void das_result_int_unaligned ( vec4f_unaligned * result, int r );
void das_result_float_unaligned ( vec4f_unaligned * result, float r );
void das_result_double_unaligned ( vec4f_unaligned * result, double r );
void das_result_string_unaligned ( vec4f_unaligned * result, char * r );
void das_result_ptr_unaligned ( vec4f_unaligned * result, void * r );

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ namespace das
static __forceinline vec4f from ( uint64_t x ) { return v_cast_vec4f(v_ldui_half(&x)); }
};

#if !defined(_MSC_VER) && !defined(__APPLE__) && defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffffULL
#if !defined(_MSC_VER) && !defined(__APPLE__) && !defined(_EMSCRIPTEN_VER) && defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffffULL
template <>
struct cast <long long int> {
static __forceinline long long int to ( vec4f x ) { return v_extract_xi64(v_cast_vec4i(x)); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,16 +412,16 @@ public:
addIEx("RightAlt", "ImGuiKey_RightAlt", int64_t(ImGuiKey::ImGuiKey_RightAlt), das::LineInfo());
addIEx("RightSuper", "ImGuiKey_RightSuper", int64_t(ImGuiKey::ImGuiKey_RightSuper), das::LineInfo());
addIEx("Menu", "ImGuiKey_Menu", int64_t(ImGuiKey::ImGuiKey_Menu), das::LineInfo());
addIEx("0", "ImGuiKey_0", int64_t(ImGuiKey::ImGuiKey_0), das::LineInfo());
addIEx("1", "ImGuiKey_1", int64_t(ImGuiKey::ImGuiKey_1), das::LineInfo());
addIEx("2", "ImGuiKey_2", int64_t(ImGuiKey::ImGuiKey_2), das::LineInfo());
addIEx("3", "ImGuiKey_3", int64_t(ImGuiKey::ImGuiKey_3), das::LineInfo());
addIEx("4", "ImGuiKey_4", int64_t(ImGuiKey::ImGuiKey_4), das::LineInfo());
addIEx("5", "ImGuiKey_5", int64_t(ImGuiKey::ImGuiKey_5), das::LineInfo());
addIEx("6", "ImGuiKey_6", int64_t(ImGuiKey::ImGuiKey_6), das::LineInfo());
addIEx("7", "ImGuiKey_7", int64_t(ImGuiKey::ImGuiKey_7), das::LineInfo());
addIEx("8", "ImGuiKey_8", int64_t(ImGuiKey::ImGuiKey_8), das::LineInfo());
addIEx("9", "ImGuiKey_9", int64_t(ImGuiKey::ImGuiKey_9), das::LineInfo());
addIEx("_0", "ImGuiKey_0", int64_t(ImGuiKey::ImGuiKey_0), das::LineInfo());
addIEx("_1", "ImGuiKey_1", int64_t(ImGuiKey::ImGuiKey_1), das::LineInfo());
addIEx("_2", "ImGuiKey_2", int64_t(ImGuiKey::ImGuiKey_2), das::LineInfo());
addIEx("_3", "ImGuiKey_3", int64_t(ImGuiKey::ImGuiKey_3), das::LineInfo());
addIEx("_4", "ImGuiKey_4", int64_t(ImGuiKey::ImGuiKey_4), das::LineInfo());
addIEx("_5", "ImGuiKey_5", int64_t(ImGuiKey::ImGuiKey_5), das::LineInfo());
addIEx("_6", "ImGuiKey_6", int64_t(ImGuiKey::ImGuiKey_6), das::LineInfo());
addIEx("_7", "ImGuiKey_7", int64_t(ImGuiKey::ImGuiKey_7), das::LineInfo());
addIEx("_8", "ImGuiKey_8", int64_t(ImGuiKey::ImGuiKey_8), das::LineInfo());
addIEx("_9", "ImGuiKey_9", int64_t(ImGuiKey::ImGuiKey_9), das::LineInfo());
addIEx("A", "ImGuiKey_A", int64_t(ImGuiKey::ImGuiKey_A), das::LineInfo());
addIEx("B", "ImGuiKey_B", int64_t(ImGuiKey::ImGuiKey_B), das::LineInfo());
addIEx("C", "ImGuiKey_C", int64_t(ImGuiKey::ImGuiKey_C), das::LineInfo());
Expand Down
Loading

0 comments on commit 07358a8

Please sign in to comment.