You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/scripting.md
+33-2Lines changed: 33 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,19 @@ let message = "hello";
88
88
let result = a + b;
89
89
```
90
90
91
-
Script variables currently support integers, floats, and strings.
91
+
Script variable types and capabilities:
92
+
93
+
| Type | Literal/Example | Description | Ops/Comparisons |
94
+
| --- | --- | --- | --- |
95
+
| Integer (int, internally i64) |`123`, `-42`| Signed 64-bit integer | +, -, *, /; can mix with DWARF integer-like scalars |
96
+
| Boolean (bool) | from comparisons: `a < b`| Produced by comparisons/logical expressions | logical AND/OR (script only); when mixing with DWARF integers, treated as 0/1 |
97
+
| String |`"hello"`| UTF-8 string literal | Equality `==`, `!=` with DWARF C strings; no ordering comparisons |
98
+
99
+
Notes:
100
+
1. Script variables do not support user-defined structs/arrays/pointers; access such data via DWARF variables (member access, deref, constant index) to obtain scalars first.
101
+
2. Floating-point arithmetic is not supported.
102
+
3. Unary minus `-` is supported and can be nested (e.g., `-1`, `-(-1)`), parsed as `0 - expr`.
103
+
4. Transport encodes booleans as a single byte 0/1; the renderer displays `true`/`false`.
92
104
93
105
### Local Variables, Parameters, and Global Variables
94
106
@@ -205,7 +217,7 @@ let quotient = a / b; // Division
205
217
206
218
1. Parentheses `()`
207
219
2. Member access `.`, Array access `[]`
208
-
3. Pointer dereference `*`, Address of `&`
220
+
3. Pointer dereference `*`, Address of `&`, Unary minus `-`
209
221
4. Multiplication `/`, Division `/`
210
222
5. Addition `+`, Subtraction `-`
211
223
6. Comparisons `==`, `!=`, `<`, `<=`, `>`, `>=`
@@ -226,6 +238,11 @@ let complex = (x + y) / (a - b);
226
238
- Operands are treated as booleans with "non-zero is true" semantics
227
239
- Current implementation evaluates both sides (no short-circuit yet)
228
240
241
+
Boolean values
242
+
243
+
- Comparisons and logical operators produce boolean results.
244
+
- Transport encodes booleans as a single byte 0/1. The renderer displays them as `true`/`false`.
245
+
229
246
Examples
230
247
231
248
```ghostscope
@@ -238,6 +255,20 @@ trace main:entry {
238
255
}
239
256
```
240
257
258
+
### Unary Minus
259
+
260
+
- Semantics: negate an expression; recursive nesting is supported.
261
+
- Parsing: treated as `0 - expr`, ensuring `-1`, `-x`, and `-(-1)` evaluate as signed integers.
0 commit comments