FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/src/simulate/runtime_table.cpp at split-heap · Bais/daScript · GitHub
Bais
/
daScript
Public
forked from
GaijinEntertainment/daScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
daScript
/
src
/
simulate
/
runtime_table.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (66 loc) · 2.34 KB
Breadcrumbs
daScript
/
src
/
simulate
/
runtime_table.cpp
Copy path
File metadata and controls
81 lines (66 loc) · 2.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
include
"
daScript/misc/platform.h
"
#
include
"
daScript/simulate/runtime_table.h
"
namespace
das
{
void
table_lock
( Context & context, Array & arr ) {
arr.
lock
++;
if
( arr.
lock
==
0
) {
context.
throw_error
(
"
table lock overflow
"
);
}
}
void
table_unlock
( Context & context, Array & arr ) {
if
( arr.
lock
==
0
) {
context.
throw_error
(
"
table lock underflow
"
);
}
arr.
lock
--;
}
//
SimNode_Table
vec4f
SimNode_Table::eval
( Context & context ) {
Table * tab = (Table *)tabExpr->
evalPtr
(context);
DAS_EXCEPTION_POINT
;
vec4f xkey = keyExpr->
eval
(context);
DAS_EXCEPTION_POINT
;
return
tabEval
( context, tab, xkey );
}
//
TableIterator
size_t
TableIterator::nextValid
( Table * tab,
size_t
index )
const
{
for
( ; index < tab->
capacity
; index++ )
if
( tab->
distance
[index]>=
0
)
break
;
return
index;
}
bool
TableIterator::first
( Context & context, IteratorContext & itc ) {
vec4f ll = source->
eval
(context);
DAS_ITERATOR_EXCEPTION_POINT
;
auto
pTable = cast<Table *>::
to
(ll);
table_lock
(context, *pTable);
DAS_ITERATOR_EXCEPTION_POINT
;
size_t
index =
nextValid
(pTable,
0
);
char
* data =
getData
(pTable);
itc.
value
= cast<
char
*>::
from
(data + index * stride);
itc.
table_end
= data + pTable->
capacity
* stride;
itc.
table
= pTable;
return
(
bool
) pTable->
size
;
}
bool
TableIterator::next
( Context &, IteratorContext & itc ) {
char
* data = cast<
char
*>::
to
(itc.
value
);
char
* tableData =
getData
(itc.
table
);
size_t
index =
nextValid
(itc.
table
, (data - tableData) / stride +
1
);
data = tableData + index * stride;
itc.
value
= cast<
char
*>::
from
(data);
return
data != itc.
table_end
;
}
void
TableIterator::close
( Context & context, IteratorContext & itc ) {
if
( itc.
table
) {
table_unlock
(context, *itc.
table
);
}
}
//
TableKeysIterator
char
*
TableKeysIterator::getData
( Table * tab )
const
{
return
tab->
keys
;
}
//
TableValuesIterator
char
*
TableValuesIterator::getData
( Table * tab )
const
{
return
tab->
data
;
}
}
Back
|
FazBrowse Home
|
New Git URL