Skip to content

Commit 129b8ef

Browse files
committed
some new uxn examples
1 parent a6a6349 commit 129b8ef

File tree

6 files changed

+77
-4
lines changed

6 files changed

+77
-4
lines changed

editors/micro_callisto.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rules:
88
- statement: "\\b(let|enable|requires|struct|version|return|const|enum|restrict)\\b"
99
- statement: "\\b(continue|break|union|alias|overwrite|error|extern|call|raw)\\b"
1010
- statement: "\\b(implement|as|try|catch|throw|unsafe|man|ptr|anon)\\b"
11-
- type: "\\b(addr|void|u8|i8|u16|i16|u32|i32|u64|i64|size|usize|cell|array)\\b"
11+
- type: "\\b(addr|void|u8|i8|u16|i16|u32|i32|u64|i64|size|usize|cell|array|bool)\\b"
1212
- type: "\\b[A-Z]+[a-zA-Z_0-9]*[a-z]+[a-zA-Z_0-9]*\\b"
1313

1414
- constant.string:
File renamed without changes.

examples/uxn/file.cal

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# this is a cat program
2+
3+
include "cores/select.cal"
4+
include "std/io.cal"
5+
include "std/args.cal"
6+
include "uxn/file.cal"
7+
8+
if get_args_length 1 = then
9+
"Please pass a file name" print_str new_line
10+
0 exit
11+
end
12+
13+
let Array fileName
14+
1 &fileName get_arg
15+
&fileName 0 uxn_open_file
16+
17+
let u8 ch
18+
while true do
19+
&ch 1 0 try uxn_read_file
20+
catch
21+
0 exit
22+
end
23+
24+
ch print_ch
25+
end

examples/uxn/screen.cal

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
include "cores/select.cal"
2+
include "std/io.cal"
3+
include "uxn/uxn.cal"
4+
include "uxn/screen.cal"
5+
include "uxn/system.cal"
6+
7+
let bool drawn
8+
let cell w
9+
let cell h
10+
11+
func plot cell x cell y cell colour begin
12+
x uxn_screen_set_x
13+
y uxn_screen_set_y
14+
colour 0 uxn_pixel_set_colour uxn_set_pixel
15+
end
16+
17+
func screen_vector begin
18+
if drawn not then
19+
let cell x
20+
let cell y
21+
22+
while y h < do
23+
0 -> x
24+
while x w < do
25+
if x y and 0 = then
26+
x y 1 plot
27+
end
28+
29+
x 1 + -> x
30+
end
31+
32+
y 1 + -> y
33+
end
34+
35+
1 -> drawn
36+
end
37+
38+
uxn_brk
39+
end
40+
41+
uxn_get_screen_size -> h -> w
42+
43+
0x0FFF uxn_set_red
44+
0x0FFF uxn_set_green
45+
0x0FFF uxn_set_blue
46+
&screen_vector uxn_set_screen_vector
47+
48+
uxn_brk

source/stackCheck.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ class StackChecker {
226226
}
227227

228228
foreach (i, ref cond ; node.condition) {
229-
if (cond.empty()) {
230-
Error(node.error, "Empty condition in if statement");
231-
}
229+
//if (cond.empty()) {
230+
// Error(node.error, "Empty condition in if statement");
231+
//}
232232

233233
StackCell[] oldStack;
234234

0 commit comments

Comments
 (0)