Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions daslib/builtin.das
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def push_clone(var Arr : array<auto(numT)>; var varr : numT[] ==const) {
def push_clone(var Arr : array<auto(numT)[]>; varr : numT[] ==const) {
static_if (typeinfo can_copy(type<numT>)) {
static_if (typeinfo sizeof(Arr[0]) == typeinfo sizeof(varr)) {
if (typeinfo can_clone_from_const(varr)) {
static_if (typeinfo can_clone_from_const(varr)) {
for (t in varr) {
Arr[__builtin_array_push_back_zero(Arr, typeinfo sizeof(Arr[0]))] := t
}
Expand Down Expand Up @@ -889,7 +889,7 @@ def insert_clone(var Tab : table<auto(keyT); auto(valT)>; at : keyT | #; var val
[unused_argument(Tab, at, val)]
def insert_clone(var Tab : table<auto(keyT); auto(valT)>; at : keyT | #; val : valT ==const | #) {
static_if (typeinfo can_clone(val)) {
if (typeinfo can_clone_from_const(val)) {
static_if (typeinfo can_clone_from_const(val)) {
unsafe(Tab[at]) := val
} else {
concept_assert(false, "can't insert value, which can't be cloned from const")
Expand All @@ -911,7 +911,7 @@ def insert_clone(var Tab : table<auto(keyT); auto(valT)[]>; at : keyT | #; var v
[unused_argument(Tab, at, val)]
def insert_clone(var Tab : table<auto(keyT); auto(valT)[]>; at : keyT | #; val : valT[] ==const | #) {
static_if (typeinfo can_clone(val)) {
if (typeinfo can_clone_from_const(val)) {
static_if (typeinfo can_clone_from_const(val)) {
unsafe(Tab[at]) := val
} else {
concept_assert(false, "can't insert value, which can't be cloned from const")
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def clone_to_move(var clone_src : auto(TT) ==const | #) : TT -const -# {

def clone_dim(var a; b : auto | #) {
static_if (typeinfo is_dim(a) && typeinfo is_dim(b) && typeinfo dim(a) == typeinfo dim(b)) {
if (typeinfo is_pod(a)) {
static_if (typeinfo is_pod(a)) {
unsafe {
memcpy(addr(a[0]), addr(b[0]), typeinfo sizeof(a[0]) * length(a))
}
Expand Down
6 changes: 3 additions & 3 deletions daslib/decs_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def private append_iterator(arch_name : string; var qloop : ExprFor?; a; prefix,
qloop.iterators |> resize(qli + 1)
qloop.iterators[qli] := "{prefix}{a.name}{suffix}"
qloop.iteratorsAka |> resize(qli + 1)
if (typeinfo has_field<_aka>(a)) {
static_if (typeinfo has_field<_aka>(a)) {
qloop.iteratorsAka[qli] := a._aka
} else {
qloop.iteratorsAka[qli] := ""
Expand Down Expand Up @@ -384,7 +384,7 @@ class DecsQueryMacro : AstCallMacro {
macro_verify(totalArgs == 1 || totalArgs == 2, prog, expr.at, "expecting query($(block_with_arguments)) or query(eid,$(block_with_arguments))")
let qt = totalArgs == 2 ? DecsQueryType.eid_query : DecsQueryType.query
let block_arg_index = totalArgs - 1
return <- self->implement(expr, block_arg_index, qt)
return <- implement(expr, block_arg_index, qt)
}
def implement(var expr : ExprCallMacro?; block_arg_index : int; qt : DecsQueryType) : ExpressionPtr {
for (arg in expr.arguments) {
Expand Down Expand Up @@ -539,7 +539,7 @@ class DecsFindQueryMacro : DecsQueryMacro {
//! Note: if return is missing, or end of find_query block is reached - its assumed that find_query did not find anything, and will return false.
def override visit(prog : ProgramPtr; mod : Module?; var expr : ExprCallMacro?) : ExpressionPtr {
macro_verify(length(expr.arguments) == 1, prog, expr.at, "expecting find_query($(block_with_arguments))")
return <- self->implement(expr, 0, DecsQueryType.find_query)
return <- implement(expr, 0, DecsQueryType.find_query)
}
}

Expand Down
5 changes: 2 additions & 3 deletions daslib/json_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,9 @@ def from_JV(v : JsonValue const explicit?; ent : auto(EnumT); defV : EnumT = def
if (v == null || !((v.value is _string) || (v.value is _number) || (v.value is _longint))) return defV
if (v.value is _string) {
let name = v.value as _string
var res : auto(EnumTT) = default<EnumT>
let ti = typeinfo rtti_typeinfo(type<EnumT>)
for (ef in *ti.enumType) {
return unsafe(reinterpret<EnumTT>(ef.value)) if (name == ef.name)
return unsafe(reinterpret<EnumT>(ef.value)) if (name == ef.name)
}
panic("not a valid enumeration {name} in {typeinfo typename(type<EnumT>)}")
} else {
Expand Down Expand Up @@ -474,7 +473,7 @@ def from_JV(v : JsonValue const explicit?; anything : auto(TT)) {
let arr & = v.value as _array
ret |> reserve(arr |> long_length)
for (a in arr) {
if (typeinfo can_copy(anything[0])) {
static_if (typeinfo can_copy(anything[0])) {
ret |> push_clone <| _::from_JV(a, decltype_noref(anything[0]))
} else {
ret |> emplace <| _::from_JV(a, decltype_noref(anything[0]))
Expand Down
10 changes: 10 additions & 0 deletions daslib/linq.das
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,16 @@ def top_n_by_with_cmp(var a : iterator<auto(TT)>; n : int; cmp : block<(v1 : TT
return <- buf
}

def public spliced_push_heap(var buf : array<auto(TT)>; cmp : block<(x, y : TT) : bool>) {
//! Thin re-export of sort_boost::push_heap so plan_decs_order_family's bounded-heap splice can call it via _:: from any user module without requiring sort_boost directly.
sort_boost::push_heap(buf, cmp)
}

def public spliced_pop_heap(var buf : array<auto(TT)>; cmp : block<(x, y : TT) : bool>) {
//! Thin re-export of sort_boost::pop_heap for the bounded-heap splice (see spliced_push_heap).
sort_boost::pop_heap(buf, cmp)
}

def unique_key(a) {
//! generates unique key of workhorse type for the value
static_if (typeinfo is_workhorse(a)) {
Expand Down
Loading
Loading