Skip to content

Commit

Permalink
Merge branch 'main' into 20241108_New
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeLikeCXK authored Nov 27, 2024
2 parents 37e168a + d61203a commit 2f7f32e
Show file tree
Hide file tree
Showing 302 changed files with 4,292 additions and 1,837 deletions.
2 changes: 1 addition & 1 deletion DagorEngine.rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b4ab12b2e452692a210e0707e93fd988769f3dd7
e1b257771f10be67b195ae0de780d15028763dc3
5 changes: 4 additions & 1 deletion _docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ python:
sphinx:
configuration: _docs/conf.py

formats: all
formats:
- pdf


14 changes: 13 additions & 1 deletion _docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
width: 75%;
}

/* Override width of the main page*/

.wy-nav-content{
max-width: 90%;
max-width: 100%;
}

audio, canvas, video {
Expand All @@ -41,4 +43,14 @@ audio, canvas, video {
line-height: 1.4;
}

/* Override margins of the images and text blocks*/

.rst-content .align-center {
margin-bottom: 14px;
}

p {
margin-bottom: 14px;
}


38 changes: 20 additions & 18 deletions prog/1stPartyLibs/daScript/daslib/ast_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def isExpression(t:TypeDeclPtr; top:bool=true) : bool
else
return false

def is_same_or_inherited ( parent,child: Structure? )
def is_same_or_inherited ( parent,child: Structure const? )
var ch = child
while ch != null
if parent == ch
Expand Down Expand Up @@ -193,7 +193,7 @@ def find_arg(args:AnnotationArgumentList; argn:string) : RttiValue
return get_annotation_argument_value(a)
return RttiValue_nothing()

def private apply_tag_annotation(tag:string; ann:FunctionAnnotationPtr)
def private apply_tag_annotation(tag:string; var ann:FunctionAnnotationPtr)
var inscope funcs : array<FunctionPtr>
for_each_tag_function(this_module(), tag) <| $ ( func )
funcs |> push_clone(func)
Expand Down Expand Up @@ -277,7 +277,7 @@ def setup_macro(name: string; at:LineInfo) : ExprBlock?
move(fn.body) <| blk
if !(compiling_module() |> add_function(fn))
panic("failed to setup macro, can't add function {fn.name}")
return res
return unsafe(reinterpret<ExprBlock?> res)
else
if fn.body.__rtti != "ExprBlock"
panic("expecting func.ExprBlock")
Expand Down Expand Up @@ -450,7 +450,7 @@ class BetterRttiVisitor : AstVariantMacro
return <- makeAsOrSafeAs(expr, new [[ExprConstPtr() at=expr.at]])
return <- [[ExpressionPtr]]

def private walk_and_convert_array ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_array ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
let total = any_array_size(data)
if total != 0
let stride = info.firstType.sizeOf
Expand All @@ -464,7 +464,7 @@ def private walk_and_convert_array ( data : uint8?; info:TypeDeclPtr; at:LineInf
else
return <- new [[ExprMakeStruct() at=at, makeType<-clone_type(info)]]

def private walk_and_convert_dim ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_dim ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
let stride = info.baseSizeOf
let total = info.countOf
var inscope einfo <- clone_type(info)
Expand All @@ -476,14 +476,14 @@ def private walk_and_convert_dim ( data : uint8?; info:TypeDeclPtr; at:LineInfo
emplace(mkArr.values, elem)
return <- mkArr

def private walk_and_convert_pointer ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_pointer ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
unsafe
let pdata = *(reinterpret<uint8??> data)
let pdata = *(reinterpret<uint8 const??> data)
var elem <- walk_and_convert(pdata, info.firstType, at)
var mkAsc <- new [[ExprAscend() at=at, subexpr <- elem]]
return mkAsc

def private walk_and_convert_tuple ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_tuple ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
var inscope mkArr <- new [[ExprMakeTuple() at=at, recordType<-clone_type(info)]]
for idx in range( info.argTypes |> length)
let offset = get_tuple_field_offset(info,idx)
Expand All @@ -492,7 +492,7 @@ def private walk_and_convert_tuple ( data : uint8?; info:TypeDeclPtr; at:LineInf
emplace(mkArr.values, elem)
return <- mkArr

def private walk_and_convert_structure ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_structure ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
var inscope mkStruct <- new [[ExprMakeStruct() at=at, makeType<-clone_type(info)]]
let stype = info.structType
var inscope mkS <- new [[ MakeStruct() ]]
Expand All @@ -508,7 +508,7 @@ def private walk_and_convert_structure ( data : uint8?; info:TypeDeclPtr; at:Lin
emplace(mkStruct.structs, mkS)
return <- mkStruct

def private walk_and_convert_variant ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_variant ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
unsafe
let vindex = * reinterpret<int?> data
let offset = get_variant_field_offset(info,vindex)
Expand All @@ -520,7 +520,7 @@ def private walk_and_convert_variant ( data : uint8?; info:TypeDeclPtr; at:LineI
emplace(mkVariant.variants, mkS)
return mkVariant

def private walk_and_convert_table ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_table ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
let total = any_table_size(data)
if total != 0
var inscope tupT <- new [[TypeDecl() baseType=Type tTuple, at=at]]
Expand All @@ -543,7 +543,7 @@ def private walk_and_convert_table ( data : uint8?; info:TypeDeclPtr; at:LineInf
else
return <- new [[ExprMakeStruct() at=at, makeType<-clone_type(info)]]

def private walk_and_convert_basic ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_basic ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
unsafe
if info.baseType == Type tInt
return new [[ExprConstInt() at=at, value=*reinterpret<int?> data]]
Expand Down Expand Up @@ -575,7 +575,7 @@ def private walk_and_convert_basic ( data : uint8?; info:TypeDeclPtr; at:LineInf
panic("unsupported {info.baseType}")
return [[ExpressionPtr]]

def private walk_and_convert_enumeration ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert_enumeration ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
var eval = 0l
if info.baseType == Type tEnumeration
eval = int64(*unsafe(reinterpret<int?> data))
Expand All @@ -589,17 +589,19 @@ def private walk_and_convert_enumeration ( data : uint8?; info:TypeDeclPtr; at:L
panic("unsupported enumeration")
let name = info.enumType |> find_enum_name(eval)
panic("can't find name of enum value {eval} in {describe(info)}") if name == ""
return <- new [[ExprConstEnumeration() enumType:=info.enumType, value:=name]]
return <- new [[ExprConstEnumeration()
enumType:=unsafe(reinterpret<Enumeration?> info.enumType),
value:=name]]

def private walk_and_convert ( data : uint8?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
def private walk_and_convert ( data : uint8 const?; info:TypeDeclPtr; at:LineInfo ) : ExpressionPtr
// print("0x{intptr(data)} {describe(info)}\n")
if info.dim |> length != 0
return <- walk_and_convert_dim(data,info,at)
elif info.baseType == Type tArray
return <- walk_and_convert_array(data,info,at)
elif info.baseType == Type tPointer
unsafe
if *reinterpret<uint8??>data == null
if *reinterpret<uint8 const??>data == null
return new [[ExprConstPtr() at=at]]
elif info.firstType==null || info.firstType.isVoid
return new [[ExprConstPtr() at=at]]
Expand All @@ -622,13 +624,13 @@ def convert_to_expression ( var value : auto& ==const; at:LineInfo )
var inscope info <- typeinfo(ast_typedecl value)
unsafe
let pval = addr(value)
return walk_and_convert(reinterpret<uint8?> pval, info, at)
return walk_and_convert(reinterpret<uint8 const?> pval, info, at)

def convert_to_expression ( value : auto ==const; at:LineInfo )
var inscope info <- typeinfo(ast_typedecl value)
unsafe
let pval = addr(value)
return walk_and_convert(reinterpret<uint8?> pval, info, at)
return walk_and_convert(reinterpret<uint8 const?> pval, info, at)

def convert_to_expression ( var value : auto ==const )
return <- convert_to_expression(value,[[LineInfo]])
Expand Down
2 changes: 1 addition & 1 deletion prog/1stPartyLibs/daScript/daslib/dap.das
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def joj(val : JsonValue?; id : string) : JsonValue?
if val == null || !(val is _object)
return res
get(val as _object, id) <| $(v)
res = v
res = unsafe(reinterpret<JsonValue?> v)
return res

def jon(val : JsonValue?; id : string; defVal = 0lf) : double
Expand Down
8 changes: 5 additions & 3 deletions prog/1stPartyLibs/daScript/daslib/debug.das
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class DAWalker: DapiDataWalker
return false
return true

def override beforeStructure(ps: void?; si: StructInfo): void
def override beforeStructure(ps: void const?; si: StructInfo): void
visited |> emplace([[auto ps, si.hash]])

def override beforeStructureField(ps:void?; si: StructInfo; pv: void?; vi:VarInfo; last: bool): void
Expand Down Expand Up @@ -582,7 +582,9 @@ class private DAStackWalker: DapiStackWalker
let iblock = intptr(pp._block)
let isBlock = (iblock & 1ul) != 0ul
let funcInfo = isBlock ? [[FuncInfo?]] : pp.info
ctx.stack |> emplace([[DAStackFrame() func=funcInfo, isBlock=isBlock, spAddr=intptr(sp) ]])
ctx.stack |> emplace([[DAStackFrame()
func=unsafe(reinterpret<FuncInfo?> funcInfo),
isBlock=isBlock, spAddr=intptr(sp) ]])

def override onVariable(inf: FuncInfo; vinfo: LocalVariableInfo; arg: void?; inScope: bool): void
if !inScope
Expand Down Expand Up @@ -858,7 +860,7 @@ class private DAgent: DapiDebugAgent
ctxData |> reset_debug_flags()
self->onPause(ctx, at, reason, text)

def beforePause(ctxData: DAContext; at: LineInfo)
def beforePause(var ctxData: DAContext; at: LineInfo)
pauseCtx = ctxData.ctx
pauseAt = unsafe(addr(at))
evalFrame.varId = 1000ul //EVAL_POOL
Expand Down
6 changes: 3 additions & 3 deletions prog/1stPartyLibs/daScript/daslib/debug_eval.das
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let INVALID_VALUE = LONG_MIN
struct public Result
tinfo : TypeInfo
value : float4
data : void?
data : void const?
error : string

struct TokenStream
Expand Down Expand Up @@ -116,7 +116,7 @@ def loadI ( data:void?; t:auto(TT) )

def getPD ( var st:TokenStream; result:Result; offset:int = 0 ) : void?
unsafe
var data : void?
var data : void const?
if result.data != null
data = result.data
else
Expand All @@ -131,7 +131,7 @@ def getPD ( var st:TokenStream; result:Result; offset:int = 0 ) : void?
if pdata == null
return null
data = *pdata
return (reinterpret<uint8?>data) + offset
return (reinterpret<uint8 const?>data) + offset

def getI ( var st:TokenStream; result:Result ) : int64
if result.tinfo.dimSize != 0u
Expand Down
12 changes: 7 additions & 5 deletions prog/1stPartyLibs/daScript/daslib/jobque_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ class private NewJobMacro : AstFunctionAnnotation
fld._type.flags &= ~(TypeDeclFlags constant)
fld.flags &= ~(FieldDeclarationFlags capturedConstant)
var inscope pclone <- make_clone_structure(stype_ptr)
let const_clone = pclone.arguments[1]._type.flags.constant
compiling_module() |> add_function(pclone)
compiling_module() |> add_structure(stype)
// make an @@<function<(var L;L):void> type
// make an @@<function<(var L;L):void> type or @@<function<(var L;var L):void> type - depending on how the capture went
var inscope ftype <- new [[TypeDecl() at=call.at, baseType=Type tFunction ]]
move_new(ftype.firstType) <| new [[TypeDecl() at=call.at, baseType=Type tVoid]]
ftype.argTypes |> emplace_new <| clone_type(sttype)
ftype.argTypes |> emplace <| sttype
ftype.argTypes[1].flags |= TypeDeclFlags constant
if const_clone
ftype.argTypes[1].flags |= TypeDeclFlags constant
// make a new_job_invoke call
var inscope ncall <- new [[ExprCall() at=call.at, name:="{call.name}_invoke"]]
ncall.arguments |> emplace_new <| clone_expression(call.arguments[0])
Expand Down Expand Up @@ -263,17 +265,17 @@ def each_clone ( var channel:Channel?; tinfo : auto(TT) )
finally
channel |> release

def public capture_jobque_channel ( ch:Channel? ) : Channel?
def public capture_jobque_channel ( var ch:Channel? ) : Channel?
//! this function is used to capture a channel that is used by the jobque.
ch |> add_ref
return ch

def public capture_jobque_job_status ( js:JobStatus? ) : JobStatus?
def public capture_jobque_job_status ( var js:JobStatus? ) : JobStatus?
//! this function is used to capture a job status that is used by the jobque.
js |> add_ref
return js

def public capture_jobque_lock_box ( js:LockBox? ) : LockBox?
def public capture_jobque_lock_box ( var js:LockBox? ) : LockBox?
//! this function is used to capture a lock box that is used by the jobque.
js |> add_ref
return js
Expand Down
8 changes: 4 additions & 4 deletions prog/1stPartyLibs/daScript/daslib/json.das
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def private parse_value ( var itv : iterator<TokenAt>; var error : string & ) :
if sym == '['
var arr : array<JsonValue?>
while !empty(itv)
let value = parse_value(itv, error)
var value = parse_value(itv, error)
if value == null
if error |> starts_with("unexpected ]") && length(arr)==0
error = ""
Expand Down Expand Up @@ -240,7 +240,7 @@ def private parse_value ( var itv : iterator<TokenAt>; var error : string & ) :
let key = ahead.value as _string
if !expect_symbol(itv, ahead, ':', error)
return null
let value = parse_value(itv, error)
var value = parse_value(itv, error)
if value == null
return null
if !allow_duplicate_keys && key_exists(tab,key)
Expand Down Expand Up @@ -279,14 +279,14 @@ def read_json ( text : string implicit; var error : string& ) : JsonValue?
//! if `error` is not empty, it contains the parsing error message.
error = ""
var lex <- lexer(text)
let res = parse_value(lex,error)
var res = parse_value(lex,error)
delete lex
return res

def read_json ( text : array<uint8>; var error : string& ) : JsonValue?
error = ""
var lex <- lexer(text)
let res = parse_value(lex,error)
var res = parse_value(lex,error)
delete lex
return res

Expand Down
4 changes: 2 additions & 2 deletions prog/1stPartyLibs/daScript/daslib/json_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def JV(value): JsonValue?
static_if typeinfo(is_dim value)
var arr: array<JsonValue?>
for t in value
arr |> push_clone(JV(t))
arr |> push(JV(t))
return _::JV(arr)
static_if typeinfo(typename value) == "json::JsonValue?" || typeinfo(typename value) == "json::JsonValue? const"
return value
Expand Down Expand Up @@ -446,7 +446,7 @@ def JV(value): JsonValue?
static_elif typeinfo(is_iterable value)
var arr: array<JsonValue?>
for x in value
arr |> push_clone <| _::JV(x)
arr |> push <| _::JV(x)
return _::JV(arr)
static_elif typeinfo(is_variant value)
var map: table<string; JsonValue?>
Expand Down
2 changes: 1 addition & 1 deletion prog/1stPartyLibs/daScript/daslib/linked_list.das
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class %ListClass
def %ListClass
head = null
tail = null
def add ( data : %Foo? )
def add ( var data : %Foo? )
var node = new [[LLNode_%ListClass data=data]]
if head == null
head = node
Expand Down
4 changes: 2 additions & 2 deletions prog/1stPartyLibs/daScript/daslib/lint.das
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class LintVisitor : AstVisitor
else
self->lint_error("variable {v.name}: {describe(v._type)} is never used (be careful, initializer has side effects)", v.at)
return
if can_make_const && v._type.baseType != Type tPointer && !v._type.flags.constant && !v._type.flags.removeConstant && !v.access_flags.access_ref// && !v._type.flags.smartPtr
if can_make_const && v._type.baseType != Type tPointer && !v._type.flags.constant && !v._type.flags.removeConstant && !v.access_flags.access_ref && v._type.canCloneFromConst// && !v._type.flags.smartPtr
self->lint_error("variable {v.name}: {describe(v._type)} can be made const (declare with 'let')", v.at)
return
if can_make_const && v._type.baseType == Type tPointer && !v._type.flags.constant && !v._type.flags.removeConstant && !(v.access_flags.access_ref || v.access_flags.access_pass)
if can_make_const && v._type.baseType == Type tPointer && !v._type.flags.constant && !v._type.flags.removeConstant && !(v.access_flags.access_ref || v.access_flags.access_pass) && v._type.canCloneFromConst
self->lint_error("variable {v.name}: {describe(v._type)} can be made const (declare with 'let')", v.at)
return

Expand Down
2 changes: 1 addition & 1 deletion prog/1stPartyLibs/daScript/daslib/macro_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CaptureBlock : AstVisitor
return
let vptr = get_ptr(expr.variable)
if !(scope |> key_exists(vptr))
captured[vptr] = get_ptr(expr)
captured[vptr] = unsafe(reinterpret<ExprVar?> 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 Down
Loading

0 comments on commit 2f7f32e

Please sign in to comment.