Commit Graph

4869 Commits

Author SHA1 Message Date
Irmen de Jong
326eab3dd1 unit test for defer, describe defer and if expression in docs 2024-10-22 22:19:49 +02:00
Irmen de Jong
6da1f7eb4c don't remove essential subroutines even though they seem unused 2024-10-22 21:17:02 +02:00
Irmen de Jong
1e82483152 ast printer correctly prints ifexpression 2024-10-22 21:14:55 +02:00
Irmen de Jong
6e2fd41a8b ast printer correctly prints unroll and continue 2024-10-22 21:14:26 +02:00
Irmen de Jong
9927af1095 about var inits 2024-10-22 01:08:42 +02:00
Irmen de Jong
7585b6ef6f fix issues with calling the defer handler 2024-10-21 19:49:38 +02:00
Irmen de Jong
a6159702da defers are now only registered/called when flow of control actually reached the defer statement
a defer statement sets its corresponding bit in a bitmask that is shifted in the defer handler routine to see what defer blocks to call.
2024-10-21 00:55:51 +02:00
Irmen de Jong
0247fb0d84 some ast2 var tweaks 2024-10-21 00:20:54 +02:00
Irmen de Jong
6de760885f fix defer push/pop typecasting issues 2024-10-19 21:45:49 +02:00
Irmen de Jong
9851d14fb9 added if expression: ubyte a = if b>0 44 else 55
it doesn't generate the best code yet, like regular ifs do.
2024-10-19 15:34:04 +02:00
Irmen de Jong
d5fc69d3e4 fix instruction index error in optimizer 2024-10-19 14:45:53 +02:00
Irmen de Jong
a40d120f2a more defer sanity checks 2024-10-18 22:32:49 +02:00
Irmen de Jong
fcdd9414d9 fix defer interfering with return value, fix prefix expression error when operand is functioncall that doesn't return a value. 2024-10-18 21:43:09 +02:00
Irmen de Jong
272a1001a8 fix bad optimization of floats.pop/push call 2024-10-18 21:04:18 +02:00
Irmen de Jong
2a52241f1c defer is now done *after* calculating a return value 2024-10-18 20:56:27 +02:00
Irmen de Jong
d8f1822c12 fixes 2024-10-18 20:32:46 +02:00
Irmen de Jong
ce7d094adb Zig-like "defer" to clean up stuff when leaving the scope of the current routine. 2024-10-18 01:30:20 +02:00
Irmen de Jong
a0cf1889a3 omit more redundant 0-initializations ("stz's") 2024-10-17 22:51:39 +02:00
Irmen de Jong
38ef394e15 IR codegen: global vars with numeric initialization value are now also put into the VARIABLESWITHINIT section rather than requiring explicit code instructions to initialize them in INITGLOBALS.
Note that something similar, such as putting those variables inline in the program initialized with their value and all, cannot be done for the 6502 codegen: the program needs a mechanism to reset ALL variables when it runs a second time.
2024-10-16 22:15:51 +02:00
Irmen de Jong
abbf7c7cb0 compiler name change: prog8c (was p8compile)
fat jar file also changed:  prog8c-X.Y-all.jar    (was: prog8compiler-X.Y-all.jar)
2024-10-16 18:36:19 +02:00
Irmen de Jong
ca5f7ae32f global (block-level) variables that get initialized with an array index expression now get a constant value as well if possible. This reduces the number of instructions in the init globals code block 2024-10-16 02:14:19 +02:00
Irmen de Jong
cbc4b75e50 IR now contains "bool" as a type instead of already erasing it into "ubyte". (boolean literals still are simply just 1 and 0 values) 2024-10-16 01:03:35 +02:00
Irmen de Jong
65ddcf91d0 remove unused syscalls 2024-10-15 18:24:55 +02:00
Irmen de Jong
5280e1b449 err msgs 2024-10-13 21:33:13 +02:00
Irmen de Jong
b6ffb81909 Merge branch 'next-version' 2024-10-13 21:20:10 +02:00
Irmen de Jong
e9edffa9f0 remove support for array-to-array assignments (other than initialization of variable declaration)
Just use an explicit sys.memcopy(src, dest, sizeof(dest))  or assign array members individually.
2024-10-13 20:02:43 +02:00
Irmen de Jong
0dd1c17ff4 avoid possible crash 2024-10-13 17:51:14 +02:00
Irmen de Jong
aef211e5f3 stricter array literal element type handling (number,bool,address-of).
More consistent implicit address-of handling if array literals contain by-ref identifiers (such as subroutine names)
2024-10-13 17:46:41 +02:00
Irmen de Jong
66829203d8 New [x]*42 syntax to create array literals with repeated values (like "abc"*10 already exists for strings)
Should be used in place of array initializer expressions that contain only a single numeric value to initialize the whole array with. That isn't supported anymore.
2024-10-13 05:16:08 +02:00
Irmen de Jong
7a0eaf3148 Remove array initialization by single value.
New compiler and kotlin version.
2024-10-13 04:31:56 +02:00
Irmen de Jong
fa5479ee5f fix ast printing of arrays with duplicate elements 2024-10-13 04:30:46 +02:00
Irmen de Jong
03412cacba added examples/cx16/balloonflight.p8 2024-10-13 00:51:07 +02:00
Irmen de Jong
01a38a0b11 Merge branch 'monogfx_fill_optimization' 2024-10-12 17:29:38 +02:00
Irmen de Jong
f43c14bd78 doc 2024-10-12 17:29:28 +02:00
Irmen de Jong
fb23452383 optimize monogfx.fill() 2024-10-12 17:18:00 +02:00
Irmen de Jong
ab7dde1450 todo 2024-10-12 13:04:19 +02:00
Irmen de Jong
8d9bc2f5ff fixing all sorts of things about assigning arrays to arrays 2024-10-12 12:33:46 +02:00
Irmen de Jong
7651ccc84e fix a type error 2024-10-11 00:50:05 +02:00
Irmen de Jong
1a6b95b388 house cleaning 2024-10-10 20:46:18 +02:00
Irmen de Jong
78ec1e7512 version 2024-10-09 22:21:04 +02:00
Irmen de Jong
7e38d26c33 added several color fade functions to the palette module (cx16) 2024-10-09 21:48:04 +02:00
Irmen de Jong
ed09dd4e9e improve automatic type conversions for return values, fixes #155 2024-10-09 20:04:05 +02:00
Irmen de Jong
5731b79554 don't allow problematic string and array assignments anymore, improve error messages.
In certain cases you will need to use string.copy() explicitly to overwrite strings with new strings.
2024-10-09 00:51:05 +02:00
Irmen de Jong
eaa22a9d13 added callfar2() builtin function that allows to set A,X,Y and Carry arguments. 2024-10-08 21:36:04 +02:00
Irmen de Jong
b2bdfe8482 fix ir rndseed() 2024-10-08 20:40:00 +02:00
Irmen de Jong
fea531be9a add sys.sizeof_bool, _ubyte, _uword constants 2024-10-07 20:45:13 +02:00
Irmen de Jong
7c69d38588 scan all asmsubs to see if another subroutine is referenced. Fixes #153 2024-10-07 20:39:49 +02:00
Irmen de Jong
a088ee56b0 function inlining can no longer get into an infinite loop. Fixes #154 2024-10-07 19:58:04 +02:00
Irmen de Jong
ae669af904 add sys.sizeof_byte, _word, _float constants
because Antlr doesn't allow the grammar to contain a sizeof(typename) rule to override the sizeof(identifier) rule
2024-10-07 19:17:37 +02:00
Irmen de Jong
d1ddf05e38 check that block address leaves room for program startup logic 2024-10-03 22:30:06 +02:00