Skip to content

Commit 7d174a1

Browse files
committed
Show/hide destructors
1 parent 451bfd7 commit 7d174a1

File tree

9 files changed

+51
-13
lines changed

9 files changed

+51
-13
lines changed

ecr/domain/core/core-keywords.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ class CoreKeywords {
263263
add("stack");
264264
add("stop");
265265
add("system");
266+
add("take");
266267
add("variable");
267268
add("wait");
268269
add("while");

ecr/domain/core/variable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
int core_variable(Runtime* runtime) {
22
print("variable handler\n");
3-
return 0;
3+
4+
return runtime->getPC() + 1;
45
};

ecr/ecr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#define DEBUG 0 // set to 1 to debug, 0 for no debugging
1+
#define DEBUG 1 // set to 1 to debug, 0 for no debugging
2+
#define DESTROY 0 // set to 1 to show destructors
23

34
#include <stdio.h>
45
#include <stdlib.h>

ecr/keyword.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class KeywordArray {
170170
delete array;
171171
delete list;
172172
delete choices;
173+
#if DESTROY
173174
print("KeywordArray: Delete %s\n", name);
175+
#endif
174176
}
175177
};

ecr/test.eco

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
1-
2,0,1,2:3,4:{,2:5,6:7,}
2-
3,0,1,2:3,4:{,2:8,6:9,}
3-
4,0,1,2:3,4:{,2:10,6:11,}
4-
5,0,12,2:3
1+
2,0,1,2:3,4:5,6:7,8:9,10:11,12:[,],13:14
2+
4,0,15,2:16,12:{,2:17,18:19,}
3+
5,0,15,2:16,12:{,2:20,18:21,}
4+
6,0,15,2:16,12:{,2:22,18:5,}
5+
7,0,23,2:16
56

67
core
7-
print
8+
variable
89
type
9-
None
10+
symbol
11+
valueHolder
12+
True
13+
name
14+
Var1
15+
elements
16+
1
17+
index
18+
0
1019
value
20+
used
21+
False
22+
print
23+
None
1124
text
1225
content
1326
Hello: world!
1427
int
1528
12345
1629
boolean
17-
True
1830
exit
1931

ecr/test.ecs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
! Test script
22

3+
variable Var1
4+
35
print `Hello: world!`
46
print 12345
57
print true

ecr/test.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
[
2+
{
3+
"debug": false,
4+
"domain": "core",
5+
"elements": 1,
6+
"index": 0,
7+
"keyword": "variable",
8+
"lino": 2,
9+
"name": "Var1",
10+
"type": "symbol",
11+
"used": false,
12+
"value": [],
13+
"valueHolder": true
14+
},
215
{
316
"debug": true,
417
"domain": "core",
518
"keyword": "print",
6-
"lino": 2,
19+
"lino": 4,
720
"type": null,
821
"value": {
922
"content": "Hello: world!",
@@ -14,7 +27,7 @@
1427
"debug": true,
1528
"domain": "core",
1629
"keyword": "print",
17-
"lino": 3,
30+
"lino": 5,
1831
"type": null,
1932
"value": {
2033
"content": 12345,
@@ -25,7 +38,7 @@
2538
"debug": true,
2639
"domain": "core",
2740
"keyword": "print",
28-
"lino": 4,
41+
"lino": 6,
2942
"type": null,
3043
"value": {
3144
"content": true,
@@ -36,7 +49,7 @@
3649
"debug": true,
3750
"domain": "core",
3851
"keyword": "exit",
39-
"lino": 5,
52+
"lino": 7,
4053
"type": null
4154
}
4255
]

ecr/text.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ class Text {
3737
///////////////////////////////////////////////////////////////////////
3838
// Destructor
3939
~Text() {
40+
#if DESTROY
4041
if (strcmp(name, "<noname>") != 0) {
4142
print("Text: Delete %s\n", name);
4243
}
44+
#endif
4345
delete text;
4446
}
4547

@@ -325,6 +327,8 @@ class TextArray {
325327
~TextArray() {
326328
delete array;
327329
delete list;
330+
#if DESTROY
328331
print("TextArray: Delete %s\n", name);
332+
#endif
329333
}
330334
};

ecr/value.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class ValueArray {
168168
delete array;
169169
delete list;
170170
delete valueKeywords;
171+
#if DESTROY
171172
print("ValueArray: Delete %s\n", name);
173+
#endif
172174
}
173175
};

0 commit comments

Comments
 (0)