Compare commits

..

612 commits

Author SHA1 Message Date
Norayr Chilingarian
65baeb77a9
Merge pull request #113 from robdaemon/fix-gcc-15
Fixes build problems on gcc 15
2026-02-04 12:51:31 +04:00
Robert Roland
9fce469f23 Fixes build problems on gcc 15
GCC 15 changes the C language standard to gnu23, and VOC compiles just fine on gnu11.

Tested against GCC 15 and GCC 14.
2026-02-03 17:43:38 -08:00
Norayr Chilingarian
84516b2ac6 prevents orphaned or misplaced comments from being written to symbol
files.
2025-07-19 05:56:37 +04:00
Norayr Chilingarian
a517a42357 comments length increased, multiline comments are also now possible. 2025-07-19 05:48:27 +04:00
Norayr Chilingarian
50b5a1438e better handling of faulty symbol files. ethStrings comments fixed. 2025-07-19 05:13:09 +04:00
Norayr Chilingarian
fa9e73f7af adapted Base64 file from Oberon S3. 2025-07-10 23:08:59 +04:00
Norayr Chilingarian
a9465ccfc6 bootstrap sources. 2025-06-24 18:27:35 +04:00
Norayr Chilingarian
dac6504f12 comments in symbol files, viewable by showdef browser. 2025-06-24 17:44:19 +04:00
Norayr Chilingarian
2f1ce08aff should fix type-bound procedure name mismatch between calls and definitions 2025-06-14 17:12:48 +04:00
Carlos Une
28c327be28 Math, MathL: add procedure fcmp 2025-05-08 15:48:46 +04:00
Norayr Chilingarian
94683df1d8
Merge pull request #111 from InnaKhachikyan/master
modified Index checking to handle run-time variable index containing …
2025-04-23 02:46:44 +04:00
Inna Khachikyan
f0e92c7434 modified Index checking to handle run-time variable index containing negative value 2025-04-17 23:44:56 +04:00
Norayr Chilingarian
71488ffe85
Merge pull request #110 from rbmk-plus/master
add ctags, fix dead links, and other minor fixes
2025-04-04 18:13:57 +00:00
sevoves
378de43274 rewording doc/ctags.md 2025-04-04 22:00:31 +04:00
sevoves
1fbbb68dc7 rewording ctags doc 2025-04-04 21:56:16 +04:00
sevoves
9846292b85 minor changes in docs 2025-04-04 21:51:30 +04:00
sevoves
bb7a731197 small change in ctags.md 2025-04-04 21:44:46 +04:00
sevoves
7dafb02d1e add ctags doc 2025-04-04 21:40:59 +04:00
sevoves
5e52f8c231 add ctags doc and remove comments from oberon.ctags 2025-04-04 21:39:45 +04:00
sevoves
e298d10d99 rewording in configure.c 2025-04-04 15:43:44 +04:00
sevoves
3460b9f78a create macros for ignoring flood warnings 2025-04-04 15:37:41 +04:00
sevoves
089ca94207 remove scope pop in ctag since file is the scope 2025-04-04 00:38:41 +04:00
sevoves
b12029e3ed remove warning floods for MinGW compiler 2025-04-03 22:26:20 +04:00
sevoves
cd06cd32b1 ignore common warnings in gcc and clang 2025-04-03 22:09:20 +04:00
sevoves
7691293a5b replace egrep with grep -E for less warnings 2025-04-03 21:05:42 +04:00
sevoves
d005317424 address more caveats in oberon.ctags 2025-04-03 20:57:00 +04:00
sevoves
a25b44ae21 exclude all confidence test files without extension except expect 2025-04-03 20:38:12 +04:00
sevoves
e64d4c4d44 add test binaries to .gitignore 2025-04-03 20:14:24 +04:00
sevoves
ac82959092 add stuff to .gitignore 2025-04-03 20:05:37 +04:00
sevoves
cb098d448d update deaed links in ReadMe 2025-04-03 19:20:01 +04:00
sevoves
9e9bbe7581 fix empty link in ReadMe 2025-04-03 19:00:09 +04:00
sevoves
9084ca288b rewording ceveats on oberon.ctags 2025-04-03 16:29:13 +04:00
sevoves
233761e7fa more matches 2025-04-03 08:16:27 +04:00
sevoves
e936f7d7b0 fix typo in ReadMe 2025-04-03 07:52:59 +04:00
sevoves
c4f3792047 add ctags 2025-04-03 07:52:22 +04:00
Norayr Chilingarian
812b3a56d6
Merge pull request #106 from tkurtbond/openbsdinstallfailsldconfig
Don't try to uninstall the shared libraries unless the directory exists.
2025-03-13 16:19:38 +04:00
Norayr Chilingarian
764e018de2
Merge pull request #108 from pascalecu/feat/netbsd
feat: add netbsd support (#107)
2025-03-13 16:17:37 +04:00
Ștefan-Iulian Alecu
b22fc3fd3f
feat: add netbsd support in configure.c 2025-03-12 02:07:15 +02:00
Norayr Chilingarian
2178fa7b18 now test server can listen on any ipv4 address. 2025-02-21 04:52:54 +04:00
Norayr Chilingarian
e36e862c8c Revert "now test server can listen on any ipv4 address."
This reverts commit afe5a2d824.
2025-02-21 04:52:20 +04:00
Norayr Chilingarian
afe5a2d824 now test server can listen on any ipv4 address. 2025-02-21 04:48:39 +04:00
T. Kurt Bond
7d14452a51 Don't try to uninstall the shared libraries unless the directory exists.
Otherwise it fails on OpenBSD during the first installation with:

    ldconfig: /usr/local/sw/versions/voc/git/lib: No such file or directory
2025-01-17 08:10:47 -05:00
Norayr Chilingarian
8d2d479664 unix nil check won't prevent windows builds. 2024-08-23 13:51:15 +04:00
9292b2a7d5
Merge pull request #102 from antranigv/master
set language to Oberon
2024-05-11 21:44:48 +04:00
Antranig Vartanian
e189882af8
set language to Oberon 2024-05-11 21:43:22 +04:00
Norayr Chilingarian
48741af5ac
Merge pull request #101 from vishaps/catching_segfault
now "NIL access" error in Modules.Mod indeed works.
2024-04-13 05:13:38 +04:00
Norayr Chilingarian
7fb61a066b now "NIL access" error in Modules.Mod indeed works. 2024-04-13 04:14:18 +04:00
Norayr Chilingarian
7ea99e20a0 fixed crash introduced in commit aed9134e99
see comments in OPB.Mod
2024-04-12 21:52:25 +04:00
Norayr Chilingarian
a7fe55d434 changed hardcoded test file name to the one which exists in current
directory.
2024-03-21 19:36:43 +04:00
Norayr Chilingarian
85dff7734d wrapper function for compatibility with project oberon 13 sources. 2024-03-14 18:01:26 +04:00
Norayr Chilingarian
e376e59f58 md5sum test will now work with binary files as well. 2024-02-21 03:30:49 +04:00
Norayr Chilingarian
75c155f8ec md5 sum calculation example. 2024-01-26 02:20:24 +04:00
Norayr Chilingarian
dfaf2d3622 example on how to read commandline arguments with Texts. 2024-01-14 17:15:40 +04:00
Norayr Chilingarian
5a93546143 insignificant readme and makefile changes. 2023-12-13 15:56:49 +04:00
Norayr Chilingarian
ff42920226 gcc: warning: switch ‘-gstabs’ is no longer supported - removed it. 2023-10-05 17:03:30 +04:00
Norayr Chilingarian
c4213e333a small fix to build options, whitespace is necessary. 2023-10-05 17:00:23 +04:00
Norayr Chilingarian
b8d08c007a additional opts should be on the left of other CFLAGS,
this fixes linking to third party libraries issue on some operating systems
including Ubuntu and Debian, probably older gcc 11 is to blame.
Did not notice this problem on Gentoo, at least with gcc 13.
2023-10-05 16:54:37 +04:00
Norayr Chilingarian
bd35c73c1f more changes for tcc 2023-04-26 04:01:15 +04:00
Faraz Vahedi
7ca08f1ef1
Remove an unused import 2022-07-04 16:31:45 +00:00
Norayr Chilingarian
9e3995d0ee added Reset() function to VT100 module. 2022-05-26 01:29:02 +04:00
Norayr Chilingarian
590398b27e update of bootstrap files. 2022-03-15 17:23:17 +04:00
Norayr Chilingarian
32ec67552f fix in ooc Strings modules to prevent index out of range error. 2022-03-15 17:20:41 +04:00
Norayr Chilingarian
bc8adf76c1 fixes "memory past end of source var" warning, solution by @kekcleader;
issue: https://github.com/vishaps/voc/issues/96
2021-12-27 19:52:27 +04:00
Norayr Chilingarian
3d62284b32 typo fix: oname should be ONAME
https://github.com/vishaps/voc/issues/97
2021-12-27 19:38:05 +04:00
dcwbrown
8bd5388ffb Merge branch 'master' of https://github.com/vishaps/voc 2020-06-16 18:23:27 +01:00
David C W Brown
c9b56ea10e Remove GC blocking IF test, add abstract comment to each compiler mod. 2020-06-16 18:12:30 +01:00
Norayr Chilingarian
cfa8aa2c39
Merge pull request #85 from vishaps/ooc_c_sizes
fixed ooc.C typesizes and made X11 examples compile.
2020-04-02 23:32:15 +04:00
Norayr Chilingarian
ff87e23780 fixed ooc.C typesizes and made X11 examples compile. 2020-03-29 20:40:36 +04:00
Dave Brown
63008f6d30 Fix -OC set size in usage text 2019-11-19 19:45:23 +00:00
Dave Brown
7f4b284aef Correct set size in component pascal compatability mode 2019-11-19 15:53:20 +00:00
Dave Brown
2ddbf5d517 Correct Args.argc to INTEGER rather than LONGINT 2019-11-09 11:32:03 +00:00
Norayr Chilingarian
6ae2f96d08 Undecl var fix (#74)
* fix like 78036911d2

* OPT.DynArr to be precise

* removed PromoteIntConstToLInt() function call

* update of bootstrap sources.
2019-11-07 16:20:08 +00:00
David C W Brown
760e14bbe1
Still trying to get build status to refresh. 2019-11-04 19:30:42 +00:00
David C W Brown
1d48dd8114
Trying harder to get build status to refresh, part 2. 2019-11-04 19:29:12 +00:00
David C W Brown
84b6f0aa92
Trying harder to get build status to refresh, part 1. 2019-11-04 19:28:52 +00:00
David C W Brown
0b136c44e9
No real change - attempting to clear the github cache of build status svg. 2019-11-04 19:22:49 +00:00
David C W Brown
93b6ecc234
Use https to get build status. 2019-11-04 18:24:47 +00:00
David C W Brown
b2f7087966
Reflect distinction between build (make full) and install (make install) 2019-11-04 18:23:17 +00:00
David Brown
e4743120de Add support for building in a path containing spaces. 2019-11-04 16:06:16 +00:00
David C W Brown
8cec6b3794
A bit more info about static vs dynamic linking
Some systems support only one.
2019-10-11 17:41:45 +01:00
David Brown
49cb239730 Update autobuild scripts for freenas server 2019-10-11 17:24:05 +01:00
Norayr Chilingarian
7b9b5cb4f1 simpler way of removing 'static' for tcc in configure.c, reverted oberon.mk back, according to this comment: a35668bf93 (r35448231) update of bootstrap sources. 2019-10-11 15:00:02 +04:00
Norayr Chilingarian
9626a95daa updated bootstrap files, main change should be in ext-tools.c (linking
options, whitespace removed)
2019-10-10 17:46:12 +04:00
Norayr Chilingarian
a35668bf93 initial tcc/linux changes 2019-10-10 17:41:18 +04:00
David Brown
e3a07e77fa Trigger again 2019-01-07 19:17:34 +00:00
David Brown
e07c125017 Trigger again 2019-01-07 18:58:35 +00:00
David Brown
d40b590306 Merge branch 'master' of https://github.com/vishaps/voc 2019-01-07 18:47:40 +00:00
David Brown
5e903cb3d9 Trigger build 2019-01-07 18:47:15 +00:00
David C W Brown
2e93bc0909
Correct the other reference to the windows installation doc. 2019-01-07 18:10:33 +00:00
David Brown
6842928bf8 Integrate rangechecked casting correction from @svorkoetter. 2019-01-04 18:54:55 +00:00
Norayr Chilingarian
8890fe1336 windows installation document link fixed. 2018-11-24 00:28:13 +04:00
David Brown
af38056518 Add ruminations on how Oberon Files.Mod behaviour differs from conventional systems. 2018-04-27 13:58:10 +01:00
David Brown
b1b4d6b602 Update bootstrap C source files. 2018-04-24 18:53:02 +01:00
David Brown
ee01f97392 Expose file name and path max lengths in Files.Mod. 2018-04-24 18:51:39 +01:00
David Brown
f7904230c9 Update bootstrap C source files. 2018-04-24 17:46:55 +01:00
David Brown
70f2839c76 Add 'Filename too long' error in Files.Mod. 2018-04-24 17:32:38 +01:00
David Brown
1c8828ede1 Update bootstrap C source files. 2018-04-24 16:11:16 +01:00
David Brown
f458b98ff2 Enable index checks in Files.Mod and OPS.Mod. 2018-04-24 16:04:56 +01:00
David Brown
66f0363474 Fix missing quotes in path setting for tests, allowing them to run in linux under windows. 2018-04-24 12:21:57 +01:00
David C W Brown
3c66e07ff0 Merge branch 'master' of https://github.com/vishaps/voc 2018-04-23 20:45:28 +01:00
David C W Brown
afe570e096 Restore temporarily commented git clone in autobuild runbuilds.pl 2018-04-23 20:45:01 +01:00
David C W Brown
8a0b3d5b4c Merge branch 'master' of https://github.com/vishaps/voc 2018-04-23 20:22:23 +01:00
David C W Brown
9928bfe70d Fix build order of Reals.Mod in Microsoft C builds. 2018-04-23 20:21:50 +01:00
David C W Brown
5ec7c2359b Merge branch 'master' of https://github.com/vishaps/voc 2018-04-23 18:25:19 +01:00
David C W Brown
175eafb900 New autobuild system 2018-04-23 18:24:41 +01:00
David C W Brown
2de6345b99
Update ReadMe.md 2018-04-23 17:29:05 +01:00
David C W Brown
2d8cd4a478
Update ReadMe.md 2018-04-23 17:28:43 +01:00
David C W Brown
02ea27e8b5
Update ReadMe.md 2018-04-22 20:21:09 +01:00
David C W Brown
ffad2a1a14
Update ReadMe.md 2018-04-22 20:13:09 +01:00
David C W Brown
a2f3f72795
Update ReadMe.md 2018-04-22 20:11:17 +01:00
David C W Brown
56ea3f3a27
Update ReadMe.md 2018-04-22 19:55:37 +01:00
David C W Brown
1bd4070e06
Update ReadMe.md 2018-04-22 18:23:44 +01:00
David C W Brown
1da977da55
Update ReadMe.md 2018-04-22 18:21:10 +01:00
norayr
419e90e073 in order to instigate new build and update the build status png synced
beep.Mod with actual library sources.
2018-04-14 23:09:26 +04:00
Norayr Chilingarian
4bbacbaaa4 brought sources in sync with current library state. 2018-04-10 23:29:14 +04:00
Norayr Chilingarian
c43644ffeb bootstrap sources update. 2018-04-10 22:51:26 +04:00
Norayr Chilingarian
9470716304 issue #64 https://github.com/vishaps/voc/issues/64 2018-04-10 22:48:37 +04:00
David Brown
1bd70f367e Correct size_t definition for OpenBSD .gt. 6.2 thanks to @ibara 2017-09-06 13:07:00 +01:00
norayr
2ec7f3277a applied changes for the issue #61, with the @jtempl fix 9e3e13af63 2017-09-02 22:20:03 +04:00
norayr
bad584ec32 make bootstrap. 2017-08-08 15:39:44 +04:00
norayr
511186f0a4 applied temple's fix for the ofront issue #30, endless recoursion for
cyclic array types.
c7d37c9162
2017-08-08 15:37:29 +04:00
norayr
9f3893bb42 should fix library build. 2017-06-21 21:45:26 +04:00
norayr
e626e5c97d updated bootstrap sources. 2017-06-21 21:33:03 +04:00
norayr
211f69c89a moved strtoreal functions to strings module. 2017-06-21 20:58:10 +04:00
norayr
b5c76a0ee3 implemented In.Real and In.LongReal, unless it'll be implemented better. 2017-06-21 20:45:58 +04:00
David Brown
5c86750aed Enable Mac static linking. 2017-02-15 18:58:39 +00:00
David Brown
8063b0c595 Fix dynamic linking on Mac. Static linking not working. 2017-02-15 18:34:00 +00:00
David Brown
44d5e0f325 Remove obsolete LDCONFIG env var generation in configure.c 2017-01-02 12:00:36 +00:00
David Brown
284b105c80 Update bootstrap C sources. 2017-01-01 01:28:40 +00:00
David Brown
ba9498b592 Fix verbose display of gcc command. 2017-01-01 01:27:58 +00:00
David Brown
a4dfd37908 Update bootstrap C source. 2016-12-29 15:30:06 +00:00
David Brown
0666629e1e J. Templ heap tweaks - improved handling in extreme memory scenarios. 2016-12-29 15:28:04 +00:00
David Brown
6a20f8f951 Fix for dynamic library installation. 2016-12-28 14:47:16 +00:00
David Brown
ee6e5fe7b4 Update bootstrap C source 2016-12-28 13:06:10 +00:00
David Brown
265ac23f6e Restore 4*Unit heap allocation multiple. 2016-12-28 13:05:16 +00:00
David Brown
66b7ea0be0 Merge branch 'master' of https://github.com/vishaps/voc 2016-12-28 12:35:43 +00:00
David Brown
6c9fdacce5 Update bootstrap C source 2016-12-28 12:34:28 +00:00
David Brown
173c83f217 Integrate OFront fix for unsigned DIV in heap. 2016-12-28 12:33:34 +00:00
Norayr Chilingarian
2a65229fef added 'make install' to the readme. 2016-12-26 00:09:35 +04:00
David Brown
d292b4b2c9 Update bootstrap C sources. 2016-12-22 17:17:34 +00:00
David Brown
535f80d91c Integrate jtempl heap allocation recursion fix. 2016-12-22 17:16:42 +00:00
David Brown
37fc052d95 Update autobuild report 2016-12-22 16:36:05 +00:00
David Brown
b66d7bf2ef Display configuration in Visual C makefile 2016-12-22 14:55:03 +00:00
David Brown
4dac1f29d5 Fix conditional syntax in autobuild script. 2016-12-22 14:42:53 +00:00
David Brown
da14bc6398 Add Visual C x86 autobuild. 2016-12-22 14:35:11 +00:00
David Brown
572587ec56 Add new autobuild machine vim-obs32. 2016-12-21 18:16:25 +00:00
David Brown
ee197d741a Update C bootstrap source. 2016-12-21 13:02:11 +00:00
David Brown
3ba0d7ae2c Update Visual C make.cmd, use separate compilation for LOLA conf test. 2016-12-21 13:01:14 +00:00
David Brown
305781e000 Version 2.1.0 - update version and add history. 2016-12-20 17:27:47 +00:00
David Brown
3cb60cc59f Update C bootstrap source. 2016-12-20 15:17:12 +00:00
David Brown
412a8c3337 Document compilation; remove OpenBSD debugging. 2016-12-20 15:16:18 +00:00
David Brown
c6388006b9 Update bootstrap C source. 2016-12-19 16:12:09 +00:00
David Brown
8220c4e807 Fix heap for -OC build on 32 bit systems. 2016-12-19 16:11:32 +00:00
David Brown
43117e79f7 Integrate JTempl's new OFront heap implementation using unsigned address arithmetic. 2016-12-19 16:00:57 +00:00
David Brown
6f43c272c9 Update bootstrap C sources. 2016-12-18 17:13:46 +00:00
David Brown
7386767d84 Fix binary dir determination for mingw/msc. 2016-12-18 17:12:00 +00:00
David Brown
fc385eca3c Update bootstrap C sources. 2016-12-18 16:34:33 +00:00
David Brown
5c5ca01dbc Fix overenthusiastic deletion of .sym files for -F forcenewym. Whoops. 2016-12-18 16:33:41 +00:00
David Brown
28d4bc8219 -F doesn'teven try opening existing sym file. -s silently replaces old version sym file. 2016-12-18 14:51:27 +00:00
David Brown
4c7aa1720a Update bootstrap C sources. 2016-12-18 13:05:05 +00:00
David Brown
460b879829 Build link list based on imports, not on modules compiled by compiler instance. 2016-12-18 13:03:59 +00:00
David Brown
4a71f43e72 Update bootstrap C source files. 2016-12-14 16:56:57 +00:00
David Brown
e85091289e Fix array assignment size validation to accept equal sizes. 2016-12-14 16:55:16 +00:00
David Brown
1e9c1af8ef Update bootstrap C sources. 2016-12-13 20:16:38 +00:00
David Brown
41a239c5aa Fix heap address comparisons for sign crossing. 2016-12-13 20:15:29 +00:00
David Brown
6507b4ede3 Update bootstrap C sources. 2016-12-13 18:53:34 +00:00
David Brown
85eeef6ae4 Supportix dump of block with uncleared GC flag in bit 0 of tag. 2016-12-13 18:52:42 +00:00
David Brown
d4c5d63978 Update bootstrap C sources. 2016-12-13 18:43:20 +00:00
David Brown
30bae1a622 Fix dump of chunk that crosses +ve to -ve address. Could this be the underlying issue in Heap? 2016-12-13 18:42:16 +00:00
David Brown
d7de570177 Update bootstrap C sources. 2016-12-13 18:27:35 +00:00
David Brown
a377c7c3bf Still chasing OpenBSD issue. Add heap dump. Looks like a GC fault. 2016-12-13 18:25:50 +00:00
David Brown
13241fabba Update bootstrap C sources. 2016-12-12 20:06:40 +00:00
David Brown
c5561dd0e0 Make type descriptor dump resilient to increments (mid-GC) tags. 2016-12-12 20:06:00 +00:00
David Brown
d9fb831fcf Update bootstrap C sources. 2016-12-12 18:43:32 +00:00
David Brown
4444d06e4e Remove duplocate ModuleDesc in Modules. Add type descriptor dumping. 2016-12-12 18:42:36 +00:00
David Brown
80512b6ecc Update bootstrap sources. 2016-12-11 20:19:08 +00:00
David Brown
f75a98d3dc Display text run dump according to its dynamic type. 2016-12-11 20:18:34 +00:00
David Brown
27e3b57616 Update bootstrap sources. 2016-12-11 17:43:47 +00:00
David Brown
6e28d3f2fd Ha! Now fix hexdump for -OC build. 2016-12-11 17:43:05 +00:00
David Brown
c409b84e68 Update bootstrap sources. 2016-12-11 17:32:23 +00:00
David Brown
3c1e64375e Fix hexdump on 32 bit builds. 2016-12-11 17:31:25 +00:00
David Brown
fb3017e3e2 Update bootstrap C source. 2016-12-11 17:19:18 +00:00
David Brown
a2d98748b6 Add hex and hexdump to Out.Mod, more debugging for OpenBSD. 2016-12-11 17:18:24 +00:00
David Brown
7d0cc741ae Update bootstrap C source 2016-12-11 14:11:33 +00:00
David Brown
a1ac23a09f More debug to catch OpenBSD intermittent text read failure. 2016-12-11 14:10:46 +00:00
David Brown
7aad84604b Update bootstrap C source. 2016-12-10 18:45:47 +00:00
David Brown
18a365429b Add dubug dump to Texts.Mod to help catch OpenBSD specific read failure. 2016-12-10 18:44:59 +00:00
David Brown
c3fc777f6f Update bootsrap C sources. 2016-12-09 17:50:59 +00:00
David Brown
d12393cc8c Build to local directory and install as separate optional step. 2016-12-09 17:47:48 +00:00
David Brown
c41cb011b6 Working on autobuild. 2016-12-07 17:39:17 +00:00
David Brown
dab579bdd5 Working on autobuild. 2016-12-07 17:29:18 +00:00
David Brown
f3ff731794 Working on autobuild. 2016-12-07 17:18:00 +00:00
David Brown
06be24f32f Working on build system 2016-12-07 17:06:52 +00:00
David Brown
2ec543867b Working on build system 2016-12-07 17:03:36 +00:00
David Brown
0313c30307 Working on build system 2016-12-07 16:42:59 +00:00
David Brown
86fddce532 Merge branch 'master' of https://github.com/vishaps/voc 2016-12-07 16:32:21 +00:00
David Brown
442f377b7e New autobuild process 2016-12-07 16:29:01 +00:00
norayr
fd27239b2d changed help to conform to the binary name. -- noch 2016-12-07 19:47:51 +04:00
norayr
04760174fb Merge branch 'master' of https://github.com/vishaps/voc 2016-12-07 19:44:58 +04:00
norayr
1e15d47936 renamed to vbeautify, added makefile. -- noch 2016-12-07 19:43:45 +04:00
norayr
e6532bfe23 reverted back Texts module changes. 2016-12-07 19:40:08 +04:00
norayr
886c18303e added dump text functions to beautifier. 2016-12-07 19:38:07 +04:00
norayr
9f6c788219 texts module can save plain ascii files with CloseAscii function. 2016-12-07 19:31:48 +04:00
norayr
d18008eafa Beautifier compiled 2016-12-07 18:57:55 +04:00
David Brown
2e436a2d9e More fiddling with auto build scripts. 2016-12-07 14:06:39 +00:00
David Brown
da1ad6e871 I'm still making a mess of the auto build scripts. 2016-12-07 14:05:04 +00:00
David Brown
bde475c384 Silly me, it's a .sh, not a .pl., temporarily have buildall pick up the new .sh. 2016-12-07 14:03:07 +00:00
norayr
ada56e2770 Beautifier converted to plain ascii file. 2016-12-07 17:44:45 +04:00
norayr
9d7f23c918 ocat fixed 2016-12-07 17:44:01 +04:00
norayr
c5f0e1e345 added original Beautifier module. 2016-12-07 17:43:09 +04:00
David Brown
72ba766a2d Slightly simplify auto build repository sync. 2016-12-07 13:11:30 +00:00
David Brown
16c3f32484 Merge branch 'master' of https://github.com/vishaps/voc 2016-12-07 13:09:06 +00:00
David Brown
4b0fb0d1fb Slightly simplify auto build repository sync. 2016-12-07 13:07:21 +00:00
David Brown
83d943297f Use single quote string dilimieters for printf in oberon.mk. 2016-12-06 18:46:37 +00:00
norayr
576c57b39b update of bootstrap sources. 2016-12-06 20:38:09 +04:00
norayr
d210376421 reverted back to using string literals. -- noch 2016-12-06 20:35:58 +04:00
norayr
58ea173d94 added "showdef" related information to the readme. -- noch 2016-12-06 18:28:33 +04:00
norayr
8d28c1b1bb updated bootstrap sources. -- noch 2016-12-06 17:52:15 +04:00
norayr
4fda478a28 replaced most of string constants by OPT.sometyp.strobj.name. -- noch 2016-12-06 17:47:48 +04:00
norayr
d009eb2e34 updated bootstrap c sources. -- noch 2016-12-06 13:13:02 +04:00
norayr
6cd7727802 removed tests. -- noch 2016-12-06 13:11:44 +04:00
norayr
93eea47e54 improved warning message. -- noch 2016-12-06 11:32:21 +04:00
norayr
22c5977fe3 updated bootstrap sources. -- noch 2016-12-05 22:13:29 +04:00
norayr
836e26dd47 added TRUE, FALSE, SET to the check. -- noch 2016-12-05 22:12:10 +04:00
norayr
711283cba5 added type aliasing check and warning. -- noch 2016-12-05 22:06:10 +04:00
David Brown
de049dc80c Add OPM_InstallDir to ignored differences between bootstrap and installable builds. 2016-12-05 17:23:34 +00:00
David Brown
cf2da3000f Record curpos on every inR.Read. Add more debug to catch OpenBSD read failure. 2016-12-05 17:00:55 +00:00
David Brown
c7e88f4634 Update bootstrap C source. 2016-12-05 12:07:40 +00:00
David Brown
e6c858e6e7 Prototype for finding installation based on binary name. 2016-12-04 17:56:06 +00:00
David Brown
a6049e7b82 Update bootstrap C sources. 2016-12-03 18:44:22 +00:00
David Brown
1ae3a2ff32 Simplify ARGV setup. Add trial binary directory discovery code. 2016-12-03 18:43:13 +00:00
David Brown
8c9d029df3 Fix error message display during library build. 2016-12-03 12:07:16 +00:00
Norayr Chilingarian
61828e6a47 Merge branch 'ulm_tidy' 2016-12-02 19:12:16 +04:00
David Brown
6beeaa5626 Update bootstrap C sources. 2016-12-02 13:03:18 +00:00
David Brown
5c3b42be09 Fix incorrect dynarray length type merge with subsequent longint in IdentList. 2016-12-02 13:02:35 +00:00
David Brown
6c0c666f91 Update bootstrap C sources. 2016-12-02 12:27:03 +00:00
David Brown
c57a91210b Append 'LL' to large integer constants to avoid OpenBSD gcc warnings. 2016-12-02 12:26:21 +00:00
David Brown
62c6d5c2a4 Update C bootstrap source. 2016-12-01 18:40:01 +00:00
David Brown
c65b89daf3 Update confidence tests for arg handling move. Remove unused vars in Platform. 2016-12-01 18:39:02 +00:00
David Brown
299b0636ad Fix Platform initialisation, move common Arg handling code from Platfrom to Modules. 2016-12-01 18:08:08 +00:00
David Brown
aed9134e99 Allow Revised Oberon array assignment (source may be shorter than target). 2016-12-01 17:57:27 +00:00
David Brown
b16e82f866 Update open FileDescs at deregistration resulting from delete, rename or register. 2016-11-30 18:13:32 +00:00
David Brown
67e4848eb7 PlatformWindows file sharing mode parity with PlatfromUnix. Allow GC to collect unused files. 2016-11-30 15:49:27 +00:00
norayr
0e1c5fe498 ulm library compiled by fixing integer, longint, shortint and set sizes. -- noch 2016-11-30 19:39:26 +04:00
David Brown
f72b4280b7 Merge branch 'master' of https://github.com/vishaps/voc 2016-11-29 15:44:23 +00:00
David Brown
19af6d76d3 Update bootstrap C source. 2016-11-29 15:43:11 +00:00
David Brown
9f0cbccf55 Various fixes to OS vs Oberon file lifetime management in Files.Mod. 2016-11-29 15:27:30 +00:00
norayr
c549f5847b fixed Longint to Byte Arr function; -- noch 2016-11-29 16:45:18 +04:00
norayr
247852e0b7 fixed overflow in LRealToByteArr; -- noch 2016-11-29 16:14:15 +04:00
norayr
047d8b94e7 plongrealarray had to be pointer to longrealarray. -- noch 2016-11-29 15:00:18 +04:00
norayr
a22c894fd4 removed ORP PO13 compiler version from the voc source tree. -- noch 2016-11-29 13:13:48 +04:00
David Brown
51ae4c3241 Update C bootstrap. 2016-11-28 15:57:49 +00:00
David Brown
d5c3d2aae5 Merge __GUARDEQP changes from OFront. 2016-11-28 15:57:04 +00:00
David Brown
b9339c9516 Merge heap fix for negative addresses from OFront. Fix ulmSets CharSet size. 2016-11-28 14:56:10 +00:00
David Brown
c630f86399 Update C bootstrap sources 2016-11-27 16:49:12 +00:00
David Brown
6a7cba23a7 Force output flush and nonzero return code on assertion failure in Files.Mod 2016-11-27 16:48:03 +00:00
David Brown
7279aa91be Update bootstrap C source. 2016-11-25 13:03:26 +00:00
David Brown
cbf78cb6f1 Fix allocation size for dynarry dope vector - ADDRESS rather than LONGINT. 2016-11-25 12:45:33 +00:00
David Brown
5ae282dc9f Trigger build (after dragging each build machine past the v2.00 tag.) 2016-11-24 19:00:46 +00:00
David Brown
056a317e54 Remove SetHalt documentation - code was already disabled. 2016-11-24 18:10:51 +00:00
David Brown
1a8799d21c Merge branch 'ADRINT': updates version number to 2.00. 2016-11-24 17:59:24 +00:00
David Brown
000c541afa Update version from 1.95 to 2.00. 2016-11-24 17:55:26 +00:00
David Brown
f6a839b710 Merge branch 'master' of https://github.com/vishaps/voc 2016-11-24 17:44:58 +00:00
David Brown
7296800b03 Merge branch 'ADRINT' 2016-11-24 17:34:53 +00:00
David Brown
610cc38efa Update C bootstrap source. 2016-11-24 13:06:00 +00:00
David Brown
1c137d2d7a Doc updates. Add warning for anonymous ARAY or RECORD parameter types. 2016-11-24 12:49:59 +00:00
David Brown
036b8eef41 Update bootstrap. 2016-11-19 15:17:51 +00:00
David Brown
3798b9c537 Fix mingw/msc support on pre Windows 10 systems. 2016-11-19 00:42:35 +00:00
David Brown
2321695270 Hopefully fix 64 bit cygwin and mingw builds. 2016-11-18 17:26:10 +00:00
David Brown
bf65c3744b Split windows build into parallel cygwin and mingw builds, remove old nas builds. 2016-11-18 17:10:29 +00:00
David Brown
8e1897fe17 Ha! Still getting the wrong security for new machines to build. Lets try again. 2016-11-18 14:49:11 +00:00
David Brown
66105ee5ae Add output of id command to poostpush log. 2016-11-18 14:17:08 +00:00
David Brown
fd744350ed Update bootstrap. 2016-11-18 13:07:34 +00:00
David Brown
7abdaf2312 Add new test virtual machines 2016-11-18 12:50:07 +00:00
David Brown
654b6ecb24 Add offset assertions to Files.Mod. 2016-11-16 12:33:53 +00:00
David Brown
13da50007e Honour file path in showdef module argument. 2016-11-16 11:56:40 +00:00
David Brown
240885d841 Restore showdef lookup of installed library modules. 2016-11-15 23:40:26 +00:00
David Brown
65db905f0b Fix misfiring of error 308 by calculating type sizes when not already calculated. 2016-11-15 22:59:43 +00:00
David Brown
c12aae020d Add IsConsole tests to compiler.mod, update bootstrap. 2016-11-15 18:03:57 +00:00
David Brown
6da0d5d685 Build with colour output when on a tty/console. 2016-11-15 17:33:05 +00:00
David Brown
f08e49d856 Fix and simplify fingerprinting for 64 bit values 2016-11-15 11:51:29 +00:00
David Brown
f9c72a37b0 Fix mingw build. 2016-11-14 21:25:04 +00:00
David Brown
377bc73774 Restore text file based error support as prototyped in the ErrorExperiment branch. 2016-11-14 21:00:34 +00:00
David Brown
f7feea0ad1 Tidy browsercmd aka showdef. 2016-11-14 18:19:56 +00:00
David Brown
bb143a6162 Include Int and Set type size in symbol fingerprint. 2016-11-13 20:35:53 +00:00
David Brown
716240bdd6 Simplify runtime error reporting and move to platform common source. 2016-11-12 10:20:50 +00:00
David Brown
ed7043324d Remove redundant writer in OPM. Fix Files.Readline for CR/LF and guarantee 0 termination. 2016-11-11 18:23:31 +00:00
Ivan Sukin
aa5252dc6b Fixed typo in Features.md (#47) 2016-11-11 15:20:27 +00:00
David Brown
ef815aa131 Add version to symbol files to avoid confusing symptoms from format changes. 2016-11-10 18:54:40 +00:00
David Brown
9f5d4c6b0d Fix mingw where ENABLE_VIRTUAL_TERMINAL_PROCESSING is undefined. 2016-11-10 12:52:23 +00:00
David Brown
2cd28725ea Update bootstrap 2016-11-10 11:57:59 +00:00
David Brown
45d3daa11e Windows: enable VT100 support and use SYSTEM.ADDRESS for FileHandle. 2016-11-10 11:56:35 +00:00
David Brown
c93705920e Remove redundant sync that causes error on windows. Update console for Windows cr/lf. 2016-11-10 11:22:23 +00:00
David Brown
c2e97de495 Update bootstrap. 2016-11-08 20:42:36 +00:00
David Brown
1d6c7889b1 Use _alloca /only/ on MSC, not on mingw. Elsewhere it is alloca. 2016-11-08 20:18:14 +00:00
David Brown
eeb168c026 Support Microsoft C make again following dual library (O2 and OC) support. 2016-11-08 18:37:15 +00:00
David Brown
a17c087a41 Uppercase internal SYSTEM.H types address, int*, uint*. Completed. 2016-11-08 12:13:58 +00:00
David Brown
baeb2db81f Uppercase internal SYSTEM.H types address, int*, uint*. Phase 1. 2016-11-08 11:48:33 +00:00
David Brown
1935f63cd6 Fix ABS in SYSTEM.h and fix tools/make/ignore. 2016-11-02 12:59:51 +00:00
David Brown
668c2ef508 Minor documentation updates. 2016-11-02 12:12:59 +00:00
David Brown
c63bc9e093 Fix readme table of contents layout. 2016-11-01 11:58:54 +00:00
David Brown
6a9861355f Update features documentation for -O2/-OC 2016-10-31 18:51:38 +00:00
David Brown
4f74364b59 Don't let expected differences between bootstrap and built compiler show as changes. Update Readme. 2016-10-31 11:47:51 +00:00
David Brown
2a242ae960 Add Oakwood 'In' module and a test for it. 2016-10-30 14:22:10 +00:00
David Brown
03556336ce Restore result variable just for issue #40 using same fix as J. Templ. 2016-10-28 21:00:07 +01:00
David Brown
6a4748e2af Update bootstrap and fix source change tests. Typo in command ine help. 2016-10-28 20:06:30 +01:00
David Brown
126ef6d479 Remove o_result variable obsoleted by restoration of alloca usage. 2016-10-28 19:06:08 +01:00
David Brown
cf49ec30b9 Restore use of alloca for string value copies. mingw build fixes. Support Linux subsystem for Windows. 2016-10-28 18:13:42 +01:00
David Brown
d906629d2a Close old symbol file before reopening it to rewrite it. 2016-10-28 12:21:34 +01:00
David Brown
c3515d8e4b Use Unix line endings for isptest.mod. 2016-10-20 19:48:23 +01:00
David Brown
1e7d3ca4fd Add isptest (active) and In.Mod (not yet used). 2016-10-20 19:20:25 +01:00
David Brown
a4c372253b Fix AssertFail parameter type in Platformwindows.Mod. 2016-10-18 18:52:10 +01:00
David Brown
300b67a572 Remove -msse2, fix halt code type on windows platform. 2016-10-18 18:12:33 +01:00
David Brown
4a9f674b10 Don't build oocFilenames.Mod twice. 2016-10-18 12:09:35 +01:00
David Brown
2d8c9c4757 Make math test work across x86/x64. 2016-10-17 12:49:05 +01:00
David Brown
eda7e88185 Add test for Math and MathL modules. 2016-10-16 15:21:32 +01:00
David Brown
a10c530f98 Trigger rebuild. 2016-10-16 12:38:32 +01:00
David Brown
531e9e090c Oops. Another VT100 file case change. 2016-10-15 22:57:48 +01:00
David Brown
a4ca50f71f Fix case of VT100 in make file. 2016-10-15 21:29:20 +01:00
David Brown
1507d9cb0a Force git rename of VT100 in bootstrap, make SYSTEM.* mdel independent. 2016-10-15 19:05:08 +01:00
David Brown
80de6dc216 Rationalise -O2 vs -OC library build. 2016-10-15 17:15:05 +01:00
David Brown
b231efb466 Updated outtest expected results. 2016-10-12 12:30:27 +01:00
David Brown
ea30615235 Omit hex display of 0.0/0.0 from outtest as it differs between x86 and arm. 2016-10-12 12:08:39 +01:00
David Brown
dd6f704e68 Don't display sign for NaN as x86 and arm generate it differently for 0.0/0.0 2016-10-12 11:49:21 +01:00
David Brown
f0a68cf6f9 Improved Out.Real* layout and build type independence. 2016-10-12 11:12:08 +01:00
David Brown
1a3364269e Remove unwanted result files from git and correct use of sudo in buildall. 2016-10-11 15:35:37 +01:00
David Brown
1ef199dd93 Add hard reset and clean to buildall script. 2016-10-11 12:22:07 +01:00
David Brown
fb3753c55d Add hard reset and clean to postpush script. 2016-10-11 12:11:57 +01:00
David Brown
ee77ec43ca Out.Mod. Add buffer, simplify real output. 2016-10-11 11:42:22 +01:00
David Brown
ebd1a2e695 Add tests for Out.Real, Out.LongReal. 2016-10-08 17:30:44 +01:00
David Brown
a828ff79a4 Implement Out.Real and Out.LongReal. 2016-10-08 17:02:46 +01:00
David Brown
b71526ff5c Add Mathl.Mod. Math and Mathl now compiling, but little tested. 2016-10-04 12:04:43 +01:00
David Brown
80c9d36a7a (Largely untested) Oakwood Math.Mod, some SETxx fixes. 2016-10-03 20:05:22 +01:00
David Brown
fcb51a6c23 Fix Platform.Write on 32 bit builds. 2016-10-01 17:58:16 +01:00
David Brown
c2567a2600 Reorganise system and runtime library modules for both O2 and OC builds. 2016-10-01 17:26:44 +01:00
David Brown
c924a33a05 Better set constant checking. 2016-10-01 10:49:25 +01:00
David Brown
d344c9ce80 Set size testing and constant size propagation. 2016-09-30 20:30:58 +01:00
David Brown
7238be5257 Use SET64 representation in the compiler. 2016-09-30 19:00:33 +01:00
David Brown
2e02f9204c Accept all SET types in INCL. 2016-09-30 18:42:59 +01:00
David Brown
1fa182c7ce Fix generalised ReadNum and use for Sym reading. 2016-09-30 18:15:46 +01:00
David Brown
3dc5049d5a Stepping toward generalised ReadNum. 2016-09-30 17:19:26 +01:00
David Brown
6dedf34785 SET32 and SET64 compatibility and bootstrap update. 2016-09-30 16:38:22 +01:00
David Brown
08bf8d2fc3 Propagate NL spelling change to PlatformWindows. 2016-09-29 10:28:40 +01:00
David Brown
25d99fd36a Add SYSTEM.SET32 and 64 types. Fix 32 bit build. 2016-09-28 18:48:56 +01:00
David Brown
212bcd58b9 Beginning adding -OC (large model) runtime library 2016-09-28 11:38:53 +01:00
David Brown
9ffafc59b4 Reenable library files, fix LONGREAL constants and type casts. 2016-09-26 19:01:59 +01:00
David Brown
ef0a447a68 Fix shared library naming, and getcwd warning. 2016-09-25 16:32:44 +01:00
David Brown
a6f0088299 Trigger build 2016-09-25 15:50:24 +01:00
David Brown
4bc697f49d Add files missed on last commit. 2016-09-25 15:36:00 +01:00
David Brown
41bf2c037d Separate install subdirs for diff size models. Lots of tidying and renaming. 2016-09-25 15:26:04 +01:00
David Brown
8ab4057a10 Make address strobj be equiv int type and remove param checking hack. 2016-09-24 12:13:26 +01:00
David Brown
d683df3e72 Fix browser command following TypSize move. 2016-09-23 19:34:18 +01:00
David Brown
fb002de0dd Move alignment and type size code from OPC to OPT. Remove search path in bootstrap compiler. 2016-09-23 19:04:26 +01:00
David Brown
8017aa445c Beginning to simplify build process 2016-09-23 17:12:02 +01:00
David Brown
22a4f8e263 Use SYSTEM.ADDRESS in libraries. Build all with -O2. Support INC(a,b) for any int a,b that support a:=a+b. 2016-09-23 13:04:24 +01:00
David Brown
f1cbbdba28 Simplify __TYPEOF. 2016-09-23 11:10:33 +01:00
David Brown
cca132d784 More adjustments to ADDRESS vs LONGINT. An -O2 on 64 bit compiler has worked once! 2016-09-23 10:53:24 +01:00
David Brown
7b8eed9993 Revert LEN() to returnng LONGINT 2016-09-22 20:48:13 +01:00
David Brown
b40dc4e2f8 Some support in makefile for 32 bit model. 2016-09-22 20:02:46 +01:00
David Brown
b158671cf8 SYSTEM.ADR and LEN both return SYSTEM.ADDRESS. 2016-09-22 18:40:35 +01:00
David Brown
246a961055 Tidy OPM, update usage display. 2016-09-22 15:03:08 +01:00
David Brown
76b6a8fc23 Clean option handling and add size model and target machine options. 2016-09-21 18:28:17 +01:00
David Brown
1c94abedc6 Simplify parameterisable memory model variables. 2016-09-21 14:28:53 +01:00
David Brown
20a97bb570 Add check that double and long long (both 64 bit) have same alignment. 2016-09-21 11:56:21 +01:00
David Brown
0ea077814f More LONGINT changes to INT64. Hopefully fixes android and pi builds. 2016-09-20 17:51:14 +01:00
David Brown
1a83167d5a Fix ethMD5 build. May need more work to be correct on 64 bit builds. 2016-09-20 16:43:34 +01:00
David Brown
9971e56451 INT64 support in the interface browser. 2016-09-18 15:52:11 +01:00
David Brown
08f09a097d Merge separately committed support for INT64 import. 2016-09-18 11:06:20 +01:00
David Brown
210870f968 Use SYSTEM.INT64 for literal and related values. 2016-09-18 11:06:16 +01:00
David Brown
636c128d14 Fix import of SYSTEM.INT64 on 32 bit builds. 2016-09-18 10:55:14 +01:00
David Brown
21964471d8 Fix import of SYSTEM.INT64 type on 32 bit platforms. 2016-09-15 17:39:30 +01:00
David Brown
dc699db9f5 Support 64 bit integer literals on all builds, and fix 64 bit Console.hex display. 2016-09-15 15:23:08 +01:00
David Brown
b8694e65ab Return d0 correctly in ulmSYSTEM read unixcall handler. Fixes #43. 2016-09-15 13:30:08 +01:00
David Brown
7fad168e40 Tidy source of HEAP a bit. 2016-09-14 14:22:24 +01:00
David Brown
a36e04ebd7 Replace FetchAddress with (original) SYSTEM.GET. 2016-09-14 14:01:31 +01:00
David Brown
7efd5a0158 More LONGINTS changed to Address. Remove special FetchAddress code in Heap. 2016-09-14 13:02:00 +01:00
David Brown
f13130bbd3 Add set size to __SETOF and __SETRNG. 2016-09-13 20:35:29 +01:00
David Brown
b8496c3736 Pass set size to __IN, remove uSET Ctype, optimize __IN size test. 2016-09-13 20:14:17 +01:00
David Brown
68c105b48c Add tests for ENTIER. 2016-09-13 19:44:01 +01:00
David Brown
516e261242 Support int64 in ABS. Remove unneccessary cast in __XF, __RF. 2016-09-12 17:03:02 +01:00
David Brown
9baf4c9429 Fix shift/rotate for all integer types, add tests, make build order work for SYSTEM.c/h changes. 2016-09-12 15:55:54 +01:00
David Brown
74a085dda3 Update bootstrap. 2016-09-11 18:33:30 +01:00
David Brown
1bce6ac9b0 Make address just a synonym for int32 or int64. 2016-09-11 18:00:35 +01:00
David Brown
24aa3c6508 -Ob not working on my FreeBSD, use -O1. Better LP64 detection for OpenBSD. 2016-09-10 12:24:06 +01:00
David Brown
83aaa70290 SYSTEM.ADDRESS signed (again), DIV, MOD full integer support, ASH and checks support 64 bit ints.
Change (back) to address type being signed.
DIV and MOD fully defined for the full range of integer on both parameters.
_X, _XF, _R and _RF checks upgraded for 64 bit support.
ASH upgraded for 64 bit.
Add div and mod tests to language confidence test.
Enable debuggable C compiler options.
2016-09-09 14:47:40 +01:00
David Brown
ebfc60f49d Define integer sizes before including SYSTEM.h 2016-09-06 20:48:22 +01:00
David Brown
682fa59e42 Fix mingw windows build. 2016-09-04 16:38:17 +01:00
David Brown
a865643d6c Change of mind: s/uintptr/address/. Replace LONGINT with ADDRESS in Platform*. 2016-09-04 14:34:24 +01:00
David Brown
90737e5677 Remove obsolete SYSTEM.ADRINT. (Not that I much like uintptr). 2016-09-03 23:28:50 +01:00
David Brown
4ec2e61ed0 Completely update addresing vars in heap from LONGINT to SYSTEM.UINTPTR. 2016-09-03 18:55:55 +01:00
David Brown
db18774de1 Allow SYSTEM.VAL of constant in CONST and use in Heap.Mod. 2016-09-03 17:47:55 +01:00
David Brown
a730d6c96b Switch SYSTEM.h uintptr type from int64 to size_t, 32 bit working again. 2016-09-03 12:01:04 +01:00
David Brown
cdd8a26481 Moving Heap.Mod to SYSTEM.UINTPTR. Only 64 bit working for now. 2016-09-03 11:56:17 +01:00
David Brown
11de6b8512 uintptr for alloc/free, some sys fns from LONGINT to int64. 2016-09-02 13:02:44 +01:00
David Brown
fdaa5ec81b Fix outdated CARD32 type in PlatformWindows. 2016-09-01 14:53:23 +01:00
David Brown
6851833a1e Remove some temporary bottstrapping types. Change 'U_' to 'u'. 2016-09-01 14:45:23 +01:00
David Brown
ee8342ef0d Moving to config independent types stage 1 - generate intxx types. 2016-09-01 14:14:06 +01:00
David Brown
159f5a3d80 Update bootstrap source and snapshot binaries 2016-09-01 12:04:17 +01:00
David Brown
68cf60c401 Renumber forms removing gaps for SInt and LInt. 2016-08-31 18:46:03 +01:00
David Brown
a1fd798f6d Remove all use of forms SInt and LInt and remove intSet using just Int instead. 2016-08-31 18:33:53 +01:00
David Brown
0508097ffe Base expression casting on C int size, remove dependencies on form=LInt. 2016-08-31 17:15:44 +01:00
David Brown
b3c71fb2f0 Include int size in .sym files, fix __IN for out of range values, better naming. 2016-08-30 19:01:24 +01:00
David Brown
a33e38cf6c Add OutSize and InTyp procedures for integer symbol handling. 2016-08-29 18:34:46 +01:00
David Brown
7d7579a36d Remove unused AlignSize proc, and clean sym files before compiler build. 2016-08-29 17:47:54 +01:00
David Brown
5033d09f32 Record constant size in symbol tables, make full is now successful. 2016-08-27 18:49:52 +01:00
David Brown
7df022d94e Add SYSTEM types INT8 through INT64. Define LINT as derived type of SYSTEM.INT64. 2016-08-26 18:59:50 +01:00
David Brown
b6385f8b8c Add basic SYSTEM.ADRINT type. 2016-08-26 16:28:07 +01:00
David C W Brown
da88496c5f Tidy (#41)
* Deduplicate common constants into OPM and do some source format tidying.

* Fix postpush buildall script to force checkout of updated buildall.

* Show enlistment branch in makefiles

* Support non-printables in string literals and tidy case alignment and constant literals.

* Common code for MIN and MAX of integer types.

* Common code for SInt/Int/LInt in ConstOp parameter preparation.

* Common code for SInt/Int/LInt in Op parameter preparation.

* Refactor SetIntType to work with byte size directly. Prepare to revert my incorrect VAL changes.

* Original meaning of VAL restored. Many library files disabled until use of VAL in 64 bits fixed.

* Make Reals.Mod independent of INTEGER size and add reals tests.

* Implement fraction, IsInfinity and IsNaN in oocLowReal.Mod.

* OPB little simplifications and ShorterSize/LongerSize functions.

* Add test for alignment computability

* Replace alignment constants with calculated alignment.

* typ.size aware OPV.Convert

* Add SYSTEM_INT64 and make tests name independent.

* Remove SYSTEM.H includes (string.h and stdint.h).

* Replace uses of uintptr_t and size_t with SYSTEM_ADDRESS.

* Sad hack to make FreeBSD and OpenBSD happy with memcpy declaration.

* Detect 64 bit on FreeBSD, and size_t defined on OpenBSD.

* %zd not supportd by mingw, cast strnlen return to int.

* Add debug for intermittent failure only on OpenBSD.

* Add textTexts as a confidence test and tidy up a couple of other tests.

* Update binary test process.
2016-08-25 14:41:00 +01:00
David Brown
1f41d80b1e Resnap test binaries with improved buinary extraction. 2016-08-24 18:45:52 +01:00
David Brown
3a7b742ea7 Update binary test process. 2016-08-24 16:26:43 +01:00
David Brown
ca2cc52a44 Port updated tests and binary snapping, with corrected Reals code, from tidy branch. 2016-08-24 14:10:06 +01:00
David Brown
b1dc7d77e8 Update boostrap source 2016-07-22 20:20:57 +01:00
David Brown
6d957bf0bb Remove unused variable and export. Thanks Oleg. 2016-07-22 18:56:14 +01:00
David Brown
d9c319ef3a Fix initial Time() value and fix GetTimeOfDay on Windows. Thanks Oleg. 2016-07-22 14:25:39 +01:00
David C W Brown
c07485d5a4 Merge pull request #37 from vishaps/FileList
Remove limit on numeric value of OS handles from Files.Mod
2016-07-21 14:15:02 +01:00
David Brown
d43279d053 postpushpl fix buildall parameter (yes, again). 2016-07-21 13:58:46 +01:00
David Brown
0d988a8ea0 postpush.pl fix branch passed to buildall. 2016-07-21 12:56:10 +01:00
David Brown
ff9a45bc1a postpush.pl must pull latest changed branch to get appropriate buildall.pl. 2016-07-21 12:49:27 +01:00
David Brown
61eb8199d4 Make autobuild use latest changed branch. 2016-07-21 12:39:10 +01:00
David Brown
c21975dc2a Remove limit on numeric value of OS file handle. 2016-07-21 12:26:20 +01:00
David Brown
0004fca318 Status report tweaks. 2016-07-20 14:32:15 +01:00
David Brown
92e892c450 Fix success colour and width of build status report. 2016-07-20 12:25:41 +01:00
David Brown
4bbfe120c7 Add reporting of generated assembler changes. 2016-07-20 11:15:19 +01:00
David Brown
b3e2c5f9a6 Second attempt at disabling assembler generation for cygwin 64. 2016-07-19 21:55:47 +01:00
David Brown
0349189479 Separate assembly source by build flavour. 2016-07-19 20:38:41 +01:00
David Brown
359aa1c43f Add preliminary tests for generated code changes in the confidence tests. 2016-07-19 17:59:04 +01:00
David Brown
ece90b85c5 Omit (more) platform specific settings from code change tests. 2016-07-19 15:54:09 +01:00
David Brown
d6acf11700 Update bootstrap sources. 2016-07-19 15:37:07 +01:00
David Brown
afb70fa178 Try explicitly calling 'sh' in confidence tests to avoid limitation on termux. 2016-07-18 17:25:25 +01:00
David Brown
3f6c6243cb Fix typo in typedef of U_INTEGER. Thanks Oleg! 2016-07-18 16:41:52 +01:00
David Brown
d12e72a428 Merge branch 'master' of https://github.com/vishaps/voc 2016-07-17 11:44:51 +01:00
David Brown
d8882462b1 Still fiddling to make test.sh work everywhere. Set first line to #!/bin/sh. 2016-07-17 11:44:25 +01:00
David CW Brown
cd53085613 Language test script must be executable. 2016-07-17 11:06:49 +01:00
David Brown
f2e12bf481 Make confidence test .sh s executable under cygwin by putting #! on first line. 2016-07-16 20:59:12 +01:00
David Brown
c146cab6c1 Add tests for ASH, SYSTEM.LSH and SYSTEM.ROT. 2016-07-16 18:29:51 +01:00
David Brown
5b77460e4f Use typedefs rather than defines for basic types. 2016-07-15 20:26:40 +01:00
David Brown
d3ee82a0c4 Remove invalid working source. 2016-07-15 17:23:04 +01:00
David Brown
64790ceff7 Remove invalid working source. 2016-07-15 17:02:15 +01:00
David Brown
347cefc614 Fix quoting of parameters passed through to 64 bit shell. 2016-07-15 16:58:45 +01:00
David Brown
c7511287bb Fix mismatchedbracket in buildall.pl. 2016-07-15 15:42:37 +01:00
David Brown
b5dbf13af4 Try using git pull to get updated buildall.pl as raw fetch is never up to date. 2016-07-15 15:30:26 +01:00
David Brown
86de8a6fe5 Try adding cygwin and mingw 64 bit builds. 2016-07-15 15:12:08 +01:00
David Brown
8bf94eddfe Still getting buildall.pl right. 2016-07-15 13:05:21 +01:00
David Brown
77f8280e90 Missingg comma typo in buildall.pl. 2016-07-15 13:00:27 +01:00
David Brown
16072f9dc3 Move all build commands back into buildall.pl. 2016-07-15 12:57:31 +01:00
David Brown
73ff9f50a2 Try again to handle multifold builds without losing singlefold build status. 2016-07-14 20:14:23 +01:00
David Brown
a42d4c4a03 Another try at handling the Windows twofold build. 2016-07-14 19:39:32 +01:00
David Brown
9145a64b44 Fix buildall build directories for windows and android. 2016-07-14 18:06:20 +01:00
David Brown
e8738e51de Add termux build to buildall. 2016-07-14 17:01:20 +01:00
David Brown
f1af9e01e9 Merge branch 'master' of ssh://github.com/vishaps/voc 2016-07-14 16:20:21 +01:00
David Brown
d4fe8b3bdc Add mingw32 bit build to autobuild. 2016-07-14 16:19:50 +01:00
David C W Brown
9903c9c435 Fix table formatting. 2016-07-14 09:44:52 +01:00
David Brown
240c29c6dd Omit config dependent strings from source change tests. 2016-07-11 12:50:06 +01:00
David Brown
f784a41f8f Update bootstrap sources. 2016-07-11 11:01:11 +01:00
David Brown
57cd40aa9d Experiment with assmbly code listing - thinking about new tests. 2016-07-10 16:49:30 +01:00
David Brown
156d9b0183 For now, just link to a directory containing copies of the latest logs. 2016-07-10 15:17:43 +01:00
David Brown
66d36728db Point status at a directory so github doesn't try to cache it. 2016-07-10 14:59:43 +01:00
David Brown
d59bfa05d3 Fix build status formatting 2016-07-10 14:48:06 +01:00
David Brown
2c2fa4963c Link to build status that can access logs, add date, time and branch to status. 2016-07-10 14:21:49 +01:00
David Brown
5c8b98dd05 Don't trigger autobuild when change only affects .md or .svg files. 2016-07-09 23:15:02 +01:00
David Brown
89e2616c5b Fix equality test in sourcechanges.pl 2016-07-08 23:37:59 +01:00
David Brown
92e2c51806 Move version string physically into Version binary, fix diff parm on centos. 2016-07-08 23:28:51 +01:00
David Brown
365275ebcd Check in buildall.pl changes too. Oops. 2016-07-08 22:59:58 +01:00
David Brown
b445d95772 Use source diff to identify compiler changes. 2016-07-08 22:47:40 +01:00
David Brown
9ad2a86827 Try adding a TOC to the readme, and formatting the hello app code. 2016-07-08 18:33:51 +01:00
David Brown
2a352ff67b Add cygwin32 build and more thoughts on 64 bit support and runtime error reporting. 2016-07-08 17:17:09 +01:00
David Brown
56256a49f2 Fix hex parsing, readme typos. 2016-07-08 12:53:30 +01:00
David Brown
d50e08ac3f Buildall.pl script switched to master branch. 2016-07-06 18:55:56 +01:00
David C W Brown
66f2e812ed Merge pull request #32 from vishaps/v2docs
Getting docs together and adding report of fledgeling auto-build.
2016-07-06 18:43:42 +01:00
David Brown
8e4367e5c9 ReadMe tweaking. Simplify. Add References and links. 2016-07-06 17:20:12 +01:00
David Brown
1f73ab6856 Just a bit more font height. 2016-07-01 22:45:40 +01:00
David Brown
f780a801f4 10% increase of build status font height. 2016-07-01 21:24:44 +01:00
David Brown
bb519dc27a Reenable most builds. 2016-07-01 21:08:45 +01:00
David Brown
b7871e1927 move text down very slightly. 2016-07-01 21:02:26 +01:00
David Brown
0c5d71dc19 buildall.pl typo 2016-07-01 20:52:12 +01:00
David Brown
2d531ad8d6 Tweak build report border 2016-07-01 20:50:17 +01:00
David Brown
8f7e25fe2f Begin to add logs to build report 2016-07-01 20:35:11 +01:00
David Brown
e16f1c13b6 Prettify build report 2016-07-01 20:15:53 +01:00
David Brown
96f84b3937 Tweak build report 2016-07-01 19:58:55 +01:00
David Brown
feff10c22c Tweak build report 2016-07-01 19:52:04 +01:00
David Brown
43d120814c Log scanner beginning to work. 2016-07-01 19:40:19 +01:00
David Brown
4981afd55a Pickup of latest buildall.pl working. 2016-07-01 18:19:55 +01:00
David Brown
e68743eadc Make sure buildall starts in the cirrect directory. 2016-07-01 15:53:29 +01:00
David Brown
3c8a347d33 Need to remove prior buildall.pl as wget won't overwrite. 2016-07-01 15:44:06 +01:00
David Brown
c7984ffdac Build machine to pick up latest buildall.pl every time. 2016-07-01 15:32:18 +01:00
David Brown
ec7888859c Omit OPC and OPM from checksums as they contain the build date. 2016-07-01 15:16:11 +01:00
David Brown
78540bcaba Move test build scripts. 2016-07-01 14:50:05 +01:00
David Brown
b2e446d352 Typo in vishap.make 2016-07-01 14:17:26 +01:00
David Brown
6470000cff Parse logs for build and test status. 2016-06-30 21:02:06 +01:00
David Brown
35c3921be4 Merge branch 'v2docs' of https://github.com/vishaps/voc into v2docs 2016-06-30 20:11:54 +01:00
David Brown
c45c111237 Add brnachname to checksum fileneame. 2016-06-30 20:11:09 +01:00
David Brown
3cd3376139 Test build progress 2016-06-30 19:41:14 +01:00
David Brown
d97668a209 Initial checksum support in build. 2016-06-30 18:36:17 +01:00
David Brown
d24d436808 Wow, svg is working fine. 2016-06-30 12:07:54 +01:00
David Brown
54757d336c Phew, just a typo. build-staus. 2016-06-30 11:41:12 +01:00
David Brown
3ac00d5535 Avoid htaccess. Try svg directly again. 2016-06-30 11:39:10 +01:00
David Brown
5aabb5a955 Another checkin to see if no-cache fixes it. 2016-06-29 23:53:15 +01:00
David Brown
5c93ec0bcd Try without the raw=true. 2016-06-29 22:44:25 +01:00
David Brown
15ee11b2aa Aother attempt to get the readme to display the passing status image from brownsmeet.com. 2016-06-29 17:31:15 +01:00
David Brown
fe0803e6be Try another way to get passing status image into readme. 2016-06-29 16:16:38 +00:00
David Brown
d2f03dbd18 Merge branch 'v2docs' of https://github.com/vishaps/voc into v2docs 2016-06-29 12:48:59 +01:00
David Brown
f9ced032af Can github access my SVG? 2016-06-29 12:48:35 +01:00
David C W Brown
92365d501c Add passing build extraction script. 2016-06-27 21:02:23 +01:00
David C W Brown
99bd3b3105 Checkin real (not merged) postpush.pl 2016-06-27 20:46:43 +01:00
David C W Brown
a15f943d5b Unwanted merge commit. Bloody git. 2016-06-27 20:44:12 +01:00
David C W Brown
77f6fa772c Working post push hook now? 2016-06-27 20:41:49 +01:00
David Brown
3a17e1a656 Debugging postpush.pl 2016-06-27 17:56:19 +01:00
David Brown
61c9790edc Debugging postpush.pl 2016-06-27 17:53:20 +01:00
David Brown
dff410e5b5 Debugging postpush.pl 2016-06-27 17:49:22 +01:00
David Brown
71e5e38d89 Debugging postpush.pl 2016-06-27 17:43:49 +01:00
David Brown
f383a6c032 Correct quoting in postpush.pl. 2016-06-27 17:23:18 +01:00
David Brown
45c8b1d617 Merge branch 'v2docs' of https://github.com/vishaps/voc into v2docs 2016-06-27 17:08:14 +01:00
David Brown
88dd4e4d13 Emit 'now set path' message at end of 'make full'. 2016-06-27 17:07:54 +01:00
David C W Brown
b495b2725c Some more significant ReadMe work. 2016-06-27 15:53:36 +01:00
David Brown
a359e16ae9 webhook progress 2016-06-27 12:31:00 +01:00
David Brown
44889a1b2f Add newline to postpush script 2016-06-26 17:12:47 +01:00
David Brown
a5a8809b91 Git push webhook script beginning to work. Fiddle with readme. 2016-06-26 17:07:40 +01:00
David Brown
d8e26c635e Another readme twiddle to generate a github hook. 2016-06-24 00:30:27 +01:00
David C W Brown
03805e5fdb Simple readme change (to ttry json web hook). 2016-06-23 14:29:27 +01:00
David C W Brown
f2c55cc4de Simple readme change (to test web hook). 2016-06-23 14:25:31 +01:00
David Brown
119365d4a9 Add buildall perl script 2016-06-22 14:12:14 +01:00
David Brown
739a94313b Slight doc changes, new multi-machine build approach. 2016-06-20 18:36:44 +01:00
David
f050fc2fe4 Nice error message when install dir inaccessible. 2016-06-18 17:44:02 +01:00
David Brown
342d883d11 Update version to 1.95. Add more early version documentation. 2016-06-18 16:38:42 +01:00
David Brown
f828e80e56 Start organising documentation. 2016-06-18 12:05:23 +01:00
David C W Brown
f838e58c50 Make tests shell scripts executable. 2016-06-17 13:41:02 +01:00
David Brown
2b3b6a822a File mode corrections. Add lol filetype to 'lf' eolns. 2016-06-16 18:14:58 +01:00
David Brown
1a7a7615df Add olang readme as v2changes in triage dir. 2016-06-16 16:52:05 +01:00
David Brown
43c5f44c10 Add bootstrap and master make files. 2016-06-16 16:51:11 +01:00
David Brown
be80ad7ae3 Remove unneeded tests result files. 2016-06-16 16:43:10 +01:00
David Brown
8b0bd9c675 Update tools to v2. 2016-06-16 16:31:59 +01:00
David Brown
ce855c93c8 Update test files to v2. 2016-06-16 16:25:36 +01:00
David Brown
a9b273e30a Fix line endings. 2016-06-16 16:14:30 +01:00
David Brown
c64a75bd78 Add .git configuration files to enlistment root. 2016-06-16 15:54:40 +01:00
David C W Brown
f9dc858d29 Remove binary files incorrectly checked in. 2016-06-16 15:36:31 +01:00
David Brown
7bdc53145e Update library source to V2. 2016-06-16 14:56:42 +01:00
David Brown
4245c6e8b3 Update system source to V2. 2016-06-16 14:14:39 +01:00
David Brown
efb7b6b030 Update compiler source to V2. 2016-06-16 13:58:01 +01:00
David Brown
efefcf0fb4 Add confidence tests. 2016-06-16 13:56:34 +01:00
David Brown
1304822769 Rename lib to library. 2016-06-16 13:56:12 +01:00
David Brown
b7536a8446 Move Args.Mod out of system as it's not part of the compiler build. 2016-06-16 13:07:17 +01:00
David Brown
49e9fd3533 Move Oberon.Mod to system. 2016-06-16 13:00:46 +01:00
David Brown
6c6791edf9 Consoldate v4 library files part 2. 2016-06-16 12:59:23 +01:00
David Brown
126f758836 Consoldate v4 library files part 1 2016-06-16 12:58:46 +01:00
David Brown
d6d9666713 Consolidate ulm library files. 2016-06-16 12:55:13 +01:00
David Brown
e4309559f3 Consolidate s3 library files. 2016-06-16 12:49:53 +01:00
David Brown
9021308e47 Consolidate ooc2 library files. 2016-06-16 12:46:51 +01:00
David Brown
6a1b2f4967 Consolidate ooc library files. 2016-06-16 12:42:49 +01:00
David Brown
c374e343af Rename system files to v2 conventions. 2016-06-16 12:36:03 +01:00
David Brown
f48876d5db Remove unneeded Files and Kernel variants. 2016-06-16 12:30:52 +01:00
David Brown
5b3062f475 Consolidate files in system directory. 2016-06-16 12:29:25 +01:00
David Brown
72dedc9bf6 Remove par directory and mv system directory under src. 2016-06-16 12:09:14 +01:00
David Brown
e4153701ea Rename compiler directory to 'compiler'. 2016-06-16 12:07:37 +01:00
David Brown
9cc63cc6c2 Compiler source directory: consolidate duplicate files. 2016-06-16 12:06:42 +01:00
David Brown
ead30cb27b Begin update to V2. Move old files to triage. 2016-06-16 11:52:06 +01:00
David C W Brown
593774a3fc Remove latest vocstatic binaries
Former-commit-id: 0af64a79258a79a5882d95dffd0b656be56dc472
2016-06-15 14:06:49 +01:00
Norayr Chilingarian
042ff66d14 added -fno-stack-protector to linux gcc makefiles. -- noch
Former-commit-id: 7f6c73341414af134c2ae23cd5dab5629d0d5fe5
2016-05-02 03:13:04 +04:00
norayr
aeadd58952 fixed Oberon.Mod; now Oberon.DumpLog works.
Former-commit-id: 4e2da4f92e77fcce3db1291cbfafd2f430d7bac9
2016-02-24 15:21:16 +04:00
Norayr Chilingarian
2991026809 added problematic ubuntu version to faq file
Former-commit-id: 5f80704eb0feffdf11d42f1aee7671639b209c55
2016-02-04 01:27:29 +04:00
Norayr Chilingarian
4838e91966 s/ooc/voc -- noch
Former-commit-id: bdf7be9896a5c74170ab6b35df5269ab03a0ab08
2016-01-22 01:16:08 +04:00
Norayr Chilingarian
f3790d78f5 fixed makefile name in the "COMPILE" file. [issue](https://github.com/norayr/voc/issues/6); -- noch
Former-commit-id: e403827d4660bd70f76fc71c372bd722992f1b06
2016-01-19 19:07:36 +04:00
Norayr Chilingarian
63ba3074cf reverted darwin makefile by fixing default prefix. -- noch
Former-commit-id: 9fc7d7b6c480bacc01f93f1c819f7b7642e42bc4
2016-01-19 17:05:23 +04:00
Norayr Chilingarian
f05ecf6102 Unix.Timeval fix. suseconds_t is 4 bytes on osx x86_64 apparently.
Therefore Timeval.usec is INTEGER. Thanks to Jon Kleiser for [raising](https://github.com/norayr/voc/issues/5) the question.
bootstrap binary updated. Kernel0. Kernel modules affected. -- noch


Former-commit-id: 177f08f0e0e37f9c7ba9d08a91da7c08006c92a4
2016-01-19 16:54:26 +04:00
norayr
bac3c2cb49 apparently, openbsd bootstrap binary was not added to the git. (:
Former-commit-id: 02a909696d0d60377099e957f56fa7fb9e51cf4c
2016-01-16 01:09:32 +04:00
norayr
e5f0949578 yet another readme fix.
Former-commit-id: 9293edffacd2be1fd3dd61ef8a114023903e90c4
2016-01-15 13:55:40 +04:00
norayr
eca49ba0a4 fixed link in the readme
Former-commit-id: bfbd8cd87dd9cf84cfaa62aea3cf7e01a14ef05a
2016-01-15 13:52:34 +04:00
norayr
c64f107f80 source of example
Former-commit-id: 00eb04bf2d4b5945dfc23470415f5526281d9e6f
2016-01-13 16:07:39 +04:00
norayr
7ef2017a7c spaces
Former-commit-id: eeb2006ca8007dc48eed9baadcee4982e107fad2
2016-01-13 16:06:31 +04:00
norayr
0bd38727b7 code
Former-commit-id: a1e328df71183c99f4b6df1269b40789262c0e9b
2016-01-13 16:05:38 +04:00
norayr
b9676648c4 added openbsd
Former-commit-id: 1d89d43a9bc26bbf2a2dd201168d2144fa21fa34
2016-01-13 16:03:23 +04:00
norayr
e4d62c1419 fix
Former-commit-id: 4bdf3528c2ecae2374aeb704924a69305b318658
2016-01-13 16:02:13 +04:00
norayr
9ff2932042 docs update
Former-commit-id: da10006200ec7ae574342c95b0f52e177878fb70
2016-01-13 15:58:18 +04:00
norayr
12e7369e17 added site link
Former-commit-id: 087d2decc936e9785d36a1bacaa3f6507b5e923e
2016-01-13 15:55:28 +04:00
norayr
163c316e92 docs improvement.
Former-commit-id: a986cf542ca3d51ea57f4779b6c53b2f91d6494d
2016-01-13 15:53:08 +04:00
norayr
93335d8460 updated documentation.
Former-commit-id: a97fc806e7a76069b323a27db060227923941b82
2016-01-13 15:48:37 +04:00
norayr
6425e7f899 fixed default prefix in darwin makefile
Former-commit-id: 9f1ee2651fabb7519ac0dfd74bba6d439674629e
2016-01-13 14:35:10 +04:00
norayr
ecc94a305b fixed home path
Former-commit-id: f494740aadd2584f3994f1dc5746f9c4ddf0429e
2016-01-13 14:34:16 +04:00
Norayr Chilingarian
f1badbacbd Merge pull request #4 from antranigv/master
OpenBSD port

Former-commit-id: dbd10b24185b9cd34458b862e24771bcdfb08149
2016-01-13 13:25:45 +03:00
Antranig Vartanian
f3089c9942 some changes for OpenBSD
Former-commit-id: d570c60e3c
2016-01-13 14:24:08 +04:00
Antranig Vartanian
10e2d4c807 chaned TimeDesc in File0.Mod and File.Mod -- antranigv
Former-commit-id: 3cdb5b1d3a
2015-12-12 21:58:47 +04:00
Antranig Vartanian
1a2082bfc2 changed variable l type from LONGINT to INTEGER in Kernel.Mod and
Kernel0.Mod --antranigv


Former-commit-id: 135f9ec6b4
2015-12-12 21:26:06 +04:00
Antranig Vartanian
40441e13ae changed Kernel.Mod from Kernel0.Mod -- antranigv
Former-commit-id: 47d97361f6
2015-12-12 21:03:26 +04:00
Antranig Vartanian
b5bf7f48fc changed Kernel0.Mod for TimeDesc -- antranigv
Former-commit-id: 90ef9158d4
2015-12-12 20:57:00 +04:00
Antranig Vartanian
5143a1557e fixed FdSet size -- antranigv
Former-commit-id: a80cd3b643
2015-12-12 20:30:40 +04:00
Antranig Vartanian
4366edec85 changes on SYSTEM.h for Malloc -- antranigv
Former-commit-id: ab04bdfdc6
2015-12-06 21:59:45 +04:00
Antranig Vartanian
10eecb8a2e changes AND makefile for OpenBSD -- antranigv
Former-commit-id: 3ceda03627
2015-12-06 21:38:43 +04:00
Antranig Vartanian
4bebc891a4 updated Unix.Mod for OpenBSD -- antranigv
Former-commit-id: c3a5559aab
2015-12-06 21:27:13 +04:00
Antranig Vartanian
7d3258c2f2 initial of OpenBSD changes for voc on X86_64
Former-commit-id: 0170d2b442
2015-12-03 22:50:57 +04:00
norayr
5305dbaa89 argc is INTEGER on 64bit; fixed. -- noch
Former-commit-id: defc630a5e
2015-11-20 14:53:41 +04:00
norayr
edad955821 reported by pdewacht: if eol is 0DX only, then voc wasn't able to handle
this correctly http://paste.lisp.org/display/158971#1

this is base62 encoded test module http://paste.lisp.org/display/158971

fixed.; -- noch


Former-commit-id: ebd0d78ce2
2015-11-10 22:18:35 +04:00
norayr
b8b1012e9a fixed error reported by pdewacht: with -l option voc hung if error was
at the last line, and no eol followed. ; -- noch


Former-commit-id: fff1337578
2015-11-10 19:52:51 +04:00
norayr
7607ee8651 sometimes it can crash because of this line. commented for now. fonts
are not necessary anyway.


Former-commit-id: 815795588b
2015-10-12 20:31:28 +04:00
norayr
df223b96a4 support for SYSTEM.ADR("x") added, i. e. for chars. sync with jtempl's
version; -- noch


Former-commit-id: 8887c4edb0
2015-10-09 13:36:54 +04:00
norayr
11acf6faca check for IMPORT SYSTEM in CheckSysFlag, synced with jtempl's version.
Former-commit-id: fced3875b7
2015-10-09 12:21:53 +04:00
Norayr Chilingarian
85dc46c036 fixed endless recursion in Stars for inherited imported fie
synced with Templ version of Ofront.


Former-commit-id: 5afbe2cfbc
2015-10-08 20:04:02 +04:00
norayr
b00409910c added DumpLog function to Oberon module; -- noch
Former-commit-id: 6433d592bb
2015-09-15 19:16:46 +04:00
Norayr Chilingarian
e9f1a2710a voc07R - revised oberon compiler's compatFiles module fixed to comply
with new Unix.Mod, which was previously fixed to comply with x86_64
libc types.


Former-commit-id: 8b66c787da
2015-07-19 17:04:16 +04:00
norayr
ed83cf0074 updated faq about fedora issues; -- noch
Former-commit-id: 85c75c41ac
2015-07-18 19:09:43 +04:00
norayr
2d94e27d49 added OptionChar to Oberon.Mod; -- noch
Former-commit-id: 0d5e6da7dc
2015-07-01 15:56:47 +04:00
norayr
d04bc11849 moved Oberon.Mod to v4_compat directory. -- noch;
Former-commit-id: 2beff88af5
2015-07-01 15:52:22 +04:00
norayr
4d34283a4e fixed bug found by zorko
and described
[here](https://code.google.com/p/ofront/issues/detail?id=6) with a
little modification.


Former-commit-id: 7ff54e56bd
2015-06-16 21:33:41 +04:00
norayr
015617518c small fix; -- noch
Former-commit-id: 643e79f65d
2015-06-03 20:41:55 +04:00
Norayr Chilingarian
7d5cab1590 added events example.
Former-commit-id: 3665c36d27
2015-05-27 02:56:52 +04:00
Norayr Chilingarian
31c5b31dae makefiles fixed
Former-commit-id: fbdf562e2e
2015-05-27 02:03:59 +04:00
norayr
93d8df0e4f freebsd binary update. -- noch
Former-commit-id: 566f40700e
2015-05-20 17:07:31 +00:00
norayr
734ee7b330 unix module fixes for freebsd; -- noch
Former-commit-id: d749f3e8e9
2015-05-20 16:20:39 +00:00
norayr
4174762c96 SetJmp fixed on darwin; -- noch
Former-commit-id: ffe9476fd2
2015-05-20 23:12:28 +08:00
norayr
da7c2ed8b0 added struct stat size check to Unix.Mod, will test it on different
platforms.


Former-commit-id: 15274cbfb0
2015-05-20 18:40:48 +04:00
norayr
9dde57e9cd it seems that jmp_buf has some 4 bytes long field at the end, which is not described in header file. see http://hastebin.com/conujujeyu.pl for reference. i have also checked offsets.
Former-commit-id: 6b4e51db23
2015-05-08 07:09:56 +00:00
norayr
140439d5ab small fix
Former-commit-id: aebc553e5d
2015-05-20 15:43:12 +04:00
norayr
0c9215f5f2 set_jmp structure wrapper fixed; -- noch
Former-commit-id: 8e31893ecb
2015-05-20 15:38:57 +04:00
norayr
5e4ecf9050 JmpBufCheck added to Kernel.Mod as in ofront; -- noch
Former-commit-id: 337f7d754a
2015-05-20 14:20:50 +04:00
662 changed files with 136686 additions and 62292 deletions

40
.gitattributes vendored Normal file
View file

@ -0,0 +1,40 @@
# Cygwin git and github for windows differ in their eol convention: Github for
# windows uses crlf, but cygwin git uses LF.
# Since we want the same enlistment to work both ways, we need to specify and stick
# with end of line convention for all files.
# Therefore we choose LF for all files except windows command scripts.
* text=auto
*.md text eol=lf
*.c text eol=lf
*.h text eol=lf
*.Mod text eol=lf
*.mod text eol=lf
*.Lola text eol=lf
*.lola text eol=lf
*.make text eol=lf
*makefile text eol=lf
*.sh text eol=lf
.git* text eol=lf
*.cmd text eol=crlf
# Symbol files are binaries
*.sym binary
# Other binaries (these are not normally checked in.)
*.o binary
*.obj binary
*stackdump binary
*exe binary
# Provide type information to improve block annotation in git diff output.
*.Mod diff=pascal
*.c diff=cpp
*.h diff=cpp
# Set the language to Oberon
*.Mod linguist-language=Oberon
*.mod linguist-language=Oberon

10
.gitconfig Normal file
View file

@ -0,0 +1,10 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
autocrlf = true
# safecrlf = false
[push]
default = simple

46
.gitignore vendored Normal file
View file

@ -0,0 +1,46 @@
/*.sublime-*
/Configuration.Mod
/Configuration.Make
/build/*
/install/*
/*.exe
/*.obj
/*.[cho]
/*.lib
/*.map
/*.sym
/*.asm
/*.mod
/Errors.Txt
/Errors.txt
/olang
/src/test/**/*.exe
/src/test/**/*.c
/src/test/**/*.h
/src/test/**/*.o
/src/test/**/*.obj
/src/test/**/*.sym
**/*.stackdump
!/src/test/confidence/**/expected
/src/test/confidence/**/input
/src/test/confidence/**/result
/src/test/confidence/**/result-*
/src/test/confidence/**/*[^.]*
/src/test/confidence/**/*.asm
/src/test/confidence/**/*.s
/src/test/confidence/**/*.map
/bootstrap/*/SYSTEM.[ch]
/bootstrap/*/Errors.Txt
/bootstrap/*/WindowsWrapper.h
/.DS_store
**/.DS_store
**/*.dSYM
**/.tmp.*
/*.pdb
/*.ilk
/t/*
/triage/BasicTypeSize.md
/triage/Roadmap.md
triage/system/*
tags
voc

21
COMPILE
View file

@ -1,21 +0,0 @@
currently three bootstrap static binaries provided, for x86_64, x86, and armv6j_hardfp (works on raspberry pi) gnu/linux targets.
0) prerequisites: libc6-dev on debian, glibc-devel, glibc-static on fedora.
1) make with corresponding makefile
if it's rasp pi or other armhf platform then do
# make -f makefile.gcc.armv6j_hardfp
if it's x86 then
# make -f makefile.gcc.x86
and if it's x86_64, then default makefile is for this platform
# make
(theoretically you can also change TARCH in makefile and type make)
2) # sudo make install
this will install voc in /opt/voc-<version> and create /opt/voc symlink to it.
add /opt/voc/bin to your PATH and enjoy, compile, have fun!
-- noch

View file

@ -1,67 +0,0 @@
vishap oberon compiler
======================
How to install
==============
just cd into source directory and type
>make -f makefile.linux.gcc.x86_64
if you are on linux x86_64 system and you want voc to use gcc as backend.
otherwise use corresponding makefile.
then type
>sudo make install
- or see COMPILE file.
How to use
==========
Type voc and it'll show you help.
voc -M will compile your module and link it statically to libVishapOberon.
voc -m will link the module dynamically.
If you have more than one module, and you want them to be compiled into elf filethen:
Let's assume we have module M0 which imports M1;
>voc -l M1.Mod -s M0.Mod -M
Here -l is a global option.
Module M1 will be compiled with -s option, i. e. sym file will be generated.
Module M0 will be compiled and linked statically.
In case you have modules in different directories, like "ui", "logic", "math", then you need to export MODULES environment variable like this:
>export MODULES=".:ui:logic:math"
and after call voc
>voc -s ui0.Mod
Otherwise you can use full path:
>voc -s ui/ui0.Mod
build rpm
=========
if you'd like to build an rpm installer, then
* compress sources as voc-1.0.src.tar.bz2
assuming you in voc directory
> cd ..
> tar -jcvpf voc-1.0.src.tar.bz2 voc
* put them to ~/rpmbuild/SOURCES (on some systems as root to /usr/src/redhat/SOURCES/) or other similar location.
> mkdir -p ~/rpmbuild/SOURCES
> cp voc-1.0.src.tar.bz2 ~/rpmbuild/SOURCES
* cd to voc directory and run
> rpmbuild -ba voc.spec
this should create voc rpm installers.

305
ReadMe.md Normal file
View file

@ -0,0 +1,305 @@
![Build status](https://brownsmeet.com/githubhook/vishaps-status)
# Ѵishap Oberon
[Ѵishap Oberon](https://vishap.oberon.am/) is a free and open source (GPLv3)
implementation of the Oberon-2 language and libraries for use on
conventional operating systems such as Linux, BSD, Android, Mac and Windows.
Vishap's Oberon Compiler (voc) uses a C backend (gcc, clang, tcc or msc) to compile
Oberon programs under Unix, Mac or Windows. Vishap Oberon includes
libraries from the Ulm, oo2c and Ofront Oberon compilers, as well as
default libraries complying with the Oakwood Guidelines for Oberon-2 compilers.
### Contents
&nbsp;&nbsp;&nbsp;&nbsp;[**Installation**](#installation)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**Compiling a 'Hello' application**](#a-hello-application)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**License**](#license)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**Platform support and porting**](#platform-support-and-porting)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**Language support and libraries**](#language-support-and-libraries)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**History**](#history)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**Roadmap**](#roadmap)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**Contributors**](#contributors)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**Origin of the name "Ѵishap Oberon"**](#origin-of-the-name-Ѵishap-oberon)<br>
&nbsp;&nbsp;&nbsp;&nbsp;[**References**](#references)<br>
## Installation
It is easy to install the Oberon compiler and libraries
with the following simple steps:
1. Install pre-requisites such as git, gcc, static C libraries, diff utils.
2. Clone the repository: `git clone https://github.com/vishaps/voc`.
3. Optionally `export CC=clang` or `export CC=tcc`.
4. run `make full`.
5. Optionally install to a system directory such as /opt or /usr/local/share with `make install` (might be with sudo).
6. Set your PATH variable to include the compiler binary.
These are detailed below:
#### 1. Install prerequisites
| Platform | Packages |
| --------- | ------------ |
| Debian/Ubuntu/Mint ... | `apt-get install git` |
| Fedora/RHEL/CentOS ... | `yum install git gcc glibc-static` (`dnf` instead of `yum` on recent Fedoras) |
| FreeBSD/OpenBSD/NetBSD | `pkg install git` |
| OpenSUSE | `zypper install gcc git-core make glibc-devel-static` |
| Cygwin | use setup-x86[_x64] to add packages git, make, diffutils and gcc-core |
| Darwin | type 'git' at the command line and accept the prompt to install it. |
More details, including for MingW and MS C, in [**Installation**](/doc/Installation.md).
#### 2. Clone and build the compiler and libraries
1. `git clone https://github.com/vishaps/voc`
2. `cd voc`
3. `make full`
`make full` will create an installation directory under your local repository at voc/install.
`mmake full` runs `ldconfig` to configure the linker to find libraries in voc/install, but you
need to update your program search PATH yourself (see step 4 below).
#### 3. Optionally install to a system directory
Run `make install` as root to copy the voc/install directory to the appropriate directory
for your OS as follows:
| System | Where `make install` puts the installation |
| ------- | -------------------------------------- |
| Linux | `/opt/voc` |
| BSD | `/usr/local/share/voc` |
| Windows | See [**Windows installation**](/doc/Winstallation.md) |
| Termux | `/data/data/com.termux/files/opt/voc` |
`make install` updates `ldconfg` with the new library locations.
#### 4. Set your PATH environment variable
Since there are so many ways that different systems and users manage their PATHs, we leave
it to you to update your path to include the compiler binary.
Both `make full` and `make install` display instructions on setting the path specific to your
system.
For reference this will be:
| Installation choice | Set path |
| --------- | -------------------------------------- |
| Just `make full` | `export PATH="your-repository-clone/install/bin:$PATH"` |
| `make install` on Linux | `export PATH="/opt/voc/bin:$PATH"` |
| `make install` on BSD | `export PATH="/usr/local/share/voc/bin:$PATH"` |
| `make install` on Windows | See [**Windows installation**](/doc/Winstallation.md) |
| `make install` on Termux | `export PATH="/data/data/com.termux/files/opt/voc/bin:$PATH"` |
Also see [**Installation**](/doc/Installation.md).
The compiler finds the rest of the installation based on the location from which it is loaded.
## A 'Hello' application
Anything appended to Oberon.Log is automatically written to stdout, so the
following conventional Oberon program will display 'Hello.':
```Modula-2
MODULE hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
BEGIN
Texts.OpenWriter(W);
Texts.WriteString(W, "Hello."); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END hello.
```
Alternatively the Oakwood module Out can be used to write directly to stdout:
```Modula-2
MODULE hello;
IMPORT Out;
BEGIN
Out.String("Hello."); Out.Ln
END hello.
```
Compile as follows:
voc hello.mod -m
The -m parameter tells voc that this is a main module, and to generate an
executable binary.
Execute as usual on Linux (`./hello`) or Windows (`hello`).
For more details on compilation, see [**Compiling**](/doc/Compiling.md).
### Viewing the interfaces of included modules.
In order to see the definition of a module's interface, use the "showdef" program.
```
$ showdef Out
DEFINITION Out;
VAR
IsConsole-: BOOLEAN;
PROCEDURE Char(ch: CHAR);
PROCEDURE Flush;
PROCEDURE Int(x: INT64; n: INT64);
PROCEDURE Ln;
PROCEDURE LongReal(x: LONGREAL; n: INT16);
PROCEDURE Open;
PROCEDURE Real(x: REAL; n: INT16);
PROCEDURE String(str: ARRAY OF CHAR);
END Out.
```
## License
Vishap Oberon's frontend and C backend engine is a fork of Josef Templs Ofront, which has been released
under the FreeBSD License. Unlike Ofront, Vishap Oberon does not include the Oberon v4 GUI environment.
The Ulm Oberon Library and the Ooc libraries are distributed under GPL. Proprietry code
using these libraries may not be statically linked.
Voc tools are distributed under GPLv3.
Most of the runtime in libVishapOberon is distributed under GPLv3 with runtime exception.
## Platform support and porting
Vishap Oberon supports 32 and 64 bit little-endian architectures including Intel x86 and x86_64, 32 bit arm and aarch64.
It compiles under gcc, clang, tcc and Microsoft Visual C.
Installation supports GNU/Linux, MAC OSX, BSD and Windows (native and cygwin).
A C program (src/tools/make/configure.c) detects the details of the C compiler
and operating system on which it is running.
The following systems are recognised:
- Linux, including Ubuntu and Centos derivatives.
- The BSDs, including OpenBSD and FreeBSD.
- Cygwin under Windows, MingW under Cygwin, Bash on Ubuntu on Windows.
Additionally a Windows .cmd is provided for building with Microsoft C.
For details, including how to add support for unrecognised systems, see
[**Porting**](/doc/Porting.md).
## Language support and libraries
Vishap Oberon supports the Oberon 2 programming language, including type-bound procedures. SYSTEM.Mod includes additional functionality and some changes for 64 bit support.
#### Integer and set type sizes:
| Type | -O2 option (default) | -OC option |
| --- | --- | --- |
| SHORTINT | 8 bit | 16 bit |
| INTEGER | 16 bit | 32 bit |
| LONGINT | 32 bit | 64 bit |
| SET | 32 bit | 64 bit |
#### Libraries
Included libraries ease porting of code from the major Oberon systems:
- Oberon V4 and S3 compatible library set.
- Ooc (optimizing oberon-2 compiler) library port.
- Ulms Oberon system library port.
- Oakwood standard libraries.
- Some other freely redistributable libraries.
Oakwood libraries are supported for both -O2 and -OC options, whereas the ULM, OOC and ETH system 3 libraries are only available on -O2 (default) compilations.
Vishap Oberon also supports some features of Oberon-07.
See also [**Features**](/doc/Features.md).
## Contributors
Joseph Templ developed ofront as a tool to translate Oberon-2 programs into semantically equivalent
C programs. It was Copyrighted in 1995, and transferred to the Free BSD license in 2012.
From Joseph's github repository:
> Design and implementation of ofront is due to Josef Templ ... ofront has been based in part on Regis Crelier's PhD thesis and Stefan Gehring's diploma thesis, both at ETH Zurich, Institute for Computer Systems.
Norayr Chilingarian forked ofront in 2013, porting extensive libraries from [ULM Oberon](http://www.mathematik.uni-ulm.de/oberon/), [OO2C](https://github.com/Spirit-of-Oberon/oo2c) and ETH Oberon System 3, and adding support for more platforms including 64 bit systems.
David Brown has worked on adding support for more platforms incuding windows using MSC, cygwin or mingw since January 2016. More recently he has generalised basic type support within the compiler to allow e.g. 64 bit LONGINT on 32 bit systems, and 32 bit LONGINT on 64 bit systems.
## Oberon
Oberon is a programming language, an operating system and a graphical
user interface. Originally designed and implemented by by Niklaus Wirth and
Jürg Gutknecht at ETH Zürich in the late 1980s, it demonstrates that the
fundamentals of a modern OS and GUI can be implemented in clean and simple code
orders of magnitude smaller than found in contemporary systems.
The Oberon programming language is an evolution of the Pascal and Modula
languages. While it adds garbage collection, extensible types and (in
Oberon-2) type-bound procedures, it is also simplified following the principals
of Einstein and Antoine de Saint-Exupéry:
> Make it as simple as possible, but not simpler. (Albert Einstein)
> Perfection is finally attained not when there is no longer anything to add, but
> when there is no longer anything to take away. (Antoine de Saint-Exupéry,
> translated by Lewis Galantière.)
## Origin of the name "Ѵishap Oberon"
Vishaps are dragons inhabiting the Armenian Highlands.
We decided to name the project “Vishap” because ties between compilers and dragons have ancient traditions.
Also, Vishaps are known in tales, fiction. [This page](http://blog.fogus.me/2015/04/27/six-works-of-computer-science-fiction/) refers to some technologies as “computer science fiction”. Among them to Oberon. This brings another meaning, Oberon is like aliens, ghosts. And Vishaps.
## References
###### Oberon
- [The History of Modula-2 and Oberon](http://people.inf.ethz.ch/wirth/Articles/Modula-Oberon-June.pdf)
- [The Programming Language Oberon](https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon.Report.pdf)
- [Project Oberon: The Design of an Operating System and Compiler ](https://people.inf.ethz.ch/wirth/ProjectOberon1992.pdf)
- [Oberon - the Overlooked Jewel](http://pascal.hansotten.com/uploads/oberonpi/Oberon%20article.pdf)
###### Oberon 2
- [Differences between Oberon and Oberon-2](https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=89e5bd3cf006bde4821599cdc57a37de5dc84bcd)
- [The Programming Language Oberon-2](http://www.ssw.uni-linz.ac.at/Research/Papers/Oberon2.pdf)
- [Programming in Oberon. Steps beyond Pascal and Modula](https://people.inf.ethz.ch/wirth/ProgInOberonWR.pdf)
- [The Oakwood Guidelines for Oberon-2 Compiler Developers](http://www.math.bas.bg/bantchev/place/oberon/oakwood-guidelines.pdf)
###### Oberon 07
- [Difference between Oberon-07 and Oberon](https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.pdf)
- [The Programming Language Oberon-07](https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf)
- [Programming in Oberon - a Tutorial](https://www.inf.ethz.ch/personal/wirth/Oberon/PIO.pdf)
###### Links
- [Niklaus Wirth's personal page at ETH Zurich](https://www.inf.ethz.ch/personal/wirth/)
- [Selected articles by Niklaus Wirth](https://people.inf.ethz.ch/wirth/SelectedArticles.pdf)
- [ETH Oberon publications page](https://web.archive.org/web/20191207155011/http://www.ethoberon.ethz.ch/books.html)
- [Joseph Templ's ofront on github](https://github.com/jtempl/ofront)
- [Software Templ OG](http://www.software-templ.com)
## History
See [**History**](/doc/History.md).

227
bootstrap/SYSTEM.c Normal file
View file

@ -0,0 +1,227 @@
/*
* The body prefix file of the voc(jet backend) runtime system, Version 1.0
*
* Copyright (c) Software Templ, 1994, 1995
*
* Module SYSTEM is subject to change any time without prior notification.
* Software Templ disclaims all warranties with regard to module SYSTEM,
* in particular shall Software Templ not be liable for any damage resulting
* from inappropriate use or modification of module SYSTEM.
*
* Version 1.1 jt, 24.11.95 fixes for correct pointer arithmetic on Cray computers
* jt 31.1.2007 ANSI prototypes for malloc and exit in order to avoid cc warnings
*
*/
#include "SYSTEM.h"
#include "stdarg.h"
#include <signal.h>
// Procedure verions of SYSTEM.H versions used when a multiply accessed
// parameter has side effects.
INT64 SYSTEM_DIV(INT64 x, INT64 y)
{
if (x == 0) return 0;
if (x >= 0)
if (y >= 0) {return x/y;}
else {return -((x-y-1)/(-y));}
else
if (y >= 0) {return -((y-x-1)/y);}
else {return (-x)/(-y);}
}
INT64 SYSTEM_MOD(INT64 x, INT64 y)
{
if (x == 0) return 0;
if (x >= 0)
if (y >= 0) {return x % y;}
else {return (y+1) + ((x-1) % (-y));}
else
if (y >= 0) {return (y-1) - ((-x-1) % y);}
else {return -((-x) % (-y));}
}
INT64 SYSTEM_ENTIER(double x)
{
INT64 y;
if (x >= 0)
return (INT64)x;
else {
y = (INT64)x;
if (y <= x) return y; else return y - 1;
}
}
void SYSTEM_INHERIT(ADDRESS *t, ADDRESS *t0)
{
t -= __TPROC0OFF;
t0 -= __TPROC0OFF;
while (*t0 != __EOM) {*t = *t0; t--; t0--;}
}
void SYSTEM_ENUMP(void *adr, ADDRESS n, void (*P)())
{
while (n > 0) {
P((ADDRESS)(*((void**)(adr))));
adr = ((void**)adr) + 1;
n--;
}
}
void SYSTEM_ENUMR(void *adr, ADDRESS *typ, ADDRESS size, ADDRESS n, void (*P)())
{
ADDRESS *t, off;
typ++;
while (n > 0) {
t = typ;
off = *t;
while (off >= 0) {P(*(ADDRESS*)((char*)adr+off)); t++; off = *t;}
adr = ((char*)adr) + size;
n--;
}
}
extern void Heap_Lock();
extern void Heap_Unlock();
SYSTEM_PTR SYSTEM_NEWARR(ADDRESS *typ, ADDRESS elemsz, int elemalgn, int nofdim, int nofdyn, ...)
{
ADDRESS nofelems, size, dataoff, n, nptr, *x, *p, nofptrs, i, *ptab, off;
va_list ap;
va_start(ap, nofdyn);
nofelems = 1;
while (nofdim > 0) {
nofelems = nofelems * va_arg(ap, ADDRESS); nofdim--;
if (nofelems <= 0) __HALT(-20);
}
va_end(ap);
dataoff = nofdyn * sizeof(ADDRESS);
if (elemalgn > sizeof(ADDRESS)) {
n = dataoff % elemalgn;
if (n != 0) dataoff += elemalgn - n;
}
size = dataoff + nofelems * elemsz;
Heap_Lock();
if (typ == NIL) {
/* element typ does not contain pointers */
x = Heap_NEWBLK(size);
}
else if (typ == (ADDRESS*)POINTER__typ) {
/* element type is a pointer */
x = Heap_NEWBLK(size + nofelems * sizeof(ADDRESS));
p = (ADDRESS*)(ADDRESS)x[-1];
p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */
while (n <= nofelems) {*p = n*sizeof(ADDRESS); p++; n++;}
*p = - (nofelems + 1) * sizeof(ADDRESS); /* sentinel */
x[-1] -= nofelems * sizeof(ADDRESS);
}
else {
/* element type is a record that contains pointers */
ptab = typ + 1; nofptrs = 0;
while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */
nptr = nofelems * nofptrs; /* total number of pointers */
x = Heap_NEWBLK(size + nptr * sizeof(ADDRESS));
p = (ADDRESS*)(ADDRESS)x[- 1];
p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
p -= nptr - 1; n = 0; off = dataoff;
while (n < nofelems) {i = 0;
while (i < nofptrs) {*p = off + ptab[i]; p++; i++;}
off += elemsz; n++;
}
*p = - (nptr + 1) * sizeof(ADDRESS); /* sentinel */
x[-1] -= nptr * sizeof(ADDRESS);
}
if (nofdyn != 0) {
/* setup len vector for index checks */
va_start(ap, nofdyn);
p = x;
while (nofdyn > 0) {*p = va_arg(ap, ADDRESS); p++, nofdyn--;}
va_end(ap);
}
Heap_Unlock();
return x;
}
typedef void (*SystemSignalHandler)(INT32); // = Platform_SignalHandler
#ifndef _WIN32
// Unix signal handling
SystemSignalHandler handler[10] = {0}; // Adjust the array size to include signal 11
void segfaultHandler(int signal) {
__HALT(-10);
}
// Revised signal handler to accommodate additional signals like SIGSEGV
void signalHandler(int s) {
if ((s >= 2 && s <= 4) || s == 11) { // Include SIGSEGV (usually signal 11)
if (handler[s-2]) {
handler[s-2](s);
}
}
// Ignore other signals
}
void SystemSetHandler(int s, ADDRESS h) {
if ((s >= 2 && s <= 4) || s == 11) {
int needtosetsystemhandler = handler[s-2] == 0;
handler[s-2] = (SystemSignalHandler)h;
if (needtosetsystemhandler) {
signal(s, signalHandler);
}
}
}
void setupAutomaticSegfaultHandler() {
SystemSetHandler(11, (ADDRESS)segfaultHandler); // Register handler for SIGSEGV
}
#else
// Windows system remains as is since Windows does not use SIGSEGV in the same way
#include "WindowsWrapper.h"
SystemSignalHandler SystemInterruptHandler = 0;
SystemSignalHandler SystemQuitHandler = 0;
BOOL ConsoleCtrlHandlerSet = FALSE;
BOOL WINAPI SystemConsoleCtrlHandler(DWORD ctrlType) {
if ((ctrlType == CTRL_C_EVENT) || (ctrlType == CTRL_BREAK_EVENT)) {
if (SystemInterruptHandler) {
SystemInterruptHandler(2); // SIGINT
return TRUE;
}
} else {
if (SystemQuitHandler) {
SystemQuitHandler(3); // SIGQUIT
return TRUE;
}
}
return FALSE;
}
void EnsureConsoleCtrlHandler() {
if (!ConsoleCtrlHandlerSet) {
SetConsoleCtrlHandler(SystemConsoleCtrlHandler, TRUE);
ConsoleCtrlHandlerSet = TRUE;
}
}
void SystemSetInterruptHandler(ADDRESS h) {
EnsureConsoleCtrlHandler();
SystemInterruptHandler = (SystemSignalHandler)h;
}
void SystemSetQuitHandler(ADDRESS h) {
EnsureConsoleCtrlHandler();
SystemQuitHandler = (SystemSignalHandler)h;
}
#endif

337
bootstrap/SYSTEM.h Normal file
View file

@ -0,0 +1,337 @@
#ifndef SYSTEM__h
#define SYSTEM__h
// 64 bit system detection
#if (__SIZEOF_POINTER__ == 8) || defined (_LP64) || defined(__LP64__) || defined(_WIN64)
#define o__64
#endif
// Declare memcpy in a way compatible with C compilers intrinsic
// built in implementations.
#if defined (o__64)
#if defined(_WIN64)
typedef unsigned long long size_t;
#else
typedef unsigned long size_t;
#endif
#else
#if defined(__OpenBSD__)
typedef unsigned long size_t;
#else
typedef unsigned int size_t;
#endif
#endif
#define _SIZE_T_DECLARED // For FreeBSD
#define _SIZE_T_DEFINED_ // For OpenBSD
void *memcpy(void *dest, const void *source, size_t size);
#if defined _MSC_VER
#define alloca _alloca
#endif
void *alloca(size_t size);
// Declare fixed size versions of basic intger types
#if defined (o__64) && !defined(_WIN64)
// LP64
typedef long INT64;
typedef unsigned long UINT64;
#else
// ILP32 or LLP64
typedef long long INT64;
typedef unsigned long long UINT64;
#endif
typedef int INT32;
typedef unsigned int UINT32;
typedef short int INT16;
typedef unsigned short int UINT16;
typedef signed char INT8;
typedef unsigned char UINT8;
// The compiler uses 'import' and 'export' which translate to 'extern' and
// nothing respectively.
#define import extern
#define export
// Known constants
#define NIL ((void*)0)
#define __MAXEXT 16
#define POINTER__typ ((ADDRESS*)(1)) // not NIL and not a valid type
// Oberon types
typedef INT8 BOOLEAN;
typedef INT8 SYSTEM_BYTE;
typedef UINT8 CHAR;
typedef float REAL;
typedef double LONGREAL;
typedef void* SYSTEM_PTR;
// 'ADDRESS' is a synonym for an integer of pointer size
#if defined (o__64)
#define ADDRESS INT64
#else
#define ADDRESS INT32
#endif
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// OS Memory allocation interfaces are in PlatformXXX.Mod
extern ADDRESS Platform_OSAllocate (ADDRESS size);
extern void Platform_OSFree (ADDRESS addr);
// Assertions and Halts
extern void Modules_Halt(INT32 x);
extern void Modules_AssertFail(INT32 x);
#define __HALT(x) Modules_Halt((INT32)(x))
#define __ASSERT(cond, x) if (!(cond)) Modules_AssertFail((INT32)(x))
// Index checking
static inline INT64 __XF(INT64 i, UINT64 ub) {
if (i < 0 || (UINT64)i >= ub) __HALT(-2);
return i;
}
#define __X(i, ub) (((i) >= 0 && (i) < (ub)) ? (i) : (__HALT(-2),0))
// Range checking, and checked SHORT and CHR functions
static inline INT64 __RF(UINT64 i, UINT64 ub) {if (i >= ub) {__HALT(-8);} return i;}
#define __R(i, ub) (((i)<(ub))?i:(__HALT(-8),0))
#define __SHORT(x, ub) ((int)((UINT64)(x)+(ub)<(ub)+(ub)?(x):(__HALT(-8),0)))
#define __SHORTF(x, ub) ((int)(__RF((x)+(ub),(ub)+(ub))-(ub)))
#define __CHR(x) ((CHAR)__R(x, 256))
#define __CHRF(x) ((CHAR)__RF(x, 256))
// Signal handling in SYSTEM.c
#ifndef _WIN32
extern void SystemSetHandler(int s, ADDRESS h);
#else
extern void SystemSetInterruptHandler(ADDRESS h);
extern void SystemSetQuitHandler (ADDRESS h);
#endif
// String comparison
static inline int __str_cmp(CHAR *x, CHAR *y){
INT64 i = 0;
CHAR ch1, ch2;
do {ch1 = x[i]; ch2 = y[i]; i++;
if (!ch1) return -(int)ch2;
} while (ch1==ch2);
return (int)ch1 - (int)ch2;
}
#define __STRCMP(a,b) __str_cmp((CHAR*)(a), (CHAR*)(b))
// Inline string, record and array copy
#define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \
while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;}
#define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t))
#define __DUP(x, l, t) x=(void*)memcpy(alloca(l*sizeof(t)),x,l*sizeof(t))
#define __DEL(x)
/* SYSTEM ops */
#define __VAL(t, x) (*(t*)&(x))
#define __GET(a, x, t) x=*(t*)(ADDRESS)(a)
#define __PUT(a, x, t) *(t*)(ADDRESS)(a)=x
#define __LSHL(x, n, s) ((INT##s)((UINT##s)(x)<<(n)))
#define __LSHR(x, n, s) ((INT##s)((UINT##s)(x)>>(n)))
#define __LSH(x, n, s) ((n)>=0? __LSHL(x, n, s): __LSHR(x, -(n), s))
#define __ROTL(x, n, s) ((INT##s)((UINT##s)(x)<<(n)|(UINT##s)(x)>>(s-(n))))
#define __ROTR(x, n, s) ((INT##s)((UINT##s)(x)>>(n)|(UINT##s)(x)<<(s-(n))))
#define __ROT(x, n, s) ((n)>=0? __ROTL(x, n, s): __ROTR(x, -(n), s))
#define __ASHL(x, n) ((INT64)(x)<<(n))
#define __ASHR(x, n) ((INT64)(x)>>(n))
#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n)))
static inline INT64 SYSTEM_ASH(INT64 x, INT64 n) {return __ASH(x,n);}
#define __ASHF(x, n) SYSTEM_ASH((INT64)(x), (INT64)(n))
#define __MOVE(s, d, n) memcpy((char*)(ADDRESS)(d),(char*)(ADDRESS)(s),n)
extern INT64 SYSTEM_DIV(INT64 x, INT64 y);
#define __DIVF(x, y) SYSTEM_DIV(x, y)
#define __DIV(x, y) (((x)>0 && (y)>0) ? (x)/(y) : __DIVF(x, y))
extern INT64 SYSTEM_MOD(INT64 x, INT64 y);
#define __MODF(x, y) SYSTEM_MOD(x, y)
#define __MOD(x, y) (((x)>0 && (y)>0) ? (x)%(y) : __MODF(x, y))
extern INT64 SYSTEM_ENTIER (double x);
#define __ENTIER(x) SYSTEM_ENTIER(x)
#define __ABS(x) (((x)<0)?-(x):(x))
static inline INT32 SYSTEM_ABS64(INT64 i) {return i >= 0 ? i : -i;}
static inline INT64 SYSTEM_ABS32(INT32 i) {return i >= 0 ? i : -i;}
#define __ABSF(x) ((sizeof(x) <= 4) ? SYSTEM_ABS32(x) : SYSTEM_ABS64(x))
static inline double SYSTEM_ABSD(double i) {return i >= 0.0 ? i : -i;}
#define __ABSFD(x) SYSTEM_ABSD(x)
#define __CAP(ch) ((CHAR)((ch)&0x5f))
#define __ODD(x) ((x)&1)
#define __IN(x, s, size) (((unsigned int)(x))<size && ((((UINT##size)(s))>>(x))&1))
// todo tested versions of SETOF and SETRNG: check that x, l and h fit size
#define __SETOF(x, size) ((UINT##size)1<<(x))
#define __SETRNG(l, h, size) ((~(UINT##size)0<<(l))&~(UINT##size)0>>(size-1-(h)))
#define __MASK(x, m) ((x)&~(m))
#define __BIT(x, n) (*(UINT64*)(x)>>(n)&1)
// Runtime checks
#define __RETCHK __retchk: __HALT(-3); return 0;
#define __CASECHK __HALT(-4)
#define __WITHCHK __HALT(-7)
#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(ADDRESS)typ##__typ)
#define __TYPEOF(p) (*(((ADDRESS**)(p))-1))
#define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level)
#define __GUARDP(p, typ, level) ((typ*)(__ISP(p,typ,level)?p:(__HALT(-5),p)))
#define __GUARDR(r, typ, level) (*((typ*)(__IS(r##__typ,typ,level)?r:(__HALT(-5),r))))
#define __GUARDA(p, typ, level) ((struct typ*)(__IS(__TYPEOF(p),typ,level)?p:(__HALT(-5),p)))
#define __GUARDEQR(p, dyntyp, typ) if(dyntyp!=typ##__typ) __HALT(-6);*(p)
#define __GUARDEQP(p, typ) if(__TYPEOF(p)!=typ##__typ)__HALT(-6);*((typ*)p)
// Module entry/registration/exit
extern void Heap_REGCMD();
extern SYSTEM_PTR Heap_REGMOD();
extern void Heap_REGTYP();
extern void Heap_INCREF();
#define __DEFMOD static void *m; if (m!=0) {return m;}
#define __REGCMD(name, cmd) Heap_REGCMD(m, (CHAR*)name, cmd)
#define __REGMOD(name, enum) if (m==0) {m = Heap_REGMOD((CHAR*)name,enum);}
#define __ENDMOD return m
#define __MODULE_IMPORT(name) Heap_INCREF(name##__init())
// Main module initialisation, registration and finalisation
extern void Modules_Init(INT32 argc, ADDRESS argv);
extern void Heap_FINALL();
extern void setupAutomaticSegfaultHandler();
#ifndef _WIN32
#define __INIT(argc, argv) static void *m; setupAutomaticSegfaultHandler(); Modules_Init(argc, (ADDRESS)&argv);
#else
#define __INIT(argc, argv) static void *m; Modules_Init(argc, (ADDRESS)&argv);
#endif
#define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum)
#define __FINI Heap_FINALL(); return 0
// Memory allocation
extern SYSTEM_PTR Heap_NEWBLK (ADDRESS size);
extern SYSTEM_PTR Heap_NEWREC (ADDRESS tag);
extern SYSTEM_PTR SYSTEM_NEWARR(ADDRESS*, ADDRESS, int, int, int, ...);
#define __SYSNEW(p, len) p = Heap_NEWBLK((ADDRESS)(len))
#define __NEW(p, t) p = Heap_NEWREC((ADDRESS)t##__typ)
#define __NEWARR SYSTEM_NEWARR
/* Type handling */
extern void SYSTEM_INHERIT(ADDRESS *t, ADDRESS *t0);
extern void SYSTEM_ENUMP (void *adr, ADDRESS n, void (*P)());
extern void SYSTEM_ENUMR (void *adr, ADDRESS *typ, ADDRESS size, ADDRESS n, void (*P)());
#define __TDESC(t, m, n) \
static struct t##__desc { \
ADDRESS tproc[m]; /* Proc for each ptr field */ \
ADDRESS tag; \
ADDRESS next; /* Module table type list points here */ \
ADDRESS level; \
ADDRESS module; \
char name[24]; \
ADDRESS basep[__MAXEXT]; /* List of bases this extends */ \
ADDRESS reserved; \
ADDRESS blksz; /* xxx_typ points here */ \
ADDRESS ptr[n+1]; /* Offsets of ptrs up to -ve sentinel */ \
} t##__desc
#define __BASEOFF (__MAXEXT+1) // blksz as index to base.
#define __TPROC0OFF (__BASEOFF+24/sizeof(ADDRESS)+5) // blksz as index to tproc IFF m=1.
#define __EOM 1
#define __TDFLDS(name, size) {__EOM}, 1, 0, 0, 0, name, {0}, 0, size
#define __ENUMP(adr, n, P) SYSTEM_ENUMP(adr, (ADDRESS)(n), P)
#define __ENUMR(adr, typ, size, n, P) SYSTEM_ENUMR(adr, typ, (ADDRESS)(size), (ADDRESS)(n), P)
#define __INITYP(t, t0, level) \
t##__typ = (ADDRESS*)&t##__desc.blksz; \
memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(ADDRESS)); \
t##__desc.basep[level] = (ADDRESS)t##__typ; \
t##__desc.module = (ADDRESS)m; \
if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \
t##__desc.blksz = (t##__desc.blksz+5*sizeof(ADDRESS)-1)/(4*sizeof(ADDRESS))*(4*sizeof(ADDRESS)); \
Heap_REGTYP(m, (ADDRESS)&t##__desc.next); \
SYSTEM_INHERIT(t##__typ, t0##__typ)
// Oberon-2 type bound procedures support
#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(ADDRESS)proc
#define __SEND(typ, num, funtyp, parlist) ((funtyp)((ADDRESS)*(typ-(__TPROC0OFF+num))))parlist
#endif

View file

@ -0,0 +1,10 @@
// WindowsWrapper.h
//
// Includes Windows.h while avoiding conflicts with Oberon types.
#define BOOLEAN _BOOLEAN
#define CHAR _CHAR
#include <windows.h>
#undef BOOLEAN
#undef CHAR

View file

@ -0,0 +1,213 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Configuration.h"
#include "Heap.h"
#include "OPB.h"
#include "OPC.h"
#include "OPM.h"
#include "OPP.h"
#include "OPT.h"
#include "OPV.h"
#include "Platform.h"
#include "Strings.h"
#include "VT100.h"
#include "extTools.h"
static void Compiler_FindLocalObjectFiles (CHAR *objectnames, ADDRESS objectnames__len);
export void Compiler_Module (BOOLEAN *done);
static void Compiler_PropagateElementaryTypeSizes (void);
export void Compiler_Translate (void);
static void Compiler_Trap (INT32 sig);
void Compiler_Module (BOOLEAN *done)
{
BOOLEAN ext, new;
OPT_Node p = NIL;
OPP_Module(&p, OPM_Options);
if (OPM_noerr) {
OPV_Init();
OPT_InitRecno();
OPV_AdrAndSize(OPT_topScope);
OPT_Export(&ext, &new);
if (OPM_noerr) {
OPM_OpenFiles((void*)OPT_SelfName, 256);
OPM_DeleteObj((void*)OPT_SelfName, 256);
OPC_Init();
OPV_Module(p);
if (OPM_noerr) {
if ((__IN(10, OPM_Options, 32) && __STRCMP(OPM_modName, "SYSTEM") != 0)) {
OPM_DeleteSym((void*)OPT_SelfName, 256);
OPM_LogVT100((CHAR*)"32m", 4);
OPM_LogWStr((CHAR*)" Main program.", 16);
OPM_LogVT100((CHAR*)"0m", 3);
} else {
if (new) {
OPM_LogVT100((CHAR*)"32m", 4);
OPM_LogWStr((CHAR*)" New symbol file.", 19);
OPM_LogVT100((CHAR*)"0m", 3);
OPM_RegisterNewSym();
} else if (ext) {
OPM_LogWStr((CHAR*)" Extended symbol file.", 24);
OPM_RegisterNewSym();
}
}
} else {
OPM_DeleteSym((void*)OPT_SelfName, 256);
}
}
}
OPM_CloseFiles();
OPT_Close();
OPM_LogWLn();
*done = OPM_noerr;
}
static void Compiler_PropagateElementaryTypeSizes (void)
{
OPT_Struct adrinttyp = NIL;
OPT_sysptrtyp->size = OPM_AddressSize;
OPT_sysptrtyp->idfp = OPT_sysptrtyp->form;
OPM_FPrint(&OPT_sysptrtyp->idfp, OPT_sysptrtyp->size);
OPT_adrtyp->size = OPM_AddressSize;
OPT_adrtyp->idfp = OPT_adrtyp->form;
OPM_FPrint(&OPT_adrtyp->idfp, OPT_adrtyp->size);
adrinttyp = OPT_IntType(OPM_AddressSize);
OPT_adrtyp->strobj = adrinttyp->strobj;
OPT_sinttyp = OPT_IntType(OPM_ShortintSize);
OPT_inttyp = OPT_IntType(OPM_IntegerSize);
OPT_linttyp = OPT_IntType(OPM_LongintSize);
OPT_sintobj->typ = OPT_sinttyp;
OPT_intobj->typ = OPT_inttyp;
OPT_lintobj->typ = OPT_linttyp;
switch (OPM_SetSize) {
case 4:
OPT_settyp = OPT_set32typ;
break;
default:
OPT_settyp = OPT_set64typ;
break;
}
OPT_setobj->typ = OPT_settyp;
if (__STRCMP(OPM_Model, "C") == 0) {
OPT_cpbytetyp->strobj->name[4] = 0x00;
} else {
OPT_cpbytetyp->strobj->name[4] = '@';
}
}
static void Compiler_FindLocalObjectFiles (CHAR *objectnames, ADDRESS objectnames__len)
{
OPT_Link l = NIL;
CHAR fn[64];
Platform_FileIdentity id;
objectnames[0] = 0x00;
l = OPT_Links;
while (l != NIL) {
__COPY(l->name, fn, 64);
Strings_Append((CHAR*)".sym", 5, (void*)fn, 64);
if (Platform_IdentifyByName(fn, 64, &id, Platform_FileIdentity__typ) == 0) {
__COPY(l->name, fn, 64);
Strings_Append((CHAR*)".o", 3, (void*)fn, 64);
if (Platform_IdentifyByName(fn, 64, &id, Platform_FileIdentity__typ) == 0) {
Strings_Append((CHAR*)" ", 2, (void*)objectnames, objectnames__len);
Strings_Append(fn, 64, (void*)objectnames, objectnames__len);
} else {
OPM_LogVT100((CHAR*)"91m", 4);
OPM_LogWStr((CHAR*)"Link warning: a local symbol file is present for module ", 57);
OPM_LogWStr(l->name, 256);
OPM_LogWStr((CHAR*)", but local object file '", 26);
OPM_LogWStr(fn, 64);
OPM_LogWStr((CHAR*)"' is missing.", 14);
OPM_LogVT100((CHAR*)"0m", 3);
OPM_LogWLn();
}
}
l = l->next;
}
}
void Compiler_Translate (void)
{
BOOLEAN done;
CHAR linkfiles[2048];
if (OPM_OpenPar()) {
for (;;) {
OPM_Init(&done);
if (!done) {
return;
}
OPM_InitOptions();
Compiler_PropagateElementaryTypeSizes();
Heap_GC(0);
Compiler_Module(&done);
if (!done) {
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Module compilation failed.", 27);
OPM_LogWLn();
Platform_Exit(1);
}
if (!__IN(13, OPM_Options, 32)) {
if (__IN(14, OPM_Options, 32)) {
extTools_Assemble(OPM_modName, 32);
} else {
if (!__IN(10, OPM_Options, 32)) {
extTools_Assemble(OPM_modName, 32);
} else {
Compiler_FindLocalObjectFiles((void*)linkfiles, 2048);
extTools_LinkMain((void*)OPM_modName, 32, __IN(15, OPM_Options, 32), linkfiles, 2048);
}
}
}
}
}
}
static void Compiler_Trap (INT32 sig)
{
Heap_FINALL();
if (sig == 3) {
Platform_Exit(0);
} else {
if (sig == 4) {
OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36);
OPM_LogWLn();
}
Platform_Exit(2);
}
}
export int main(int argc, char **argv)
{
__INIT(argc, argv);
__MODULE_IMPORT(Configuration);
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(OPB);
__MODULE_IMPORT(OPC);
__MODULE_IMPORT(OPM);
__MODULE_IMPORT(OPP);
__MODULE_IMPORT(OPT);
__MODULE_IMPORT(OPV);
__MODULE_IMPORT(Platform);
__MODULE_IMPORT(Strings);
__MODULE_IMPORT(VT100);
__MODULE_IMPORT(extTools);
__REGMAIN("Compiler", 0);
__REGCMD("Translate", Compiler_Translate);
/* BEGIN */
Platform_SetInterruptHandler(Compiler_Trap);
Platform_SetQuitHandler(Compiler_Trap);
Platform_SetBadInstructionHandler(Compiler_Trap);
Compiler_Translate();
__FINI;
}

View file

@ -0,0 +1,24 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
export CHAR Configuration_versionLong[76];
export void *Configuration__init(void)
{
__DEFMOD;
__REGMOD("Configuration", 0);
/* BEGIN */
__MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76);
__ENDMOD;
}

View file

@ -0,0 +1,15 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Configuration__h
#define Configuration__h
#include "SYSTEM.h"
import CHAR Configuration_versionLong[76];
import void *Configuration__init(void);
#endif // Configuration

1097
bootstrap/unix-44/Files.c Normal file

File diff suppressed because it is too large Load diff

70
bootstrap/unix-44/Files.h Normal file
View file

@ -0,0 +1,70 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Files__h
#define Files__h
#include "SYSTEM.h"
typedef
struct Files_FileDesc *Files_File;
typedef
struct Files_FileDesc {
INT32 _prvt0;
char _prvt1[560];
} Files_FileDesc;
typedef
struct Files_Rider {
INT32 res;
BOOLEAN eof;
char _prvt0[15];
} Files_Rider;
import INT16 Files_MaxPathLength, Files_MaxNameLength;
import ADDRESS *Files_FileDesc__typ;
import ADDRESS *Files_Rider__typ;
import Files_File Files_Base (Files_Rider *r, ADDRESS *r__typ);
import void Files_ChangeDirectory (CHAR *path, ADDRESS path__len, INT16 *res);
import void Files_Close (Files_File f);
import void Files_Delete (CHAR *name, ADDRESS name__len, INT16 *res);
import void Files_GetDate (Files_File f, INT32 *t, INT32 *d);
import void Files_GetName (Files_File f, CHAR *name, ADDRESS name__len);
import INT32 Files_Length (Files_File f);
import Files_File Files_New (CHAR *name, ADDRESS name__len);
import Files_File Files_Old (CHAR *name, ADDRESS name__len);
import INT32 Files_Pos (Files_Rider *r, ADDRESS *r__typ);
import void Files_Purge (Files_File f);
import void Files_Read (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x);
import void Files_ReadBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN *x);
import void Files_ReadByte (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x);
import void Files_ReadBytes (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x, ADDRESS x__len, INT32 n);
import void Files_ReadInt (Files_Rider *R, ADDRESS *R__typ, INT16 *x);
import void Files_ReadLInt (Files_Rider *R, ADDRESS *R__typ, INT32 *x);
import void Files_ReadLReal (Files_Rider *R, ADDRESS *R__typ, LONGREAL *x);
import void Files_ReadLine (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__len);
import void Files_ReadReal (Files_Rider *R, ADDRESS *R__typ, REAL *x);
import void Files_ReadSet (Files_Rider *R, ADDRESS *R__typ, UINT32 *x);
import void Files_ReadString (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void Files_Register (Files_File f);
import void Files_Rename (CHAR *old, ADDRESS old__len, CHAR *new, ADDRESS new__len, INT16 *res);
import void Files_Set (Files_Rider *r, ADDRESS *r__typ, Files_File f, INT32 pos);
import void Files_SetSearchPath (CHAR *path, ADDRESS path__len);
import void Files_Write (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE x);
import void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x);
import void Files_WriteBytes (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x, ADDRESS x__len, INT32 n);
import void Files_WriteInt (Files_Rider *R, ADDRESS *R__typ, INT16 x);
import void Files_WriteLInt (Files_Rider *R, ADDRESS *R__typ, INT32 x);
import void Files_WriteLReal (Files_Rider *R, ADDRESS *R__typ, LONGREAL x);
import void Files_WriteNum (Files_Rider *R, ADDRESS *R__typ, INT64 x);
import void Files_WriteReal (Files_Rider *R, ADDRESS *R__typ, REAL x);
import void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x);
import void Files_WriteString (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void *Files__init(void);
#endif // Files

799
bootstrap/unix-44/Heap.c Normal file
View file

@ -0,0 +1,799 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
struct Heap__1 {
CHAR ch;
SYSTEM_PTR p;
};
typedef
struct Heap_CmdDesc *Heap_Cmd;
typedef
CHAR Heap_CmdName[24];
typedef
void (*Heap_Command)(void);
typedef
struct Heap_CmdDesc {
Heap_Cmd next;
Heap_CmdName name;
Heap_Command cmd;
} Heap_CmdDesc;
typedef
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
typedef
struct Heap_FinDesc *Heap_FinNode;
typedef
void (*Heap_Finalizer)(SYSTEM_PTR);
typedef
struct Heap_FinDesc {
Heap_FinNode next;
INT32 obj;
BOOLEAN marked;
Heap_Finalizer finalize;
} Heap_FinDesc;
typedef
struct Heap_ModuleDesc *Heap_Module;
typedef
CHAR Heap_ModuleName[20];
typedef
struct Heap_ModuleDesc {
Heap_Module next;
Heap_ModuleName name;
INT32 refcnt;
Heap_Cmd cmds;
INT32 types;
Heap_EnumProc enumPtrs;
INT32 reserved1, reserved2;
} Heap_ModuleDesc;
export SYSTEM_PTR Heap_modules;
static INT32 Heap_freeList[10];
static INT32 Heap_bigBlocks;
export INT32 Heap_allocated;
static BOOLEAN Heap_firstTry;
static INT16 Heap_ldUnit;
export INT32 Heap_heap;
static INT32 Heap_heapMin, Heap_heapMax;
export INT32 Heap_heapsize, Heap_heapMinExpand;
static Heap_FinNode Heap_fin;
static INT16 Heap_lockdepth;
static BOOLEAN Heap_interrupted;
export INT16 Heap_FileCount;
export ADDRESS *Heap_ModuleDesc__typ;
export ADDRESS *Heap_CmdDesc__typ;
export ADDRESS *Heap_FinDesc__typ;
export ADDRESS *Heap__1__typ;
static void Heap_CheckFin (void);
static void Heap_ExtendHeap (INT32 blksz);
export void Heap_FINALL (void);
static void Heap_Finalize (void);
export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len);
export void Heap_GC (BOOLEAN markStack);
static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len);
export void Heap_INCREF (Heap_Module m);
export void Heap_InitHeap (void);
export void Heap_Lock (void);
static void Heap_Mark (INT32 q);
static void Heap_MarkCandidates (INT32 n, INT32 *cand, ADDRESS cand__len);
static void Heap_MarkP (SYSTEM_PTR p);
static void Heap_MarkStack (INT32 n, INT32 *cand, ADDRESS cand__len);
export SYSTEM_PTR Heap_NEWBLK (INT32 size);
export SYSTEM_PTR Heap_NEWREC (INT32 tag);
static INT32 Heap_NewChunk (INT32 blksz);
export void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
export void Heap_REGTYP (Heap_Module m, INT32 typ);
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
static void Heap_Scan (void);
static void Heap_Sift (INT32 l, INT32 r, INT32 *a, ADDRESS a__len);
export void Heap_Unlock (void);
extern void *Heap__init();
extern ADDRESS Modules_MainStackFrame;
extern ADDRESS Platform_OSAllocate(ADDRESS size);
#define Heap_HeapModuleInit() Heap__init()
#define Heap_ModulesHalt(code) Modules_Halt(code)
#define Heap_ModulesMainStackFrame() Modules_MainStackFrame
#define Heap_OSAllocate(size) Platform_OSAllocate(size)
#define Heap_uLE(x, y) ((size_t)x <= (size_t)y)
#define Heap_uLT(x, y) ((size_t)x < (size_t)y)
void Heap_Lock (void)
{
Heap_lockdepth += 1;
}
void Heap_Unlock (void)
{
Heap_lockdepth -= 1;
if ((Heap_interrupted && Heap_lockdepth == 0)) {
Heap_ModulesHalt(-9);
}
}
SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs)
{
Heap_Module m;
if (__STRCMP(name, "Heap") == 0) {
__SYSNEW(m, 48);
} else {
__NEW(m, Heap_ModuleDesc);
}
m->types = 0;
m->cmds = NIL;
__COPY(name, m->name, 20);
m->refcnt = 0;
m->enumPtrs = enumPtrs;
m->next = (Heap_Module)(ADDRESS)Heap_modules;
Heap_modules = (SYSTEM_PTR)m;
return (void*)m;
}
INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len)
{
Heap_Module m, p;
__DUP(name, name__len, CHAR);
m = (Heap_Module)(ADDRESS)Heap_modules;
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
p = m;
m = m->next;
}
if ((m != NIL && m->refcnt == 0)) {
if (m == (Heap_Module)(ADDRESS)Heap_modules) {
Heap_modules = (SYSTEM_PTR)m->next;
} else {
p->next = m->next;
}
__DEL(name);
return 0;
} else {
if (m == NIL) {
__DEL(name);
return -1;
} else {
__DEL(name);
return m->refcnt;
}
}
__RETCHK;
}
void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
{
Heap_Cmd c;
if (__STRCMP(m->name, "Heap") == 0) {
__SYSNEW(c, 32);
} else {
__NEW(c, Heap_CmdDesc);
}
__COPY(name, c->name, 24);
c->cmd = cmd;
c->next = m->cmds;
m->cmds = c;
}
void Heap_REGTYP (Heap_Module m, INT32 typ)
{
__PUT(typ, m->types, INT32);
m->types = typ;
}
void Heap_INCREF (Heap_Module m)
{
m->refcnt += 1;
}
static INT32 Heap_NewChunk (INT32 blksz)
{
INT32 chnk, blk, end;
chnk = Heap_OSAllocate(blksz + 12);
if (chnk != 0) {
blk = chnk + 12;
end = blk + blksz;
__PUT(chnk + 4, end, INT32);
__PUT(blk, blk + 4, INT32);
__PUT(blk + 4, blksz, INT32);
__PUT(blk + 8, -4, INT32);
__PUT(blk + 12, Heap_bigBlocks, INT32);
Heap_bigBlocks = blk;
Heap_heapsize += blksz;
if (Heap_uLT(blk + 4, Heap_heapMin)) {
Heap_heapMin = blk + 4;
}
if (Heap_uLT(Heap_heapMax, end)) {
Heap_heapMax = end;
}
}
return chnk;
}
static void Heap_ExtendHeap (INT32 blksz)
{
INT32 size, chnk, j, next;
if (Heap_uLT(Heap_heapMinExpand, blksz)) {
size = blksz;
} else {
size = Heap_heapMinExpand;
}
chnk = Heap_NewChunk(size);
if (chnk != 0) {
if (Heap_uLT(chnk, Heap_heap)) {
__PUT(chnk, Heap_heap, INT32);
Heap_heap = chnk;
} else {
j = Heap_heap;
__GET(j, next, INT32);
while ((next != 0 && Heap_uLT(next, chnk))) {
j = next;
__GET(j, next, INT32);
}
__PUT(chnk, next, INT32);
__PUT(j, chnk, INT32);
}
} else if (!Heap_firstTry) {
Heap_heapMinExpand = 16;
}
}
SYSTEM_PTR Heap_NEWREC (INT32 tag)
{
INT32 i, i0, di, blksz, restsize, t, adr, end, next, prev;
SYSTEM_PTR new;
Heap_Lock();
__GET(tag, blksz, INT32);
i0 = __LSH(blksz, -Heap_ldUnit, 32);
i = i0;
if (i < 9) {
adr = Heap_freeList[i];
while (adr == 0) {
i += 1;
adr = Heap_freeList[i];
}
}
if (i < 9) {
__GET(adr + 12, next, INT32);
Heap_freeList[i] = next;
if (i != i0) {
di = i - i0;
restsize = __ASHL(di, 4);
end = adr + restsize;
__PUT(end + 4, blksz, INT32);
__PUT(end + 8, -4, INT32);
__PUT(end, end + 4, INT32);
__PUT(adr + 4, restsize, INT32);
__PUT(adr + 12, Heap_freeList[di], INT32);
Heap_freeList[di] = adr;
adr += restsize;
}
} else {
adr = Heap_bigBlocks;
prev = 0;
for (;;) {
if (adr == 0) {
if (Heap_firstTry) {
Heap_GC(1);
blksz += 16;
t = __LSH(Heap_allocated + blksz, -(2 + Heap_ldUnit), 32) * 80;
if (Heap_uLT(Heap_heapsize, t)) {
Heap_ExtendHeap(t - Heap_heapsize);
}
Heap_firstTry = 0;
new = Heap_NEWREC(tag);
if (new == NIL) {
Heap_ExtendHeap(blksz);
new = Heap_NEWREC(tag);
}
Heap_firstTry = 1;
Heap_Unlock();
return new;
} else {
Heap_Unlock();
return NIL;
}
}
__GET(adr + 4, t, INT32);
if (Heap_uLE(blksz, t)) {
break;
}
prev = adr;
__GET(adr + 12, adr, INT32);
}
restsize = t - blksz;
end = adr + restsize;
__PUT(end + 4, blksz, INT32);
__PUT(end + 8, -4, INT32);
__PUT(end, end + 4, INT32);
if (Heap_uLT(144, restsize)) {
__PUT(adr + 4, restsize, INT32);
} else {
__GET(adr + 12, next, INT32);
if (prev == 0) {
Heap_bigBlocks = next;
} else {
__PUT(prev + 12, next, INT32);
}
if (restsize != 0) {
di = __ASHR(restsize, 4);
__PUT(adr + 4, restsize, INT32);
__PUT(adr + 12, Heap_freeList[di], INT32);
Heap_freeList[di] = adr;
}
}
adr += restsize;
}
i = adr + 16;
end = adr + blksz;
while (Heap_uLT(i, end)) {
__PUT(i, 0, INT32);
__PUT(i + 4, 0, INT32);
__PUT(i + 8, 0, INT32);
__PUT(i + 12, 0, INT32);
i += 16;
}
__PUT(adr + 12, 0, INT32);
__PUT(adr, tag, INT32);
__PUT(adr + 4, 0, INT32);
__PUT(adr + 8, 0, INT32);
Heap_allocated += blksz;
Heap_Unlock();
return (SYSTEM_PTR)(ADDRESS)(adr + 4);
}
SYSTEM_PTR Heap_NEWBLK (INT32 size)
{
INT32 blksz, tag;
SYSTEM_PTR new;
Heap_Lock();
blksz = __ASHL(__ASHR(size + 31, 4), 4);
new = Heap_NEWREC((ADDRESS)&blksz);
tag = ((INT32)(ADDRESS)new + blksz) - 12;
__PUT(tag - 4, 0, INT32);
__PUT(tag, blksz, INT32);
__PUT(tag + 4, -4, INT32);
__PUT((INT32)(ADDRESS)new - 4, tag, INT32);
Heap_Unlock();
return new;
}
static void Heap_Mark (INT32 q)
{
INT32 p, tag, offset, fld, n, tagbits;
if (q != 0) {
__GET(q - 4, tagbits, INT32);
if (!__ODD(tagbits)) {
__PUT(q - 4, tagbits + 1, INT32);
p = 0;
tag = tagbits + 4;
for (;;) {
__GET(tag, offset, INT32);
if (offset < 0) {
__PUT(q - 4, (tag + offset) + 1, INT32);
if (p == 0) {
break;
}
n = q;
q = p;
__GET(q - 4, tag, INT32);
tag -= 1;
__GET(tag, offset, INT32);
fld = q + offset;
__GET(fld, p, INT32);
__PUT(fld, (SYSTEM_PTR)(ADDRESS)n, SYSTEM_PTR);
} else {
fld = q + offset;
__GET(fld, n, INT32);
if (n != 0) {
__GET(n - 4, tagbits, INT32);
if (!__ODD(tagbits)) {
__PUT(n - 4, tagbits + 1, INT32);
__PUT(q - 4, tag + 1, INT32);
__PUT(fld, (SYSTEM_PTR)(ADDRESS)p, SYSTEM_PTR);
p = q;
q = n;
tag = tagbits;
}
}
}
tag += 4;
}
}
}
}
static void Heap_MarkP (SYSTEM_PTR p)
{
Heap_Mark((INT32)(ADDRESS)p);
}
static void Heap_Scan (void)
{
INT32 chnk, adr, end, start, tag, i, size, freesize;
Heap_bigBlocks = 0;
i = 1;
while (i < 9) {
Heap_freeList[i] = 0;
i += 1;
}
freesize = 0;
Heap_allocated = 0;
chnk = Heap_heap;
while (chnk != 0) {
adr = chnk + 12;
__GET(chnk + 4, end, INT32);
while (Heap_uLT(adr, end)) {
__GET(adr, tag, INT32);
if (__ODD(tag)) {
if (freesize != 0) {
start = adr - freesize;
__PUT(start, start + 4, INT32);
__PUT(start + 4, freesize, INT32);
__PUT(start + 8, -4, INT32);
i = __LSH(freesize, -Heap_ldUnit, 32);
freesize = 0;
if (Heap_uLT(i, 9)) {
__PUT(start + 12, Heap_freeList[i], INT32);
Heap_freeList[i] = start;
} else {
__PUT(start + 12, Heap_bigBlocks, INT32);
Heap_bigBlocks = start;
}
}
tag -= 1;
__PUT(adr, tag, INT32);
__GET(tag, size, INT32);
Heap_allocated += size;
adr += size;
} else {
__GET(tag, size, INT32);
freesize += size;
adr += size;
}
}
if (freesize != 0) {
start = adr - freesize;
__PUT(start, start + 4, INT32);
__PUT(start + 4, freesize, INT32);
__PUT(start + 8, -4, INT32);
i = __LSH(freesize, -Heap_ldUnit, 32);
freesize = 0;
if (Heap_uLT(i, 9)) {
__PUT(start + 12, Heap_freeList[i], INT32);
Heap_freeList[i] = start;
} else {
__PUT(start + 12, Heap_bigBlocks, INT32);
Heap_bigBlocks = start;
}
}
__GET(chnk, chnk, INT32);
}
}
static void Heap_Sift (INT32 l, INT32 r, INT32 *a, ADDRESS a__len)
{
INT32 i, j;
INT32 x;
j = l;
x = a[j];
for (;;) {
i = j;
j = __ASHL(j, 1) + 1;
if ((j < r && Heap_uLT(a[j], a[j + 1]))) {
j += 1;
}
if (j > r || Heap_uLE(a[j], x)) {
break;
}
a[i] = a[j];
}
a[i] = x;
}
static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len)
{
INT32 l, r;
INT32 x;
l = __ASHR(n, 1);
r = n - 1;
while (l > 0) {
l -= 1;
Heap_Sift(l, r, (void*)a, a__len);
}
while (r > 0) {
x = a[0];
a[0] = a[r];
a[r] = x;
r -= 1;
Heap_Sift(l, r, (void*)a, a__len);
}
}
static void Heap_MarkCandidates (INT32 n, INT32 *cand, ADDRESS cand__len)
{
INT32 chnk, end, adr, tag, next, i, ptr, size;
chnk = Heap_heap;
i = 0;
while (chnk != 0) {
__GET(chnk + 4, end, INT32);
adr = chnk + 12;
while (Heap_uLT(adr, end)) {
__GET(adr, tag, INT32);
if (__ODD(tag)) {
__GET(tag - 1, size, INT32);
adr += size;
ptr = adr + 4;
while (Heap_uLT(cand[i], ptr)) {
i += 1;
if (i == n) {
return;
}
}
} else {
__GET(tag, size, INT32);
ptr = adr + 4;
adr += size;
while (Heap_uLT(cand[i], ptr)) {
i += 1;
if (i == n) {
return;
}
}
if (Heap_uLT(cand[i], adr)) {
Heap_Mark(ptr);
}
}
if (Heap_uLE(end, cand[i])) {
adr = end;
}
}
__GET(chnk, chnk, INT32);
}
}
static void Heap_CheckFin (void)
{
Heap_FinNode n;
INT32 tag;
n = Heap_fin;
while (n != NIL) {
__GET(n->obj - 4, tag, INT32);
if (!__ODD(tag)) {
n->marked = 0;
Heap_Mark(n->obj);
} else {
n->marked = 1;
}
n = n->next;
}
}
static void Heap_Finalize (void)
{
Heap_FinNode n, prev;
n = Heap_fin;
prev = NIL;
while (n != NIL) {
if (!n->marked) {
if (n == Heap_fin) {
Heap_fin = Heap_fin->next;
} else {
prev->next = n->next;
}
(*n->finalize)((SYSTEM_PTR)(ADDRESS)n->obj);
if (prev == NIL) {
n = Heap_fin;
} else {
n = n->next;
}
} else {
prev = n;
n = n->next;
}
}
}
void Heap_FINALL (void)
{
Heap_FinNode n;
while (Heap_fin != NIL) {
n = Heap_fin;
Heap_fin = Heap_fin->next;
(*n->finalize)((SYSTEM_PTR)(ADDRESS)n->obj);
}
}
static void Heap_MarkStack (INT32 n, INT32 *cand, ADDRESS cand__len)
{
SYSTEM_PTR frame;
INT32 nofcand;
INT32 inc, sp, p, stack0;
struct Heap__1 align;
if (n > 0) {
Heap_MarkStack(n - 1, cand, cand__len);
if (n > 100) {
return;
}
}
if (n == 0) {
nofcand = 0;
sp = (ADDRESS)&frame;
stack0 = Heap_ModulesMainStackFrame();
inc = (ADDRESS)&align.p - (ADDRESS)&align;
if (Heap_uLT(stack0, sp)) {
inc = -inc;
}
while (sp != stack0) {
__GET(sp, p, INT32);
if ((Heap_uLE(Heap_heapMin, p) && Heap_uLT(p, Heap_heapMax))) {
if (nofcand == cand__len) {
Heap_HeapSort(nofcand, (void*)cand, cand__len);
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
nofcand = 0;
}
cand[nofcand] = p;
nofcand += 1;
}
sp += inc;
}
if (nofcand > 0) {
Heap_HeapSort(nofcand, (void*)cand, cand__len);
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
}
}
}
void Heap_GC (BOOLEAN markStack)
{
Heap_Module m;
INT32 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
INT32 cand[10000];
Heap_Lock();
m = (Heap_Module)(ADDRESS)Heap_modules;
while (m != NIL) {
if (m->enumPtrs != NIL) {
(*m->enumPtrs)(Heap_MarkP);
}
m = m->next;
}
if (markStack) {
i0 = -100;
i1 = -101;
i2 = -102;
i3 = -103;
i4 = -104;
i5 = -105;
i6 = -106;
i7 = -107;
i8 = 1;
i9 = 2;
i10 = 3;
i11 = 4;
i12 = 5;
i13 = 6;
i14 = 7;
i15 = 8;
i16 = 9;
i17 = 10;
i18 = 11;
i19 = 12;
i20 = 13;
i21 = 14;
i22 = 15;
i23 = 16;
for (;;) {
i0 += 1;
i1 += 2;
i2 += 3;
i3 += 4;
i4 += 5;
i5 += 6;
i6 += 7;
i7 += 8;
i8 += 9;
i9 += 10;
i10 += 11;
i11 += 12;
i12 += 13;
i13 += 14;
i14 += 15;
i15 += 16;
i16 += 17;
i17 += 18;
i18 += 19;
i19 += 20;
i20 += 21;
i21 += 22;
i22 += 23;
i23 += 24;
if ((i0 == -99 && i15 == 24)) {
Heap_MarkStack(32, (void*)cand, 10000);
break;
}
}
if (((((((((((((((((((((((i0 + i1) + i2) + i3) + i4) + i5) + i6) + i7) + i8) + i9) + i10) + i11) + i12) + i13) + i14) + i15) + i16) + i17) + i18) + i19) + i20) + i21) + i22) + i23 > 10000) {
return;
}
}
Heap_CheckFin();
Heap_Scan();
Heap_Finalize();
Heap_Unlock();
}
void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
{
Heap_FinNode f;
__NEW(f, Heap_FinDesc);
f->obj = (INT32)(ADDRESS)obj;
f->finalize = finalize;
f->marked = 1;
f->next = Heap_fin;
Heap_fin = f;
}
void Heap_InitHeap (void)
{
Heap_heap = 0;
Heap_heapsize = 0;
Heap_allocated = 0;
Heap_lockdepth = 0;
Heap_heapMin = -1;
Heap_heapMax = 0;
Heap_bigBlocks = 0;
Heap_heapMinExpand = 128000;
Heap_ldUnit = 4;
Heap_heap = Heap_NewChunk(128000);
__PUT(Heap_heap, 0, INT32);
Heap_firstTry = 1;
Heap_freeList[9] = 1;
Heap_FileCount = 0;
Heap_modules = NIL;
Heap_fin = NIL;
Heap_interrupted = 0;
Heap_HeapModuleInit();
}
static void EnumPtrs(void (*P)(void*))
{
P(Heap_modules);
P(Heap_fin);
}
__TDESC(Heap_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}};
__TDESC(Heap_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}};
__TDESC(Heap_FinDesc, 1, 1) = {__TDFLDS("FinDesc", 16), {0, -8}};
__TDESC(Heap__1, 1, 1) = {__TDFLDS("", 8), {4, -8}};
export void *Heap__init(void)
{
__DEFMOD;
__REGMOD("Heap", EnumPtrs);
__REGCMD("FINALL", Heap_FINALL);
__REGCMD("InitHeap", Heap_InitHeap);
__REGCMD("Lock", Heap_Lock);
__REGCMD("Unlock", Heap_Unlock);
__INITYP(Heap_ModuleDesc, Heap_ModuleDesc, 0);
__INITYP(Heap_CmdDesc, Heap_CmdDesc, 0);
__INITYP(Heap_FinDesc, Heap_FinDesc, 0);
__INITYP(Heap__1, Heap__1, 0);
/* BEGIN */
__ENDMOD;
}

73
bootstrap/unix-44/Heap.h Normal file
View file

@ -0,0 +1,73 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */
#ifndef Heap__h
#define Heap__h
#include "SYSTEM.h"
typedef
struct Heap_CmdDesc *Heap_Cmd;
typedef
CHAR Heap_CmdName[24];
typedef
void (*Heap_Command)(void);
typedef
struct Heap_CmdDesc {
Heap_Cmd next;
Heap_CmdName name;
Heap_Command cmd;
} Heap_CmdDesc;
typedef
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
typedef
void (*Heap_Finalizer)(SYSTEM_PTR);
typedef
struct Heap_ModuleDesc *Heap_Module;
typedef
CHAR Heap_ModuleName[20];
typedef
struct Heap_ModuleDesc {
Heap_Module next;
Heap_ModuleName name;
INT32 refcnt;
Heap_Cmd cmds;
INT32 types;
Heap_EnumProc enumPtrs;
char _prvt0[8];
} Heap_ModuleDesc;
import SYSTEM_PTR Heap_modules;
import INT32 Heap_allocated;
import INT32 Heap_heap;
import INT32 Heap_heapsize, Heap_heapMinExpand;
import INT16 Heap_FileCount;
import ADDRESS *Heap_ModuleDesc__typ;
import ADDRESS *Heap_CmdDesc__typ;
import void Heap_FINALL (void);
import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len);
import void Heap_GC (BOOLEAN markStack);
import void Heap_INCREF (Heap_Module m);
import void Heap_InitHeap (void);
import void Heap_Lock (void);
import SYSTEM_PTR Heap_NEWBLK (INT32 size);
import SYSTEM_PTR Heap_NEWREC (INT32 tag);
import void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
import SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
import void Heap_REGTYP (Heap_Module m, INT32 typ);
import void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
import void Heap_Unlock (void);
import void *Heap__init(void);
#endif // Heap

506
bootstrap/unix-44/Modules.c Normal file
View file

@ -0,0 +1,506 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Heap.h"
#include "Platform.h"
export INT16 Modules_res;
export CHAR Modules_resMsg[256];
export Heap_ModuleName Modules_imported, Modules_importing;
export INT32 Modules_MainStackFrame;
export INT16 Modules_ArgCount;
export INT32 Modules_ArgVector;
export CHAR Modules_BinaryDir[1024];
static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len);
export void Modules_AssertFail (INT32 code);
static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len);
static void Modules_DisplayHaltCode (INT32 code);
static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len);
static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len);
export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all);
export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len);
export void Modules_GetIntArg (INT16 n, INT32 *val);
export void Modules_Halt (INT32 code);
export void Modules_Init (INT32 argc, INT32 argvadr);
static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len);
static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len);
static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len);
export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len);
export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len);
static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static void Modules_errch (CHAR c);
static void Modules_errint (INT32 l);
static void Modules_errstring (CHAR *s, ADDRESS s__len);
extern void Heap_InitHeap();
extern void *Modules__init(void);
#define Modules_InitHeap() Heap_InitHeap()
#define Modules_ModulesInit() Modules__init()
#define Modules_modules() (Heap_Module)Heap_modules
void Modules_Init (INT32 argc, INT32 argvadr)
{
Modules_MainStackFrame = argvadr;
Modules_ArgCount = __VAL(INT16, argc);
__GET(argvadr, Modules_ArgVector, INT32);
Modules_InitHeap();
Modules_ModulesInit();
}
typedef
CHAR (*argptr__15)[1024];
void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len)
{
argptr__15 arg = NIL;
if (n < Modules_ArgCount) {
__GET(Modules_ArgVector + __ASHL(n, 2), arg, argptr__15);
__COPY(*arg, val, val__len);
}
}
void Modules_GetIntArg (INT16 n, INT32 *val)
{
CHAR s[64];
INT32 k, d, i;
s[0] = 0x00;
Modules_GetArg(n, (void*)s, 64);
i = 0;
if (s[0] == '-') {
i = 1;
}
k = 0;
d = (INT16)s[__X(i, 64)] - 48;
while ((d >= 0 && d <= 9)) {
k = k * 10 + d;
i += 1;
d = (INT16)s[__X(i, 64)] - 48;
}
if (s[0] == '-') {
k = -k;
i -= 1;
}
if (i > 0) {
*val = k;
}
}
INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len)
{
INT16 i;
CHAR arg[256];
__DUP(s, s__len, CHAR);
i = 0;
Modules_GetArg(i, (void*)arg, 256);
while ((i < Modules_ArgCount && __STRCMP(s, arg) != 0)) {
i += 1;
Modules_GetArg(i, (void*)arg, 256);
}
__DEL(s);
return i;
}
static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len)
{
INT16 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
__DEL(s);
return i;
}
static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
__DUP(s, s__len, CHAR);
i = 0;
j = Modules_CharCount(d, d__len);
while (s[__X(i, s__len)] != 0x00) {
d[__X(j, d__len)] = s[__X(i, s__len)];
i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
__DEL(s);
}
static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
__DUP(s, s__len, CHAR);
i = 0;
j = Modules_CharCount(d, d__len);
if ((j > 0 && d[__X(j - 1, d__len)] != c)) {
d[__X(j, d__len)] = c;
j += 1;
}
while (s[__X(i, s__len)] != 0x00) {
d[__X(j, d__len)] = s[__X(i, s__len)];
i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
__DEL(s);
}
static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len)
{
INT16 i;
__DUP(s, s__len, CHAR);
if (c == 0x00) {
__DEL(s);
return 0;
}
i = 0;
while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
__DEL(s);
return s[__X(i, s__len)] == c;
}
static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len)
{
__DUP(d, d__len, CHAR);
if (d[0] == 0x00) {
__DEL(d);
return 0;
}
if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) {
__DEL(d);
return 1;
}
if (d[__X(1, d__len)] == ':') {
__DEL(d);
return 1;
}
__DEL(d);
return 0;
}
static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
__DUP(s, s__len, CHAR);
if (Modules_IsAbsolute(s, s__len)) {
__COPY(s, d, d__len);
} else {
__COPY(Platform_CWD, d, d__len);
Modules_AppendPart('/', s, s__len, (void*)d, d__len);
}
__DEL(s);
}
static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len)
{
Platform_FileIdentity identity;
__DUP(s, s__len, CHAR);
__DEL(s);
return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0;
}
static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len)
{
INT16 j;
__DUP(s, s__len, CHAR);
__DUP(p, p__len, CHAR);
j = 0;
while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) {
d[__X(j, d__len)] = s[__X(*i, s__len)];
*i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) {
*i += 1;
}
__DEL(s);
__DEL(p);
}
static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
CHAR part[1024];
__DUP(s, s__len, CHAR);
i = 0;
j = 0;
while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) {
i += 1;
d[__X(j, d__len)] = '/';
j += 1;
}
d[__X(j, d__len)] = 0x00;
while (s[__X(i, s__len)] != 0x00) {
Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024);
if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) {
Modules_AppendPart('/', part, 1024, (void*)d, d__len);
}
}
__DEL(s);
}
typedef
CHAR pathstring__12[4096];
static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len)
{
pathstring__12 arg0, pathlist, pathdir, tempstr;
INT16 i, j, k;
BOOLEAN present;
if (Modules_ArgCount < 1) {
binarydir[0] = 0x00;
return;
}
Modules_GetArg(0, (void*)arg0, 4096);
i = 0;
while ((((arg0[__X(i, 4096)] != 0x00 && arg0[__X(i, 4096)] != '/')) && arg0[__X(i, 4096)] != '\\')) {
i += 1;
}
if (arg0[__X(i, 4096)] == '/' || arg0[__X(i, 4096)] == '\\') {
Modules_Trim(arg0, 4096, (void*)tempstr, 4096);
Modules_Canonify(tempstr, 4096, (void*)binarydir, binarydir__len);
present = Modules_IsFilePresent(binarydir, binarydir__len);
} else {
Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096);
i = 0;
present = 0;
while ((!present && pathlist[__X(i, 4096)] != 0x00)) {
Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)pathdir, 4096);
Modules_AppendPart('/', arg0, 4096, (void*)pathdir, 4096);
Modules_Trim(pathdir, 4096, (void*)tempstr, 4096);
Modules_Canonify(tempstr, 4096, (void*)binarydir, binarydir__len);
present = Modules_IsFilePresent(binarydir, binarydir__len);
}
}
if (present) {
k = Modules_CharCount(binarydir, binarydir__len);
while ((k > 0 && !Modules_IsOneOf(binarydir[__X(k - 1, binarydir__len)], (CHAR*)"/\\", 3))) {
k -= 1;
}
if (k == 0) {
binarydir[__X(k, binarydir__len)] = 0x00;
} else {
binarydir[__X(k - 1, binarydir__len)] = 0x00;
}
} else {
binarydir[0] = 0x00;
}
}
Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len)
{
Heap_Module m = NIL;
CHAR bodyname[64];
Heap_Command body;
__DUP(name, name__len, CHAR);
m = Modules_modules();
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
m = m->next;
}
if (m != NIL) {
Modules_res = 0;
Modules_resMsg[0] = 0x00;
} else {
Modules_res = 1;
__COPY(name, Modules_importing, 20);
__MOVE(" module \"", Modules_resMsg, 10);
Modules_Append(name, name__len, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256);
}
__DEL(name);
return m;
}
Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len)
{
Heap_Cmd c = NIL;
__DUP(name, name__len, CHAR);
c = mod->cmds;
while ((c != NIL && __STRCMP(c->name, name) != 0)) {
c = c->next;
}
if (c != NIL) {
Modules_res = 0;
Modules_resMsg[0] = 0x00;
__DEL(name);
return c->cmd;
} else {
Modules_res = 2;
__MOVE(" command \"", Modules_resMsg, 11);
__COPY(name, Modules_importing, 20);
Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256);
Modules_Append(name, name__len, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256);
__DEL(name);
return NIL;
}
__RETCHK;
}
void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all)
{
Heap_Module m = NIL, p = NIL;
INT32 refcount;
__DUP(name, name__len, CHAR);
m = Modules_modules();
if (all) {
Modules_res = 1;
__MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34);
} else {
refcount = Heap_FreeModule(name, name__len);
if (refcount == 0) {
Modules_res = 0;
} else {
if (refcount < 0) {
__MOVE("module not found", Modules_resMsg, 17);
} else {
__MOVE("clients of this module exist", Modules_resMsg, 29);
}
Modules_res = 1;
}
}
__DEL(name);
}
static void Modules_errch (CHAR c)
{
INT16 e;
e = Platform_Write(1, (ADDRESS)&c, 1);
}
static void Modules_errstring (CHAR *s, ADDRESS s__len)
{
INT32 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
Modules_errch(s[__X(i, s__len)]);
i += 1;
}
__DEL(s);
}
static void Modules_errint (INT32 l)
{
if (l < 0) {
Modules_errch('-');
l = -l;
}
if (l >= 10) {
Modules_errint(__DIV(l, 10));
}
Modules_errch(__CHR((int)__MOD(l, 10) + 48));
}
static void Modules_DisplayHaltCode (INT32 code)
{
switch (code) {
case -1:
Modules_errstring((CHAR*)"Assertion failure.", 19);
break;
case -2:
Modules_errstring((CHAR*)"Index out of range.", 20);
break;
case -3:
Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49);
break;
case -4:
Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47);
break;
case -5:
Modules_errstring((CHAR*)"Type guard failed.", 19);
break;
case -6:
Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49);
break;
case -7:
Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32);
break;
case -8:
Modules_errstring((CHAR*)"Value out of range.", 20);
break;
case -9:
Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60);
break;
case -10:
Modules_errstring((CHAR*)"NIL access.", 12);
break;
case -11:
Modules_errstring((CHAR*)"Alignment error.", 17);
break;
case -12:
Modules_errstring((CHAR*)"Divide by zero.", 16);
break;
case -13:
Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31);
break;
case -14:
Modules_errstring((CHAR*)"Invalid function argument.", 27);
break;
case -15:
Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52);
break;
case -20:
Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60);
break;
default:
break;
}
}
void Modules_Halt (INT32 code)
{
Heap_FINALL();
Modules_errstring((CHAR*)"Terminated by Halt(", 20);
Modules_errint(code);
Modules_errstring((CHAR*)"). ", 4);
if (code < 0) {
Modules_DisplayHaltCode(code);
}
Modules_errstring(Platform_NL, 3);
Platform_Exit(code);
}
void Modules_AssertFail (INT32 code)
{
Heap_FINALL();
Modules_errstring((CHAR*)"Assertion failure.", 19);
if (code != 0) {
Modules_errstring((CHAR*)" ASSERT code ", 14);
Modules_errint(code);
Modules_errstring((CHAR*)".", 2);
}
Modules_errstring(Platform_NL, 3);
if (code > 0) {
Platform_Exit(code);
} else {
Platform_Exit(-1);
}
}
export void *Modules__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Platform);
__REGMOD("Modules", 0);
/* BEGIN */
Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024);
__ENDMOD;
}

View file

@ -0,0 +1,31 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Modules__h
#define Modules__h
#include "SYSTEM.h"
#include "Heap.h"
import INT16 Modules_res;
import CHAR Modules_resMsg[256];
import Heap_ModuleName Modules_imported, Modules_importing;
import INT32 Modules_MainStackFrame;
import INT16 Modules_ArgCount;
import INT32 Modules_ArgVector;
import CHAR Modules_BinaryDir[1024];
import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len);
import void Modules_AssertFail (INT32 code);
import void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all);
import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len);
import void Modules_GetIntArg (INT16 n, INT32 *val);
import void Modules_Halt (INT32 code);
import void Modules_Init (INT32 argc, INT32 argvadr);
import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len);
import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len);
import void *Modules__init(void);
#endif // Modules

2592
bootstrap/unix-44/OPB.c Normal file

File diff suppressed because it is too large Load diff

48
bootstrap/unix-44/OPB.h Normal file
View file

@ -0,0 +1,48 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPB__h
#define OPB__h
#include "SYSTEM.h"
#include "OPS.h"
#include "OPT.h"
import void OPB_Assign (OPT_Node *x, OPT_Node y);
import void OPB_Call (OPT_Node *x, OPT_Node apar, OPT_Object fp);
import void OPB_CheckParameters (OPT_Object fp, OPT_Object ap, BOOLEAN checkNames);
import void OPB_Construct (INT8 class, OPT_Node *x, OPT_Node y);
import void OPB_DeRef (OPT_Node *x);
import OPT_Node OPB_EmptySet (void);
import void OPB_Enter (OPT_Node *procdec, OPT_Node stat, OPT_Object proc);
import void OPB_Field (OPT_Node *x, OPT_Object y);
import void OPB_In (OPT_Node *x, OPT_Node y);
import void OPB_Index (OPT_Node *x, OPT_Node y);
import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ);
import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y);
import void OPB_MOp (INT8 op, OPT_Node *x);
import OPT_Node OPB_NewBoolConst (BOOLEAN boolval);
import OPT_Node OPB_NewIntConst (INT64 intval);
import OPT_Node OPB_NewLeaf (OPT_Object obj);
import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ);
import OPT_Node OPB_NewString (OPS_String str, INT64 len);
import OPT_Node OPB_Nil (void);
import void OPB_Op (INT8 op, OPT_Node *x, OPT_Node y);
import void OPB_OptIf (OPT_Node *x);
import void OPB_Param (OPT_Node ap, OPT_Object fp);
import void OPB_PrepCall (OPT_Node *x, OPT_Object *fpar);
import void OPB_Return (OPT_Node *x, OPT_Object proc);
import void OPB_SetElem (OPT_Node *x);
import void OPB_SetRange (OPT_Node *x, OPT_Node y);
import void OPB_StFct (OPT_Node *par0, INT8 fctno, INT16 parno);
import void OPB_StPar0 (OPT_Node *par0, INT16 fctno);
import void OPB_StPar1 (OPT_Node *par0, OPT_Node x, INT8 fctno);
import void OPB_StParN (OPT_Node *par0, OPT_Node x, INT16 fctno, INT16 n);
import void OPB_StaticLink (INT8 dlev);
import void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard);
import void *OPB__init(void);
#endif // OPB

2025
bootstrap/unix-44/OPC.c Normal file

File diff suppressed because it is too large Load diff

49
bootstrap/unix-44/OPC.h Normal file
View file

@ -0,0 +1,49 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPC__h
#define OPC__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPC_Andent (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void);
import void OPC_BegStat (void);
import void OPC_Case (INT64 caseVal, INT16 form);
import void OPC_Cmp (INT16 rel);
import void OPC_CompleteIdent (OPT_Object obj);
import void OPC_Constant (OPT_Const con, INT16 form);
import void OPC_DefineInter (OPT_Object proc);
import void OPC_EndBlk (void);
import void OPC_EndBlk0 (void);
import void OPC_EndStat (void);
import void OPC_EnterBody (void);
import void OPC_EnterProc (OPT_Object proc);
import void OPC_ExitBody (void);
import void OPC_ExitProc (OPT_Object proc, BOOLEAN eoBlock, BOOLEAN implicitRet);
import void OPC_GenBdy (OPT_Node n);
import void OPC_GenEnumPtrs (OPT_Object var);
import void OPC_GenHdr (OPT_Node n);
import void OPC_GenHdrIncludes (void);
import void OPC_Halt (INT32 n);
import void OPC_Ident (OPT_Object obj);
import void OPC_Increment (BOOLEAN decrement);
import void OPC_Indent (INT16 count);
import void OPC_Init (void);
import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_IntLiteral (INT64 n, INT32 size);
import void OPC_Len (OPT_Object obj, OPT_Struct array, INT64 dim);
import BOOLEAN OPC_NeedsRetval (OPT_Object proc);
import INT32 OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INT16 vis);
import void OPC_TypeOf (OPT_Object ap);
import void *OPC__init(void);
#endif // OPC

1183
bootstrap/unix-44/OPM.c Normal file

File diff suppressed because it is too large Load diff

76
bootstrap/unix-44/OPM.h Normal file
View file

@ -0,0 +1,76 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPM__h
#define OPM__h
#include "SYSTEM.h"
import CHAR OPM_Model[10];
import INT16 OPM_AddressSize, OPM_Alignment;
import UINT32 OPM_GlobalOptions, OPM_Options;
import INT16 OPM_ShortintSize, OPM_IntegerSize, OPM_LongintSize, OPM_SetSize;
import INT64 OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
import INT32 OPM_curpos, OPM_errpos, OPM_breakpc;
import INT16 OPM_currFile, OPM_level, OPM_pc, OPM_entno;
import CHAR OPM_modName[32];
import CHAR OPM_objname[64];
import CHAR OPM_InstallDir[1024];
import CHAR OPM_ResourceDir[1024];
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void);
import void OPM_DeleteObj (CHAR *modulename, ADDRESS modulename__len);
import void OPM_DeleteSym (CHAR *modulename, ADDRESS modulename__len);
import void OPM_FPrint (INT32 *fp, INT64 val);
import void OPM_FPrintLReal (INT32 *fp, LONGREAL val);
import void OPM_FPrintReal (INT32 *fp, REAL val);
import void OPM_FPrintSet (INT32 *fp, UINT64 val);
import void OPM_Get (CHAR *ch);
import void OPM_GetComment (CHAR *text, ADDRESS text__len);
import void OPM_Init (BOOLEAN *done);
import void OPM_InitOptions (void);
import INT16 OPM_Integer (INT64 n);
import void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len);
import void OPM_LogVT100 (CHAR *vt100code, ADDRESS vt100code__len);
import void OPM_LogW (CHAR ch);
import void OPM_LogWLn (void);
import void OPM_LogWNum (INT64 i, INT64 len);
import void OPM_LogWStr (CHAR *s, ADDRESS s__len);
import INT32 OPM_Longint (INT64 n);
import void OPM_Mark (INT16 n, INT32 pos);
import void OPM_NewSym (CHAR *modName, ADDRESS modName__len);
import void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, ADDRESS moduleName__len);
import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void);
import INT64 OPM_SignedMaximum (INT32 bytecount);
import INT64 OPM_SignedMinimum (INT32 bytecount);
import void OPM_StoreComment (CHAR *text, ADDRESS text__len);
import void OPM_SymRCh (CHAR *ch);
import INT32 OPM_SymRInt (void);
import INT64 OPM_SymRInt64 (void);
import void OPM_SymRLReal (LONGREAL *lr);
import void OPM_SymRReal (REAL *r);
import void OPM_SymRSet (UINT64 *s);
import void OPM_SymWCh (CHAR ch);
import void OPM_SymWInt (INT64 i);
import void OPM_SymWLReal (LONGREAL lr);
import void OPM_SymWReal (REAL r);
import void OPM_SymWSet (UINT64 s);
import void OPM_Write (CHAR ch);
import void OPM_WriteHex (INT64 i);
import void OPM_WriteInt (INT64 i);
import void OPM_WriteLn (void);
import void OPM_WriteReal (LONGREAL r, CHAR suffx);
import void OPM_WriteString (CHAR *s, ADDRESS s__len);
import void OPM_WriteStringVar (CHAR *s, ADDRESS s__len);
import BOOLEAN OPM_eofSF (void);
import void OPM_err (INT16 n);
import void *OPM__init(void);
#endif // OPM

1881
bootstrap/unix-44/OPP.c Normal file

File diff suppressed because it is too large Load diff

16
bootstrap/unix-44/OPP.h Normal file
View file

@ -0,0 +1,16 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPP__h
#define OPP__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPP_Module (OPT_Node *prog, UINT32 opt);
import void *OPP__init(void);
#endif // OPP

666
bootstrap/unix-44/OPS.c Normal file
View file

@ -0,0 +1,666 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "OPM.h"
typedef
CHAR OPS_Name[256];
typedef
CHAR OPS_String[256];
export OPS_Name OPS_name;
export OPS_String OPS_str;
export INT16 OPS_numtyp;
export INT64 OPS_intval;
export REAL OPS_realval;
export LONGREAL OPS_lrlval;
static CHAR OPS_ch;
export void OPS_Get (INT8 *sym);
static void OPS_Identifier (INT8 *sym);
export void OPS_Init (void);
static void OPS_Number (void);
static void OPS_Str (INT8 *sym);
static void OPS_err (INT16 n);
static void OPS_err (INT16 n)
{
OPM_err(n);
}
static void OPS_Str (INT8 *sym)
{
INT16 i;
CHAR och;
i = 0;
och = OPS_ch;
for (;;) {
OPM_Get(&OPS_ch);
if (OPS_ch == och) {
break;
}
if (OPS_ch < ' ') {
OPS_err(3);
break;
}
if (i == 255) {
OPS_err(241);
break;
}
OPS_str[__X(i, 256)] = OPS_ch;
i += 1;
}
OPM_Get(&OPS_ch);
OPS_str[__X(i, 256)] = 0x00;
OPS_intval = i + 1;
if (OPS_intval == 2) {
*sym = 35;
OPS_numtyp = 1;
OPS_intval = (INT16)OPS_str[0];
} else {
*sym = 37;
}
}
static void OPS_Identifier (INT8 *sym)
{
INT16 i;
i = 0;
do {
OPS_name[__X(i, 256)] = OPS_ch;
i += 1;
OPM_Get(&OPS_ch);
} while (!(((OPS_ch < '0' || ('9' < OPS_ch && __CAP(OPS_ch) < 'A')) || 'Z' < __CAP(OPS_ch)) || i == 256));
if (i == 256) {
OPS_err(240);
i -= 1;
}
OPS_name[__X(i, 256)] = 0x00;
*sym = 38;
}
static struct Number__6 {
struct Number__6 *lnk;
} *Number__6_s;
static INT16 Ord__7 (CHAR ch, BOOLEAN hex);
static LONGREAL Ten__9 (INT16 e);
static LONGREAL Ten__9 (INT16 e)
{
LONGREAL x, p;
x = (LONGREAL)1;
p = (LONGREAL)10;
while (e > 0) {
if (__ODD(e)) {
x = x * p;
}
e = __ASHR(e, 1);
if (e > 0) {
p = p * p;
}
}
return x;
}
static INT16 Ord__7 (CHAR ch, BOOLEAN hex)
{
if (ch <= '9') {
return (INT16)ch - 48;
} else if (hex) {
return ((INT16)ch - 65) + 10;
} else {
OPS_err(2);
return 0;
}
__RETCHK;
}
static void OPS_Number (void)
{
INT16 i, m, n, d, e;
CHAR dig[24];
LONGREAL f;
CHAR expCh;
BOOLEAN neg;
struct Number__6 _s;
_s.lnk = Number__6_s;
Number__6_s = &_s;
i = 0;
m = 0;
n = 0;
d = 0;
for (;;) {
if (('0' <= OPS_ch && OPS_ch <= '9') || (((d == 0 && 'A' <= OPS_ch)) && OPS_ch <= 'F')) {
if (m > 0 || OPS_ch != '0') {
if (n < 24) {
dig[__X(n, 24)] = OPS_ch;
n += 1;
}
m += 1;
}
OPM_Get(&OPS_ch);
i += 1;
} else if (OPS_ch == '.') {
OPM_Get(&OPS_ch);
if (OPS_ch == '.') {
OPS_ch = 0x7f;
break;
} else if (d == 0) {
d = i;
} else {
OPS_err(2);
}
} else {
break;
}
}
if (d == 0) {
if (n == m) {
OPS_intval = 0;
i = 0;
if (OPS_ch == 'X') {
OPM_Get(&OPS_ch);
OPS_numtyp = 1;
if (n <= 2) {
while (i < n) {
OPS_intval = __ASHL(OPS_intval, 4) + (INT64)Ord__7(dig[__X(i, 24)], 1);
i += 1;
}
} else {
OPS_err(203);
}
} else if (OPS_ch == 'H') {
OPM_Get(&OPS_ch);
OPS_numtyp = 2;
if (n <= 16) {
if ((n == 16 && dig[0] > '7')) {
OPS_intval = -1;
}
while (i < n) {
OPS_intval = __ASHL(OPS_intval, 4) + (INT64)Ord__7(dig[__X(i, 24)], 1);
i += 1;
}
} else {
OPS_err(203);
}
} else {
OPS_numtyp = 2;
while (i < n) {
d = Ord__7(dig[__X(i, 24)], 0);
i += 1;
if (OPS_intval <= __DIV(9223372036854775807LL - (INT64)d, 10)) {
OPS_intval = OPS_intval * 10 + (INT64)d;
} else {
OPS_err(203);
}
}
}
} else {
OPS_err(203);
}
} else {
f = (LONGREAL)0;
e = 0;
expCh = 'E';
while (n > 0) {
n -= 1;
f = (Ord__7(dig[__X(n, 24)], 0) + f) / (LONGREAL)(LONGREAL)10;
}
if (OPS_ch == 'E' || OPS_ch == 'D') {
expCh = OPS_ch;
OPM_Get(&OPS_ch);
neg = 0;
if (OPS_ch == '-') {
neg = 1;
OPM_Get(&OPS_ch);
} else if (OPS_ch == '+') {
OPM_Get(&OPS_ch);
}
if (('0' <= OPS_ch && OPS_ch <= '9')) {
do {
n = Ord__7(OPS_ch, 0);
OPM_Get(&OPS_ch);
if (e <= __DIV(32767 - n, 10)) {
e = e * 10 + n;
} else {
OPS_err(203);
}
} while (!(OPS_ch < '0' || '9' < OPS_ch));
if (neg) {
e = -e;
}
} else {
OPS_err(2);
}
}
e -= (i - d) - m;
if (expCh == 'E') {
OPS_numtyp = 3;
if ((-37 < e && e <= 38)) {
if (e < 0) {
OPS_realval = (f / (LONGREAL)Ten__9(-e));
} else {
OPS_realval = (f * Ten__9(e));
}
} else {
OPS_err(203);
}
} else {
OPS_numtyp = 4;
if ((-307 < e && e <= 308)) {
if (e < 0) {
OPS_lrlval = f / (LONGREAL)Ten__9(-e);
} else {
OPS_lrlval = f * Ten__9(e);
}
} else {
OPS_err(203);
}
}
}
Number__6_s = _s.lnk;
}
static struct Get__1 {
struct Get__1 *lnk;
} *Get__1_s;
static void Comment__2 (void);
static void Comment__2 (void)
{
BOOLEAN isExported;
CHAR commentText[256];
INT16 i, nestLevel;
CHAR prevCh, nextCh;
i = 0;
while (i <= 255) {
commentText[__X(i, 256)] = 0x00;
i += 1;
}
isExported = 0;
i = 0;
nestLevel = 1;
prevCh = 0x00;
OPM_Get(&OPS_ch);
if (OPS_ch == '*') {
isExported = 1;
OPM_Get(&OPS_ch);
if (OPS_ch == ')') {
commentText[0] = 0x00;
OPM_StoreComment(commentText, 256);
OPM_Get(&OPS_ch);
return;
}
}
while ((nestLevel > 0 && OPS_ch != 0x00)) {
if ((prevCh == '(' && OPS_ch == '*')) {
nestLevel += 1;
prevCh = 0x00;
} else if ((prevCh == '*' && OPS_ch == ')')) {
nestLevel -= 1;
if (nestLevel == 0) {
OPM_Get(&OPS_ch);
} else {
prevCh = 0x00;
}
} else {
if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) {
if (i < 255) {
commentText[__X(i, 256)] = prevCh;
i += 1;
}
}
prevCh = OPS_ch;
}
if (nestLevel > 0) {
OPM_Get(&OPS_ch);
}
}
if (OPS_ch == 0x00) {
OPS_err(5);
}
if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) {
if (i < 255) {
commentText[__X(i, 256)] = prevCh;
i += 1;
} else {
OPM_LogWStr((CHAR*)"Truncating final comment character", 35);
OPM_LogWLn();
}
}
if (isExported) {
if (i >= 256) {
OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30);
OPM_LogWLn();
i = 255;
}
commentText[__X(i, 256)] = 0x00;
OPM_StoreComment(commentText, 256);
}
}
void OPS_Get (INT8 *sym)
{
INT8 s;
struct Get__1 _s;
_s.lnk = Get__1_s;
Get__1_s = &_s;
OPM_errpos = OPM_curpos - 1;
while (OPS_ch <= ' ') {
if (OPS_ch == 0x00) {
*sym = 64;
Get__1_s = _s.lnk;
return;
} else {
OPM_Get(&OPS_ch);
}
}
switch (OPS_ch) {
case '"': case '\'':
OPS_Str(&s);
break;
case '#':
s = 10;
OPM_Get(&OPS_ch);
break;
case '&':
s = 5;
OPM_Get(&OPS_ch);
break;
case '(':
OPM_Get(&OPS_ch);
if (OPS_ch == '*') {
Comment__2();
OPS_Get(&s);
} else {
s = 30;
}
break;
case ')':
s = 22;
OPM_Get(&OPS_ch);
break;
case '*':
s = 1;
OPM_Get(&OPS_ch);
break;
case '+':
s = 6;
OPM_Get(&OPS_ch);
break;
case ',':
s = 19;
OPM_Get(&OPS_ch);
break;
case '-':
s = 7;
OPM_Get(&OPS_ch);
break;
case '.':
OPM_Get(&OPS_ch);
if (OPS_ch == '.') {
OPM_Get(&OPS_ch);
s = 21;
} else {
s = 18;
}
break;
case '/':
s = 2;
OPM_Get(&OPS_ch);
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
OPS_Number();
s = 35;
break;
case ':':
OPM_Get(&OPS_ch);
if (OPS_ch == '=') {
OPM_Get(&OPS_ch);
s = 34;
} else {
s = 20;
}
break;
case ';':
s = 39;
OPM_Get(&OPS_ch);
break;
case '<':
OPM_Get(&OPS_ch);
if (OPS_ch == '=') {
OPM_Get(&OPS_ch);
s = 12;
} else {
s = 11;
}
break;
case '=':
s = 9;
OPM_Get(&OPS_ch);
break;
case '>':
OPM_Get(&OPS_ch);
if (OPS_ch == '=') {
OPM_Get(&OPS_ch);
s = 14;
} else {
s = 13;
}
break;
case 'A':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "ARRAY") == 0) {
s = 54;
}
break;
case 'B':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "BEGIN") == 0) {
s = 57;
} else if (__STRCMP(OPS_name, "BY") == 0) {
s = 29;
}
break;
case 'C':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "CASE") == 0) {
s = 46;
} else if (__STRCMP(OPS_name, "CONST") == 0) {
s = 58;
}
break;
case 'D':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "DO") == 0) {
s = 27;
} else if (__STRCMP(OPS_name, "DIV") == 0) {
s = 3;
}
break;
case 'E':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "END") == 0) {
s = 41;
} else if (__STRCMP(OPS_name, "ELSE") == 0) {
s = 42;
} else if (__STRCMP(OPS_name, "ELSIF") == 0) {
s = 43;
} else if (__STRCMP(OPS_name, "EXIT") == 0) {
s = 52;
}
break;
case 'F':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "FOR") == 0) {
s = 49;
}
break;
case 'I':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "IF") == 0) {
s = 45;
} else if (__STRCMP(OPS_name, "IN") == 0) {
s = 15;
} else if (__STRCMP(OPS_name, "IS") == 0) {
s = 16;
} else if (__STRCMP(OPS_name, "IMPORT") == 0) {
s = 62;
}
break;
case 'L':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "LOOP") == 0) {
s = 50;
}
break;
case 'M':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "MOD") == 0) {
s = 4;
} else if (__STRCMP(OPS_name, "MODULE") == 0) {
s = 63;
}
break;
case 'N':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "NIL") == 0) {
s = 36;
}
break;
case 'O':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "OR") == 0) {
s = 8;
} else if (__STRCMP(OPS_name, "OF") == 0) {
s = 25;
}
break;
case 'P':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "PROCEDURE") == 0) {
s = 61;
} else if (__STRCMP(OPS_name, "POINTER") == 0) {
s = 56;
}
break;
case 'R':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "RECORD") == 0) {
s = 55;
} else if (__STRCMP(OPS_name, "REPEAT") == 0) {
s = 48;
} else if (__STRCMP(OPS_name, "RETURN") == 0) {
s = 53;
}
break;
case 'T':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "THEN") == 0) {
s = 26;
} else if (__STRCMP(OPS_name, "TO") == 0) {
s = 28;
} else if (__STRCMP(OPS_name, "TYPE") == 0) {
s = 59;
}
break;
case 'U':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "UNTIL") == 0) {
s = 44;
}
break;
case 'V':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "VAR") == 0) {
s = 60;
}
break;
case 'W':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "WHILE") == 0) {
s = 47;
} else if (__STRCMP(OPS_name, "WITH") == 0) {
s = 51;
}
break;
case 'G': case 'H': case 'J': case 'K': case 'Q':
case 'S': case 'X': case 'Y': case 'Z':
OPS_Identifier(&s);
break;
case '[':
s = 31;
OPM_Get(&OPS_ch);
break;
case ']':
s = 23;
OPM_Get(&OPS_ch);
break;
case '^':
s = 17;
OPM_Get(&OPS_ch);
break;
case 'a': case 'b': case 'c': case 'd': case 'e':
case 'f': case 'g': case 'h': case 'i': case 'j':
case 'k': case 'l': case 'm': case 'n': case 'o':
case 'p': case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x': case 'y':
case 'z':
OPS_Identifier(&s);
break;
case '{':
s = 32;
OPM_Get(&OPS_ch);
break;
case '|':
s = 40;
OPM_Get(&OPS_ch);
break;
case '}':
s = 24;
OPM_Get(&OPS_ch);
break;
case '~':
s = 33;
OPM_Get(&OPS_ch);
break;
case 0x7f:
s = 21;
OPM_Get(&OPS_ch);
break;
default:
s = 0;
OPM_Get(&OPS_ch);
break;
}
*sym = s;
Get__1_s = _s.lnk;
}
void OPS_Init (void)
{
OPS_ch = ' ';
}
export void *OPS__init(void)
{
__DEFMOD;
__MODULE_IMPORT(OPM);
__REGMOD("OPS", 0);
__REGCMD("Init", OPS_Init);
/* BEGIN */
__ENDMOD;
}

28
bootstrap/unix-44/OPS.h Normal file
View file

@ -0,0 +1,28 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPS__h
#define OPS__h
#include "SYSTEM.h"
typedef
CHAR OPS_Name[256];
typedef
CHAR OPS_String[256];
import OPS_Name OPS_name;
import OPS_String OPS_str;
import INT16 OPS_numtyp;
import INT64 OPS_intval;
import REAL OPS_realval;
import LONGREAL OPS_lrlval;
import void OPS_Get (INT8 *sym);
import void OPS_Init (void);
import void *OPS__init(void);
#endif // OPS

2261
bootstrap/unix-44/OPT.c Normal file

File diff suppressed because it is too large Load diff

128
bootstrap/unix-44/OPT.h Normal file
View file

@ -0,0 +1,128 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPT__h
#define OPT__h
#include "SYSTEM.h"
#include "OPS.h"
typedef
struct OPT_ConstDesc *OPT_Const;
typedef
OPS_String *OPT_ConstExt;
typedef
struct OPT_ConstDesc {
OPT_ConstExt ext;
INT64 intval;
INT32 intval2;
UINT64 setval;
LONGREAL realval;
} OPT_ConstDesc;
typedef
struct OPT_LinkDesc *OPT_Link;
typedef
struct OPT_LinkDesc {
OPS_Name name;
OPT_Link next;
} OPT_LinkDesc;
typedef
struct OPT_NodeDesc *OPT_Node;
typedef
struct OPT_StrDesc *OPT_Struct;
typedef
struct OPT_ObjDesc *OPT_Object;
typedef
struct OPT_NodeDesc {
OPT_Node left, right, link;
INT8 class, subcl;
BOOLEAN readonly;
OPT_Struct typ;
OPT_Object obj;
OPT_Const conval;
} OPT_NodeDesc;
typedef
struct OPT_ObjDesc {
OPT_Object left, right, link, scope;
OPS_Name name;
BOOLEAN leaf;
INT8 mode, mnolev, vis, history;
BOOLEAN used, fpdone;
INT32 fprint;
OPT_Struct typ;
OPT_Const conval;
INT32 adr, linkadr;
INT16 x;
OPT_ConstExt comment;
} OPT_ObjDesc;
typedef
struct OPT_StrDesc {
INT8 form, comp, mno, extlev;
INT16 ref, sysflag;
INT32 n, size, align, txtpos;
BOOLEAN allocated, pbused, pvused;
char _prvt0[4];
INT32 idfp;
char _prvt1[8];
OPT_Struct BaseTyp;
OPT_Object link, strobj;
} OPT_StrDesc;
import OPT_Object OPT_topScope;
import OPT_Struct OPT_undftyp, OPT_niltyp, OPT_notyp, OPT_bytetyp, OPT_cpbytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_settyp, OPT_set32typ, OPT_set64typ, OPT_realtyp, OPT_lrltyp, OPT_stringtyp, OPT_adrtyp, OPT_sysptrtyp;
import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj, OPT_setobj;
import INT8 OPT_nofGmod;
import OPT_Object OPT_GlbMod[64];
import OPS_Name OPT_SelfName;
import BOOLEAN OPT_SYSimported;
import OPT_Link OPT_Links;
import ADDRESS *OPT_ConstDesc__typ;
import ADDRESS *OPT_ObjDesc__typ;
import ADDRESS *OPT_StrDesc__typ;
import ADDRESS *OPT_NodeDesc__typ;
import ADDRESS *OPT_LinkDesc__typ;
import void OPT_Align (INT32 *adr, INT32 base);
import INT32 OPT_BaseAlignment (OPT_Struct typ);
import void OPT_Close (void);
import void OPT_CloseScope (void);
import void OPT_Export (BOOLEAN *ext, BOOLEAN *new);
import void OPT_FPrintErr (OPT_Object obj, INT16 errcode);
import void OPT_FPrintObj (OPT_Object obj);
import void OPT_FPrintStr (OPT_Struct typ);
import void OPT_Find (OPT_Object *res);
import void OPT_FindField (OPS_Name name, OPT_Struct typ, OPT_Object *res);
import void OPT_FindImport (OPT_Object mod, OPT_Object *res);
import void OPT_IdFPrint (OPT_Struct typ);
import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done);
import void OPT_Init (OPS_Name name, UINT32 opt);
import void OPT_InitRecno (void);
import void OPT_Insert (OPS_Name name, OPT_Object *obj);
import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old);
import INT16 OPT_IntSize (INT64 n);
import OPT_Struct OPT_IntType (INT32 size);
import OPT_Const OPT_NewConst (void);
import OPT_ConstExt OPT_NewExt (void);
import OPT_Node OPT_NewNode (INT8 class);
import OPT_Object OPT_NewObj (void);
import OPT_Struct OPT_NewStr (INT8 form, INT8 comp);
import void OPT_OpenScope (INT8 level, OPT_Object owner);
import OPT_Struct OPT_SetType (INT32 size);
import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir);
import INT32 OPT_SizeAlignment (INT32 size);
import void OPT_TypSize (OPT_Struct typ);
import void *OPT__init(void);
#endif // OPT

1585
bootstrap/unix-44/OPV.c Normal file

File diff suppressed because it is too large Load diff

18
bootstrap/unix-44/OPV.h Normal file
View file

@ -0,0 +1,18 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPV__h
#define OPV__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPV_AdrAndSize (OPT_Object topScope);
import void OPV_Init (void);
import void OPV_Module (OPT_Node prog);
import void *OPV__init(void);
#endif // OPV

345
bootstrap/unix-44/Out.c Normal file
View file

@ -0,0 +1,345 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Heap.h"
#include "Platform.h"
export BOOLEAN Out_IsConsole;
static CHAR Out_buf[128];
static INT16 Out_in;
export void Out_Char (CHAR ch);
export void Out_Flush (void);
export void Out_Hex (INT64 x, INT64 n);
export void Out_Int (INT64 x, INT64 n);
static INT32 Out_Length (CHAR *s, ADDRESS s__len);
export void Out_Ln (void);
export void Out_LongReal (LONGREAL x, INT16 n);
export void Out_Open (void);
export void Out_Real (REAL x, INT16 n);
static void Out_RealP (LONGREAL x, INT16 n, BOOLEAN long_);
export void Out_String (CHAR *str, ADDRESS str__len);
export LONGREAL Out_Ten (INT16 e);
static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i);
static void Out_prepend (CHAR *t, ADDRESS t__len, CHAR *s, ADDRESS s__len, INT16 *i);
#define Out_Entier64(x) (INT64)(x)
void Out_Flush (void)
{
INT16 error;
if (Out_in > 0) {
error = Platform_Write(1, (ADDRESS)Out_buf, Out_in);
}
Out_in = 0;
}
void Out_Open (void)
{
}
void Out_Char (CHAR ch)
{
if (Out_in >= 128) {
Out_Flush();
}
Out_buf[__X(Out_in, 128)] = ch;
Out_in += 1;
if (ch == 0x0a) {
Out_Flush();
}
}
static INT32 Out_Length (CHAR *s, ADDRESS s__len)
{
INT32 l;
l = 0;
while ((l < s__len && s[__X(l, s__len)] != 0x00)) {
l += 1;
}
return l;
}
void Out_String (CHAR *str, ADDRESS str__len)
{
INT32 l;
INT16 error;
__DUP(str, str__len, CHAR);
l = Out_Length((void*)str, str__len);
if (Out_in + l > 128) {
Out_Flush();
}
if (l > 128) {
error = Platform_Write(1, (ADDRESS)str, l);
} else {
__MOVE((ADDRESS)str, (ADDRESS)&Out_buf[__X(Out_in, 128)], l);
Out_in += __SHORT(l, 32768);
}
__DEL(str);
}
void Out_Int (INT64 x, INT64 n)
{
CHAR s[22];
INT16 i;
BOOLEAN negative;
negative = x < 0;
if (x == (-9223372036854775807LL-1)) {
__MOVE("8085774586302733229", s, 20);
i = 19;
} else {
if (x < 0) {
x = -x;
}
s[0] = __CHR(48 + __MOD(x, 10));
x = __DIV(x, 10);
i = 1;
while (x != 0) {
s[__X(i, 22)] = __CHR(48 + __MOD(x, 10));
x = __DIV(x, 10);
i += 1;
}
}
if (negative) {
s[__X(i, 22)] = '-';
i += 1;
}
while (n > (INT64)i) {
Out_Char(' ');
n -= 1;
}
while (i > 0) {
i -= 1;
Out_Char(s[__X(i, 22)]);
}
}
void Out_Hex (INT64 x, INT64 n)
{
if (n < 1) {
n = 1;
} else if (n > 16) {
n = 16;
}
if (x >= 0) {
while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) {
n += 1;
}
}
x = __ROT(x, __ASHL(16 - n, 2), 64);
while (n > 0) {
x = __ROTL(x, 4, 64);
n -= 1;
if (__MASK(x, -16) < 10) {
Out_Char(__CHR(__MASK(x, -16) + 48));
} else {
Out_Char(__CHR((__MASK(x, -16) - 10) + 65));
}
}
}
void Out_Ln (void)
{
Out_String(Platform_NL, 3);
Out_Flush();
}
static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i)
{
*i -= 1;
s[__X(*i, s__len)] = __CHR(__MOD(n, 10) + 48);
}
static void Out_prepend (CHAR *t, ADDRESS t__len, CHAR *s, ADDRESS s__len, INT16 *i)
{
INT16 j;
INT32 l;
__DUP(t, t__len, CHAR);
l = Out_Length((void*)t, t__len);
if (l > *i) {
l = *i;
}
*i -= __SHORT(l, 32768);
j = 0;
while (j < l) {
s[__X(*i + j, s__len)] = t[__X(j, t__len)];
j += 1;
}
__DEL(t);
}
LONGREAL Out_Ten (INT16 e)
{
LONGREAL r, power;
r = (LONGREAL)1;
power = (LONGREAL)10;
while (e > 0) {
if (__ODD(e)) {
r = r * power;
}
power = power * power;
e = __ASHR(e, 1);
}
return r;
}
static void Out_RealP (LONGREAL x, INT16 n, BOOLEAN long_)
{
INT16 e;
INT64 f;
CHAR s[30];
INT16 i, el;
LONGREAL x0;
BOOLEAN nn, en;
INT64 m;
INT16 d, dr;
e = (INT16)__MASK(__ASHR((__VAL(INT64, x)), 52), -2048);
f = __MASK((__VAL(INT64, x)), -4503599627370496LL);
nn = (__VAL(INT64, x) < 0 && !((e == 2047 && f != 0)));
if (nn) {
n -= 1;
}
i = 30;
if (e == 2047) {
if (f == 0) {
Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i);
} else {
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
}
} else {
if (long_) {
el = 3;
dr = n - 6;
if (dr > 17) {
dr = 17;
}
d = dr;
if (d < 15) {
d = 15;
}
} else {
el = 2;
dr = n - 5;
if (dr > 9) {
dr = 9;
}
d = dr;
if (d < 6) {
d = 6;
}
}
if (e == 0) {
while (el > 0) {
i -= 1;
s[__X(i, 30)] = '0';
el -= 1;
}
i -= 1;
s[__X(i, 30)] = '+';
m = 0;
} else {
if (nn) {
x = -x;
}
e = __SHORT(__ASHR((e - 1023) * 77, 8), 32768);
if (e >= 0) {
x = x / (LONGREAL)Out_Ten(e);
} else {
x = Out_Ten(-e) * x;
}
if (x >= (LONGREAL)10) {
x = 1.00000000000000e-001 * x;
e += 1;
}
en = e < 0;
if (en) {
e = -e;
}
while (el > 0) {
Out_digit(e, (void*)s, 30, &i);
e = __DIV(e, 10);
el -= 1;
}
i -= 1;
if (en) {
s[__X(i, 30)] = '-';
} else {
s[__X(i, 30)] = '+';
}
x0 = Out_Ten(d - 1);
x = x0 * x;
x = x + 5.00000000000000e-001;
if (x >= (LONGREAL)10 * x0) {
x = 1.00000000000000e-001 * x;
e += 1;
}
m = Out_Entier64(x);
}
i -= 1;
if (long_) {
s[__X(i, 30)] = 'D';
} else {
s[__X(i, 30)] = 'E';
}
if (dr < 2) {
dr = 2;
}
while ((d > dr && __MOD(m, 10) == 0)) {
m = __DIV(m, 10);
d -= 1;
}
while (d > 1) {
Out_digit(m, (void*)s, 30, &i);
m = __DIV(m, 10);
d -= 1;
}
i -= 1;
s[__X(i, 30)] = '.';
Out_digit(m, (void*)s, 30, &i);
}
n -= 30 - i;
while (n > 0) {
Out_Char(' ');
n -= 1;
}
if (nn) {
Out_Char('-');
}
while (i < 30) {
Out_Char(s[__X(i, 30)]);
i += 1;
}
}
void Out_Real (REAL x, INT16 n)
{
Out_RealP(x, n, 0);
}
void Out_LongReal (LONGREAL x, INT16 n)
{
Out_RealP(x, n, 1);
}
export void *Out__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Platform);
__REGMOD("Out", 0);
__REGCMD("Flush", Out_Flush);
__REGCMD("Ln", Out_Ln);
__REGCMD("Open", Out_Open);
/* BEGIN */
Out_IsConsole = Platform_IsConsole(1);
Out_in = 0;
__ENDMOD;
}

25
bootstrap/unix-44/Out.h Normal file
View file

@ -0,0 +1,25 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Out__h
#define Out__h
#include "SYSTEM.h"
import BOOLEAN Out_IsConsole;
import void Out_Char (CHAR ch);
import void Out_Flush (void);
import void Out_Hex (INT64 x, INT64 n);
import void Out_Int (INT64 x, INT64 n);
import void Out_Ln (void);
import void Out_LongReal (LONGREAL x, INT16 n);
import void Out_Open (void);
import void Out_Real (REAL x, INT16 n);
import void Out_String (CHAR *str, ADDRESS str__len);
import LONGREAL Out_Ten (INT16 e);
import void *Out__init(void);
#endif // Out

View file

@ -0,0 +1,535 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
typedef
struct Platform_FileIdentity {
INT32 volume, index, mtime;
} Platform_FileIdentity;
typedef
void (*Platform_SignalHandler)(INT32);
export BOOLEAN Platform_LittleEndian;
export INT16 Platform_PID;
export CHAR Platform_CWD[256];
static INT32 Platform_TimeStart;
export INT16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
export CHAR Platform_NL[3];
export ADDRESS *Platform_FileIdentity__typ;
export BOOLEAN Platform_Absent (INT16 e);
export INT16 Platform_Chdir (CHAR *n, ADDRESS n__len);
export INT16 Platform_Close (INT32 h);
export BOOLEAN Platform_ConnectionFailed (INT16 e);
export void Platform_Delay (INT32 ms);
export BOOLEAN Platform_DifferentFilesystems (INT16 e);
export INT16 Platform_Error (void);
export void Platform_Exit (INT32 code);
export void Platform_GetClock (INT32 *t, INT32 *d);
export void Platform_GetEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec);
export INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ);
export INT16 Platform_IdentifyByName (CHAR *n, ADDRESS n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ);
export BOOLEAN Platform_Inaccessible (INT16 e);
export BOOLEAN Platform_Interrupted (INT16 e);
export BOOLEAN Platform_IsConsole (INT32 h);
export void Platform_MTimeAsClock (Platform_FileIdentity i, INT32 *t, INT32 *d);
export INT16 Platform_MaxNameLength (void);
export INT16 Platform_MaxPathLength (void);
export INT16 Platform_New (CHAR *n, ADDRESS n__len, INT32 *h);
export BOOLEAN Platform_NoSuchDirectory (INT16 e);
export INT32 Platform_OSAllocate (INT32 size);
export void Platform_OSFree (INT32 address);
export INT16 Platform_OldRO (CHAR *n, ADDRESS n__len, INT32 *h);
export INT16 Platform_OldRW (CHAR *n, ADDRESS n__len, INT32 *h);
export INT16 Platform_Read (INT32 h, INT32 p, INT32 l, INT32 *n);
export INT16 Platform_ReadBuf (INT32 h, SYSTEM_BYTE *b, ADDRESS b__len, INT32 *n);
export INT16 Platform_Rename (CHAR *o, ADDRESS o__len, CHAR *n, ADDRESS n__len);
export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
export INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence);
export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
export void Platform_SetInterruptHandler (Platform_SignalHandler handler);
export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source);
export void Platform_SetQuitHandler (Platform_SignalHandler handler);
export INT16 Platform_Size (INT32 h, INT32 *l);
export INT16 Platform_Sync (INT32 h);
export INT16 Platform_System (CHAR *cmd, ADDRESS cmd__len);
static void Platform_TestLittleEndian (void);
export INT32 Platform_Time (void);
export BOOLEAN Platform_TimedOut (INT16 e);
export BOOLEAN Platform_TooManyFiles (INT16 e);
export INT16 Platform_Truncate (INT32 h, INT32 l);
export INT16 Platform_Unlink (CHAR *n, ADDRESS n__len);
export INT16 Platform_Write (INT32 h, INT32 p, INT32 l);
static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d);
export BOOLEAN Platform_getEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#define Platform_EACCES() EACCES
#define Platform_EAGAIN() EAGAIN
#define Platform_ECONNABORTED() ECONNABORTED
#define Platform_ECONNREFUSED() ECONNREFUSED
#define Platform_EHOSTUNREACH() EHOSTUNREACH
#define Platform_EINTR() EINTR
#define Platform_EMFILE() EMFILE
#define Platform_ENETUNREACH() ENETUNREACH
#define Platform_ENFILE() ENFILE
#define Platform_ENOENT() ENOENT
#define Platform_EROFS() EROFS
#define Platform_ETIMEDOUT() ETIMEDOUT
#define Platform_EXDEV() EXDEV
#define Platform_NAMEMAX() NAME_MAX
#define Platform_PATHMAX() PATH_MAX
#define Platform_allocate(size) (ADDRESS)((void*)malloc((size_t)size))
#define Platform_chdir(n, n__len) chdir((char*)n)
#define Platform_closefile(fd) close(fd)
#define Platform_err() errno
#define Platform_exit(code) exit((int)code)
#define Platform_free(address) free((void*)address)
#define Platform_fstat(fd) fstat(fd, &s)
#define Platform_fsync(fd) fsync(fd)
#define Platform_ftruncate(fd, l) ftruncate(fd, l)
#define Platform_getcwd(cwd, cwd__len) getcwd((char*)cwd, cwd__len)
#define Platform_getenv(var, var__len) getenv((char*)var)
#define Platform_getpid() (INTEGER)getpid()
#define Platform_gettimeval() struct timeval tv; gettimeofday(&tv,0)
#define Platform_isatty(fd) isatty(fd)
#define Platform_lseek(fd, o, w) lseek(fd, o, w)
#define Platform_nanosleep(s, ns) struct timespec req, rem; req.tv_sec = s; req.tv_nsec = ns; nanosleep(&req, &rem)
#define Platform_opennew(n, n__len) open((char*)n, O_CREAT | O_TRUNC | O_RDWR, 0664)
#define Platform_openro(n, n__len) open((char*)n, O_RDONLY)
#define Platform_openrw(n, n__len) open((char*)n, O_RDWR)
#define Platform_readfile(fd, p, l) (LONGINT)read(fd, (void*)(ADDRESS)(p), l)
#define Platform_rename(o, o__len, n, n__len) rename((char*)o, (char*)n)
#define Platform_sectotm(s) struct tm *time = localtime((time_t*)&s)
#define Platform_seekcur() SEEK_CUR
#define Platform_seekend() SEEK_END
#define Platform_seekset() SEEK_SET
#define Platform_sethandler(s, h) SystemSetHandler(s, (ADDRESS)h)
#define Platform_stat(n, n__len) stat((char*)n, &s)
#define Platform_statdev() (LONGINT)s.st_dev
#define Platform_statino() (LONGINT)s.st_ino
#define Platform_statmtime() (LONGINT)s.st_mtime
#define Platform_statsize() (ADDRESS)s.st_size
#define Platform_structstats() struct stat s
#define Platform_system(str, str__len) system((char*)str)
#define Platform_tmhour() (LONGINT)time->tm_hour
#define Platform_tmmday() (LONGINT)time->tm_mday
#define Platform_tmmin() (LONGINT)time->tm_min
#define Platform_tmmon() (LONGINT)time->tm_mon
#define Platform_tmsec() (LONGINT)time->tm_sec
#define Platform_tmyear() (LONGINT)time->tm_year
#define Platform_tvsec() tv.tv_sec
#define Platform_tvusec() tv.tv_usec
#define Platform_unlink(n, n__len) unlink((char*)n)
#define Platform_writefile(fd, p, l) write(fd, (void*)(ADDRESS)(p), l)
BOOLEAN Platform_TooManyFiles (INT16 e)
{
return e == Platform_EMFILE() || e == Platform_ENFILE();
}
BOOLEAN Platform_NoSuchDirectory (INT16 e)
{
return e == Platform_ENOENT();
}
BOOLEAN Platform_DifferentFilesystems (INT16 e)
{
return e == Platform_EXDEV();
}
BOOLEAN Platform_Inaccessible (INT16 e)
{
return (e == Platform_EACCES() || e == Platform_EROFS()) || e == Platform_EAGAIN();
}
BOOLEAN Platform_Absent (INT16 e)
{
return e == Platform_ENOENT();
}
BOOLEAN Platform_TimedOut (INT16 e)
{
return e == Platform_ETIMEDOUT();
}
BOOLEAN Platform_ConnectionFailed (INT16 e)
{
return ((e == Platform_ECONNREFUSED() || e == Platform_ECONNABORTED()) || e == Platform_ENETUNREACH()) || e == Platform_EHOSTUNREACH();
}
BOOLEAN Platform_Interrupted (INT16 e)
{
return e == Platform_EINTR();
}
INT16 Platform_MaxNameLength (void)
{
return Platform_NAMEMAX();
}
INT16 Platform_MaxPathLength (void)
{
return Platform_PATHMAX();
}
INT32 Platform_OSAllocate (INT32 size)
{
return Platform_allocate(size);
}
void Platform_OSFree (INT32 address)
{
Platform_free(address);
}
typedef
CHAR (*EnvPtr__83)[1024];
BOOLEAN Platform_getEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len)
{
EnvPtr__83 p = NIL;
__DUP(var, var__len, CHAR);
p = (EnvPtr__83)(ADDRESS)Platform_getenv(var, var__len);
if (p != NIL) {
__COPY(*p, val, val__len);
}
__DEL(var);
return p != NIL;
}
void Platform_GetEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len)
{
__DUP(var, var__len, CHAR);
if (!Platform_getEnv(var, var__len, (void*)val, val__len)) {
val[0] = 0x00;
}
__DEL(var);
}
void Platform_SetInterruptHandler (Platform_SignalHandler handler)
{
Platform_sethandler(2, handler);
}
void Platform_SetQuitHandler (Platform_SignalHandler handler)
{
Platform_sethandler(3, handler);
}
void Platform_SetBadInstructionHandler (Platform_SignalHandler handler)
{
Platform_sethandler(4, handler);
}
static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d)
{
*d = (__ASHL((int)__MOD(ye, 100), 9) + __ASHL(mo + 1, 5)) + da;
*t = (__ASHL(ho, 12) + __ASHL(mi, 6)) + se;
}
void Platform_GetClock (INT32 *t, INT32 *d)
{
Platform_gettimeval();
Platform_sectotm(Platform_tvsec());
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
}
void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec)
{
Platform_gettimeval();
*sec = Platform_tvsec();
*usec = Platform_tvusec();
}
INT32 Platform_Time (void)
{
INT32 ms;
Platform_gettimeval();
ms = (int)__DIVF(Platform_tvusec(), 1000) + Platform_tvsec() * 1000;
return (int)__MOD(ms - Platform_TimeStart, 2147483647);
}
void Platform_Delay (INT32 ms)
{
INT32 s, ns;
s = __DIV(ms, 1000);
ns = (int)__MOD(ms, 1000) * 1000000;
Platform_nanosleep(s, ns);
}
INT16 Platform_System (CHAR *cmd, ADDRESS cmd__len)
{
__DUP(cmd, cmd__len, CHAR);
__DEL(cmd);
return Platform_system(cmd, cmd__len);
}
INT16 Platform_Error (void)
{
return Platform_err();
}
INT16 Platform_OldRO (CHAR *n, ADDRESS n__len, INT32 *h)
{
INT16 fd;
fd = Platform_openro(n, n__len);
if (fd < 0) {
return Platform_err();
} else {
*h = fd;
return 0;
}
__RETCHK;
}
INT16 Platform_OldRW (CHAR *n, ADDRESS n__len, INT32 *h)
{
INT16 fd;
fd = Platform_openrw(n, n__len);
if (fd < 0) {
return Platform_err();
} else {
*h = fd;
return 0;
}
__RETCHK;
}
INT16 Platform_New (CHAR *n, ADDRESS n__len, INT32 *h)
{
INT16 fd;
fd = Platform_opennew(n, n__len);
if (fd < 0) {
return Platform_err();
} else {
*h = fd;
return 0;
}
__RETCHK;
}
INT16 Platform_Close (INT32 h)
{
if (Platform_closefile(h) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
BOOLEAN Platform_IsConsole (INT32 h)
{
return Platform_isatty(h) != 0;
}
INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ)
{
Platform_structstats();
if (Platform_fstat(h) < 0) {
return Platform_err();
}
(*identity).volume = Platform_statdev();
(*identity).index = Platform_statino();
(*identity).mtime = Platform_statmtime();
return 0;
}
INT16 Platform_IdentifyByName (CHAR *n, ADDRESS n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ)
{
__DUP(n, n__len, CHAR);
Platform_structstats();
if (Platform_stat(n, n__len) < 0) {
__DEL(n);
return Platform_err();
}
(*identity).volume = Platform_statdev();
(*identity).index = Platform_statino();
(*identity).mtime = Platform_statmtime();
__DEL(n);
return 0;
}
BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2)
{
return (i1.index == i2.index && i1.volume == i2.volume);
}
BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2)
{
return i1.mtime == i2.mtime;
}
void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source)
{
(*target).mtime = source.mtime;
}
void Platform_MTimeAsClock (Platform_FileIdentity i, INT32 *t, INT32 *d)
{
Platform_sectotm(i.mtime);
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
}
INT16 Platform_Size (INT32 h, INT32 *l)
{
Platform_structstats();
if (Platform_fstat(h) < 0) {
return Platform_err();
}
*l = Platform_statsize();
return 0;
}
INT16 Platform_Read (INT32 h, INT32 p, INT32 l, INT32 *n)
{
*n = Platform_readfile(h, p, l);
if (*n < 0) {
*n = 0;
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_ReadBuf (INT32 h, SYSTEM_BYTE *b, ADDRESS b__len, INT32 *n)
{
*n = Platform_readfile(h, (ADDRESS)b, b__len);
if (*n < 0) {
*n = 0;
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Write (INT32 h, INT32 p, INT32 l)
{
INT32 written;
written = Platform_writefile(h, p, l);
if (written < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Sync (INT32 h)
{
if (Platform_fsync(h) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence)
{
if (Platform_lseek(h, offset, whence) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Truncate (INT32 h, INT32 l)
{
if (Platform_ftruncate(h, l) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Unlink (CHAR *n, ADDRESS n__len)
{
if (Platform_unlink(n, n__len) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Chdir (CHAR *n, ADDRESS n__len)
{
INT16 r;
if ((Platform_chdir(n, n__len) >= 0 && Platform_getcwd((void*)Platform_CWD, 256) != NIL)) {
return 0;
} else {
return Platform_err();
}
__RETCHK;
}
INT16 Platform_Rename (CHAR *o, ADDRESS o__len, CHAR *n, ADDRESS n__len)
{
if (Platform_rename(o, o__len, n, n__len) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
void Platform_Exit (INT32 code)
{
Platform_exit(code);
}
static void Platform_TestLittleEndian (void)
{
INT16 i;
i = 1;
__GET((ADDRESS)&i, Platform_LittleEndian, BOOLEAN);
}
__TDESC(Platform_FileIdentity, 1, 0) = {__TDFLDS("FileIdentity", 12), {-4}};
export void *Platform__init(void)
{
__DEFMOD;
__REGMOD("Platform", 0);
__INITYP(Platform_FileIdentity, Platform_FileIdentity, 0);
/* BEGIN */
Platform_TestLittleEndian();
Platform_TimeStart = 0;
Platform_TimeStart = Platform_Time();
Platform_PID = Platform_getpid();
if (Platform_getcwd((void*)Platform_CWD, 256) == NIL) {
Platform_CWD[0] = 0x00;
}
Platform_SeekSet = Platform_seekset();
Platform_SeekCur = Platform_seekcur();
Platform_SeekEnd = Platform_seekend();
Platform_NL[0] = 0x0a;
Platform_NL[1] = 0x00;
__ENDMOD;
}

View file

@ -0,0 +1,74 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Platform__h
#define Platform__h
#include "SYSTEM.h"
typedef
struct Platform_FileIdentity {
INT32 _prvt0;
char _prvt1[8];
} Platform_FileIdentity;
typedef
void (*Platform_SignalHandler)(INT32);
import BOOLEAN Platform_LittleEndian;
import INT16 Platform_PID;
import CHAR Platform_CWD[256];
import INT16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
import CHAR Platform_NL[3];
import ADDRESS *Platform_FileIdentity__typ;
import BOOLEAN Platform_Absent (INT16 e);
import INT16 Platform_Chdir (CHAR *n, ADDRESS n__len);
import INT16 Platform_Close (INT32 h);
import BOOLEAN Platform_ConnectionFailed (INT16 e);
import void Platform_Delay (INT32 ms);
import BOOLEAN Platform_DifferentFilesystems (INT16 e);
import INT16 Platform_Error (void);
import void Platform_Exit (INT32 code);
import void Platform_GetClock (INT32 *t, INT32 *d);
import void Platform_GetEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec);
import INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ);
import INT16 Platform_IdentifyByName (CHAR *n, ADDRESS n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ);
import BOOLEAN Platform_Inaccessible (INT16 e);
import BOOLEAN Platform_Interrupted (INT16 e);
import BOOLEAN Platform_IsConsole (INT32 h);
import void Platform_MTimeAsClock (Platform_FileIdentity i, INT32 *t, INT32 *d);
import INT16 Platform_MaxNameLength (void);
import INT16 Platform_MaxPathLength (void);
import INT16 Platform_New (CHAR *n, ADDRESS n__len, INT32 *h);
import BOOLEAN Platform_NoSuchDirectory (INT16 e);
import INT32 Platform_OSAllocate (INT32 size);
import void Platform_OSFree (INT32 address);
import INT16 Platform_OldRO (CHAR *n, ADDRESS n__len, INT32 *h);
import INT16 Platform_OldRW (CHAR *n, ADDRESS n__len, INT32 *h);
import INT16 Platform_Read (INT32 h, INT32 p, INT32 l, INT32 *n);
import INT16 Platform_ReadBuf (INT32 h, SYSTEM_BYTE *b, ADDRESS b__len, INT32 *n);
import INT16 Platform_Rename (CHAR *o, ADDRESS o__len, CHAR *n, ADDRESS n__len);
import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
import INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence);
import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
import void Platform_SetInterruptHandler (Platform_SignalHandler handler);
import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source);
import void Platform_SetQuitHandler (Platform_SignalHandler handler);
import INT16 Platform_Size (INT32 h, INT32 *l);
import INT16 Platform_Sync (INT32 h);
import INT16 Platform_System (CHAR *cmd, ADDRESS cmd__len);
import INT32 Platform_Time (void);
import BOOLEAN Platform_TimedOut (INT16 e);
import BOOLEAN Platform_TooManyFiles (INT16 e);
import INT16 Platform_Truncate (INT32 h, INT32 l);
import INT16 Platform_Unlink (CHAR *n, ADDRESS n__len);
import INT16 Platform_Write (INT32 h, INT32 p, INT32 l);
import BOOLEAN Platform_getEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
import void *Platform__init(void);
#endif // Platform

157
bootstrap/unix-44/Reals.c Normal file
View file

@ -0,0 +1,157 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len);
export void Reals_Convert (REAL x, INT16 n, CHAR *d, ADDRESS d__len);
export void Reals_ConvertH (REAL y, CHAR *d, ADDRESS d__len);
export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len);
export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len);
export INT16 Reals_Expo (REAL x);
export INT16 Reals_ExpoL (LONGREAL x);
export void Reals_SetExpo (REAL *x, INT16 ex);
export REAL Reals_Ten (INT16 e);
export LONGREAL Reals_TenL (INT16 e);
static CHAR Reals_ToHex (INT16 i);
REAL Reals_Ten (INT16 e)
{
LONGREAL r, power;
r = (LONGREAL)1;
power = (LONGREAL)10;
while (e > 0) {
if (__ODD(e)) {
r = r * power;
}
power = power * power;
e = __ASHR(e, 1);
}
return r;
}
LONGREAL Reals_TenL (INT16 e)
{
LONGREAL r, power;
r = (LONGREAL)1;
power = (LONGREAL)10;
for (;;) {
if (__ODD(e)) {
r = r * power;
}
e = __ASHR(e, 1);
if (e <= 0) {
return r;
}
power = power * power;
}
__RETCHK;
}
INT16 Reals_Expo (REAL x)
{
INT16 i;
__GET((ADDRESS)&x + 2, i, INT16);
return __MASK(__ASHR(i, 7), -256);
}
void Reals_SetExpo (REAL *x, INT16 ex)
{
CHAR c;
__GET((ADDRESS)x + 3, c, CHAR);
__PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR);
__GET((ADDRESS)x + 2, c, CHAR);
__PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR);
}
INT16 Reals_ExpoL (LONGREAL x)
{
INT16 i;
__GET((ADDRESS)&x + 6, i, INT16);
return __MASK(__ASHR(i, 4), -2048);
}
void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len)
{
INT32 i, j, k;
if (x < (LONGREAL)0) {
x = -x;
}
k = 0;
if (n > 9) {
i = __SHORT(__ENTIER(x / (LONGREAL)(LONGREAL)1000000000), 2147483648LL);
j = __SHORT(__ENTIER(x - i * (LONGREAL)1000000000), 2147483648LL);
if (j < 0) {
j = 0;
}
while (k < 9) {
d[__X(k, d__len)] = __CHR((int)__MOD(j, 10) + 48);
j = __DIV(j, 10);
k += 1;
}
} else {
i = __SHORT(__ENTIER(x), 2147483648LL);
}
while (k < n) {
d[__X(k, d__len)] = __CHR((int)__MOD(i, 10) + 48);
i = __DIV(i, 10);
k += 1;
}
}
void Reals_Convert (REAL x, INT16 n, CHAR *d, ADDRESS d__len)
{
Reals_ConvertL(x, n, (void*)d, d__len);
}
static CHAR Reals_ToHex (INT16 i)
{
if (i < 10) {
return __CHR(i + 48);
} else {
return __CHR(i + 55);
}
__RETCHK;
}
static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len)
{
INT16 i;
INT32 l;
CHAR by;
i = 0;
l = b__len;
while (i < l) {
by = __VAL(CHAR, b[__X(i, b__len)]);
d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4));
d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16));
i += 1;
}
}
void Reals_ConvertH (REAL y, CHAR *d, ADDRESS d__len)
{
Reals_BytesToHex((void*)&y, 4, (void*)d, d__len * 1);
}
void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len)
{
Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1);
}
export void *Reals__init(void)
{
__DEFMOD;
__REGMOD("Reals", 0);
/* BEGIN */
__ENDMOD;
}

23
bootstrap/unix-44/Reals.h Normal file
View file

@ -0,0 +1,23 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Reals__h
#define Reals__h
#include "SYSTEM.h"
import void Reals_Convert (REAL x, INT16 n, CHAR *d, ADDRESS d__len);
import void Reals_ConvertH (REAL y, CHAR *d, ADDRESS d__len);
import void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len);
import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len);
import INT16 Reals_Expo (REAL x);
import INT16 Reals_ExpoL (LONGREAL x);
import void Reals_SetExpo (REAL *x, INT16 ex);
import REAL Reals_Ten (INT16 e);
import LONGREAL Reals_TenL (INT16 e);
import void *Reals__init(void);
#endif // Reals

374
bootstrap/unix-44/Strings.c Normal file
View file

@ -0,0 +1,374 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Reals.h"
export void Strings_Append (CHAR *extra, ADDRESS extra__len, CHAR *dest, ADDRESS dest__len);
export void Strings_Cap (CHAR *s, ADDRESS s__len);
export void Strings_Delete (CHAR *s, ADDRESS s__len, INT16 pos, INT16 n);
export void Strings_Extract (CHAR *source, ADDRESS source__len, INT16 pos, INT16 n, CHAR *dest, ADDRESS dest__len);
export void Strings_Insert (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
export INT16 Strings_Length (CHAR *s, ADDRESS s__len);
export BOOLEAN Strings_Match (CHAR *string, ADDRESS string__len, CHAR *pattern, ADDRESS pattern__len);
export INT16 Strings_Pos (CHAR *pattern, ADDRESS pattern__len, CHAR *s, ADDRESS s__len, INT16 pos);
export void Strings_Replace (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
export void Strings_StrToLongReal (CHAR *s, ADDRESS s__len, LONGREAL *r);
export void Strings_StrToReal (CHAR *s, ADDRESS s__len, REAL *r);
INT16 Strings_Length (CHAR *s, ADDRESS s__len)
{
INT32 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
if (i <= 32767) {
__DEL(s);
return __SHORT(i, 32768);
} else {
__DEL(s);
return 32767;
}
__RETCHK;
}
void Strings_Append (CHAR *extra, ADDRESS extra__len, CHAR *dest, ADDRESS dest__len)
{
INT16 n1, n2, i;
__DUP(extra, extra__len, CHAR);
n1 = Strings_Length(dest, dest__len);
n2 = Strings_Length(extra, extra__len);
i = 0;
while ((i < n2 && (i + n1) < dest__len)) {
dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)];
i += 1;
}
if ((i + n1) < dest__len) {
dest[__X(i + n1, dest__len)] = 0x00;
}
__DEL(extra);
}
void Strings_Insert (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len)
{
INT16 n1, n2, i;
__DUP(source, source__len, CHAR);
n1 = Strings_Length(dest, dest__len);
n2 = Strings_Length(source, source__len);
if (pos < 0) {
pos = 0;
}
if (pos > n1) {
Strings_Append(dest, dest__len, (void*)source, source__len);
__DEL(source);
return;
}
if ((pos + n2) < dest__len) {
i = n1;
while (i >= pos) {
if ((i + n2) < dest__len) {
dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)];
}
i -= 1;
}
}
i = 0;
while (i < n2) {
dest[__X(pos + i, dest__len)] = source[__X(i, source__len)];
i += 1;
}
__DEL(source);
}
void Strings_Delete (CHAR *s, ADDRESS s__len, INT16 pos, INT16 n)
{
INT16 len, i;
len = Strings_Length(s, s__len);
if (pos < 0) {
pos = 0;
} else if (pos >= len) {
return;
}
if (pos + n < len) {
i = pos + n;
while (i < len) {
s[__X(i - n, s__len)] = s[__X(i, s__len)];
i += 1;
}
if ((i - n) < s__len) {
s[__X(i - n, s__len)] = 0x00;
}
} else {
s[__X(pos, s__len)] = 0x00;
}
}
void Strings_Replace (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len)
{
__DUP(source, source__len, CHAR);
Strings_Delete((void*)dest, dest__len, pos, pos + Strings_Length(source, source__len));
Strings_Insert(source, source__len, pos, (void*)dest, dest__len);
__DEL(source);
}
void Strings_Extract (CHAR *source, ADDRESS source__len, INT16 pos, INT16 n, CHAR *dest, ADDRESS dest__len)
{
INT16 len, destLen, i;
__DUP(source, source__len, CHAR);
len = Strings_Length(source, source__len);
destLen = __SHORT(dest__len, 32768) - 1;
if (pos < 0) {
pos = 0;
}
if (pos >= len) {
dest[0] = 0x00;
__DEL(source);
return;
}
i = 0;
while (((((pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) {
if (i < destLen) {
dest[__X(i, dest__len)] = source[__X(pos + i, source__len)];
}
i += 1;
}
dest[__X(i, dest__len)] = 0x00;
__DEL(source);
}
INT16 Strings_Pos (CHAR *pattern, ADDRESS pattern__len, CHAR *s, ADDRESS s__len, INT16 pos)
{
INT16 n1, n2, i, j;
__DUP(pattern, pattern__len, CHAR);
__DUP(s, s__len, CHAR);
n1 = Strings_Length(s, s__len);
n2 = Strings_Length(pattern, pattern__len);
if (n2 == 0) {
__DEL(pattern);
__DEL(s);
return 0;
}
i = pos;
while (i <= n1 - n2) {
if (s[__X(i, s__len)] == pattern[0]) {
j = 1;
while ((j < n2 && s[__X(i + j, s__len)] == pattern[__X(j, pattern__len)])) {
j += 1;
}
if (j == n2) {
__DEL(pattern);
__DEL(s);
return i;
}
}
i += 1;
}
__DEL(pattern);
__DEL(s);
return -1;
}
void Strings_Cap (CHAR *s, ADDRESS s__len)
{
INT16 i;
i = 0;
while (s[__X(i, s__len)] != 0x00) {
if (('a' <= s[__X(i, s__len)] && s[__X(i, s__len)] <= 'z')) {
s[__X(i, s__len)] = __CAP(s[__X(i, s__len)]);
}
i += 1;
}
}
static struct Match__7 {
struct Match__7 *lnk;
} *Match__7_s;
static BOOLEAN M__8 (CHAR *name, ADDRESS name__len, CHAR *mask, ADDRESS mask__len, INT16 n, INT16 m);
static BOOLEAN M__8 (CHAR *name, ADDRESS name__len, CHAR *mask, ADDRESS mask__len, INT16 n, INT16 m)
{
while ((((n >= 0 && m >= 0)) && mask[__X(m, mask__len)] != '*')) {
if (name[__X(n, name__len)] != mask[__X(m, mask__len)]) {
return 0;
}
n -= 1;
m -= 1;
}
if (m < 0) {
return n < 0;
}
while ((m >= 0 && mask[__X(m, mask__len)] == '*')) {
m -= 1;
}
if (m < 0) {
return 1;
}
while (n >= 0) {
if (M__8(name, name__len, mask, mask__len, n, m)) {
return 1;
}
n -= 1;
}
return 0;
}
BOOLEAN Strings_Match (CHAR *string, ADDRESS string__len, CHAR *pattern, ADDRESS pattern__len)
{
struct Match__7 _s;
BOOLEAN __retval;
__DUP(string, string__len, CHAR);
__DUP(pattern, pattern__len, CHAR);
_s.lnk = Match__7_s;
Match__7_s = &_s;
__retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1);
Match__7_s = _s.lnk;
__DEL(string);
__DEL(pattern);
;
return __retval;
}
void Strings_StrToReal (CHAR *s, ADDRESS s__len, REAL *r)
{
INT16 p, e;
REAL y, g;
BOOLEAN neg, negE;
__DUP(s, s__len, CHAR);
p = 0;
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
if (s[__X(p, s__len)] == '-') {
neg = 1;
p += 1;
} else {
neg = 0;
}
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
y = (REAL)0;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
y = y * (REAL)10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (s[__X(p, s__len)] == '.') {
p += 1;
g = (REAL)1;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
g = g / (REAL)(REAL)10;
y = y + g * ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
}
if (s[__X(p, s__len)] == 'D' || s[__X(p, s__len)] == 'E') {
p += 1;
e = 0;
if (s[__X(p, s__len)] == '-') {
negE = 1;
p += 1;
} else {
negE = 0;
}
while (s[__X(p, s__len)] == '0') {
p += 1;
}
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
e = e * 10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (negE) {
y = y / (REAL)Reals_Ten(e);
} else {
y = y * Reals_Ten(e);
}
}
if (neg) {
y = -y;
}
*r = y;
__DEL(s);
}
void Strings_StrToLongReal (CHAR *s, ADDRESS s__len, LONGREAL *r)
{
INT16 p, e;
LONGREAL y, g;
BOOLEAN neg, negE;
__DUP(s, s__len, CHAR);
p = 0;
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
if (s[__X(p, s__len)] == '-') {
neg = 1;
p += 1;
} else {
neg = 0;
}
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
y = (LONGREAL)0;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
y = y * (LONGREAL)10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (s[__X(p, s__len)] == '.') {
p += 1;
g = (LONGREAL)1;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
g = g / (LONGREAL)(LONGREAL)10;
y = y + g * ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
}
if (s[__X(p, s__len)] == 'D' || s[__X(p, s__len)] == 'E') {
p += 1;
e = 0;
if (s[__X(p, s__len)] == '-') {
negE = 1;
p += 1;
} else {
negE = 0;
}
while (s[__X(p, s__len)] == '0') {
p += 1;
}
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
e = e * 10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (negE) {
y = y / (LONGREAL)Reals_Ten(e);
} else {
y = y * Reals_Ten(e);
}
}
if (neg) {
y = -y;
}
*r = y;
__DEL(s);
}
export void *Strings__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Reals);
__REGMOD("Strings", 0);
/* BEGIN */
__ENDMOD;
}

View file

@ -0,0 +1,25 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Strings__h
#define Strings__h
#include "SYSTEM.h"
import void Strings_Append (CHAR *extra, ADDRESS extra__len, CHAR *dest, ADDRESS dest__len);
import void Strings_Cap (CHAR *s, ADDRESS s__len);
import void Strings_Delete (CHAR *s, ADDRESS s__len, INT16 pos, INT16 n);
import void Strings_Extract (CHAR *source, ADDRESS source__len, INT16 pos, INT16 n, CHAR *dest, ADDRESS dest__len);
import void Strings_Insert (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
import INT16 Strings_Length (CHAR *s, ADDRESS s__len);
import BOOLEAN Strings_Match (CHAR *string, ADDRESS string__len, CHAR *pattern, ADDRESS pattern__len);
import INT16 Strings_Pos (CHAR *pattern, ADDRESS pattern__len, CHAR *s, ADDRESS s__len, INT16 pos);
import void Strings_Replace (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
import void Strings_StrToLongReal (CHAR *s, ADDRESS s__len, LONGREAL *r);
import void Strings_StrToReal (CHAR *s, ADDRESS s__len, REAL *r);
import void *Strings__init(void);
#endif // Strings

1833
bootstrap/unix-44/Texts.c Normal file

File diff suppressed because it is too large Load diff

172
bootstrap/unix-44/Texts.h Normal file
View file

@ -0,0 +1,172 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Texts__h
#define Texts__h
#include "SYSTEM.h"
#include "Files.h"
typedef
struct Texts_BufDesc {
INT32 len;
char _prvt0[4];
} Texts_BufDesc;
typedef
Texts_BufDesc *Texts_Buffer;
typedef
struct Texts_ElemMsg {
char _prvt0[1];
} Texts_ElemMsg;
typedef
struct Texts_ElemDesc *Texts_Elem;
typedef
struct Texts_CopyMsg { /* Texts_ElemMsg */
Texts_Elem e;
} Texts_CopyMsg;
typedef
struct Texts_RunDesc {
INT32 _prvt0;
char _prvt1[15];
} Texts_RunDesc;
typedef
void (*Texts_Handler)(Texts_Elem, Texts_ElemMsg*, ADDRESS *);
typedef
struct Texts_ElemDesc {
char _prvt0[20];
INT32 W, H;
Texts_Handler handle;
char _prvt1[4];
} Texts_ElemDesc;
typedef
struct Texts_FileMsg { /* Texts_ElemMsg */
INT16 id;
INT32 pos;
Files_Rider r;
} Texts_FileMsg;
typedef
struct Texts_FontDesc {
char _prvt0[32];
} Texts_FontDesc;
typedef
Texts_FontDesc *Texts_FontsFont;
typedef
struct Texts_IdentifyMsg { /* Texts_ElemMsg */
CHAR mod[32], proc[32];
} Texts_IdentifyMsg;
typedef
struct Texts_TextDesc *Texts_Text;
typedef
void (*Texts_Notifier)(Texts_Text, INT16, INT32, INT32);
typedef
struct Texts_Reader {
BOOLEAN eot;
Texts_FontsFont fnt;
INT8 col, voff;
Texts_Elem elem;
char _prvt0[32];
} Texts_Reader;
typedef
struct Texts_Scanner { /* Texts_Reader */
BOOLEAN eot;
Texts_FontsFont fnt;
INT8 col, voff;
Texts_Elem elem;
char _prvt0[32];
CHAR nextCh;
INT16 line, class;
INT32 i;
REAL x;
LONGREAL y;
CHAR c;
INT8 len;
CHAR s[64];
} Texts_Scanner;
typedef
struct Texts_TextDesc {
INT32 len;
Texts_Notifier notify;
char _prvt0[12];
} Texts_TextDesc;
typedef
struct Texts_Writer {
Texts_Buffer buf;
Texts_FontsFont fnt;
INT8 col, voff;
char _prvt0[26];
} Texts_Writer;
import Texts_Elem Texts_new;
import ADDRESS *Texts_FontDesc__typ;
import ADDRESS *Texts_RunDesc__typ;
import ADDRESS *Texts_ElemMsg__typ;
import ADDRESS *Texts_ElemDesc__typ;
import ADDRESS *Texts_FileMsg__typ;
import ADDRESS *Texts_CopyMsg__typ;
import ADDRESS *Texts_IdentifyMsg__typ;
import ADDRESS *Texts_BufDesc__typ;
import ADDRESS *Texts_TextDesc__typ;
import ADDRESS *Texts_Reader__typ;
import ADDRESS *Texts_Scanner__typ;
import ADDRESS *Texts_Writer__typ;
import void Texts_Append (Texts_Text T, Texts_Buffer B);
import void Texts_ChangeLooks (Texts_Text T, INT32 beg, INT32 end, UINT32 sel, Texts_FontsFont fnt, INT8 col, INT8 voff);
import void Texts_Close (Texts_Text T, CHAR *name, ADDRESS name__len);
import void Texts_Copy (Texts_Buffer SB, Texts_Buffer DB);
import void Texts_CopyElem (Texts_Elem SE, Texts_Elem DE);
import void Texts_Delete (Texts_Text T, INT32 beg, INT32 end);
import Texts_Text Texts_ElemBase (Texts_Elem E);
import INT32 Texts_ElemPos (Texts_Elem E);
import void Texts_Insert (Texts_Text T, INT32 pos, Texts_Buffer B);
import void Texts_Load (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
import void Texts_Open (Texts_Text T, CHAR *name, ADDRESS name__len);
import void Texts_OpenBuf (Texts_Buffer B);
import void Texts_OpenReader (Texts_Reader *R, ADDRESS *R__typ, Texts_Text T, INT32 pos);
import void Texts_OpenScanner (Texts_Scanner *S, ADDRESS *S__typ, Texts_Text T, INT32 pos);
import void Texts_OpenWriter (Texts_Writer *W, ADDRESS *W__typ);
import INT32 Texts_Pos (Texts_Reader *R, ADDRESS *R__typ);
import void Texts_Read (Texts_Reader *R, ADDRESS *R__typ, CHAR *ch);
import void Texts_ReadElem (Texts_Reader *R, ADDRESS *R__typ);
import void Texts_ReadPrevElem (Texts_Reader *R, ADDRESS *R__typ);
import void Texts_Recall (Texts_Buffer *B);
import void Texts_Save (Texts_Text T, INT32 beg, INT32 end, Texts_Buffer B);
import void Texts_Scan (Texts_Scanner *S, ADDRESS *S__typ);
import void Texts_SetColor (Texts_Writer *W, ADDRESS *W__typ, INT8 col);
import void Texts_SetFont (Texts_Writer *W, ADDRESS *W__typ, Texts_FontsFont fnt);
import void Texts_SetOffset (Texts_Writer *W, ADDRESS *W__typ, INT8 voff);
import void Texts_Store (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
import void Texts_Write (Texts_Writer *W, ADDRESS *W__typ, CHAR ch);
import void Texts_WriteDate (Texts_Writer *W, ADDRESS *W__typ, INT32 t, INT32 d);
import void Texts_WriteElem (Texts_Writer *W, ADDRESS *W__typ, Texts_Elem e);
import void Texts_WriteHex (Texts_Writer *W, ADDRESS *W__typ, INT32 x);
import void Texts_WriteInt (Texts_Writer *W, ADDRESS *W__typ, INT64 x, INT64 n);
import void Texts_WriteLn (Texts_Writer *W, ADDRESS *W__typ);
import void Texts_WriteLongReal (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x, INT16 n);
import void Texts_WriteLongRealHex (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x);
import void Texts_WriteReal (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n);
import void Texts_WriteRealFix (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n, INT16 k);
import void Texts_WriteRealHex (Texts_Writer *W, ADDRESS *W__typ, REAL x);
import void Texts_WriteString (Texts_Writer *W, ADDRESS *W__typ, CHAR *s, ADDRESS s__len);
import void *Texts__init(void);
#endif // Texts

275
bootstrap/unix-44/VT100.c Normal file
View file

@ -0,0 +1,275 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Out.h"
#include "Strings.h"
export CHAR VT100_CSI[5];
static CHAR VT100_tmpstr[32];
export void VT100_CHA (INT16 n);
export void VT100_CNL (INT16 n);
export void VT100_CPL (INT16 n);
export void VT100_CUB (INT16 n);
export void VT100_CUD (INT16 n);
export void VT100_CUF (INT16 n);
export void VT100_CUP (INT16 n, INT16 m);
export void VT100_CUU (INT16 n);
export void VT100_DECTCEMh (void);
export void VT100_DECTCEMl (void);
export void VT100_DSR (INT16 n);
export void VT100_ED (INT16 n);
export void VT100_EL (INT16 n);
static void VT100_EscSeq (INT16 n, CHAR *letter, ADDRESS letter__len);
static void VT100_EscSeq0 (CHAR *letter, ADDRESS letter__len);
static void VT100_EscSeq2 (INT16 n, INT16 m, CHAR *letter, ADDRESS letter__len);
static void VT100_EscSeqSwapped (INT16 n, CHAR *letter, ADDRESS letter__len);
export void VT100_HVP (INT16 n, INT16 m);
export void VT100_IntToStr (INT32 int_, CHAR *str, ADDRESS str__len);
export void VT100_RCP (void);
export void VT100_Reset (void);
static void VT100_Reverse0 (CHAR *str, ADDRESS str__len, INT16 start, INT16 end);
export void VT100_SCP (void);
export void VT100_SD (INT16 n);
export void VT100_SGR (INT16 n);
export void VT100_SGR2 (INT16 n, INT16 m);
export void VT100_SU (INT16 n);
export void VT100_SetAttr (CHAR *attr, ADDRESS attr__len);
static void VT100_Reverse0 (CHAR *str, ADDRESS str__len, INT16 start, INT16 end)
{
CHAR h;
while (start < end) {
h = str[__X(start, str__len)];
str[__X(start, str__len)] = str[__X(end, str__len)];
str[__X(end, str__len)] = h;
start += 1;
end -= 1;
}
}
void VT100_IntToStr (INT32 int_, CHAR *str, ADDRESS str__len)
{
CHAR b[21];
INT16 s, e;
INT8 maxLength;
maxLength = 11;
if (int_ == (-2147483647-1)) {
__MOVE("-2147483648", b, 12);
e = 11;
} else {
if (int_ < 0) {
b[0] = '-';
int_ = -int_;
s = 1;
} else {
s = 0;
}
e = s;
do {
b[__X(e, 21)] = __CHR((int)__MOD(int_, 10) + 48);
int_ = __DIV(int_, 10);
e += 1;
} while (!(int_ == 0));
b[__X(e, 21)] = 0x00;
VT100_Reverse0((void*)b, 21, s, e - 1);
}
__COPY(b, str, str__len);
}
static void VT100_EscSeq0 (CHAR *letter, ADDRESS letter__len)
{
CHAR cmd[9];
__DUP(letter, letter__len, CHAR);
__COPY(VT100_CSI, cmd, 9);
Strings_Append(letter, letter__len, (void*)cmd, 9);
Out_String(cmd, 9);
__DEL(letter);
}
static void VT100_EscSeq (INT16 n, CHAR *letter, ADDRESS letter__len)
{
CHAR nstr[2];
CHAR cmd[7];
__DUP(letter, letter__len, CHAR);
VT100_IntToStr(n, (void*)nstr, 2);
__COPY(VT100_CSI, cmd, 7);
Strings_Append(nstr, 2, (void*)cmd, 7);
Strings_Append(letter, letter__len, (void*)cmd, 7);
Out_String(cmd, 7);
__DEL(letter);
}
static void VT100_EscSeqSwapped (INT16 n, CHAR *letter, ADDRESS letter__len)
{
CHAR nstr[2];
CHAR cmd[7];
__DUP(letter, letter__len, CHAR);
VT100_IntToStr(n, (void*)nstr, 2);
__COPY(VT100_CSI, cmd, 7);
Strings_Append(letter, letter__len, (void*)cmd, 7);
Strings_Append(nstr, 2, (void*)cmd, 7);
Out_String(cmd, 7);
__DEL(letter);
}
static void VT100_EscSeq2 (INT16 n, INT16 m, CHAR *letter, ADDRESS letter__len)
{
CHAR nstr[5], mstr[5];
CHAR cmd[12];
__DUP(letter, letter__len, CHAR);
VT100_IntToStr(n, (void*)nstr, 5);
VT100_IntToStr(m, (void*)mstr, 5);
__COPY(VT100_CSI, cmd, 12);
Strings_Append(nstr, 5, (void*)cmd, 12);
Strings_Append((CHAR*)";", 2, (void*)cmd, 12);
Strings_Append(mstr, 5, (void*)cmd, 12);
Strings_Append(letter, letter__len, (void*)cmd, 12);
Out_String(cmd, 12);
__DEL(letter);
}
void VT100_Reset (void)
{
CHAR cmd[6];
__COPY("\033", cmd, 6);
Strings_Append((CHAR*)"c", 2, (void*)cmd, 6);
Out_String(cmd, 6);
Out_Ln();
}
void VT100_CUU (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"A", 2);
}
void VT100_CUD (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"B", 2);
}
void VT100_CUF (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"C", 2);
}
void VT100_CUB (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"D", 2);
}
void VT100_CNL (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"E", 2);
}
void VT100_CPL (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"F", 2);
}
void VT100_CHA (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"G", 2);
}
void VT100_CUP (INT16 n, INT16 m)
{
VT100_EscSeq2(n, m, (CHAR*)"H", 2);
}
void VT100_ED (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"J", 2);
}
void VT100_EL (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"K", 2);
}
void VT100_SU (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"S", 2);
}
void VT100_SD (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"T", 2);
}
void VT100_HVP (INT16 n, INT16 m)
{
VT100_EscSeq2(n, m, (CHAR*)"f", 2);
}
void VT100_SGR (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"m", 2);
}
void VT100_SGR2 (INT16 n, INT16 m)
{
VT100_EscSeq2(n, m, (CHAR*)"m", 2);
}
void VT100_DSR (INT16 n)
{
VT100_EscSeq(6, (CHAR*)"n", 2);
}
void VT100_SCP (void)
{
VT100_EscSeq0((CHAR*)"s", 2);
}
void VT100_RCP (void)
{
VT100_EscSeq0((CHAR*)"u", 2);
}
void VT100_DECTCEMl (void)
{
VT100_EscSeq0((CHAR*)"\?25l", 5);
}
void VT100_DECTCEMh (void)
{
VT100_EscSeq0((CHAR*)"\?25h", 5);
}
void VT100_SetAttr (CHAR *attr, ADDRESS attr__len)
{
CHAR tmpstr[16];
__DUP(attr, attr__len, CHAR);
__COPY(VT100_CSI, tmpstr, 16);
Strings_Append(attr, attr__len, (void*)tmpstr, 16);
Out_String(tmpstr, 16);
__DEL(attr);
}
export void *VT100__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Out);
__MODULE_IMPORT(Strings);
__REGMOD("VT100", 0);
__REGCMD("DECTCEMh", VT100_DECTCEMh);
__REGCMD("DECTCEMl", VT100_DECTCEMl);
__REGCMD("RCP", VT100_RCP);
__REGCMD("Reset", VT100_Reset);
__REGCMD("SCP", VT100_SCP);
/* BEGIN */
__COPY("\033", VT100_CSI, 5);
Strings_Append((CHAR*)"[", 2, (void*)VT100_CSI, 5);
__ENDMOD;
}

38
bootstrap/unix-44/VT100.h Normal file
View file

@ -0,0 +1,38 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef VT100__h
#define VT100__h
#include "SYSTEM.h"
import CHAR VT100_CSI[5];
import void VT100_CHA (INT16 n);
import void VT100_CNL (INT16 n);
import void VT100_CPL (INT16 n);
import void VT100_CUB (INT16 n);
import void VT100_CUD (INT16 n);
import void VT100_CUF (INT16 n);
import void VT100_CUP (INT16 n, INT16 m);
import void VT100_CUU (INT16 n);
import void VT100_DECTCEMh (void);
import void VT100_DECTCEMl (void);
import void VT100_DSR (INT16 n);
import void VT100_ED (INT16 n);
import void VT100_EL (INT16 n);
import void VT100_HVP (INT16 n, INT16 m);
import void VT100_IntToStr (INT32 int_, CHAR *str, ADDRESS str__len);
import void VT100_RCP (void);
import void VT100_Reset (void);
import void VT100_SCP (void);
import void VT100_SD (INT16 n);
import void VT100_SGR (INT16 n);
import void VT100_SGR2 (INT16 n, INT16 m);
import void VT100_SU (INT16 n);
import void VT100_SetAttr (CHAR *attr, ADDRESS attr__len);
import void *VT100__init(void);
#endif // VT100

View file

@ -0,0 +1,139 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Configuration.h"
#include "Heap.h"
#include "Modules.h"
#include "OPM.h"
#include "Out.h"
#include "Platform.h"
#include "Strings.h"
typedef
CHAR extTools_CommandString[4096];
static extTools_CommandString extTools_CFLAGS;
export void extTools_Assemble (CHAR *moduleName, ADDRESS moduleName__len);
static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len);
export void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN statically, CHAR *additionalopts, ADDRESS additionalopts__len);
static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRESS cmd__len);
static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRESS cmd__len)
{
INT16 r, status, exitcode;
extTools_CommandString fullcmd;
__DUP(title, title__len, CHAR);
__DUP(cmd, cmd__len, CHAR);
if (__IN(18, OPM_Options, 32)) {
Out_String((CHAR*)" ", 3);
Out_String(cmd, cmd__len);
Out_Ln();
}
__COPY(cmd, fullcmd, 4096);
Heap_GC(0);
r = Platform_System(fullcmd, 4096);
status = __MASK(r, -128);
exitcode = __ASHR(r, 8);
if (exitcode > 127) {
exitcode = exitcode - 256;
}
if (r != 0) {
Out_String(title, title__len);
Out_String(cmd, cmd__len);
Out_Ln();
Out_String((CHAR*)"-- failed: status ", 19);
Out_Int(status, 1);
Out_String((CHAR*)", exitcode ", 12);
Out_Int(exitcode, 1);
Out_String((CHAR*)".", 2);
Out_Ln();
if ((status == 0 && exitcode == 127)) {
Out_String((CHAR*)"Is the C compiler in the current command path\?", 47);
Out_Ln();
}
if (status != 0) {
Modules_Halt(status);
} else {
Modules_Halt(exitcode);
}
}
__DEL(title);
__DEL(cmd);
}
static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len)
{
__DUP(additionalopts, additionalopts__len, CHAR);
__COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len);
Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len);
Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len);
Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len);
Strings_Append(additionalopts, additionalopts__len, (void*)s, s__len);
Strings_Append((CHAR*)" ", 2, (void*)s, s__len);
Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 4096);
Strings_Append(extTools_CFLAGS, 4096, (void*)s, s__len);
Strings_Append((CHAR*)" ", 2, (void*)s, s__len);
__DEL(additionalopts);
}
void extTools_Assemble (CHAR *moduleName, ADDRESS moduleName__len)
{
extTools_CommandString cmd;
__DUP(moduleName, moduleName__len, CHAR);
extTools_InitialiseCompilerCommand((void*)cmd, 4096, (CHAR*)"", 1);
Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 4096);
Strings_Append(moduleName, moduleName__len, (void*)cmd, 4096);
Strings_Append((CHAR*)".c", 3, (void*)cmd, 4096);
extTools_execute((CHAR*)"C compile: ", 12, cmd, 4096);
__DEL(moduleName);
}
void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN statically, CHAR *additionalopts, ADDRESS additionalopts__len)
{
extTools_CommandString cmd;
__DUP(additionalopts, additionalopts__len, CHAR);
extTools_InitialiseCompilerCommand((void*)cmd, 4096, additionalopts, additionalopts__len);
Strings_Append(moduleName, moduleName__len, (void*)cmd, 4096);
Strings_Append((CHAR*)".c ", 4, (void*)cmd, 4096);
if (statically) {
Strings_Append((CHAR*)" -static", 9, (void*)cmd, 4096);
}
Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 4096);
Strings_Append(moduleName, moduleName__len, (void*)cmd, 4096);
if (!statically || 1) {
Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 4096);
Strings_Append(OPM_InstallDir, 1024, (void*)cmd, 4096);
Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 4096);
Strings_Append((CHAR*)" -lvoc", 7, (void*)cmd, 4096);
Strings_Append((CHAR*)"-O", 3, (void*)cmd, 4096);
Strings_Append(OPM_Model, 10, (void*)cmd, 4096);
Strings_Append((CHAR*)"", 1, (void*)cmd, 4096);
}
extTools_execute((CHAR*)"C compile and link: ", 21, cmd, 4096);
__DEL(additionalopts);
}
export void *extTools__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Configuration);
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Modules);
__MODULE_IMPORT(OPM);
__MODULE_IMPORT(Out);
__MODULE_IMPORT(Platform);
__MODULE_IMPORT(Strings);
__REGMOD("extTools", 0);
/* BEGIN */
__ENDMOD;
}

View file

@ -0,0 +1,16 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef extTools__h
#define extTools__h
#include "SYSTEM.h"
import void extTools_Assemble (CHAR *moduleName, ADDRESS moduleName__len);
import void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN statically, CHAR *additionalopts, ADDRESS additionalopts__len);
import void *extTools__init(void);
#endif // extTools

View file

@ -0,0 +1,213 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Configuration.h"
#include "Heap.h"
#include "OPB.h"
#include "OPC.h"
#include "OPM.h"
#include "OPP.h"
#include "OPT.h"
#include "OPV.h"
#include "Platform.h"
#include "Strings.h"
#include "VT100.h"
#include "extTools.h"
static void Compiler_FindLocalObjectFiles (CHAR *objectnames, ADDRESS objectnames__len);
export void Compiler_Module (BOOLEAN *done);
static void Compiler_PropagateElementaryTypeSizes (void);
export void Compiler_Translate (void);
static void Compiler_Trap (INT32 sig);
void Compiler_Module (BOOLEAN *done)
{
BOOLEAN ext, new;
OPT_Node p = NIL;
OPP_Module(&p, OPM_Options);
if (OPM_noerr) {
OPV_Init();
OPT_InitRecno();
OPV_AdrAndSize(OPT_topScope);
OPT_Export(&ext, &new);
if (OPM_noerr) {
OPM_OpenFiles((void*)OPT_SelfName, 256);
OPM_DeleteObj((void*)OPT_SelfName, 256);
OPC_Init();
OPV_Module(p);
if (OPM_noerr) {
if ((__IN(10, OPM_Options, 32) && __STRCMP(OPM_modName, "SYSTEM") != 0)) {
OPM_DeleteSym((void*)OPT_SelfName, 256);
OPM_LogVT100((CHAR*)"32m", 4);
OPM_LogWStr((CHAR*)" Main program.", 16);
OPM_LogVT100((CHAR*)"0m", 3);
} else {
if (new) {
OPM_LogVT100((CHAR*)"32m", 4);
OPM_LogWStr((CHAR*)" New symbol file.", 19);
OPM_LogVT100((CHAR*)"0m", 3);
OPM_RegisterNewSym();
} else if (ext) {
OPM_LogWStr((CHAR*)" Extended symbol file.", 24);
OPM_RegisterNewSym();
}
}
} else {
OPM_DeleteSym((void*)OPT_SelfName, 256);
}
}
}
OPM_CloseFiles();
OPT_Close();
OPM_LogWLn();
*done = OPM_noerr;
}
static void Compiler_PropagateElementaryTypeSizes (void)
{
OPT_Struct adrinttyp = NIL;
OPT_sysptrtyp->size = OPM_AddressSize;
OPT_sysptrtyp->idfp = OPT_sysptrtyp->form;
OPM_FPrint(&OPT_sysptrtyp->idfp, OPT_sysptrtyp->size);
OPT_adrtyp->size = OPM_AddressSize;
OPT_adrtyp->idfp = OPT_adrtyp->form;
OPM_FPrint(&OPT_adrtyp->idfp, OPT_adrtyp->size);
adrinttyp = OPT_IntType(OPM_AddressSize);
OPT_adrtyp->strobj = adrinttyp->strobj;
OPT_sinttyp = OPT_IntType(OPM_ShortintSize);
OPT_inttyp = OPT_IntType(OPM_IntegerSize);
OPT_linttyp = OPT_IntType(OPM_LongintSize);
OPT_sintobj->typ = OPT_sinttyp;
OPT_intobj->typ = OPT_inttyp;
OPT_lintobj->typ = OPT_linttyp;
switch (OPM_SetSize) {
case 4:
OPT_settyp = OPT_set32typ;
break;
default:
OPT_settyp = OPT_set64typ;
break;
}
OPT_setobj->typ = OPT_settyp;
if (__STRCMP(OPM_Model, "C") == 0) {
OPT_cpbytetyp->strobj->name[4] = 0x00;
} else {
OPT_cpbytetyp->strobj->name[4] = '@';
}
}
static void Compiler_FindLocalObjectFiles (CHAR *objectnames, ADDRESS objectnames__len)
{
OPT_Link l = NIL;
CHAR fn[64];
Platform_FileIdentity id;
objectnames[0] = 0x00;
l = OPT_Links;
while (l != NIL) {
__COPY(l->name, fn, 64);
Strings_Append((CHAR*)".sym", 5, (void*)fn, 64);
if (Platform_IdentifyByName(fn, 64, &id, Platform_FileIdentity__typ) == 0) {
__COPY(l->name, fn, 64);
Strings_Append((CHAR*)".o", 3, (void*)fn, 64);
if (Platform_IdentifyByName(fn, 64, &id, Platform_FileIdentity__typ) == 0) {
Strings_Append((CHAR*)" ", 2, (void*)objectnames, objectnames__len);
Strings_Append(fn, 64, (void*)objectnames, objectnames__len);
} else {
OPM_LogVT100((CHAR*)"91m", 4);
OPM_LogWStr((CHAR*)"Link warning: a local symbol file is present for module ", 57);
OPM_LogWStr(l->name, 256);
OPM_LogWStr((CHAR*)", but local object file '", 26);
OPM_LogWStr(fn, 64);
OPM_LogWStr((CHAR*)"' is missing.", 14);
OPM_LogVT100((CHAR*)"0m", 3);
OPM_LogWLn();
}
}
l = l->next;
}
}
void Compiler_Translate (void)
{
BOOLEAN done;
CHAR linkfiles[2048];
if (OPM_OpenPar()) {
for (;;) {
OPM_Init(&done);
if (!done) {
return;
}
OPM_InitOptions();
Compiler_PropagateElementaryTypeSizes();
Heap_GC(0);
Compiler_Module(&done);
if (!done) {
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Module compilation failed.", 27);
OPM_LogWLn();
Platform_Exit(1);
}
if (!__IN(13, OPM_Options, 32)) {
if (__IN(14, OPM_Options, 32)) {
extTools_Assemble(OPM_modName, 32);
} else {
if (!__IN(10, OPM_Options, 32)) {
extTools_Assemble(OPM_modName, 32);
} else {
Compiler_FindLocalObjectFiles((void*)linkfiles, 2048);
extTools_LinkMain((void*)OPM_modName, 32, __IN(15, OPM_Options, 32), linkfiles, 2048);
}
}
}
}
}
}
static void Compiler_Trap (INT32 sig)
{
Heap_FINALL();
if (sig == 3) {
Platform_Exit(0);
} else {
if (sig == 4) {
OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36);
OPM_LogWLn();
}
Platform_Exit(2);
}
}
export int main(int argc, char **argv)
{
__INIT(argc, argv);
__MODULE_IMPORT(Configuration);
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(OPB);
__MODULE_IMPORT(OPC);
__MODULE_IMPORT(OPM);
__MODULE_IMPORT(OPP);
__MODULE_IMPORT(OPT);
__MODULE_IMPORT(OPV);
__MODULE_IMPORT(Platform);
__MODULE_IMPORT(Strings);
__MODULE_IMPORT(VT100);
__MODULE_IMPORT(extTools);
__REGMAIN("Compiler", 0);
__REGCMD("Translate", Compiler_Translate);
/* BEGIN */
Platform_SetInterruptHandler(Compiler_Trap);
Platform_SetQuitHandler(Compiler_Trap);
Platform_SetBadInstructionHandler(Compiler_Trap);
Compiler_Translate();
__FINI;
}

View file

@ -0,0 +1,24 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
export CHAR Configuration_versionLong[76];
export void *Configuration__init(void)
{
__DEFMOD;
__REGMOD("Configuration", 0);
/* BEGIN */
__MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76);
__ENDMOD;
}

View file

@ -0,0 +1,15 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Configuration__h
#define Configuration__h
#include "SYSTEM.h"
import CHAR Configuration_versionLong[76];
import void *Configuration__init(void);
#endif // Configuration

1097
bootstrap/unix-48/Files.c Normal file

File diff suppressed because it is too large Load diff

70
bootstrap/unix-48/Files.h Normal file
View file

@ -0,0 +1,70 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Files__h
#define Files__h
#include "SYSTEM.h"
typedef
struct Files_FileDesc *Files_File;
typedef
struct Files_FileDesc {
INT32 _prvt0;
char _prvt1[560];
} Files_FileDesc;
typedef
struct Files_Rider {
INT32 res;
BOOLEAN eof;
char _prvt0[15];
} Files_Rider;
import INT16 Files_MaxPathLength, Files_MaxNameLength;
import ADDRESS *Files_FileDesc__typ;
import ADDRESS *Files_Rider__typ;
import Files_File Files_Base (Files_Rider *r, ADDRESS *r__typ);
import void Files_ChangeDirectory (CHAR *path, ADDRESS path__len, INT16 *res);
import void Files_Close (Files_File f);
import void Files_Delete (CHAR *name, ADDRESS name__len, INT16 *res);
import void Files_GetDate (Files_File f, INT32 *t, INT32 *d);
import void Files_GetName (Files_File f, CHAR *name, ADDRESS name__len);
import INT32 Files_Length (Files_File f);
import Files_File Files_New (CHAR *name, ADDRESS name__len);
import Files_File Files_Old (CHAR *name, ADDRESS name__len);
import INT32 Files_Pos (Files_Rider *r, ADDRESS *r__typ);
import void Files_Purge (Files_File f);
import void Files_Read (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x);
import void Files_ReadBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN *x);
import void Files_ReadByte (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x);
import void Files_ReadBytes (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x, ADDRESS x__len, INT32 n);
import void Files_ReadInt (Files_Rider *R, ADDRESS *R__typ, INT16 *x);
import void Files_ReadLInt (Files_Rider *R, ADDRESS *R__typ, INT32 *x);
import void Files_ReadLReal (Files_Rider *R, ADDRESS *R__typ, LONGREAL *x);
import void Files_ReadLine (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__len);
import void Files_ReadReal (Files_Rider *R, ADDRESS *R__typ, REAL *x);
import void Files_ReadSet (Files_Rider *R, ADDRESS *R__typ, UINT32 *x);
import void Files_ReadString (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void Files_Register (Files_File f);
import void Files_Rename (CHAR *old, ADDRESS old__len, CHAR *new, ADDRESS new__len, INT16 *res);
import void Files_Set (Files_Rider *r, ADDRESS *r__typ, Files_File f, INT32 pos);
import void Files_SetSearchPath (CHAR *path, ADDRESS path__len);
import void Files_Write (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE x);
import void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x);
import void Files_WriteBytes (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x, ADDRESS x__len, INT32 n);
import void Files_WriteInt (Files_Rider *R, ADDRESS *R__typ, INT16 x);
import void Files_WriteLInt (Files_Rider *R, ADDRESS *R__typ, INT32 x);
import void Files_WriteLReal (Files_Rider *R, ADDRESS *R__typ, LONGREAL x);
import void Files_WriteNum (Files_Rider *R, ADDRESS *R__typ, INT64 x);
import void Files_WriteReal (Files_Rider *R, ADDRESS *R__typ, REAL x);
import void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x);
import void Files_WriteString (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void *Files__init(void);
#endif // Files

799
bootstrap/unix-48/Heap.c Normal file
View file

@ -0,0 +1,799 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
struct Heap__1 {
CHAR ch;
SYSTEM_PTR p;
};
typedef
struct Heap_CmdDesc *Heap_Cmd;
typedef
CHAR Heap_CmdName[24];
typedef
void (*Heap_Command)(void);
typedef
struct Heap_CmdDesc {
Heap_Cmd next;
Heap_CmdName name;
Heap_Command cmd;
} Heap_CmdDesc;
typedef
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
typedef
struct Heap_FinDesc *Heap_FinNode;
typedef
void (*Heap_Finalizer)(SYSTEM_PTR);
typedef
struct Heap_FinDesc {
Heap_FinNode next;
INT32 obj;
BOOLEAN marked;
Heap_Finalizer finalize;
} Heap_FinDesc;
typedef
struct Heap_ModuleDesc *Heap_Module;
typedef
CHAR Heap_ModuleName[20];
typedef
struct Heap_ModuleDesc {
Heap_Module next;
Heap_ModuleName name;
INT32 refcnt;
Heap_Cmd cmds;
INT32 types;
Heap_EnumProc enumPtrs;
INT32 reserved1, reserved2;
} Heap_ModuleDesc;
export SYSTEM_PTR Heap_modules;
static INT32 Heap_freeList[10];
static INT32 Heap_bigBlocks;
export INT32 Heap_allocated;
static BOOLEAN Heap_firstTry;
static INT16 Heap_ldUnit;
export INT32 Heap_heap;
static INT32 Heap_heapMin, Heap_heapMax;
export INT32 Heap_heapsize, Heap_heapMinExpand;
static Heap_FinNode Heap_fin;
static INT16 Heap_lockdepth;
static BOOLEAN Heap_interrupted;
export INT16 Heap_FileCount;
export ADDRESS *Heap_ModuleDesc__typ;
export ADDRESS *Heap_CmdDesc__typ;
export ADDRESS *Heap_FinDesc__typ;
export ADDRESS *Heap__1__typ;
static void Heap_CheckFin (void);
static void Heap_ExtendHeap (INT32 blksz);
export void Heap_FINALL (void);
static void Heap_Finalize (void);
export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len);
export void Heap_GC (BOOLEAN markStack);
static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len);
export void Heap_INCREF (Heap_Module m);
export void Heap_InitHeap (void);
export void Heap_Lock (void);
static void Heap_Mark (INT32 q);
static void Heap_MarkCandidates (INT32 n, INT32 *cand, ADDRESS cand__len);
static void Heap_MarkP (SYSTEM_PTR p);
static void Heap_MarkStack (INT32 n, INT32 *cand, ADDRESS cand__len);
export SYSTEM_PTR Heap_NEWBLK (INT32 size);
export SYSTEM_PTR Heap_NEWREC (INT32 tag);
static INT32 Heap_NewChunk (INT32 blksz);
export void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
export void Heap_REGTYP (Heap_Module m, INT32 typ);
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
static void Heap_Scan (void);
static void Heap_Sift (INT32 l, INT32 r, INT32 *a, ADDRESS a__len);
export void Heap_Unlock (void);
extern void *Heap__init();
extern ADDRESS Modules_MainStackFrame;
extern ADDRESS Platform_OSAllocate(ADDRESS size);
#define Heap_HeapModuleInit() Heap__init()
#define Heap_ModulesHalt(code) Modules_Halt(code)
#define Heap_ModulesMainStackFrame() Modules_MainStackFrame
#define Heap_OSAllocate(size) Platform_OSAllocate(size)
#define Heap_uLE(x, y) ((size_t)x <= (size_t)y)
#define Heap_uLT(x, y) ((size_t)x < (size_t)y)
void Heap_Lock (void)
{
Heap_lockdepth += 1;
}
void Heap_Unlock (void)
{
Heap_lockdepth -= 1;
if ((Heap_interrupted && Heap_lockdepth == 0)) {
Heap_ModulesHalt(-9);
}
}
SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs)
{
Heap_Module m;
if (__STRCMP(name, "Heap") == 0) {
__SYSNEW(m, 48);
} else {
__NEW(m, Heap_ModuleDesc);
}
m->types = 0;
m->cmds = NIL;
__COPY(name, m->name, 20);
m->refcnt = 0;
m->enumPtrs = enumPtrs;
m->next = (Heap_Module)(ADDRESS)Heap_modules;
Heap_modules = (SYSTEM_PTR)m;
return (void*)m;
}
INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len)
{
Heap_Module m, p;
__DUP(name, name__len, CHAR);
m = (Heap_Module)(ADDRESS)Heap_modules;
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
p = m;
m = m->next;
}
if ((m != NIL && m->refcnt == 0)) {
if (m == (Heap_Module)(ADDRESS)Heap_modules) {
Heap_modules = (SYSTEM_PTR)m->next;
} else {
p->next = m->next;
}
__DEL(name);
return 0;
} else {
if (m == NIL) {
__DEL(name);
return -1;
} else {
__DEL(name);
return m->refcnt;
}
}
__RETCHK;
}
void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
{
Heap_Cmd c;
if (__STRCMP(m->name, "Heap") == 0) {
__SYSNEW(c, 32);
} else {
__NEW(c, Heap_CmdDesc);
}
__COPY(name, c->name, 24);
c->cmd = cmd;
c->next = m->cmds;
m->cmds = c;
}
void Heap_REGTYP (Heap_Module m, INT32 typ)
{
__PUT(typ, m->types, INT32);
m->types = typ;
}
void Heap_INCREF (Heap_Module m)
{
m->refcnt += 1;
}
static INT32 Heap_NewChunk (INT32 blksz)
{
INT32 chnk, blk, end;
chnk = Heap_OSAllocate(blksz + 12);
if (chnk != 0) {
blk = chnk + 12;
end = blk + blksz;
__PUT(chnk + 4, end, INT32);
__PUT(blk, blk + 4, INT32);
__PUT(blk + 4, blksz, INT32);
__PUT(blk + 8, -4, INT32);
__PUT(blk + 12, Heap_bigBlocks, INT32);
Heap_bigBlocks = blk;
Heap_heapsize += blksz;
if (Heap_uLT(blk + 4, Heap_heapMin)) {
Heap_heapMin = blk + 4;
}
if (Heap_uLT(Heap_heapMax, end)) {
Heap_heapMax = end;
}
}
return chnk;
}
static void Heap_ExtendHeap (INT32 blksz)
{
INT32 size, chnk, j, next;
if (Heap_uLT(Heap_heapMinExpand, blksz)) {
size = blksz;
} else {
size = Heap_heapMinExpand;
}
chnk = Heap_NewChunk(size);
if (chnk != 0) {
if (Heap_uLT(chnk, Heap_heap)) {
__PUT(chnk, Heap_heap, INT32);
Heap_heap = chnk;
} else {
j = Heap_heap;
__GET(j, next, INT32);
while ((next != 0 && Heap_uLT(next, chnk))) {
j = next;
__GET(j, next, INT32);
}
__PUT(chnk, next, INT32);
__PUT(j, chnk, INT32);
}
} else if (!Heap_firstTry) {
Heap_heapMinExpand = 16;
}
}
SYSTEM_PTR Heap_NEWREC (INT32 tag)
{
INT32 i, i0, di, blksz, restsize, t, adr, end, next, prev;
SYSTEM_PTR new;
Heap_Lock();
__GET(tag, blksz, INT32);
i0 = __LSH(blksz, -Heap_ldUnit, 32);
i = i0;
if (i < 9) {
adr = Heap_freeList[i];
while (adr == 0) {
i += 1;
adr = Heap_freeList[i];
}
}
if (i < 9) {
__GET(adr + 12, next, INT32);
Heap_freeList[i] = next;
if (i != i0) {
di = i - i0;
restsize = __ASHL(di, 4);
end = adr + restsize;
__PUT(end + 4, blksz, INT32);
__PUT(end + 8, -4, INT32);
__PUT(end, end + 4, INT32);
__PUT(adr + 4, restsize, INT32);
__PUT(adr + 12, Heap_freeList[di], INT32);
Heap_freeList[di] = adr;
adr += restsize;
}
} else {
adr = Heap_bigBlocks;
prev = 0;
for (;;) {
if (adr == 0) {
if (Heap_firstTry) {
Heap_GC(1);
blksz += 16;
t = __LSH(Heap_allocated + blksz, -(2 + Heap_ldUnit), 32) * 80;
if (Heap_uLT(Heap_heapsize, t)) {
Heap_ExtendHeap(t - Heap_heapsize);
}
Heap_firstTry = 0;
new = Heap_NEWREC(tag);
if (new == NIL) {
Heap_ExtendHeap(blksz);
new = Heap_NEWREC(tag);
}
Heap_firstTry = 1;
Heap_Unlock();
return new;
} else {
Heap_Unlock();
return NIL;
}
}
__GET(adr + 4, t, INT32);
if (Heap_uLE(blksz, t)) {
break;
}
prev = adr;
__GET(adr + 12, adr, INT32);
}
restsize = t - blksz;
end = adr + restsize;
__PUT(end + 4, blksz, INT32);
__PUT(end + 8, -4, INT32);
__PUT(end, end + 4, INT32);
if (Heap_uLT(144, restsize)) {
__PUT(adr + 4, restsize, INT32);
} else {
__GET(adr + 12, next, INT32);
if (prev == 0) {
Heap_bigBlocks = next;
} else {
__PUT(prev + 12, next, INT32);
}
if (restsize != 0) {
di = __ASHR(restsize, 4);
__PUT(adr + 4, restsize, INT32);
__PUT(adr + 12, Heap_freeList[di], INT32);
Heap_freeList[di] = adr;
}
}
adr += restsize;
}
i = adr + 16;
end = adr + blksz;
while (Heap_uLT(i, end)) {
__PUT(i, 0, INT32);
__PUT(i + 4, 0, INT32);
__PUT(i + 8, 0, INT32);
__PUT(i + 12, 0, INT32);
i += 16;
}
__PUT(adr + 12, 0, INT32);
__PUT(adr, tag, INT32);
__PUT(adr + 4, 0, INT32);
__PUT(adr + 8, 0, INT32);
Heap_allocated += blksz;
Heap_Unlock();
return (SYSTEM_PTR)(ADDRESS)(adr + 4);
}
SYSTEM_PTR Heap_NEWBLK (INT32 size)
{
INT32 blksz, tag;
SYSTEM_PTR new;
Heap_Lock();
blksz = __ASHL(__ASHR(size + 31, 4), 4);
new = Heap_NEWREC((ADDRESS)&blksz);
tag = ((INT32)(ADDRESS)new + blksz) - 12;
__PUT(tag - 4, 0, INT32);
__PUT(tag, blksz, INT32);
__PUT(tag + 4, -4, INT32);
__PUT((INT32)(ADDRESS)new - 4, tag, INT32);
Heap_Unlock();
return new;
}
static void Heap_Mark (INT32 q)
{
INT32 p, tag, offset, fld, n, tagbits;
if (q != 0) {
__GET(q - 4, tagbits, INT32);
if (!__ODD(tagbits)) {
__PUT(q - 4, tagbits + 1, INT32);
p = 0;
tag = tagbits + 4;
for (;;) {
__GET(tag, offset, INT32);
if (offset < 0) {
__PUT(q - 4, (tag + offset) + 1, INT32);
if (p == 0) {
break;
}
n = q;
q = p;
__GET(q - 4, tag, INT32);
tag -= 1;
__GET(tag, offset, INT32);
fld = q + offset;
__GET(fld, p, INT32);
__PUT(fld, (SYSTEM_PTR)(ADDRESS)n, SYSTEM_PTR);
} else {
fld = q + offset;
__GET(fld, n, INT32);
if (n != 0) {
__GET(n - 4, tagbits, INT32);
if (!__ODD(tagbits)) {
__PUT(n - 4, tagbits + 1, INT32);
__PUT(q - 4, tag + 1, INT32);
__PUT(fld, (SYSTEM_PTR)(ADDRESS)p, SYSTEM_PTR);
p = q;
q = n;
tag = tagbits;
}
}
}
tag += 4;
}
}
}
}
static void Heap_MarkP (SYSTEM_PTR p)
{
Heap_Mark((INT32)(ADDRESS)p);
}
static void Heap_Scan (void)
{
INT32 chnk, adr, end, start, tag, i, size, freesize;
Heap_bigBlocks = 0;
i = 1;
while (i < 9) {
Heap_freeList[i] = 0;
i += 1;
}
freesize = 0;
Heap_allocated = 0;
chnk = Heap_heap;
while (chnk != 0) {
adr = chnk + 12;
__GET(chnk + 4, end, INT32);
while (Heap_uLT(adr, end)) {
__GET(adr, tag, INT32);
if (__ODD(tag)) {
if (freesize != 0) {
start = adr - freesize;
__PUT(start, start + 4, INT32);
__PUT(start + 4, freesize, INT32);
__PUT(start + 8, -4, INT32);
i = __LSH(freesize, -Heap_ldUnit, 32);
freesize = 0;
if (Heap_uLT(i, 9)) {
__PUT(start + 12, Heap_freeList[i], INT32);
Heap_freeList[i] = start;
} else {
__PUT(start + 12, Heap_bigBlocks, INT32);
Heap_bigBlocks = start;
}
}
tag -= 1;
__PUT(adr, tag, INT32);
__GET(tag, size, INT32);
Heap_allocated += size;
adr += size;
} else {
__GET(tag, size, INT32);
freesize += size;
adr += size;
}
}
if (freesize != 0) {
start = adr - freesize;
__PUT(start, start + 4, INT32);
__PUT(start + 4, freesize, INT32);
__PUT(start + 8, -4, INT32);
i = __LSH(freesize, -Heap_ldUnit, 32);
freesize = 0;
if (Heap_uLT(i, 9)) {
__PUT(start + 12, Heap_freeList[i], INT32);
Heap_freeList[i] = start;
} else {
__PUT(start + 12, Heap_bigBlocks, INT32);
Heap_bigBlocks = start;
}
}
__GET(chnk, chnk, INT32);
}
}
static void Heap_Sift (INT32 l, INT32 r, INT32 *a, ADDRESS a__len)
{
INT32 i, j;
INT32 x;
j = l;
x = a[j];
for (;;) {
i = j;
j = __ASHL(j, 1) + 1;
if ((j < r && Heap_uLT(a[j], a[j + 1]))) {
j += 1;
}
if (j > r || Heap_uLE(a[j], x)) {
break;
}
a[i] = a[j];
}
a[i] = x;
}
static void Heap_HeapSort (INT32 n, INT32 *a, ADDRESS a__len)
{
INT32 l, r;
INT32 x;
l = __ASHR(n, 1);
r = n - 1;
while (l > 0) {
l -= 1;
Heap_Sift(l, r, (void*)a, a__len);
}
while (r > 0) {
x = a[0];
a[0] = a[r];
a[r] = x;
r -= 1;
Heap_Sift(l, r, (void*)a, a__len);
}
}
static void Heap_MarkCandidates (INT32 n, INT32 *cand, ADDRESS cand__len)
{
INT32 chnk, end, adr, tag, next, i, ptr, size;
chnk = Heap_heap;
i = 0;
while (chnk != 0) {
__GET(chnk + 4, end, INT32);
adr = chnk + 12;
while (Heap_uLT(adr, end)) {
__GET(adr, tag, INT32);
if (__ODD(tag)) {
__GET(tag - 1, size, INT32);
adr += size;
ptr = adr + 4;
while (Heap_uLT(cand[i], ptr)) {
i += 1;
if (i == n) {
return;
}
}
} else {
__GET(tag, size, INT32);
ptr = adr + 4;
adr += size;
while (Heap_uLT(cand[i], ptr)) {
i += 1;
if (i == n) {
return;
}
}
if (Heap_uLT(cand[i], adr)) {
Heap_Mark(ptr);
}
}
if (Heap_uLE(end, cand[i])) {
adr = end;
}
}
__GET(chnk, chnk, INT32);
}
}
static void Heap_CheckFin (void)
{
Heap_FinNode n;
INT32 tag;
n = Heap_fin;
while (n != NIL) {
__GET(n->obj - 4, tag, INT32);
if (!__ODD(tag)) {
n->marked = 0;
Heap_Mark(n->obj);
} else {
n->marked = 1;
}
n = n->next;
}
}
static void Heap_Finalize (void)
{
Heap_FinNode n, prev;
n = Heap_fin;
prev = NIL;
while (n != NIL) {
if (!n->marked) {
if (n == Heap_fin) {
Heap_fin = Heap_fin->next;
} else {
prev->next = n->next;
}
(*n->finalize)((SYSTEM_PTR)(ADDRESS)n->obj);
if (prev == NIL) {
n = Heap_fin;
} else {
n = n->next;
}
} else {
prev = n;
n = n->next;
}
}
}
void Heap_FINALL (void)
{
Heap_FinNode n;
while (Heap_fin != NIL) {
n = Heap_fin;
Heap_fin = Heap_fin->next;
(*n->finalize)((SYSTEM_PTR)(ADDRESS)n->obj);
}
}
static void Heap_MarkStack (INT32 n, INT32 *cand, ADDRESS cand__len)
{
SYSTEM_PTR frame;
INT32 nofcand;
INT32 inc, sp, p, stack0;
struct Heap__1 align;
if (n > 0) {
Heap_MarkStack(n - 1, cand, cand__len);
if (n > 100) {
return;
}
}
if (n == 0) {
nofcand = 0;
sp = (ADDRESS)&frame;
stack0 = Heap_ModulesMainStackFrame();
inc = (ADDRESS)&align.p - (ADDRESS)&align;
if (Heap_uLT(stack0, sp)) {
inc = -inc;
}
while (sp != stack0) {
__GET(sp, p, INT32);
if ((Heap_uLE(Heap_heapMin, p) && Heap_uLT(p, Heap_heapMax))) {
if (nofcand == cand__len) {
Heap_HeapSort(nofcand, (void*)cand, cand__len);
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
nofcand = 0;
}
cand[nofcand] = p;
nofcand += 1;
}
sp += inc;
}
if (nofcand > 0) {
Heap_HeapSort(nofcand, (void*)cand, cand__len);
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
}
}
}
void Heap_GC (BOOLEAN markStack)
{
Heap_Module m;
INT32 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
INT32 cand[10000];
Heap_Lock();
m = (Heap_Module)(ADDRESS)Heap_modules;
while (m != NIL) {
if (m->enumPtrs != NIL) {
(*m->enumPtrs)(Heap_MarkP);
}
m = m->next;
}
if (markStack) {
i0 = -100;
i1 = -101;
i2 = -102;
i3 = -103;
i4 = -104;
i5 = -105;
i6 = -106;
i7 = -107;
i8 = 1;
i9 = 2;
i10 = 3;
i11 = 4;
i12 = 5;
i13 = 6;
i14 = 7;
i15 = 8;
i16 = 9;
i17 = 10;
i18 = 11;
i19 = 12;
i20 = 13;
i21 = 14;
i22 = 15;
i23 = 16;
for (;;) {
i0 += 1;
i1 += 2;
i2 += 3;
i3 += 4;
i4 += 5;
i5 += 6;
i6 += 7;
i7 += 8;
i8 += 9;
i9 += 10;
i10 += 11;
i11 += 12;
i12 += 13;
i13 += 14;
i14 += 15;
i15 += 16;
i16 += 17;
i17 += 18;
i18 += 19;
i19 += 20;
i20 += 21;
i21 += 22;
i22 += 23;
i23 += 24;
if ((i0 == -99 && i15 == 24)) {
Heap_MarkStack(32, (void*)cand, 10000);
break;
}
}
if (((((((((((((((((((((((i0 + i1) + i2) + i3) + i4) + i5) + i6) + i7) + i8) + i9) + i10) + i11) + i12) + i13) + i14) + i15) + i16) + i17) + i18) + i19) + i20) + i21) + i22) + i23 > 10000) {
return;
}
}
Heap_CheckFin();
Heap_Scan();
Heap_Finalize();
Heap_Unlock();
}
void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
{
Heap_FinNode f;
__NEW(f, Heap_FinDesc);
f->obj = (INT32)(ADDRESS)obj;
f->finalize = finalize;
f->marked = 1;
f->next = Heap_fin;
Heap_fin = f;
}
void Heap_InitHeap (void)
{
Heap_heap = 0;
Heap_heapsize = 0;
Heap_allocated = 0;
Heap_lockdepth = 0;
Heap_heapMin = -1;
Heap_heapMax = 0;
Heap_bigBlocks = 0;
Heap_heapMinExpand = 128000;
Heap_ldUnit = 4;
Heap_heap = Heap_NewChunk(128000);
__PUT(Heap_heap, 0, INT32);
Heap_firstTry = 1;
Heap_freeList[9] = 1;
Heap_FileCount = 0;
Heap_modules = NIL;
Heap_fin = NIL;
Heap_interrupted = 0;
Heap_HeapModuleInit();
}
static void EnumPtrs(void (*P)(void*))
{
P(Heap_modules);
P(Heap_fin);
}
__TDESC(Heap_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 48), {0, 28, -12}};
__TDESC(Heap_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 32), {0, -8}};
__TDESC(Heap_FinDesc, 1, 1) = {__TDFLDS("FinDesc", 16), {0, -8}};
__TDESC(Heap__1, 1, 1) = {__TDFLDS("", 8), {4, -8}};
export void *Heap__init(void)
{
__DEFMOD;
__REGMOD("Heap", EnumPtrs);
__REGCMD("FINALL", Heap_FINALL);
__REGCMD("InitHeap", Heap_InitHeap);
__REGCMD("Lock", Heap_Lock);
__REGCMD("Unlock", Heap_Unlock);
__INITYP(Heap_ModuleDesc, Heap_ModuleDesc, 0);
__INITYP(Heap_CmdDesc, Heap_CmdDesc, 0);
__INITYP(Heap_FinDesc, Heap_FinDesc, 0);
__INITYP(Heap__1, Heap__1, 0);
/* BEGIN */
__ENDMOD;
}

73
bootstrap/unix-48/Heap.h Normal file
View file

@ -0,0 +1,73 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */
#ifndef Heap__h
#define Heap__h
#include "SYSTEM.h"
typedef
struct Heap_CmdDesc *Heap_Cmd;
typedef
CHAR Heap_CmdName[24];
typedef
void (*Heap_Command)(void);
typedef
struct Heap_CmdDesc {
Heap_Cmd next;
Heap_CmdName name;
Heap_Command cmd;
} Heap_CmdDesc;
typedef
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
typedef
void (*Heap_Finalizer)(SYSTEM_PTR);
typedef
struct Heap_ModuleDesc *Heap_Module;
typedef
CHAR Heap_ModuleName[20];
typedef
struct Heap_ModuleDesc {
Heap_Module next;
Heap_ModuleName name;
INT32 refcnt;
Heap_Cmd cmds;
INT32 types;
Heap_EnumProc enumPtrs;
char _prvt0[8];
} Heap_ModuleDesc;
import SYSTEM_PTR Heap_modules;
import INT32 Heap_allocated;
import INT32 Heap_heap;
import INT32 Heap_heapsize, Heap_heapMinExpand;
import INT16 Heap_FileCount;
import ADDRESS *Heap_ModuleDesc__typ;
import ADDRESS *Heap_CmdDesc__typ;
import void Heap_FINALL (void);
import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len);
import void Heap_GC (BOOLEAN markStack);
import void Heap_INCREF (Heap_Module m);
import void Heap_InitHeap (void);
import void Heap_Lock (void);
import SYSTEM_PTR Heap_NEWBLK (INT32 size);
import SYSTEM_PTR Heap_NEWREC (INT32 tag);
import void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
import SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
import void Heap_REGTYP (Heap_Module m, INT32 typ);
import void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
import void Heap_Unlock (void);
import void *Heap__init(void);
#endif // Heap

506
bootstrap/unix-48/Modules.c Normal file
View file

@ -0,0 +1,506 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Heap.h"
#include "Platform.h"
export INT16 Modules_res;
export CHAR Modules_resMsg[256];
export Heap_ModuleName Modules_imported, Modules_importing;
export INT32 Modules_MainStackFrame;
export INT16 Modules_ArgCount;
export INT32 Modules_ArgVector;
export CHAR Modules_BinaryDir[1024];
static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len);
export void Modules_AssertFail (INT32 code);
static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len);
static void Modules_DisplayHaltCode (INT32 code);
static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len);
static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len);
export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all);
export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len);
export void Modules_GetIntArg (INT16 n, INT32 *val);
export void Modules_Halt (INT32 code);
export void Modules_Init (INT32 argc, INT32 argvadr);
static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len);
static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len);
static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len);
export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len);
export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len);
static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static void Modules_errch (CHAR c);
static void Modules_errint (INT32 l);
static void Modules_errstring (CHAR *s, ADDRESS s__len);
extern void Heap_InitHeap();
extern void *Modules__init(void);
#define Modules_InitHeap() Heap_InitHeap()
#define Modules_ModulesInit() Modules__init()
#define Modules_modules() (Heap_Module)Heap_modules
void Modules_Init (INT32 argc, INT32 argvadr)
{
Modules_MainStackFrame = argvadr;
Modules_ArgCount = __VAL(INT16, argc);
__GET(argvadr, Modules_ArgVector, INT32);
Modules_InitHeap();
Modules_ModulesInit();
}
typedef
CHAR (*argptr__15)[1024];
void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len)
{
argptr__15 arg = NIL;
if (n < Modules_ArgCount) {
__GET(Modules_ArgVector + __ASHL(n, 2), arg, argptr__15);
__COPY(*arg, val, val__len);
}
}
void Modules_GetIntArg (INT16 n, INT32 *val)
{
CHAR s[64];
INT32 k, d, i;
s[0] = 0x00;
Modules_GetArg(n, (void*)s, 64);
i = 0;
if (s[0] == '-') {
i = 1;
}
k = 0;
d = (INT16)s[__X(i, 64)] - 48;
while ((d >= 0 && d <= 9)) {
k = k * 10 + d;
i += 1;
d = (INT16)s[__X(i, 64)] - 48;
}
if (s[0] == '-') {
k = -k;
i -= 1;
}
if (i > 0) {
*val = k;
}
}
INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len)
{
INT16 i;
CHAR arg[256];
__DUP(s, s__len, CHAR);
i = 0;
Modules_GetArg(i, (void*)arg, 256);
while ((i < Modules_ArgCount && __STRCMP(s, arg) != 0)) {
i += 1;
Modules_GetArg(i, (void*)arg, 256);
}
__DEL(s);
return i;
}
static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len)
{
INT16 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
__DEL(s);
return i;
}
static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
__DUP(s, s__len, CHAR);
i = 0;
j = Modules_CharCount(d, d__len);
while (s[__X(i, s__len)] != 0x00) {
d[__X(j, d__len)] = s[__X(i, s__len)];
i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
__DEL(s);
}
static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
__DUP(s, s__len, CHAR);
i = 0;
j = Modules_CharCount(d, d__len);
if ((j > 0 && d[__X(j - 1, d__len)] != c)) {
d[__X(j, d__len)] = c;
j += 1;
}
while (s[__X(i, s__len)] != 0x00) {
d[__X(j, d__len)] = s[__X(i, s__len)];
i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
__DEL(s);
}
static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len)
{
INT16 i;
__DUP(s, s__len, CHAR);
if (c == 0x00) {
__DEL(s);
return 0;
}
i = 0;
while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
__DEL(s);
return s[__X(i, s__len)] == c;
}
static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len)
{
__DUP(d, d__len, CHAR);
if (d[0] == 0x00) {
__DEL(d);
return 0;
}
if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) {
__DEL(d);
return 1;
}
if (d[__X(1, d__len)] == ':') {
__DEL(d);
return 1;
}
__DEL(d);
return 0;
}
static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
__DUP(s, s__len, CHAR);
if (Modules_IsAbsolute(s, s__len)) {
__COPY(s, d, d__len);
} else {
__COPY(Platform_CWD, d, d__len);
Modules_AppendPart('/', s, s__len, (void*)d, d__len);
}
__DEL(s);
}
static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len)
{
Platform_FileIdentity identity;
__DUP(s, s__len, CHAR);
__DEL(s);
return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0;
}
static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len)
{
INT16 j;
__DUP(s, s__len, CHAR);
__DUP(p, p__len, CHAR);
j = 0;
while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) {
d[__X(j, d__len)] = s[__X(*i, s__len)];
*i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) {
*i += 1;
}
__DEL(s);
__DEL(p);
}
static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
CHAR part[1024];
__DUP(s, s__len, CHAR);
i = 0;
j = 0;
while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) {
i += 1;
d[__X(j, d__len)] = '/';
j += 1;
}
d[__X(j, d__len)] = 0x00;
while (s[__X(i, s__len)] != 0x00) {
Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024);
if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) {
Modules_AppendPart('/', part, 1024, (void*)d, d__len);
}
}
__DEL(s);
}
typedef
CHAR pathstring__12[4096];
static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len)
{
pathstring__12 arg0, pathlist, pathdir, tempstr;
INT16 i, j, k;
BOOLEAN present;
if (Modules_ArgCount < 1) {
binarydir[0] = 0x00;
return;
}
Modules_GetArg(0, (void*)arg0, 4096);
i = 0;
while ((((arg0[__X(i, 4096)] != 0x00 && arg0[__X(i, 4096)] != '/')) && arg0[__X(i, 4096)] != '\\')) {
i += 1;
}
if (arg0[__X(i, 4096)] == '/' || arg0[__X(i, 4096)] == '\\') {
Modules_Trim(arg0, 4096, (void*)tempstr, 4096);
Modules_Canonify(tempstr, 4096, (void*)binarydir, binarydir__len);
present = Modules_IsFilePresent(binarydir, binarydir__len);
} else {
Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096);
i = 0;
present = 0;
while ((!present && pathlist[__X(i, 4096)] != 0x00)) {
Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)pathdir, 4096);
Modules_AppendPart('/', arg0, 4096, (void*)pathdir, 4096);
Modules_Trim(pathdir, 4096, (void*)tempstr, 4096);
Modules_Canonify(tempstr, 4096, (void*)binarydir, binarydir__len);
present = Modules_IsFilePresent(binarydir, binarydir__len);
}
}
if (present) {
k = Modules_CharCount(binarydir, binarydir__len);
while ((k > 0 && !Modules_IsOneOf(binarydir[__X(k - 1, binarydir__len)], (CHAR*)"/\\", 3))) {
k -= 1;
}
if (k == 0) {
binarydir[__X(k, binarydir__len)] = 0x00;
} else {
binarydir[__X(k - 1, binarydir__len)] = 0x00;
}
} else {
binarydir[0] = 0x00;
}
}
Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len)
{
Heap_Module m = NIL;
CHAR bodyname[64];
Heap_Command body;
__DUP(name, name__len, CHAR);
m = Modules_modules();
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
m = m->next;
}
if (m != NIL) {
Modules_res = 0;
Modules_resMsg[0] = 0x00;
} else {
Modules_res = 1;
__COPY(name, Modules_importing, 20);
__MOVE(" module \"", Modules_resMsg, 10);
Modules_Append(name, name__len, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256);
}
__DEL(name);
return m;
}
Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len)
{
Heap_Cmd c = NIL;
__DUP(name, name__len, CHAR);
c = mod->cmds;
while ((c != NIL && __STRCMP(c->name, name) != 0)) {
c = c->next;
}
if (c != NIL) {
Modules_res = 0;
Modules_resMsg[0] = 0x00;
__DEL(name);
return c->cmd;
} else {
Modules_res = 2;
__MOVE(" command \"", Modules_resMsg, 11);
__COPY(name, Modules_importing, 20);
Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256);
Modules_Append(name, name__len, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256);
__DEL(name);
return NIL;
}
__RETCHK;
}
void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all)
{
Heap_Module m = NIL, p = NIL;
INT32 refcount;
__DUP(name, name__len, CHAR);
m = Modules_modules();
if (all) {
Modules_res = 1;
__MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34);
} else {
refcount = Heap_FreeModule(name, name__len);
if (refcount == 0) {
Modules_res = 0;
} else {
if (refcount < 0) {
__MOVE("module not found", Modules_resMsg, 17);
} else {
__MOVE("clients of this module exist", Modules_resMsg, 29);
}
Modules_res = 1;
}
}
__DEL(name);
}
static void Modules_errch (CHAR c)
{
INT16 e;
e = Platform_Write(1, (ADDRESS)&c, 1);
}
static void Modules_errstring (CHAR *s, ADDRESS s__len)
{
INT32 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
Modules_errch(s[__X(i, s__len)]);
i += 1;
}
__DEL(s);
}
static void Modules_errint (INT32 l)
{
if (l < 0) {
Modules_errch('-');
l = -l;
}
if (l >= 10) {
Modules_errint(__DIV(l, 10));
}
Modules_errch(__CHR((int)__MOD(l, 10) + 48));
}
static void Modules_DisplayHaltCode (INT32 code)
{
switch (code) {
case -1:
Modules_errstring((CHAR*)"Assertion failure.", 19);
break;
case -2:
Modules_errstring((CHAR*)"Index out of range.", 20);
break;
case -3:
Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49);
break;
case -4:
Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47);
break;
case -5:
Modules_errstring((CHAR*)"Type guard failed.", 19);
break;
case -6:
Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49);
break;
case -7:
Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32);
break;
case -8:
Modules_errstring((CHAR*)"Value out of range.", 20);
break;
case -9:
Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60);
break;
case -10:
Modules_errstring((CHAR*)"NIL access.", 12);
break;
case -11:
Modules_errstring((CHAR*)"Alignment error.", 17);
break;
case -12:
Modules_errstring((CHAR*)"Divide by zero.", 16);
break;
case -13:
Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31);
break;
case -14:
Modules_errstring((CHAR*)"Invalid function argument.", 27);
break;
case -15:
Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52);
break;
case -20:
Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60);
break;
default:
break;
}
}
void Modules_Halt (INT32 code)
{
Heap_FINALL();
Modules_errstring((CHAR*)"Terminated by Halt(", 20);
Modules_errint(code);
Modules_errstring((CHAR*)"). ", 4);
if (code < 0) {
Modules_DisplayHaltCode(code);
}
Modules_errstring(Platform_NL, 3);
Platform_Exit(code);
}
void Modules_AssertFail (INT32 code)
{
Heap_FINALL();
Modules_errstring((CHAR*)"Assertion failure.", 19);
if (code != 0) {
Modules_errstring((CHAR*)" ASSERT code ", 14);
Modules_errint(code);
Modules_errstring((CHAR*)".", 2);
}
Modules_errstring(Platform_NL, 3);
if (code > 0) {
Platform_Exit(code);
} else {
Platform_Exit(-1);
}
}
export void *Modules__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Platform);
__REGMOD("Modules", 0);
/* BEGIN */
Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024);
__ENDMOD;
}

View file

@ -0,0 +1,31 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Modules__h
#define Modules__h
#include "SYSTEM.h"
#include "Heap.h"
import INT16 Modules_res;
import CHAR Modules_resMsg[256];
import Heap_ModuleName Modules_imported, Modules_importing;
import INT32 Modules_MainStackFrame;
import INT16 Modules_ArgCount;
import INT32 Modules_ArgVector;
import CHAR Modules_BinaryDir[1024];
import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len);
import void Modules_AssertFail (INT32 code);
import void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all);
import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len);
import void Modules_GetIntArg (INT16 n, INT32 *val);
import void Modules_Halt (INT32 code);
import void Modules_Init (INT32 argc, INT32 argvadr);
import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len);
import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len);
import void *Modules__init(void);
#endif // Modules

2592
bootstrap/unix-48/OPB.c Normal file

File diff suppressed because it is too large Load diff

48
bootstrap/unix-48/OPB.h Normal file
View file

@ -0,0 +1,48 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPB__h
#define OPB__h
#include "SYSTEM.h"
#include "OPS.h"
#include "OPT.h"
import void OPB_Assign (OPT_Node *x, OPT_Node y);
import void OPB_Call (OPT_Node *x, OPT_Node apar, OPT_Object fp);
import void OPB_CheckParameters (OPT_Object fp, OPT_Object ap, BOOLEAN checkNames);
import void OPB_Construct (INT8 class, OPT_Node *x, OPT_Node y);
import void OPB_DeRef (OPT_Node *x);
import OPT_Node OPB_EmptySet (void);
import void OPB_Enter (OPT_Node *procdec, OPT_Node stat, OPT_Object proc);
import void OPB_Field (OPT_Node *x, OPT_Object y);
import void OPB_In (OPT_Node *x, OPT_Node y);
import void OPB_Index (OPT_Node *x, OPT_Node y);
import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ);
import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y);
import void OPB_MOp (INT8 op, OPT_Node *x);
import OPT_Node OPB_NewBoolConst (BOOLEAN boolval);
import OPT_Node OPB_NewIntConst (INT64 intval);
import OPT_Node OPB_NewLeaf (OPT_Object obj);
import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ);
import OPT_Node OPB_NewString (OPS_String str, INT64 len);
import OPT_Node OPB_Nil (void);
import void OPB_Op (INT8 op, OPT_Node *x, OPT_Node y);
import void OPB_OptIf (OPT_Node *x);
import void OPB_Param (OPT_Node ap, OPT_Object fp);
import void OPB_PrepCall (OPT_Node *x, OPT_Object *fpar);
import void OPB_Return (OPT_Node *x, OPT_Object proc);
import void OPB_SetElem (OPT_Node *x);
import void OPB_SetRange (OPT_Node *x, OPT_Node y);
import void OPB_StFct (OPT_Node *par0, INT8 fctno, INT16 parno);
import void OPB_StPar0 (OPT_Node *par0, INT16 fctno);
import void OPB_StPar1 (OPT_Node *par0, OPT_Node x, INT8 fctno);
import void OPB_StParN (OPT_Node *par0, OPT_Node x, INT16 fctno, INT16 n);
import void OPB_StaticLink (INT8 dlev);
import void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard);
import void *OPB__init(void);
#endif // OPB

2025
bootstrap/unix-48/OPC.c Normal file

File diff suppressed because it is too large Load diff

49
bootstrap/unix-48/OPC.h Normal file
View file

@ -0,0 +1,49 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPC__h
#define OPC__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPC_Andent (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void);
import void OPC_BegStat (void);
import void OPC_Case (INT64 caseVal, INT16 form);
import void OPC_Cmp (INT16 rel);
import void OPC_CompleteIdent (OPT_Object obj);
import void OPC_Constant (OPT_Const con, INT16 form);
import void OPC_DefineInter (OPT_Object proc);
import void OPC_EndBlk (void);
import void OPC_EndBlk0 (void);
import void OPC_EndStat (void);
import void OPC_EnterBody (void);
import void OPC_EnterProc (OPT_Object proc);
import void OPC_ExitBody (void);
import void OPC_ExitProc (OPT_Object proc, BOOLEAN eoBlock, BOOLEAN implicitRet);
import void OPC_GenBdy (OPT_Node n);
import void OPC_GenEnumPtrs (OPT_Object var);
import void OPC_GenHdr (OPT_Node n);
import void OPC_GenHdrIncludes (void);
import void OPC_Halt (INT32 n);
import void OPC_Ident (OPT_Object obj);
import void OPC_Increment (BOOLEAN decrement);
import void OPC_Indent (INT16 count);
import void OPC_Init (void);
import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_IntLiteral (INT64 n, INT32 size);
import void OPC_Len (OPT_Object obj, OPT_Struct array, INT64 dim);
import BOOLEAN OPC_NeedsRetval (OPT_Object proc);
import INT32 OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INT16 vis);
import void OPC_TypeOf (OPT_Object ap);
import void *OPC__init(void);
#endif // OPC

1183
bootstrap/unix-48/OPM.c Normal file

File diff suppressed because it is too large Load diff

76
bootstrap/unix-48/OPM.h Normal file
View file

@ -0,0 +1,76 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPM__h
#define OPM__h
#include "SYSTEM.h"
import CHAR OPM_Model[10];
import INT16 OPM_AddressSize, OPM_Alignment;
import UINT32 OPM_GlobalOptions, OPM_Options;
import INT16 OPM_ShortintSize, OPM_IntegerSize, OPM_LongintSize, OPM_SetSize;
import INT64 OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
import INT32 OPM_curpos, OPM_errpos, OPM_breakpc;
import INT16 OPM_currFile, OPM_level, OPM_pc, OPM_entno;
import CHAR OPM_modName[32];
import CHAR OPM_objname[64];
import CHAR OPM_InstallDir[1024];
import CHAR OPM_ResourceDir[1024];
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void);
import void OPM_DeleteObj (CHAR *modulename, ADDRESS modulename__len);
import void OPM_DeleteSym (CHAR *modulename, ADDRESS modulename__len);
import void OPM_FPrint (INT32 *fp, INT64 val);
import void OPM_FPrintLReal (INT32 *fp, LONGREAL val);
import void OPM_FPrintReal (INT32 *fp, REAL val);
import void OPM_FPrintSet (INT32 *fp, UINT64 val);
import void OPM_Get (CHAR *ch);
import void OPM_GetComment (CHAR *text, ADDRESS text__len);
import void OPM_Init (BOOLEAN *done);
import void OPM_InitOptions (void);
import INT16 OPM_Integer (INT64 n);
import void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len);
import void OPM_LogVT100 (CHAR *vt100code, ADDRESS vt100code__len);
import void OPM_LogW (CHAR ch);
import void OPM_LogWLn (void);
import void OPM_LogWNum (INT64 i, INT64 len);
import void OPM_LogWStr (CHAR *s, ADDRESS s__len);
import INT32 OPM_Longint (INT64 n);
import void OPM_Mark (INT16 n, INT32 pos);
import void OPM_NewSym (CHAR *modName, ADDRESS modName__len);
import void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, ADDRESS moduleName__len);
import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void);
import INT64 OPM_SignedMaximum (INT32 bytecount);
import INT64 OPM_SignedMinimum (INT32 bytecount);
import void OPM_StoreComment (CHAR *text, ADDRESS text__len);
import void OPM_SymRCh (CHAR *ch);
import INT32 OPM_SymRInt (void);
import INT64 OPM_SymRInt64 (void);
import void OPM_SymRLReal (LONGREAL *lr);
import void OPM_SymRReal (REAL *r);
import void OPM_SymRSet (UINT64 *s);
import void OPM_SymWCh (CHAR ch);
import void OPM_SymWInt (INT64 i);
import void OPM_SymWLReal (LONGREAL lr);
import void OPM_SymWReal (REAL r);
import void OPM_SymWSet (UINT64 s);
import void OPM_Write (CHAR ch);
import void OPM_WriteHex (INT64 i);
import void OPM_WriteInt (INT64 i);
import void OPM_WriteLn (void);
import void OPM_WriteReal (LONGREAL r, CHAR suffx);
import void OPM_WriteString (CHAR *s, ADDRESS s__len);
import void OPM_WriteStringVar (CHAR *s, ADDRESS s__len);
import BOOLEAN OPM_eofSF (void);
import void OPM_err (INT16 n);
import void *OPM__init(void);
#endif // OPM

1881
bootstrap/unix-48/OPP.c Normal file

File diff suppressed because it is too large Load diff

16
bootstrap/unix-48/OPP.h Normal file
View file

@ -0,0 +1,16 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPP__h
#define OPP__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPP_Module (OPT_Node *prog, UINT32 opt);
import void *OPP__init(void);
#endif // OPP

666
bootstrap/unix-48/OPS.c Normal file
View file

@ -0,0 +1,666 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "OPM.h"
typedef
CHAR OPS_Name[256];
typedef
CHAR OPS_String[256];
export OPS_Name OPS_name;
export OPS_String OPS_str;
export INT16 OPS_numtyp;
export INT64 OPS_intval;
export REAL OPS_realval;
export LONGREAL OPS_lrlval;
static CHAR OPS_ch;
export void OPS_Get (INT8 *sym);
static void OPS_Identifier (INT8 *sym);
export void OPS_Init (void);
static void OPS_Number (void);
static void OPS_Str (INT8 *sym);
static void OPS_err (INT16 n);
static void OPS_err (INT16 n)
{
OPM_err(n);
}
static void OPS_Str (INT8 *sym)
{
INT16 i;
CHAR och;
i = 0;
och = OPS_ch;
for (;;) {
OPM_Get(&OPS_ch);
if (OPS_ch == och) {
break;
}
if (OPS_ch < ' ') {
OPS_err(3);
break;
}
if (i == 255) {
OPS_err(241);
break;
}
OPS_str[__X(i, 256)] = OPS_ch;
i += 1;
}
OPM_Get(&OPS_ch);
OPS_str[__X(i, 256)] = 0x00;
OPS_intval = i + 1;
if (OPS_intval == 2) {
*sym = 35;
OPS_numtyp = 1;
OPS_intval = (INT16)OPS_str[0];
} else {
*sym = 37;
}
}
static void OPS_Identifier (INT8 *sym)
{
INT16 i;
i = 0;
do {
OPS_name[__X(i, 256)] = OPS_ch;
i += 1;
OPM_Get(&OPS_ch);
} while (!(((OPS_ch < '0' || ('9' < OPS_ch && __CAP(OPS_ch) < 'A')) || 'Z' < __CAP(OPS_ch)) || i == 256));
if (i == 256) {
OPS_err(240);
i -= 1;
}
OPS_name[__X(i, 256)] = 0x00;
*sym = 38;
}
static struct Number__6 {
struct Number__6 *lnk;
} *Number__6_s;
static INT16 Ord__7 (CHAR ch, BOOLEAN hex);
static LONGREAL Ten__9 (INT16 e);
static LONGREAL Ten__9 (INT16 e)
{
LONGREAL x, p;
x = (LONGREAL)1;
p = (LONGREAL)10;
while (e > 0) {
if (__ODD(e)) {
x = x * p;
}
e = __ASHR(e, 1);
if (e > 0) {
p = p * p;
}
}
return x;
}
static INT16 Ord__7 (CHAR ch, BOOLEAN hex)
{
if (ch <= '9') {
return (INT16)ch - 48;
} else if (hex) {
return ((INT16)ch - 65) + 10;
} else {
OPS_err(2);
return 0;
}
__RETCHK;
}
static void OPS_Number (void)
{
INT16 i, m, n, d, e;
CHAR dig[24];
LONGREAL f;
CHAR expCh;
BOOLEAN neg;
struct Number__6 _s;
_s.lnk = Number__6_s;
Number__6_s = &_s;
i = 0;
m = 0;
n = 0;
d = 0;
for (;;) {
if (('0' <= OPS_ch && OPS_ch <= '9') || (((d == 0 && 'A' <= OPS_ch)) && OPS_ch <= 'F')) {
if (m > 0 || OPS_ch != '0') {
if (n < 24) {
dig[__X(n, 24)] = OPS_ch;
n += 1;
}
m += 1;
}
OPM_Get(&OPS_ch);
i += 1;
} else if (OPS_ch == '.') {
OPM_Get(&OPS_ch);
if (OPS_ch == '.') {
OPS_ch = 0x7f;
break;
} else if (d == 0) {
d = i;
} else {
OPS_err(2);
}
} else {
break;
}
}
if (d == 0) {
if (n == m) {
OPS_intval = 0;
i = 0;
if (OPS_ch == 'X') {
OPM_Get(&OPS_ch);
OPS_numtyp = 1;
if (n <= 2) {
while (i < n) {
OPS_intval = __ASHL(OPS_intval, 4) + (INT64)Ord__7(dig[__X(i, 24)], 1);
i += 1;
}
} else {
OPS_err(203);
}
} else if (OPS_ch == 'H') {
OPM_Get(&OPS_ch);
OPS_numtyp = 2;
if (n <= 16) {
if ((n == 16 && dig[0] > '7')) {
OPS_intval = -1;
}
while (i < n) {
OPS_intval = __ASHL(OPS_intval, 4) + (INT64)Ord__7(dig[__X(i, 24)], 1);
i += 1;
}
} else {
OPS_err(203);
}
} else {
OPS_numtyp = 2;
while (i < n) {
d = Ord__7(dig[__X(i, 24)], 0);
i += 1;
if (OPS_intval <= __DIV(9223372036854775807LL - (INT64)d, 10)) {
OPS_intval = OPS_intval * 10 + (INT64)d;
} else {
OPS_err(203);
}
}
}
} else {
OPS_err(203);
}
} else {
f = (LONGREAL)0;
e = 0;
expCh = 'E';
while (n > 0) {
n -= 1;
f = (Ord__7(dig[__X(n, 24)], 0) + f) / (LONGREAL)(LONGREAL)10;
}
if (OPS_ch == 'E' || OPS_ch == 'D') {
expCh = OPS_ch;
OPM_Get(&OPS_ch);
neg = 0;
if (OPS_ch == '-') {
neg = 1;
OPM_Get(&OPS_ch);
} else if (OPS_ch == '+') {
OPM_Get(&OPS_ch);
}
if (('0' <= OPS_ch && OPS_ch <= '9')) {
do {
n = Ord__7(OPS_ch, 0);
OPM_Get(&OPS_ch);
if (e <= __DIV(32767 - n, 10)) {
e = e * 10 + n;
} else {
OPS_err(203);
}
} while (!(OPS_ch < '0' || '9' < OPS_ch));
if (neg) {
e = -e;
}
} else {
OPS_err(2);
}
}
e -= (i - d) - m;
if (expCh == 'E') {
OPS_numtyp = 3;
if ((-37 < e && e <= 38)) {
if (e < 0) {
OPS_realval = (f / (LONGREAL)Ten__9(-e));
} else {
OPS_realval = (f * Ten__9(e));
}
} else {
OPS_err(203);
}
} else {
OPS_numtyp = 4;
if ((-307 < e && e <= 308)) {
if (e < 0) {
OPS_lrlval = f / (LONGREAL)Ten__9(-e);
} else {
OPS_lrlval = f * Ten__9(e);
}
} else {
OPS_err(203);
}
}
}
Number__6_s = _s.lnk;
}
static struct Get__1 {
struct Get__1 *lnk;
} *Get__1_s;
static void Comment__2 (void);
static void Comment__2 (void)
{
BOOLEAN isExported;
CHAR commentText[256];
INT16 i, nestLevel;
CHAR prevCh, nextCh;
i = 0;
while (i <= 255) {
commentText[__X(i, 256)] = 0x00;
i += 1;
}
isExported = 0;
i = 0;
nestLevel = 1;
prevCh = 0x00;
OPM_Get(&OPS_ch);
if (OPS_ch == '*') {
isExported = 1;
OPM_Get(&OPS_ch);
if (OPS_ch == ')') {
commentText[0] = 0x00;
OPM_StoreComment(commentText, 256);
OPM_Get(&OPS_ch);
return;
}
}
while ((nestLevel > 0 && OPS_ch != 0x00)) {
if ((prevCh == '(' && OPS_ch == '*')) {
nestLevel += 1;
prevCh = 0x00;
} else if ((prevCh == '*' && OPS_ch == ')')) {
nestLevel -= 1;
if (nestLevel == 0) {
OPM_Get(&OPS_ch);
} else {
prevCh = 0x00;
}
} else {
if ((((isExported && nestLevel == 1)) && prevCh != 0x00)) {
if (i < 255) {
commentText[__X(i, 256)] = prevCh;
i += 1;
}
}
prevCh = OPS_ch;
}
if (nestLevel > 0) {
OPM_Get(&OPS_ch);
}
}
if (OPS_ch == 0x00) {
OPS_err(5);
}
if ((((((isExported && nestLevel == 0)) && prevCh != 0x00)) && prevCh != '*')) {
if (i < 255) {
commentText[__X(i, 256)] = prevCh;
i += 1;
} else {
OPM_LogWStr((CHAR*)"Truncating final comment character", 35);
OPM_LogWLn();
}
}
if (isExported) {
if (i >= 256) {
OPM_LogWStr((CHAR*)"Warning: commentText overflow", 30);
OPM_LogWLn();
i = 255;
}
commentText[__X(i, 256)] = 0x00;
OPM_StoreComment(commentText, 256);
}
}
void OPS_Get (INT8 *sym)
{
INT8 s;
struct Get__1 _s;
_s.lnk = Get__1_s;
Get__1_s = &_s;
OPM_errpos = OPM_curpos - 1;
while (OPS_ch <= ' ') {
if (OPS_ch == 0x00) {
*sym = 64;
Get__1_s = _s.lnk;
return;
} else {
OPM_Get(&OPS_ch);
}
}
switch (OPS_ch) {
case '"': case '\'':
OPS_Str(&s);
break;
case '#':
s = 10;
OPM_Get(&OPS_ch);
break;
case '&':
s = 5;
OPM_Get(&OPS_ch);
break;
case '(':
OPM_Get(&OPS_ch);
if (OPS_ch == '*') {
Comment__2();
OPS_Get(&s);
} else {
s = 30;
}
break;
case ')':
s = 22;
OPM_Get(&OPS_ch);
break;
case '*':
s = 1;
OPM_Get(&OPS_ch);
break;
case '+':
s = 6;
OPM_Get(&OPS_ch);
break;
case ',':
s = 19;
OPM_Get(&OPS_ch);
break;
case '-':
s = 7;
OPM_Get(&OPS_ch);
break;
case '.':
OPM_Get(&OPS_ch);
if (OPS_ch == '.') {
OPM_Get(&OPS_ch);
s = 21;
} else {
s = 18;
}
break;
case '/':
s = 2;
OPM_Get(&OPS_ch);
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
OPS_Number();
s = 35;
break;
case ':':
OPM_Get(&OPS_ch);
if (OPS_ch == '=') {
OPM_Get(&OPS_ch);
s = 34;
} else {
s = 20;
}
break;
case ';':
s = 39;
OPM_Get(&OPS_ch);
break;
case '<':
OPM_Get(&OPS_ch);
if (OPS_ch == '=') {
OPM_Get(&OPS_ch);
s = 12;
} else {
s = 11;
}
break;
case '=':
s = 9;
OPM_Get(&OPS_ch);
break;
case '>':
OPM_Get(&OPS_ch);
if (OPS_ch == '=') {
OPM_Get(&OPS_ch);
s = 14;
} else {
s = 13;
}
break;
case 'A':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "ARRAY") == 0) {
s = 54;
}
break;
case 'B':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "BEGIN") == 0) {
s = 57;
} else if (__STRCMP(OPS_name, "BY") == 0) {
s = 29;
}
break;
case 'C':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "CASE") == 0) {
s = 46;
} else if (__STRCMP(OPS_name, "CONST") == 0) {
s = 58;
}
break;
case 'D':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "DO") == 0) {
s = 27;
} else if (__STRCMP(OPS_name, "DIV") == 0) {
s = 3;
}
break;
case 'E':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "END") == 0) {
s = 41;
} else if (__STRCMP(OPS_name, "ELSE") == 0) {
s = 42;
} else if (__STRCMP(OPS_name, "ELSIF") == 0) {
s = 43;
} else if (__STRCMP(OPS_name, "EXIT") == 0) {
s = 52;
}
break;
case 'F':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "FOR") == 0) {
s = 49;
}
break;
case 'I':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "IF") == 0) {
s = 45;
} else if (__STRCMP(OPS_name, "IN") == 0) {
s = 15;
} else if (__STRCMP(OPS_name, "IS") == 0) {
s = 16;
} else if (__STRCMP(OPS_name, "IMPORT") == 0) {
s = 62;
}
break;
case 'L':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "LOOP") == 0) {
s = 50;
}
break;
case 'M':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "MOD") == 0) {
s = 4;
} else if (__STRCMP(OPS_name, "MODULE") == 0) {
s = 63;
}
break;
case 'N':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "NIL") == 0) {
s = 36;
}
break;
case 'O':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "OR") == 0) {
s = 8;
} else if (__STRCMP(OPS_name, "OF") == 0) {
s = 25;
}
break;
case 'P':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "PROCEDURE") == 0) {
s = 61;
} else if (__STRCMP(OPS_name, "POINTER") == 0) {
s = 56;
}
break;
case 'R':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "RECORD") == 0) {
s = 55;
} else if (__STRCMP(OPS_name, "REPEAT") == 0) {
s = 48;
} else if (__STRCMP(OPS_name, "RETURN") == 0) {
s = 53;
}
break;
case 'T':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "THEN") == 0) {
s = 26;
} else if (__STRCMP(OPS_name, "TO") == 0) {
s = 28;
} else if (__STRCMP(OPS_name, "TYPE") == 0) {
s = 59;
}
break;
case 'U':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "UNTIL") == 0) {
s = 44;
}
break;
case 'V':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "VAR") == 0) {
s = 60;
}
break;
case 'W':
OPS_Identifier(&s);
if (__STRCMP(OPS_name, "WHILE") == 0) {
s = 47;
} else if (__STRCMP(OPS_name, "WITH") == 0) {
s = 51;
}
break;
case 'G': case 'H': case 'J': case 'K': case 'Q':
case 'S': case 'X': case 'Y': case 'Z':
OPS_Identifier(&s);
break;
case '[':
s = 31;
OPM_Get(&OPS_ch);
break;
case ']':
s = 23;
OPM_Get(&OPS_ch);
break;
case '^':
s = 17;
OPM_Get(&OPS_ch);
break;
case 'a': case 'b': case 'c': case 'd': case 'e':
case 'f': case 'g': case 'h': case 'i': case 'j':
case 'k': case 'l': case 'm': case 'n': case 'o':
case 'p': case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x': case 'y':
case 'z':
OPS_Identifier(&s);
break;
case '{':
s = 32;
OPM_Get(&OPS_ch);
break;
case '|':
s = 40;
OPM_Get(&OPS_ch);
break;
case '}':
s = 24;
OPM_Get(&OPS_ch);
break;
case '~':
s = 33;
OPM_Get(&OPS_ch);
break;
case 0x7f:
s = 21;
OPM_Get(&OPS_ch);
break;
default:
s = 0;
OPM_Get(&OPS_ch);
break;
}
*sym = s;
Get__1_s = _s.lnk;
}
void OPS_Init (void)
{
OPS_ch = ' ';
}
export void *OPS__init(void)
{
__DEFMOD;
__MODULE_IMPORT(OPM);
__REGMOD("OPS", 0);
__REGCMD("Init", OPS_Init);
/* BEGIN */
__ENDMOD;
}

28
bootstrap/unix-48/OPS.h Normal file
View file

@ -0,0 +1,28 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPS__h
#define OPS__h
#include "SYSTEM.h"
typedef
CHAR OPS_Name[256];
typedef
CHAR OPS_String[256];
import OPS_Name OPS_name;
import OPS_String OPS_str;
import INT16 OPS_numtyp;
import INT64 OPS_intval;
import REAL OPS_realval;
import LONGREAL OPS_lrlval;
import void OPS_Get (INT8 *sym);
import void OPS_Init (void);
import void *OPS__init(void);
#endif // OPS

2261
bootstrap/unix-48/OPT.c Normal file

File diff suppressed because it is too large Load diff

128
bootstrap/unix-48/OPT.h Normal file
View file

@ -0,0 +1,128 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPT__h
#define OPT__h
#include "SYSTEM.h"
#include "OPS.h"
typedef
struct OPT_ConstDesc *OPT_Const;
typedef
OPS_String *OPT_ConstExt;
typedef
struct OPT_ConstDesc {
OPT_ConstExt ext;
INT64 intval;
INT32 intval2;
UINT64 setval;
LONGREAL realval;
} OPT_ConstDesc;
typedef
struct OPT_LinkDesc *OPT_Link;
typedef
struct OPT_LinkDesc {
OPS_Name name;
OPT_Link next;
} OPT_LinkDesc;
typedef
struct OPT_NodeDesc *OPT_Node;
typedef
struct OPT_StrDesc *OPT_Struct;
typedef
struct OPT_ObjDesc *OPT_Object;
typedef
struct OPT_NodeDesc {
OPT_Node left, right, link;
INT8 class, subcl;
BOOLEAN readonly;
OPT_Struct typ;
OPT_Object obj;
OPT_Const conval;
} OPT_NodeDesc;
typedef
struct OPT_ObjDesc {
OPT_Object left, right, link, scope;
OPS_Name name;
BOOLEAN leaf;
INT8 mode, mnolev, vis, history;
BOOLEAN used, fpdone;
INT32 fprint;
OPT_Struct typ;
OPT_Const conval;
INT32 adr, linkadr;
INT16 x;
OPT_ConstExt comment;
} OPT_ObjDesc;
typedef
struct OPT_StrDesc {
INT8 form, comp, mno, extlev;
INT16 ref, sysflag;
INT32 n, size, align, txtpos;
BOOLEAN allocated, pbused, pvused;
char _prvt0[4];
INT32 idfp;
char _prvt1[8];
OPT_Struct BaseTyp;
OPT_Object link, strobj;
} OPT_StrDesc;
import OPT_Object OPT_topScope;
import OPT_Struct OPT_undftyp, OPT_niltyp, OPT_notyp, OPT_bytetyp, OPT_cpbytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_hinttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_settyp, OPT_set32typ, OPT_set64typ, OPT_realtyp, OPT_lrltyp, OPT_stringtyp, OPT_adrtyp, OPT_sysptrtyp;
import OPT_Object OPT_sintobj, OPT_intobj, OPT_lintobj, OPT_setobj;
import INT8 OPT_nofGmod;
import OPT_Object OPT_GlbMod[64];
import OPS_Name OPT_SelfName;
import BOOLEAN OPT_SYSimported;
import OPT_Link OPT_Links;
import ADDRESS *OPT_ConstDesc__typ;
import ADDRESS *OPT_ObjDesc__typ;
import ADDRESS *OPT_StrDesc__typ;
import ADDRESS *OPT_NodeDesc__typ;
import ADDRESS *OPT_LinkDesc__typ;
import void OPT_Align (INT32 *adr, INT32 base);
import INT32 OPT_BaseAlignment (OPT_Struct typ);
import void OPT_Close (void);
import void OPT_CloseScope (void);
import void OPT_Export (BOOLEAN *ext, BOOLEAN *new);
import void OPT_FPrintErr (OPT_Object obj, INT16 errcode);
import void OPT_FPrintObj (OPT_Object obj);
import void OPT_FPrintStr (OPT_Struct typ);
import void OPT_Find (OPT_Object *res);
import void OPT_FindField (OPS_Name name, OPT_Struct typ, OPT_Object *res);
import void OPT_FindImport (OPT_Object mod, OPT_Object *res);
import void OPT_IdFPrint (OPT_Struct typ);
import void OPT_Import (OPS_Name aliasName, OPS_Name name, BOOLEAN *done);
import void OPT_Init (OPS_Name name, UINT32 opt);
import void OPT_InitRecno (void);
import void OPT_Insert (OPS_Name name, OPT_Object *obj);
import void OPT_InsertImport (OPT_Object obj, OPT_Object *root, OPT_Object *old);
import INT16 OPT_IntSize (INT64 n);
import OPT_Struct OPT_IntType (INT32 size);
import OPT_Const OPT_NewConst (void);
import OPT_ConstExt OPT_NewExt (void);
import OPT_Node OPT_NewNode (INT8 class);
import OPT_Object OPT_NewObj (void);
import OPT_Struct OPT_NewStr (INT8 form, INT8 comp);
import void OPT_OpenScope (INT8 level, OPT_Object owner);
import OPT_Struct OPT_SetType (INT32 size);
import OPT_Struct OPT_ShorterOrLongerType (OPT_Struct x, INT16 dir);
import INT32 OPT_SizeAlignment (INT32 size);
import void OPT_TypSize (OPT_Struct typ);
import void *OPT__init(void);
#endif // OPT

1585
bootstrap/unix-48/OPV.c Normal file

File diff suppressed because it is too large Load diff

18
bootstrap/unix-48/OPV.h Normal file
View file

@ -0,0 +1,18 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPV__h
#define OPV__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPV_AdrAndSize (OPT_Object topScope);
import void OPV_Init (void);
import void OPV_Module (OPT_Node prog);
import void *OPV__init(void);
#endif // OPV

345
bootstrap/unix-48/Out.c Normal file
View file

@ -0,0 +1,345 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Heap.h"
#include "Platform.h"
export BOOLEAN Out_IsConsole;
static CHAR Out_buf[128];
static INT16 Out_in;
export void Out_Char (CHAR ch);
export void Out_Flush (void);
export void Out_Hex (INT64 x, INT64 n);
export void Out_Int (INT64 x, INT64 n);
static INT32 Out_Length (CHAR *s, ADDRESS s__len);
export void Out_Ln (void);
export void Out_LongReal (LONGREAL x, INT16 n);
export void Out_Open (void);
export void Out_Real (REAL x, INT16 n);
static void Out_RealP (LONGREAL x, INT16 n, BOOLEAN long_);
export void Out_String (CHAR *str, ADDRESS str__len);
export LONGREAL Out_Ten (INT16 e);
static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i);
static void Out_prepend (CHAR *t, ADDRESS t__len, CHAR *s, ADDRESS s__len, INT16 *i);
#define Out_Entier64(x) (INT64)(x)
void Out_Flush (void)
{
INT16 error;
if (Out_in > 0) {
error = Platform_Write(1, (ADDRESS)Out_buf, Out_in);
}
Out_in = 0;
}
void Out_Open (void)
{
}
void Out_Char (CHAR ch)
{
if (Out_in >= 128) {
Out_Flush();
}
Out_buf[__X(Out_in, 128)] = ch;
Out_in += 1;
if (ch == 0x0a) {
Out_Flush();
}
}
static INT32 Out_Length (CHAR *s, ADDRESS s__len)
{
INT32 l;
l = 0;
while ((l < s__len && s[__X(l, s__len)] != 0x00)) {
l += 1;
}
return l;
}
void Out_String (CHAR *str, ADDRESS str__len)
{
INT32 l;
INT16 error;
__DUP(str, str__len, CHAR);
l = Out_Length((void*)str, str__len);
if (Out_in + l > 128) {
Out_Flush();
}
if (l > 128) {
error = Platform_Write(1, (ADDRESS)str, l);
} else {
__MOVE((ADDRESS)str, (ADDRESS)&Out_buf[__X(Out_in, 128)], l);
Out_in += __SHORT(l, 32768);
}
__DEL(str);
}
void Out_Int (INT64 x, INT64 n)
{
CHAR s[22];
INT16 i;
BOOLEAN negative;
negative = x < 0;
if (x == (-9223372036854775807LL-1)) {
__MOVE("8085774586302733229", s, 20);
i = 19;
} else {
if (x < 0) {
x = -x;
}
s[0] = __CHR(48 + __MOD(x, 10));
x = __DIV(x, 10);
i = 1;
while (x != 0) {
s[__X(i, 22)] = __CHR(48 + __MOD(x, 10));
x = __DIV(x, 10);
i += 1;
}
}
if (negative) {
s[__X(i, 22)] = '-';
i += 1;
}
while (n > (INT64)i) {
Out_Char(' ');
n -= 1;
}
while (i > 0) {
i -= 1;
Out_Char(s[__X(i, 22)]);
}
}
void Out_Hex (INT64 x, INT64 n)
{
if (n < 1) {
n = 1;
} else if (n > 16) {
n = 16;
}
if (x >= 0) {
while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) {
n += 1;
}
}
x = __ROT(x, __ASHL(16 - n, 2), 64);
while (n > 0) {
x = __ROTL(x, 4, 64);
n -= 1;
if (__MASK(x, -16) < 10) {
Out_Char(__CHR(__MASK(x, -16) + 48));
} else {
Out_Char(__CHR((__MASK(x, -16) - 10) + 65));
}
}
}
void Out_Ln (void)
{
Out_String(Platform_NL, 3);
Out_Flush();
}
static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i)
{
*i -= 1;
s[__X(*i, s__len)] = __CHR(__MOD(n, 10) + 48);
}
static void Out_prepend (CHAR *t, ADDRESS t__len, CHAR *s, ADDRESS s__len, INT16 *i)
{
INT16 j;
INT32 l;
__DUP(t, t__len, CHAR);
l = Out_Length((void*)t, t__len);
if (l > *i) {
l = *i;
}
*i -= __SHORT(l, 32768);
j = 0;
while (j < l) {
s[__X(*i + j, s__len)] = t[__X(j, t__len)];
j += 1;
}
__DEL(t);
}
LONGREAL Out_Ten (INT16 e)
{
LONGREAL r, power;
r = (LONGREAL)1;
power = (LONGREAL)10;
while (e > 0) {
if (__ODD(e)) {
r = r * power;
}
power = power * power;
e = __ASHR(e, 1);
}
return r;
}
static void Out_RealP (LONGREAL x, INT16 n, BOOLEAN long_)
{
INT16 e;
INT64 f;
CHAR s[30];
INT16 i, el;
LONGREAL x0;
BOOLEAN nn, en;
INT64 m;
INT16 d, dr;
e = (INT16)__MASK(__ASHR((__VAL(INT64, x)), 52), -2048);
f = __MASK((__VAL(INT64, x)), -4503599627370496LL);
nn = (__VAL(INT64, x) < 0 && !((e == 2047 && f != 0)));
if (nn) {
n -= 1;
}
i = 30;
if (e == 2047) {
if (f == 0) {
Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i);
} else {
Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i);
}
} else {
if (long_) {
el = 3;
dr = n - 6;
if (dr > 17) {
dr = 17;
}
d = dr;
if (d < 15) {
d = 15;
}
} else {
el = 2;
dr = n - 5;
if (dr > 9) {
dr = 9;
}
d = dr;
if (d < 6) {
d = 6;
}
}
if (e == 0) {
while (el > 0) {
i -= 1;
s[__X(i, 30)] = '0';
el -= 1;
}
i -= 1;
s[__X(i, 30)] = '+';
m = 0;
} else {
if (nn) {
x = -x;
}
e = __SHORT(__ASHR((e - 1023) * 77, 8), 32768);
if (e >= 0) {
x = x / (LONGREAL)Out_Ten(e);
} else {
x = Out_Ten(-e) * x;
}
if (x >= (LONGREAL)10) {
x = 1.00000000000000e-001 * x;
e += 1;
}
en = e < 0;
if (en) {
e = -e;
}
while (el > 0) {
Out_digit(e, (void*)s, 30, &i);
e = __DIV(e, 10);
el -= 1;
}
i -= 1;
if (en) {
s[__X(i, 30)] = '-';
} else {
s[__X(i, 30)] = '+';
}
x0 = Out_Ten(d - 1);
x = x0 * x;
x = x + 5.00000000000000e-001;
if (x >= (LONGREAL)10 * x0) {
x = 1.00000000000000e-001 * x;
e += 1;
}
m = Out_Entier64(x);
}
i -= 1;
if (long_) {
s[__X(i, 30)] = 'D';
} else {
s[__X(i, 30)] = 'E';
}
if (dr < 2) {
dr = 2;
}
while ((d > dr && __MOD(m, 10) == 0)) {
m = __DIV(m, 10);
d -= 1;
}
while (d > 1) {
Out_digit(m, (void*)s, 30, &i);
m = __DIV(m, 10);
d -= 1;
}
i -= 1;
s[__X(i, 30)] = '.';
Out_digit(m, (void*)s, 30, &i);
}
n -= 30 - i;
while (n > 0) {
Out_Char(' ');
n -= 1;
}
if (nn) {
Out_Char('-');
}
while (i < 30) {
Out_Char(s[__X(i, 30)]);
i += 1;
}
}
void Out_Real (REAL x, INT16 n)
{
Out_RealP(x, n, 0);
}
void Out_LongReal (LONGREAL x, INT16 n)
{
Out_RealP(x, n, 1);
}
export void *Out__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Platform);
__REGMOD("Out", 0);
__REGCMD("Flush", Out_Flush);
__REGCMD("Ln", Out_Ln);
__REGCMD("Open", Out_Open);
/* BEGIN */
Out_IsConsole = Platform_IsConsole(1);
Out_in = 0;
__ENDMOD;
}

25
bootstrap/unix-48/Out.h Normal file
View file

@ -0,0 +1,25 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Out__h
#define Out__h
#include "SYSTEM.h"
import BOOLEAN Out_IsConsole;
import void Out_Char (CHAR ch);
import void Out_Flush (void);
import void Out_Hex (INT64 x, INT64 n);
import void Out_Int (INT64 x, INT64 n);
import void Out_Ln (void);
import void Out_LongReal (LONGREAL x, INT16 n);
import void Out_Open (void);
import void Out_Real (REAL x, INT16 n);
import void Out_String (CHAR *str, ADDRESS str__len);
import LONGREAL Out_Ten (INT16 e);
import void *Out__init(void);
#endif // Out

View file

@ -0,0 +1,535 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
typedef
struct Platform_FileIdentity {
INT32 volume, index, mtime;
} Platform_FileIdentity;
typedef
void (*Platform_SignalHandler)(INT32);
export BOOLEAN Platform_LittleEndian;
export INT16 Platform_PID;
export CHAR Platform_CWD[256];
static INT32 Platform_TimeStart;
export INT16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
export CHAR Platform_NL[3];
export ADDRESS *Platform_FileIdentity__typ;
export BOOLEAN Platform_Absent (INT16 e);
export INT16 Platform_Chdir (CHAR *n, ADDRESS n__len);
export INT16 Platform_Close (INT32 h);
export BOOLEAN Platform_ConnectionFailed (INT16 e);
export void Platform_Delay (INT32 ms);
export BOOLEAN Platform_DifferentFilesystems (INT16 e);
export INT16 Platform_Error (void);
export void Platform_Exit (INT32 code);
export void Platform_GetClock (INT32 *t, INT32 *d);
export void Platform_GetEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
export void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec);
export INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ);
export INT16 Platform_IdentifyByName (CHAR *n, ADDRESS n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ);
export BOOLEAN Platform_Inaccessible (INT16 e);
export BOOLEAN Platform_Interrupted (INT16 e);
export BOOLEAN Platform_IsConsole (INT32 h);
export void Platform_MTimeAsClock (Platform_FileIdentity i, INT32 *t, INT32 *d);
export INT16 Platform_MaxNameLength (void);
export INT16 Platform_MaxPathLength (void);
export INT16 Platform_New (CHAR *n, ADDRESS n__len, INT32 *h);
export BOOLEAN Platform_NoSuchDirectory (INT16 e);
export INT32 Platform_OSAllocate (INT32 size);
export void Platform_OSFree (INT32 address);
export INT16 Platform_OldRO (CHAR *n, ADDRESS n__len, INT32 *h);
export INT16 Platform_OldRW (CHAR *n, ADDRESS n__len, INT32 *h);
export INT16 Platform_Read (INT32 h, INT32 p, INT32 l, INT32 *n);
export INT16 Platform_ReadBuf (INT32 h, SYSTEM_BYTE *b, ADDRESS b__len, INT32 *n);
export INT16 Platform_Rename (CHAR *o, ADDRESS o__len, CHAR *n, ADDRESS n__len);
export BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
export BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
export INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence);
export void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
export void Platform_SetInterruptHandler (Platform_SignalHandler handler);
export void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source);
export void Platform_SetQuitHandler (Platform_SignalHandler handler);
export INT16 Platform_Size (INT32 h, INT32 *l);
export INT16 Platform_Sync (INT32 h);
export INT16 Platform_System (CHAR *cmd, ADDRESS cmd__len);
static void Platform_TestLittleEndian (void);
export INT32 Platform_Time (void);
export BOOLEAN Platform_TimedOut (INT16 e);
export BOOLEAN Platform_TooManyFiles (INT16 e);
export INT16 Platform_Truncate (INT32 h, INT32 l);
export INT16 Platform_Unlink (CHAR *n, ADDRESS n__len);
export INT16 Platform_Write (INT32 h, INT32 p, INT32 l);
static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d);
export BOOLEAN Platform_getEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#define Platform_EACCES() EACCES
#define Platform_EAGAIN() EAGAIN
#define Platform_ECONNABORTED() ECONNABORTED
#define Platform_ECONNREFUSED() ECONNREFUSED
#define Platform_EHOSTUNREACH() EHOSTUNREACH
#define Platform_EINTR() EINTR
#define Platform_EMFILE() EMFILE
#define Platform_ENETUNREACH() ENETUNREACH
#define Platform_ENFILE() ENFILE
#define Platform_ENOENT() ENOENT
#define Platform_EROFS() EROFS
#define Platform_ETIMEDOUT() ETIMEDOUT
#define Platform_EXDEV() EXDEV
#define Platform_NAMEMAX() NAME_MAX
#define Platform_PATHMAX() PATH_MAX
#define Platform_allocate(size) (ADDRESS)((void*)malloc((size_t)size))
#define Platform_chdir(n, n__len) chdir((char*)n)
#define Platform_closefile(fd) close(fd)
#define Platform_err() errno
#define Platform_exit(code) exit((int)code)
#define Platform_free(address) free((void*)address)
#define Platform_fstat(fd) fstat(fd, &s)
#define Platform_fsync(fd) fsync(fd)
#define Platform_ftruncate(fd, l) ftruncate(fd, l)
#define Platform_getcwd(cwd, cwd__len) getcwd((char*)cwd, cwd__len)
#define Platform_getenv(var, var__len) getenv((char*)var)
#define Platform_getpid() (INTEGER)getpid()
#define Platform_gettimeval() struct timeval tv; gettimeofday(&tv,0)
#define Platform_isatty(fd) isatty(fd)
#define Platform_lseek(fd, o, w) lseek(fd, o, w)
#define Platform_nanosleep(s, ns) struct timespec req, rem; req.tv_sec = s; req.tv_nsec = ns; nanosleep(&req, &rem)
#define Platform_opennew(n, n__len) open((char*)n, O_CREAT | O_TRUNC | O_RDWR, 0664)
#define Platform_openro(n, n__len) open((char*)n, O_RDONLY)
#define Platform_openrw(n, n__len) open((char*)n, O_RDWR)
#define Platform_readfile(fd, p, l) (LONGINT)read(fd, (void*)(ADDRESS)(p), l)
#define Platform_rename(o, o__len, n, n__len) rename((char*)o, (char*)n)
#define Platform_sectotm(s) struct tm *time = localtime((time_t*)&s)
#define Platform_seekcur() SEEK_CUR
#define Platform_seekend() SEEK_END
#define Platform_seekset() SEEK_SET
#define Platform_sethandler(s, h) SystemSetHandler(s, (ADDRESS)h)
#define Platform_stat(n, n__len) stat((char*)n, &s)
#define Platform_statdev() (LONGINT)s.st_dev
#define Platform_statino() (LONGINT)s.st_ino
#define Platform_statmtime() (LONGINT)s.st_mtime
#define Platform_statsize() (ADDRESS)s.st_size
#define Platform_structstats() struct stat s
#define Platform_system(str, str__len) system((char*)str)
#define Platform_tmhour() (LONGINT)time->tm_hour
#define Platform_tmmday() (LONGINT)time->tm_mday
#define Platform_tmmin() (LONGINT)time->tm_min
#define Platform_tmmon() (LONGINT)time->tm_mon
#define Platform_tmsec() (LONGINT)time->tm_sec
#define Platform_tmyear() (LONGINT)time->tm_year
#define Platform_tvsec() tv.tv_sec
#define Platform_tvusec() tv.tv_usec
#define Platform_unlink(n, n__len) unlink((char*)n)
#define Platform_writefile(fd, p, l) write(fd, (void*)(ADDRESS)(p), l)
BOOLEAN Platform_TooManyFiles (INT16 e)
{
return e == Platform_EMFILE() || e == Platform_ENFILE();
}
BOOLEAN Platform_NoSuchDirectory (INT16 e)
{
return e == Platform_ENOENT();
}
BOOLEAN Platform_DifferentFilesystems (INT16 e)
{
return e == Platform_EXDEV();
}
BOOLEAN Platform_Inaccessible (INT16 e)
{
return (e == Platform_EACCES() || e == Platform_EROFS()) || e == Platform_EAGAIN();
}
BOOLEAN Platform_Absent (INT16 e)
{
return e == Platform_ENOENT();
}
BOOLEAN Platform_TimedOut (INT16 e)
{
return e == Platform_ETIMEDOUT();
}
BOOLEAN Platform_ConnectionFailed (INT16 e)
{
return ((e == Platform_ECONNREFUSED() || e == Platform_ECONNABORTED()) || e == Platform_ENETUNREACH()) || e == Platform_EHOSTUNREACH();
}
BOOLEAN Platform_Interrupted (INT16 e)
{
return e == Platform_EINTR();
}
INT16 Platform_MaxNameLength (void)
{
return Platform_NAMEMAX();
}
INT16 Platform_MaxPathLength (void)
{
return Platform_PATHMAX();
}
INT32 Platform_OSAllocate (INT32 size)
{
return Platform_allocate(size);
}
void Platform_OSFree (INT32 address)
{
Platform_free(address);
}
typedef
CHAR (*EnvPtr__83)[1024];
BOOLEAN Platform_getEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len)
{
EnvPtr__83 p = NIL;
__DUP(var, var__len, CHAR);
p = (EnvPtr__83)(ADDRESS)Platform_getenv(var, var__len);
if (p != NIL) {
__COPY(*p, val, val__len);
}
__DEL(var);
return p != NIL;
}
void Platform_GetEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len)
{
__DUP(var, var__len, CHAR);
if (!Platform_getEnv(var, var__len, (void*)val, val__len)) {
val[0] = 0x00;
}
__DEL(var);
}
void Platform_SetInterruptHandler (Platform_SignalHandler handler)
{
Platform_sethandler(2, handler);
}
void Platform_SetQuitHandler (Platform_SignalHandler handler)
{
Platform_sethandler(3, handler);
}
void Platform_SetBadInstructionHandler (Platform_SignalHandler handler)
{
Platform_sethandler(4, handler);
}
static void Platform_YMDHMStoClock (INT32 ye, INT32 mo, INT32 da, INT32 ho, INT32 mi, INT32 se, INT32 *t, INT32 *d)
{
*d = (__ASHL((int)__MOD(ye, 100), 9) + __ASHL(mo + 1, 5)) + da;
*t = (__ASHL(ho, 12) + __ASHL(mi, 6)) + se;
}
void Platform_GetClock (INT32 *t, INT32 *d)
{
Platform_gettimeval();
Platform_sectotm(Platform_tvsec());
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
}
void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec)
{
Platform_gettimeval();
*sec = Platform_tvsec();
*usec = Platform_tvusec();
}
INT32 Platform_Time (void)
{
INT32 ms;
Platform_gettimeval();
ms = (int)__DIVF(Platform_tvusec(), 1000) + Platform_tvsec() * 1000;
return (int)__MOD(ms - Platform_TimeStart, 2147483647);
}
void Platform_Delay (INT32 ms)
{
INT32 s, ns;
s = __DIV(ms, 1000);
ns = (int)__MOD(ms, 1000) * 1000000;
Platform_nanosleep(s, ns);
}
INT16 Platform_System (CHAR *cmd, ADDRESS cmd__len)
{
__DUP(cmd, cmd__len, CHAR);
__DEL(cmd);
return Platform_system(cmd, cmd__len);
}
INT16 Platform_Error (void)
{
return Platform_err();
}
INT16 Platform_OldRO (CHAR *n, ADDRESS n__len, INT32 *h)
{
INT16 fd;
fd = Platform_openro(n, n__len);
if (fd < 0) {
return Platform_err();
} else {
*h = fd;
return 0;
}
__RETCHK;
}
INT16 Platform_OldRW (CHAR *n, ADDRESS n__len, INT32 *h)
{
INT16 fd;
fd = Platform_openrw(n, n__len);
if (fd < 0) {
return Platform_err();
} else {
*h = fd;
return 0;
}
__RETCHK;
}
INT16 Platform_New (CHAR *n, ADDRESS n__len, INT32 *h)
{
INT16 fd;
fd = Platform_opennew(n, n__len);
if (fd < 0) {
return Platform_err();
} else {
*h = fd;
return 0;
}
__RETCHK;
}
INT16 Platform_Close (INT32 h)
{
if (Platform_closefile(h) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
BOOLEAN Platform_IsConsole (INT32 h)
{
return Platform_isatty(h) != 0;
}
INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ)
{
Platform_structstats();
if (Platform_fstat(h) < 0) {
return Platform_err();
}
(*identity).volume = Platform_statdev();
(*identity).index = Platform_statino();
(*identity).mtime = Platform_statmtime();
return 0;
}
INT16 Platform_IdentifyByName (CHAR *n, ADDRESS n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ)
{
__DUP(n, n__len, CHAR);
Platform_structstats();
if (Platform_stat(n, n__len) < 0) {
__DEL(n);
return Platform_err();
}
(*identity).volume = Platform_statdev();
(*identity).index = Platform_statino();
(*identity).mtime = Platform_statmtime();
__DEL(n);
return 0;
}
BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2)
{
return (i1.index == i2.index && i1.volume == i2.volume);
}
BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2)
{
return i1.mtime == i2.mtime;
}
void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source)
{
(*target).mtime = source.mtime;
}
void Platform_MTimeAsClock (Platform_FileIdentity i, INT32 *t, INT32 *d)
{
Platform_sectotm(i.mtime);
Platform_YMDHMStoClock(Platform_tmyear(), Platform_tmmon(), Platform_tmmday(), Platform_tmhour(), Platform_tmmin(), Platform_tmsec(), &*t, &*d);
}
INT16 Platform_Size (INT32 h, INT32 *l)
{
Platform_structstats();
if (Platform_fstat(h) < 0) {
return Platform_err();
}
*l = Platform_statsize();
return 0;
}
INT16 Platform_Read (INT32 h, INT32 p, INT32 l, INT32 *n)
{
*n = Platform_readfile(h, p, l);
if (*n < 0) {
*n = 0;
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_ReadBuf (INT32 h, SYSTEM_BYTE *b, ADDRESS b__len, INT32 *n)
{
*n = Platform_readfile(h, (ADDRESS)b, b__len);
if (*n < 0) {
*n = 0;
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Write (INT32 h, INT32 p, INT32 l)
{
INT32 written;
written = Platform_writefile(h, p, l);
if (written < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Sync (INT32 h)
{
if (Platform_fsync(h) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence)
{
if (Platform_lseek(h, offset, whence) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Truncate (INT32 h, INT32 l)
{
if (Platform_ftruncate(h, l) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Unlink (CHAR *n, ADDRESS n__len)
{
if (Platform_unlink(n, n__len) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
INT16 Platform_Chdir (CHAR *n, ADDRESS n__len)
{
INT16 r;
if ((Platform_chdir(n, n__len) >= 0 && Platform_getcwd((void*)Platform_CWD, 256) != NIL)) {
return 0;
} else {
return Platform_err();
}
__RETCHK;
}
INT16 Platform_Rename (CHAR *o, ADDRESS o__len, CHAR *n, ADDRESS n__len)
{
if (Platform_rename(o, o__len, n, n__len) < 0) {
return Platform_err();
} else {
return 0;
}
__RETCHK;
}
void Platform_Exit (INT32 code)
{
Platform_exit(code);
}
static void Platform_TestLittleEndian (void)
{
INT16 i;
i = 1;
__GET((ADDRESS)&i, Platform_LittleEndian, BOOLEAN);
}
__TDESC(Platform_FileIdentity, 1, 0) = {__TDFLDS("FileIdentity", 12), {-4}};
export void *Platform__init(void)
{
__DEFMOD;
__REGMOD("Platform", 0);
__INITYP(Platform_FileIdentity, Platform_FileIdentity, 0);
/* BEGIN */
Platform_TestLittleEndian();
Platform_TimeStart = 0;
Platform_TimeStart = Platform_Time();
Platform_PID = Platform_getpid();
if (Platform_getcwd((void*)Platform_CWD, 256) == NIL) {
Platform_CWD[0] = 0x00;
}
Platform_SeekSet = Platform_seekset();
Platform_SeekCur = Platform_seekcur();
Platform_SeekEnd = Platform_seekend();
Platform_NL[0] = 0x0a;
Platform_NL[1] = 0x00;
__ENDMOD;
}

View file

@ -0,0 +1,74 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Platform__h
#define Platform__h
#include "SYSTEM.h"
typedef
struct Platform_FileIdentity {
INT32 _prvt0;
char _prvt1[8];
} Platform_FileIdentity;
typedef
void (*Platform_SignalHandler)(INT32);
import BOOLEAN Platform_LittleEndian;
import INT16 Platform_PID;
import CHAR Platform_CWD[256];
import INT16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd;
import CHAR Platform_NL[3];
import ADDRESS *Platform_FileIdentity__typ;
import BOOLEAN Platform_Absent (INT16 e);
import INT16 Platform_Chdir (CHAR *n, ADDRESS n__len);
import INT16 Platform_Close (INT32 h);
import BOOLEAN Platform_ConnectionFailed (INT16 e);
import void Platform_Delay (INT32 ms);
import BOOLEAN Platform_DifferentFilesystems (INT16 e);
import INT16 Platform_Error (void);
import void Platform_Exit (INT32 code);
import void Platform_GetClock (INT32 *t, INT32 *d);
import void Platform_GetEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
import void Platform_GetTimeOfDay (INT32 *sec, INT32 *usec);
import INT16 Platform_Identify (INT32 h, Platform_FileIdentity *identity, ADDRESS *identity__typ);
import INT16 Platform_IdentifyByName (CHAR *n, ADDRESS n__len, Platform_FileIdentity *identity, ADDRESS *identity__typ);
import BOOLEAN Platform_Inaccessible (INT16 e);
import BOOLEAN Platform_Interrupted (INT16 e);
import BOOLEAN Platform_IsConsole (INT32 h);
import void Platform_MTimeAsClock (Platform_FileIdentity i, INT32 *t, INT32 *d);
import INT16 Platform_MaxNameLength (void);
import INT16 Platform_MaxPathLength (void);
import INT16 Platform_New (CHAR *n, ADDRESS n__len, INT32 *h);
import BOOLEAN Platform_NoSuchDirectory (INT16 e);
import INT32 Platform_OSAllocate (INT32 size);
import void Platform_OSFree (INT32 address);
import INT16 Platform_OldRO (CHAR *n, ADDRESS n__len, INT32 *h);
import INT16 Platform_OldRW (CHAR *n, ADDRESS n__len, INT32 *h);
import INT16 Platform_Read (INT32 h, INT32 p, INT32 l, INT32 *n);
import INT16 Platform_ReadBuf (INT32 h, SYSTEM_BYTE *b, ADDRESS b__len, INT32 *n);
import INT16 Platform_Rename (CHAR *o, ADDRESS o__len, CHAR *n, ADDRESS n__len);
import BOOLEAN Platform_SameFile (Platform_FileIdentity i1, Platform_FileIdentity i2);
import BOOLEAN Platform_SameFileTime (Platform_FileIdentity i1, Platform_FileIdentity i2);
import INT16 Platform_Seek (INT32 h, INT32 offset, INT16 whence);
import void Platform_SetBadInstructionHandler (Platform_SignalHandler handler);
import void Platform_SetInterruptHandler (Platform_SignalHandler handler);
import void Platform_SetMTime (Platform_FileIdentity *target, ADDRESS *target__typ, Platform_FileIdentity source);
import void Platform_SetQuitHandler (Platform_SignalHandler handler);
import INT16 Platform_Size (INT32 h, INT32 *l);
import INT16 Platform_Sync (INT32 h);
import INT16 Platform_System (CHAR *cmd, ADDRESS cmd__len);
import INT32 Platform_Time (void);
import BOOLEAN Platform_TimedOut (INT16 e);
import BOOLEAN Platform_TooManyFiles (INT16 e);
import INT16 Platform_Truncate (INT32 h, INT32 l);
import INT16 Platform_Unlink (CHAR *n, ADDRESS n__len);
import INT16 Platform_Write (INT32 h, INT32 p, INT32 l);
import BOOLEAN Platform_getEnv (CHAR *var, ADDRESS var__len, CHAR *val, ADDRESS val__len);
import void *Platform__init(void);
#endif // Platform

157
bootstrap/unix-48/Reals.c Normal file
View file

@ -0,0 +1,157 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len);
export void Reals_Convert (REAL x, INT16 n, CHAR *d, ADDRESS d__len);
export void Reals_ConvertH (REAL y, CHAR *d, ADDRESS d__len);
export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len);
export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len);
export INT16 Reals_Expo (REAL x);
export INT16 Reals_ExpoL (LONGREAL x);
export void Reals_SetExpo (REAL *x, INT16 ex);
export REAL Reals_Ten (INT16 e);
export LONGREAL Reals_TenL (INT16 e);
static CHAR Reals_ToHex (INT16 i);
REAL Reals_Ten (INT16 e)
{
LONGREAL r, power;
r = (LONGREAL)1;
power = (LONGREAL)10;
while (e > 0) {
if (__ODD(e)) {
r = r * power;
}
power = power * power;
e = __ASHR(e, 1);
}
return r;
}
LONGREAL Reals_TenL (INT16 e)
{
LONGREAL r, power;
r = (LONGREAL)1;
power = (LONGREAL)10;
for (;;) {
if (__ODD(e)) {
r = r * power;
}
e = __ASHR(e, 1);
if (e <= 0) {
return r;
}
power = power * power;
}
__RETCHK;
}
INT16 Reals_Expo (REAL x)
{
INT16 i;
__GET((ADDRESS)&x + 2, i, INT16);
return __MASK(__ASHR(i, 7), -256);
}
void Reals_SetExpo (REAL *x, INT16 ex)
{
CHAR c;
__GET((ADDRESS)x + 3, c, CHAR);
__PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR);
__GET((ADDRESS)x + 2, c, CHAR);
__PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR);
}
INT16 Reals_ExpoL (LONGREAL x)
{
INT16 i;
__GET((ADDRESS)&x + 6, i, INT16);
return __MASK(__ASHR(i, 4), -2048);
}
void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len)
{
INT32 i, j, k;
if (x < (LONGREAL)0) {
x = -x;
}
k = 0;
if (n > 9) {
i = __SHORT(__ENTIER(x / (LONGREAL)(LONGREAL)1000000000), 2147483648LL);
j = __SHORT(__ENTIER(x - i * (LONGREAL)1000000000), 2147483648LL);
if (j < 0) {
j = 0;
}
while (k < 9) {
d[__X(k, d__len)] = __CHR((int)__MOD(j, 10) + 48);
j = __DIV(j, 10);
k += 1;
}
} else {
i = __SHORT(__ENTIER(x), 2147483648LL);
}
while (k < n) {
d[__X(k, d__len)] = __CHR((int)__MOD(i, 10) + 48);
i = __DIV(i, 10);
k += 1;
}
}
void Reals_Convert (REAL x, INT16 n, CHAR *d, ADDRESS d__len)
{
Reals_ConvertL(x, n, (void*)d, d__len);
}
static CHAR Reals_ToHex (INT16 i)
{
if (i < 10) {
return __CHR(i + 48);
} else {
return __CHR(i + 55);
}
__RETCHK;
}
static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len)
{
INT16 i;
INT32 l;
CHAR by;
i = 0;
l = b__len;
while (i < l) {
by = __VAL(CHAR, b[__X(i, b__len)]);
d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4));
d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16));
i += 1;
}
}
void Reals_ConvertH (REAL y, CHAR *d, ADDRESS d__len)
{
Reals_BytesToHex((void*)&y, 4, (void*)d, d__len * 1);
}
void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len)
{
Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1);
}
export void *Reals__init(void)
{
__DEFMOD;
__REGMOD("Reals", 0);
/* BEGIN */
__ENDMOD;
}

23
bootstrap/unix-48/Reals.h Normal file
View file

@ -0,0 +1,23 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Reals__h
#define Reals__h
#include "SYSTEM.h"
import void Reals_Convert (REAL x, INT16 n, CHAR *d, ADDRESS d__len);
import void Reals_ConvertH (REAL y, CHAR *d, ADDRESS d__len);
import void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len);
import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len);
import INT16 Reals_Expo (REAL x);
import INT16 Reals_ExpoL (LONGREAL x);
import void Reals_SetExpo (REAL *x, INT16 ex);
import REAL Reals_Ten (INT16 e);
import LONGREAL Reals_TenL (INT16 e);
import void *Reals__init(void);
#endif // Reals

374
bootstrap/unix-48/Strings.c Normal file
View file

@ -0,0 +1,374 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Reals.h"
export void Strings_Append (CHAR *extra, ADDRESS extra__len, CHAR *dest, ADDRESS dest__len);
export void Strings_Cap (CHAR *s, ADDRESS s__len);
export void Strings_Delete (CHAR *s, ADDRESS s__len, INT16 pos, INT16 n);
export void Strings_Extract (CHAR *source, ADDRESS source__len, INT16 pos, INT16 n, CHAR *dest, ADDRESS dest__len);
export void Strings_Insert (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
export INT16 Strings_Length (CHAR *s, ADDRESS s__len);
export BOOLEAN Strings_Match (CHAR *string, ADDRESS string__len, CHAR *pattern, ADDRESS pattern__len);
export INT16 Strings_Pos (CHAR *pattern, ADDRESS pattern__len, CHAR *s, ADDRESS s__len, INT16 pos);
export void Strings_Replace (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
export void Strings_StrToLongReal (CHAR *s, ADDRESS s__len, LONGREAL *r);
export void Strings_StrToReal (CHAR *s, ADDRESS s__len, REAL *r);
INT16 Strings_Length (CHAR *s, ADDRESS s__len)
{
INT32 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
if (i <= 32767) {
__DEL(s);
return __SHORT(i, 32768);
} else {
__DEL(s);
return 32767;
}
__RETCHK;
}
void Strings_Append (CHAR *extra, ADDRESS extra__len, CHAR *dest, ADDRESS dest__len)
{
INT16 n1, n2, i;
__DUP(extra, extra__len, CHAR);
n1 = Strings_Length(dest, dest__len);
n2 = Strings_Length(extra, extra__len);
i = 0;
while ((i < n2 && (i + n1) < dest__len)) {
dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)];
i += 1;
}
if ((i + n1) < dest__len) {
dest[__X(i + n1, dest__len)] = 0x00;
}
__DEL(extra);
}
void Strings_Insert (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len)
{
INT16 n1, n2, i;
__DUP(source, source__len, CHAR);
n1 = Strings_Length(dest, dest__len);
n2 = Strings_Length(source, source__len);
if (pos < 0) {
pos = 0;
}
if (pos > n1) {
Strings_Append(dest, dest__len, (void*)source, source__len);
__DEL(source);
return;
}
if ((pos + n2) < dest__len) {
i = n1;
while (i >= pos) {
if ((i + n2) < dest__len) {
dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)];
}
i -= 1;
}
}
i = 0;
while (i < n2) {
dest[__X(pos + i, dest__len)] = source[__X(i, source__len)];
i += 1;
}
__DEL(source);
}
void Strings_Delete (CHAR *s, ADDRESS s__len, INT16 pos, INT16 n)
{
INT16 len, i;
len = Strings_Length(s, s__len);
if (pos < 0) {
pos = 0;
} else if (pos >= len) {
return;
}
if (pos + n < len) {
i = pos + n;
while (i < len) {
s[__X(i - n, s__len)] = s[__X(i, s__len)];
i += 1;
}
if ((i - n) < s__len) {
s[__X(i - n, s__len)] = 0x00;
}
} else {
s[__X(pos, s__len)] = 0x00;
}
}
void Strings_Replace (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len)
{
__DUP(source, source__len, CHAR);
Strings_Delete((void*)dest, dest__len, pos, pos + Strings_Length(source, source__len));
Strings_Insert(source, source__len, pos, (void*)dest, dest__len);
__DEL(source);
}
void Strings_Extract (CHAR *source, ADDRESS source__len, INT16 pos, INT16 n, CHAR *dest, ADDRESS dest__len)
{
INT16 len, destLen, i;
__DUP(source, source__len, CHAR);
len = Strings_Length(source, source__len);
destLen = __SHORT(dest__len, 32768) - 1;
if (pos < 0) {
pos = 0;
}
if (pos >= len) {
dest[0] = 0x00;
__DEL(source);
return;
}
i = 0;
while (((((pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) {
if (i < destLen) {
dest[__X(i, dest__len)] = source[__X(pos + i, source__len)];
}
i += 1;
}
dest[__X(i, dest__len)] = 0x00;
__DEL(source);
}
INT16 Strings_Pos (CHAR *pattern, ADDRESS pattern__len, CHAR *s, ADDRESS s__len, INT16 pos)
{
INT16 n1, n2, i, j;
__DUP(pattern, pattern__len, CHAR);
__DUP(s, s__len, CHAR);
n1 = Strings_Length(s, s__len);
n2 = Strings_Length(pattern, pattern__len);
if (n2 == 0) {
__DEL(pattern);
__DEL(s);
return 0;
}
i = pos;
while (i <= n1 - n2) {
if (s[__X(i, s__len)] == pattern[0]) {
j = 1;
while ((j < n2 && s[__X(i + j, s__len)] == pattern[__X(j, pattern__len)])) {
j += 1;
}
if (j == n2) {
__DEL(pattern);
__DEL(s);
return i;
}
}
i += 1;
}
__DEL(pattern);
__DEL(s);
return -1;
}
void Strings_Cap (CHAR *s, ADDRESS s__len)
{
INT16 i;
i = 0;
while (s[__X(i, s__len)] != 0x00) {
if (('a' <= s[__X(i, s__len)] && s[__X(i, s__len)] <= 'z')) {
s[__X(i, s__len)] = __CAP(s[__X(i, s__len)]);
}
i += 1;
}
}
static struct Match__7 {
struct Match__7 *lnk;
} *Match__7_s;
static BOOLEAN M__8 (CHAR *name, ADDRESS name__len, CHAR *mask, ADDRESS mask__len, INT16 n, INT16 m);
static BOOLEAN M__8 (CHAR *name, ADDRESS name__len, CHAR *mask, ADDRESS mask__len, INT16 n, INT16 m)
{
while ((((n >= 0 && m >= 0)) && mask[__X(m, mask__len)] != '*')) {
if (name[__X(n, name__len)] != mask[__X(m, mask__len)]) {
return 0;
}
n -= 1;
m -= 1;
}
if (m < 0) {
return n < 0;
}
while ((m >= 0 && mask[__X(m, mask__len)] == '*')) {
m -= 1;
}
if (m < 0) {
return 1;
}
while (n >= 0) {
if (M__8(name, name__len, mask, mask__len, n, m)) {
return 1;
}
n -= 1;
}
return 0;
}
BOOLEAN Strings_Match (CHAR *string, ADDRESS string__len, CHAR *pattern, ADDRESS pattern__len)
{
struct Match__7 _s;
BOOLEAN __retval;
__DUP(string, string__len, CHAR);
__DUP(pattern, pattern__len, CHAR);
_s.lnk = Match__7_s;
Match__7_s = &_s;
__retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1);
Match__7_s = _s.lnk;
__DEL(string);
__DEL(pattern);
;
return __retval;
}
void Strings_StrToReal (CHAR *s, ADDRESS s__len, REAL *r)
{
INT16 p, e;
REAL y, g;
BOOLEAN neg, negE;
__DUP(s, s__len, CHAR);
p = 0;
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
if (s[__X(p, s__len)] == '-') {
neg = 1;
p += 1;
} else {
neg = 0;
}
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
y = (REAL)0;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
y = y * (REAL)10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (s[__X(p, s__len)] == '.') {
p += 1;
g = (REAL)1;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
g = g / (REAL)(REAL)10;
y = y + g * ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
}
if (s[__X(p, s__len)] == 'D' || s[__X(p, s__len)] == 'E') {
p += 1;
e = 0;
if (s[__X(p, s__len)] == '-') {
negE = 1;
p += 1;
} else {
negE = 0;
}
while (s[__X(p, s__len)] == '0') {
p += 1;
}
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
e = e * 10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (negE) {
y = y / (REAL)Reals_Ten(e);
} else {
y = y * Reals_Ten(e);
}
}
if (neg) {
y = -y;
}
*r = y;
__DEL(s);
}
void Strings_StrToLongReal (CHAR *s, ADDRESS s__len, LONGREAL *r)
{
INT16 p, e;
LONGREAL y, g;
BOOLEAN neg, negE;
__DUP(s, s__len, CHAR);
p = 0;
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
if (s[__X(p, s__len)] == '-') {
neg = 1;
p += 1;
} else {
neg = 0;
}
while (s[__X(p, s__len)] == ' ' || s[__X(p, s__len)] == '0') {
p += 1;
}
y = (LONGREAL)0;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
y = y * (LONGREAL)10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (s[__X(p, s__len)] == '.') {
p += 1;
g = (LONGREAL)1;
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
g = g / (LONGREAL)(LONGREAL)10;
y = y + g * ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
}
if (s[__X(p, s__len)] == 'D' || s[__X(p, s__len)] == 'E') {
p += 1;
e = 0;
if (s[__X(p, s__len)] == '-') {
negE = 1;
p += 1;
} else {
negE = 0;
}
while (s[__X(p, s__len)] == '0') {
p += 1;
}
while (('0' <= s[__X(p, s__len)] && s[__X(p, s__len)] <= '9')) {
e = e * 10 + ((INT16)s[__X(p, s__len)] - 48);
p += 1;
}
if (negE) {
y = y / (LONGREAL)Reals_Ten(e);
} else {
y = y * Reals_Ten(e);
}
}
if (neg) {
y = -y;
}
*r = y;
__DEL(s);
}
export void *Strings__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Reals);
__REGMOD("Strings", 0);
/* BEGIN */
__ENDMOD;
}

View file

@ -0,0 +1,25 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Strings__h
#define Strings__h
#include "SYSTEM.h"
import void Strings_Append (CHAR *extra, ADDRESS extra__len, CHAR *dest, ADDRESS dest__len);
import void Strings_Cap (CHAR *s, ADDRESS s__len);
import void Strings_Delete (CHAR *s, ADDRESS s__len, INT16 pos, INT16 n);
import void Strings_Extract (CHAR *source, ADDRESS source__len, INT16 pos, INT16 n, CHAR *dest, ADDRESS dest__len);
import void Strings_Insert (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
import INT16 Strings_Length (CHAR *s, ADDRESS s__len);
import BOOLEAN Strings_Match (CHAR *string, ADDRESS string__len, CHAR *pattern, ADDRESS pattern__len);
import INT16 Strings_Pos (CHAR *pattern, ADDRESS pattern__len, CHAR *s, ADDRESS s__len, INT16 pos);
import void Strings_Replace (CHAR *source, ADDRESS source__len, INT16 pos, CHAR *dest, ADDRESS dest__len);
import void Strings_StrToLongReal (CHAR *s, ADDRESS s__len, LONGREAL *r);
import void Strings_StrToReal (CHAR *s, ADDRESS s__len, REAL *r);
import void *Strings__init(void);
#endif // Strings

1833
bootstrap/unix-48/Texts.c Normal file

File diff suppressed because it is too large Load diff

173
bootstrap/unix-48/Texts.h Normal file
View file

@ -0,0 +1,173 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Texts__h
#define Texts__h
#include "SYSTEM.h"
#include "Files.h"
typedef
struct Texts_BufDesc {
INT32 len;
char _prvt0[4];
} Texts_BufDesc;
typedef
Texts_BufDesc *Texts_Buffer;
typedef
struct Texts_ElemMsg {
char _prvt0[1];
} Texts_ElemMsg;
typedef
struct Texts_ElemDesc *Texts_Elem;
typedef
struct Texts_CopyMsg { /* Texts_ElemMsg */
Texts_Elem e;
} Texts_CopyMsg;
typedef
struct Texts_RunDesc {
INT32 _prvt0;
char _prvt1[15];
} Texts_RunDesc;
typedef
void (*Texts_Handler)(Texts_Elem, Texts_ElemMsg*, ADDRESS *);
typedef
struct Texts_ElemDesc {
char _prvt0[20];
INT32 W, H;
Texts_Handler handle;
char _prvt1[4];
} Texts_ElemDesc;
typedef
struct Texts_FileMsg { /* Texts_ElemMsg */
INT16 id;
INT32 pos;
Files_Rider r;
} Texts_FileMsg;
typedef
struct Texts_FontDesc {
char _prvt0[32];
} Texts_FontDesc;
typedef
Texts_FontDesc *Texts_FontsFont;
typedef
struct Texts_IdentifyMsg { /* Texts_ElemMsg */
CHAR mod[32], proc[32];
} Texts_IdentifyMsg;
typedef
struct Texts_TextDesc *Texts_Text;
typedef
void (*Texts_Notifier)(Texts_Text, INT16, INT32, INT32);
typedef
struct Texts_Reader {
BOOLEAN eot;
Texts_FontsFont fnt;
INT8 col, voff;
Texts_Elem elem;
char _prvt0[32];
} Texts_Reader;
typedef
struct Texts_Scanner { /* Texts_Reader */
BOOLEAN eot;
Texts_FontsFont fnt;
INT8 col, voff;
Texts_Elem elem;
INT64 _prvt0;
char _prvt1[24];
CHAR nextCh;
INT16 line, class;
INT32 i;
REAL x;
LONGREAL y;
CHAR c;
INT8 len;
CHAR s[64];
} Texts_Scanner;
typedef
struct Texts_TextDesc {
INT32 len;
Texts_Notifier notify;
char _prvt0[12];
} Texts_TextDesc;
typedef
struct Texts_Writer {
Texts_Buffer buf;
Texts_FontsFont fnt;
INT8 col, voff;
char _prvt0[26];
} Texts_Writer;
import Texts_Elem Texts_new;
import ADDRESS *Texts_FontDesc__typ;
import ADDRESS *Texts_RunDesc__typ;
import ADDRESS *Texts_ElemMsg__typ;
import ADDRESS *Texts_ElemDesc__typ;
import ADDRESS *Texts_FileMsg__typ;
import ADDRESS *Texts_CopyMsg__typ;
import ADDRESS *Texts_IdentifyMsg__typ;
import ADDRESS *Texts_BufDesc__typ;
import ADDRESS *Texts_TextDesc__typ;
import ADDRESS *Texts_Reader__typ;
import ADDRESS *Texts_Scanner__typ;
import ADDRESS *Texts_Writer__typ;
import void Texts_Append (Texts_Text T, Texts_Buffer B);
import void Texts_ChangeLooks (Texts_Text T, INT32 beg, INT32 end, UINT32 sel, Texts_FontsFont fnt, INT8 col, INT8 voff);
import void Texts_Close (Texts_Text T, CHAR *name, ADDRESS name__len);
import void Texts_Copy (Texts_Buffer SB, Texts_Buffer DB);
import void Texts_CopyElem (Texts_Elem SE, Texts_Elem DE);
import void Texts_Delete (Texts_Text T, INT32 beg, INT32 end);
import Texts_Text Texts_ElemBase (Texts_Elem E);
import INT32 Texts_ElemPos (Texts_Elem E);
import void Texts_Insert (Texts_Text T, INT32 pos, Texts_Buffer B);
import void Texts_Load (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
import void Texts_Open (Texts_Text T, CHAR *name, ADDRESS name__len);
import void Texts_OpenBuf (Texts_Buffer B);
import void Texts_OpenReader (Texts_Reader *R, ADDRESS *R__typ, Texts_Text T, INT32 pos);
import void Texts_OpenScanner (Texts_Scanner *S, ADDRESS *S__typ, Texts_Text T, INT32 pos);
import void Texts_OpenWriter (Texts_Writer *W, ADDRESS *W__typ);
import INT32 Texts_Pos (Texts_Reader *R, ADDRESS *R__typ);
import void Texts_Read (Texts_Reader *R, ADDRESS *R__typ, CHAR *ch);
import void Texts_ReadElem (Texts_Reader *R, ADDRESS *R__typ);
import void Texts_ReadPrevElem (Texts_Reader *R, ADDRESS *R__typ);
import void Texts_Recall (Texts_Buffer *B);
import void Texts_Save (Texts_Text T, INT32 beg, INT32 end, Texts_Buffer B);
import void Texts_Scan (Texts_Scanner *S, ADDRESS *S__typ);
import void Texts_SetColor (Texts_Writer *W, ADDRESS *W__typ, INT8 col);
import void Texts_SetFont (Texts_Writer *W, ADDRESS *W__typ, Texts_FontsFont fnt);
import void Texts_SetOffset (Texts_Writer *W, ADDRESS *W__typ, INT8 voff);
import void Texts_Store (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
import void Texts_Write (Texts_Writer *W, ADDRESS *W__typ, CHAR ch);
import void Texts_WriteDate (Texts_Writer *W, ADDRESS *W__typ, INT32 t, INT32 d);
import void Texts_WriteElem (Texts_Writer *W, ADDRESS *W__typ, Texts_Elem e);
import void Texts_WriteHex (Texts_Writer *W, ADDRESS *W__typ, INT32 x);
import void Texts_WriteInt (Texts_Writer *W, ADDRESS *W__typ, INT64 x, INT64 n);
import void Texts_WriteLn (Texts_Writer *W, ADDRESS *W__typ);
import void Texts_WriteLongReal (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x, INT16 n);
import void Texts_WriteLongRealHex (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x);
import void Texts_WriteReal (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n);
import void Texts_WriteRealFix (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n, INT16 k);
import void Texts_WriteRealHex (Texts_Writer *W, ADDRESS *W__typ, REAL x);
import void Texts_WriteString (Texts_Writer *W, ADDRESS *W__typ, CHAR *s, ADDRESS s__len);
import void *Texts__init(void);
#endif // Texts

275
bootstrap/unix-48/VT100.c Normal file
View file

@ -0,0 +1,275 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Out.h"
#include "Strings.h"
export CHAR VT100_CSI[5];
static CHAR VT100_tmpstr[32];
export void VT100_CHA (INT16 n);
export void VT100_CNL (INT16 n);
export void VT100_CPL (INT16 n);
export void VT100_CUB (INT16 n);
export void VT100_CUD (INT16 n);
export void VT100_CUF (INT16 n);
export void VT100_CUP (INT16 n, INT16 m);
export void VT100_CUU (INT16 n);
export void VT100_DECTCEMh (void);
export void VT100_DECTCEMl (void);
export void VT100_DSR (INT16 n);
export void VT100_ED (INT16 n);
export void VT100_EL (INT16 n);
static void VT100_EscSeq (INT16 n, CHAR *letter, ADDRESS letter__len);
static void VT100_EscSeq0 (CHAR *letter, ADDRESS letter__len);
static void VT100_EscSeq2 (INT16 n, INT16 m, CHAR *letter, ADDRESS letter__len);
static void VT100_EscSeqSwapped (INT16 n, CHAR *letter, ADDRESS letter__len);
export void VT100_HVP (INT16 n, INT16 m);
export void VT100_IntToStr (INT32 int_, CHAR *str, ADDRESS str__len);
export void VT100_RCP (void);
export void VT100_Reset (void);
static void VT100_Reverse0 (CHAR *str, ADDRESS str__len, INT16 start, INT16 end);
export void VT100_SCP (void);
export void VT100_SD (INT16 n);
export void VT100_SGR (INT16 n);
export void VT100_SGR2 (INT16 n, INT16 m);
export void VT100_SU (INT16 n);
export void VT100_SetAttr (CHAR *attr, ADDRESS attr__len);
static void VT100_Reverse0 (CHAR *str, ADDRESS str__len, INT16 start, INT16 end)
{
CHAR h;
while (start < end) {
h = str[__X(start, str__len)];
str[__X(start, str__len)] = str[__X(end, str__len)];
str[__X(end, str__len)] = h;
start += 1;
end -= 1;
}
}
void VT100_IntToStr (INT32 int_, CHAR *str, ADDRESS str__len)
{
CHAR b[21];
INT16 s, e;
INT8 maxLength;
maxLength = 11;
if (int_ == (-2147483647-1)) {
__MOVE("-2147483648", b, 12);
e = 11;
} else {
if (int_ < 0) {
b[0] = '-';
int_ = -int_;
s = 1;
} else {
s = 0;
}
e = s;
do {
b[__X(e, 21)] = __CHR((int)__MOD(int_, 10) + 48);
int_ = __DIV(int_, 10);
e += 1;
} while (!(int_ == 0));
b[__X(e, 21)] = 0x00;
VT100_Reverse0((void*)b, 21, s, e - 1);
}
__COPY(b, str, str__len);
}
static void VT100_EscSeq0 (CHAR *letter, ADDRESS letter__len)
{
CHAR cmd[9];
__DUP(letter, letter__len, CHAR);
__COPY(VT100_CSI, cmd, 9);
Strings_Append(letter, letter__len, (void*)cmd, 9);
Out_String(cmd, 9);
__DEL(letter);
}
static void VT100_EscSeq (INT16 n, CHAR *letter, ADDRESS letter__len)
{
CHAR nstr[2];
CHAR cmd[7];
__DUP(letter, letter__len, CHAR);
VT100_IntToStr(n, (void*)nstr, 2);
__COPY(VT100_CSI, cmd, 7);
Strings_Append(nstr, 2, (void*)cmd, 7);
Strings_Append(letter, letter__len, (void*)cmd, 7);
Out_String(cmd, 7);
__DEL(letter);
}
static void VT100_EscSeqSwapped (INT16 n, CHAR *letter, ADDRESS letter__len)
{
CHAR nstr[2];
CHAR cmd[7];
__DUP(letter, letter__len, CHAR);
VT100_IntToStr(n, (void*)nstr, 2);
__COPY(VT100_CSI, cmd, 7);
Strings_Append(letter, letter__len, (void*)cmd, 7);
Strings_Append(nstr, 2, (void*)cmd, 7);
Out_String(cmd, 7);
__DEL(letter);
}
static void VT100_EscSeq2 (INT16 n, INT16 m, CHAR *letter, ADDRESS letter__len)
{
CHAR nstr[5], mstr[5];
CHAR cmd[12];
__DUP(letter, letter__len, CHAR);
VT100_IntToStr(n, (void*)nstr, 5);
VT100_IntToStr(m, (void*)mstr, 5);
__COPY(VT100_CSI, cmd, 12);
Strings_Append(nstr, 5, (void*)cmd, 12);
Strings_Append((CHAR*)";", 2, (void*)cmd, 12);
Strings_Append(mstr, 5, (void*)cmd, 12);
Strings_Append(letter, letter__len, (void*)cmd, 12);
Out_String(cmd, 12);
__DEL(letter);
}
void VT100_Reset (void)
{
CHAR cmd[6];
__COPY("\033", cmd, 6);
Strings_Append((CHAR*)"c", 2, (void*)cmd, 6);
Out_String(cmd, 6);
Out_Ln();
}
void VT100_CUU (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"A", 2);
}
void VT100_CUD (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"B", 2);
}
void VT100_CUF (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"C", 2);
}
void VT100_CUB (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"D", 2);
}
void VT100_CNL (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"E", 2);
}
void VT100_CPL (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"F", 2);
}
void VT100_CHA (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"G", 2);
}
void VT100_CUP (INT16 n, INT16 m)
{
VT100_EscSeq2(n, m, (CHAR*)"H", 2);
}
void VT100_ED (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"J", 2);
}
void VT100_EL (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"K", 2);
}
void VT100_SU (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"S", 2);
}
void VT100_SD (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"T", 2);
}
void VT100_HVP (INT16 n, INT16 m)
{
VT100_EscSeq2(n, m, (CHAR*)"f", 2);
}
void VT100_SGR (INT16 n)
{
VT100_EscSeq(n, (CHAR*)"m", 2);
}
void VT100_SGR2 (INT16 n, INT16 m)
{
VT100_EscSeq2(n, m, (CHAR*)"m", 2);
}
void VT100_DSR (INT16 n)
{
VT100_EscSeq(6, (CHAR*)"n", 2);
}
void VT100_SCP (void)
{
VT100_EscSeq0((CHAR*)"s", 2);
}
void VT100_RCP (void)
{
VT100_EscSeq0((CHAR*)"u", 2);
}
void VT100_DECTCEMl (void)
{
VT100_EscSeq0((CHAR*)"\?25l", 5);
}
void VT100_DECTCEMh (void)
{
VT100_EscSeq0((CHAR*)"\?25h", 5);
}
void VT100_SetAttr (CHAR *attr, ADDRESS attr__len)
{
CHAR tmpstr[16];
__DUP(attr, attr__len, CHAR);
__COPY(VT100_CSI, tmpstr, 16);
Strings_Append(attr, attr__len, (void*)tmpstr, 16);
Out_String(tmpstr, 16);
__DEL(attr);
}
export void *VT100__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Out);
__MODULE_IMPORT(Strings);
__REGMOD("VT100", 0);
__REGCMD("DECTCEMh", VT100_DECTCEMh);
__REGCMD("DECTCEMl", VT100_DECTCEMl);
__REGCMD("RCP", VT100_RCP);
__REGCMD("Reset", VT100_Reset);
__REGCMD("SCP", VT100_SCP);
/* BEGIN */
__COPY("\033", VT100_CSI, 5);
Strings_Append((CHAR*)"[", 2, (void*)VT100_CSI, 5);
__ENDMOD;
}

38
bootstrap/unix-48/VT100.h Normal file
View file

@ -0,0 +1,38 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef VT100__h
#define VT100__h
#include "SYSTEM.h"
import CHAR VT100_CSI[5];
import void VT100_CHA (INT16 n);
import void VT100_CNL (INT16 n);
import void VT100_CPL (INT16 n);
import void VT100_CUB (INT16 n);
import void VT100_CUD (INT16 n);
import void VT100_CUF (INT16 n);
import void VT100_CUP (INT16 n, INT16 m);
import void VT100_CUU (INT16 n);
import void VT100_DECTCEMh (void);
import void VT100_DECTCEMl (void);
import void VT100_DSR (INT16 n);
import void VT100_ED (INT16 n);
import void VT100_EL (INT16 n);
import void VT100_HVP (INT16 n, INT16 m);
import void VT100_IntToStr (INT32 int_, CHAR *str, ADDRESS str__len);
import void VT100_RCP (void);
import void VT100_Reset (void);
import void VT100_SCP (void);
import void VT100_SD (INT16 n);
import void VT100_SGR (INT16 n);
import void VT100_SGR2 (INT16 n, INT16 m);
import void VT100_SU (INT16 n);
import void VT100_SetAttr (CHAR *attr, ADDRESS attr__len);
import void *VT100__init(void);
#endif // VT100

View file

@ -0,0 +1,139 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Configuration.h"
#include "Heap.h"
#include "Modules.h"
#include "OPM.h"
#include "Out.h"
#include "Platform.h"
#include "Strings.h"
typedef
CHAR extTools_CommandString[4096];
static extTools_CommandString extTools_CFLAGS;
export void extTools_Assemble (CHAR *moduleName, ADDRESS moduleName__len);
static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len);
export void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN statically, CHAR *additionalopts, ADDRESS additionalopts__len);
static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRESS cmd__len);
static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRESS cmd__len)
{
INT16 r, status, exitcode;
extTools_CommandString fullcmd;
__DUP(title, title__len, CHAR);
__DUP(cmd, cmd__len, CHAR);
if (__IN(18, OPM_Options, 32)) {
Out_String((CHAR*)" ", 3);
Out_String(cmd, cmd__len);
Out_Ln();
}
__COPY(cmd, fullcmd, 4096);
Heap_GC(0);
r = Platform_System(fullcmd, 4096);
status = __MASK(r, -128);
exitcode = __ASHR(r, 8);
if (exitcode > 127) {
exitcode = exitcode - 256;
}
if (r != 0) {
Out_String(title, title__len);
Out_String(cmd, cmd__len);
Out_Ln();
Out_String((CHAR*)"-- failed: status ", 19);
Out_Int(status, 1);
Out_String((CHAR*)", exitcode ", 12);
Out_Int(exitcode, 1);
Out_String((CHAR*)".", 2);
Out_Ln();
if ((status == 0 && exitcode == 127)) {
Out_String((CHAR*)"Is the C compiler in the current command path\?", 47);
Out_Ln();
}
if (status != 0) {
Modules_Halt(status);
} else {
Modules_Halt(exitcode);
}
}
__DEL(title);
__DEL(cmd);
}
static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len, CHAR *additionalopts, ADDRESS additionalopts__len)
{
__DUP(additionalopts, additionalopts__len, CHAR);
__COPY("gcc -fPIC -g -Wno-stringop-overflow", s, s__len);
Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len);
Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len);
Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len);
Strings_Append(additionalopts, additionalopts__len, (void*)s, s__len);
Strings_Append((CHAR*)" ", 2, (void*)s, s__len);
Platform_GetEnv((CHAR*)"CFLAGS", 7, (void*)extTools_CFLAGS, 4096);
Strings_Append(extTools_CFLAGS, 4096, (void*)s, s__len);
Strings_Append((CHAR*)" ", 2, (void*)s, s__len);
__DEL(additionalopts);
}
void extTools_Assemble (CHAR *moduleName, ADDRESS moduleName__len)
{
extTools_CommandString cmd;
__DUP(moduleName, moduleName__len, CHAR);
extTools_InitialiseCompilerCommand((void*)cmd, 4096, (CHAR*)"", 1);
Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 4096);
Strings_Append(moduleName, moduleName__len, (void*)cmd, 4096);
Strings_Append((CHAR*)".c", 3, (void*)cmd, 4096);
extTools_execute((CHAR*)"C compile: ", 12, cmd, 4096);
__DEL(moduleName);
}
void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN statically, CHAR *additionalopts, ADDRESS additionalopts__len)
{
extTools_CommandString cmd;
__DUP(additionalopts, additionalopts__len, CHAR);
extTools_InitialiseCompilerCommand((void*)cmd, 4096, additionalopts, additionalopts__len);
Strings_Append(moduleName, moduleName__len, (void*)cmd, 4096);
Strings_Append((CHAR*)".c ", 4, (void*)cmd, 4096);
if (statically) {
Strings_Append((CHAR*)" -static", 9, (void*)cmd, 4096);
}
Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 4096);
Strings_Append(moduleName, moduleName__len, (void*)cmd, 4096);
if (!statically || 1) {
Strings_Append((CHAR*)" -L\"", 5, (void*)cmd, 4096);
Strings_Append(OPM_InstallDir, 1024, (void*)cmd, 4096);
Strings_Append((CHAR*)"/lib\"", 6, (void*)cmd, 4096);
Strings_Append((CHAR*)" -lvoc", 7, (void*)cmd, 4096);
Strings_Append((CHAR*)"-O", 3, (void*)cmd, 4096);
Strings_Append(OPM_Model, 10, (void*)cmd, 4096);
Strings_Append((CHAR*)"", 1, (void*)cmd, 4096);
}
extTools_execute((CHAR*)"C compile and link: ", 21, cmd, 4096);
__DEL(additionalopts);
}
export void *extTools__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Configuration);
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Modules);
__MODULE_IMPORT(OPM);
__MODULE_IMPORT(Out);
__MODULE_IMPORT(Platform);
__MODULE_IMPORT(Strings);
__REGMOD("extTools", 0);
/* BEGIN */
__ENDMOD;
}

View file

@ -0,0 +1,16 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef extTools__h
#define extTools__h
#include "SYSTEM.h"
import void extTools_Assemble (CHAR *moduleName, ADDRESS moduleName__len);
import void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN statically, CHAR *additionalopts, ADDRESS additionalopts__len);
import void *extTools__init(void);
#endif // extTools

View file

@ -0,0 +1,213 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Configuration.h"
#include "Heap.h"
#include "OPB.h"
#include "OPC.h"
#include "OPM.h"
#include "OPP.h"
#include "OPT.h"
#include "OPV.h"
#include "Platform.h"
#include "Strings.h"
#include "VT100.h"
#include "extTools.h"
static void Compiler_FindLocalObjectFiles (CHAR *objectnames, ADDRESS objectnames__len);
export void Compiler_Module (BOOLEAN *done);
static void Compiler_PropagateElementaryTypeSizes (void);
export void Compiler_Translate (void);
static void Compiler_Trap (INT32 sig);
void Compiler_Module (BOOLEAN *done)
{
BOOLEAN ext, new;
OPT_Node p = NIL;
OPP_Module(&p, OPM_Options);
if (OPM_noerr) {
OPV_Init();
OPT_InitRecno();
OPV_AdrAndSize(OPT_topScope);
OPT_Export(&ext, &new);
if (OPM_noerr) {
OPM_OpenFiles((void*)OPT_SelfName, 256);
OPM_DeleteObj((void*)OPT_SelfName, 256);
OPC_Init();
OPV_Module(p);
if (OPM_noerr) {
if ((__IN(10, OPM_Options, 32) && __STRCMP(OPM_modName, "SYSTEM") != 0)) {
OPM_DeleteSym((void*)OPT_SelfName, 256);
OPM_LogVT100((CHAR*)"32m", 4);
OPM_LogWStr((CHAR*)" Main program.", 16);
OPM_LogVT100((CHAR*)"0m", 3);
} else {
if (new) {
OPM_LogVT100((CHAR*)"32m", 4);
OPM_LogWStr((CHAR*)" New symbol file.", 19);
OPM_LogVT100((CHAR*)"0m", 3);
OPM_RegisterNewSym();
} else if (ext) {
OPM_LogWStr((CHAR*)" Extended symbol file.", 24);
OPM_RegisterNewSym();
}
}
} else {
OPM_DeleteSym((void*)OPT_SelfName, 256);
}
}
}
OPM_CloseFiles();
OPT_Close();
OPM_LogWLn();
*done = OPM_noerr;
}
static void Compiler_PropagateElementaryTypeSizes (void)
{
OPT_Struct adrinttyp = NIL;
OPT_sysptrtyp->size = OPM_AddressSize;
OPT_sysptrtyp->idfp = OPT_sysptrtyp->form;
OPM_FPrint(&OPT_sysptrtyp->idfp, OPT_sysptrtyp->size);
OPT_adrtyp->size = OPM_AddressSize;
OPT_adrtyp->idfp = OPT_adrtyp->form;
OPM_FPrint(&OPT_adrtyp->idfp, OPT_adrtyp->size);
adrinttyp = OPT_IntType(OPM_AddressSize);
OPT_adrtyp->strobj = adrinttyp->strobj;
OPT_sinttyp = OPT_IntType(OPM_ShortintSize);
OPT_inttyp = OPT_IntType(OPM_IntegerSize);
OPT_linttyp = OPT_IntType(OPM_LongintSize);
OPT_sintobj->typ = OPT_sinttyp;
OPT_intobj->typ = OPT_inttyp;
OPT_lintobj->typ = OPT_linttyp;
switch (OPM_SetSize) {
case 4:
OPT_settyp = OPT_set32typ;
break;
default:
OPT_settyp = OPT_set64typ;
break;
}
OPT_setobj->typ = OPT_settyp;
if (__STRCMP(OPM_Model, "C") == 0) {
OPT_cpbytetyp->strobj->name[4] = 0x00;
} else {
OPT_cpbytetyp->strobj->name[4] = '@';
}
}
static void Compiler_FindLocalObjectFiles (CHAR *objectnames, ADDRESS objectnames__len)
{
OPT_Link l = NIL;
CHAR fn[64];
Platform_FileIdentity id;
objectnames[0] = 0x00;
l = OPT_Links;
while (l != NIL) {
__COPY(l->name, fn, 64);
Strings_Append((CHAR*)".sym", 5, (void*)fn, 64);
if (Platform_IdentifyByName(fn, 64, &id, Platform_FileIdentity__typ) == 0) {
__COPY(l->name, fn, 64);
Strings_Append((CHAR*)".o", 3, (void*)fn, 64);
if (Platform_IdentifyByName(fn, 64, &id, Platform_FileIdentity__typ) == 0) {
Strings_Append((CHAR*)" ", 2, (void*)objectnames, objectnames__len);
Strings_Append(fn, 64, (void*)objectnames, objectnames__len);
} else {
OPM_LogVT100((CHAR*)"91m", 4);
OPM_LogWStr((CHAR*)"Link warning: a local symbol file is present for module ", 57);
OPM_LogWStr(l->name, 256);
OPM_LogWStr((CHAR*)", but local object file '", 26);
OPM_LogWStr(fn, 64);
OPM_LogWStr((CHAR*)"' is missing.", 14);
OPM_LogVT100((CHAR*)"0m", 3);
OPM_LogWLn();
}
}
l = l->next;
}
}
void Compiler_Translate (void)
{
BOOLEAN done;
CHAR linkfiles[2048];
if (OPM_OpenPar()) {
for (;;) {
OPM_Init(&done);
if (!done) {
return;
}
OPM_InitOptions();
Compiler_PropagateElementaryTypeSizes();
Heap_GC(0);
Compiler_Module(&done);
if (!done) {
OPM_LogWLn();
OPM_LogWStr((CHAR*)"Module compilation failed.", 27);
OPM_LogWLn();
Platform_Exit(1);
}
if (!__IN(13, OPM_Options, 32)) {
if (__IN(14, OPM_Options, 32)) {
extTools_Assemble(OPM_modName, 32);
} else {
if (!__IN(10, OPM_Options, 32)) {
extTools_Assemble(OPM_modName, 32);
} else {
Compiler_FindLocalObjectFiles((void*)linkfiles, 2048);
extTools_LinkMain((void*)OPM_modName, 32, __IN(15, OPM_Options, 32), linkfiles, 2048);
}
}
}
}
}
}
static void Compiler_Trap (INT32 sig)
{
Heap_FINALL();
if (sig == 3) {
Platform_Exit(0);
} else {
if (sig == 4) {
OPM_LogWStr((CHAR*)" --- Oberon compiler internal error", 36);
OPM_LogWLn();
}
Platform_Exit(2);
}
}
export int main(int argc, char **argv)
{
__INIT(argc, argv);
__MODULE_IMPORT(Configuration);
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(OPB);
__MODULE_IMPORT(OPC);
__MODULE_IMPORT(OPM);
__MODULE_IMPORT(OPP);
__MODULE_IMPORT(OPT);
__MODULE_IMPORT(OPV);
__MODULE_IMPORT(Platform);
__MODULE_IMPORT(Strings);
__MODULE_IMPORT(VT100);
__MODULE_IMPORT(extTools);
__REGMAIN("Compiler", 0);
__REGCMD("Translate", Compiler_Translate);
/* BEGIN */
Platform_SetInterruptHandler(Compiler_Trap);
Platform_SetQuitHandler(Compiler_Trap);
Platform_SetBadInstructionHandler(Compiler_Trap);
Compiler_Translate();
__FINI;
}

View file

@ -0,0 +1,24 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
export CHAR Configuration_versionLong[76];
export void *Configuration__init(void)
{
__DEFMOD;
__REGMOD("Configuration", 0);
/* BEGIN */
__MOVE("2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76);
__ENDMOD;
}

View file

@ -0,0 +1,15 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Configuration__h
#define Configuration__h
#include "SYSTEM.h"
import CHAR Configuration_versionLong[76];
import void *Configuration__init(void);
#endif // Configuration

1097
bootstrap/unix-88/Files.c Normal file

File diff suppressed because it is too large Load diff

71
bootstrap/unix-88/Files.h Normal file
View file

@ -0,0 +1,71 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Files__h
#define Files__h
#include "SYSTEM.h"
typedef
struct Files_FileDesc *Files_File;
typedef
struct Files_FileDesc {
INT64 _prvt0;
char _prvt1[584];
} Files_FileDesc;
typedef
struct Files_Rider {
INT32 res;
BOOLEAN eof;
INT64 _prvt0;
char _prvt1[8];
} Files_Rider;
import INT16 Files_MaxPathLength, Files_MaxNameLength;
import ADDRESS *Files_FileDesc__typ;
import ADDRESS *Files_Rider__typ;
import Files_File Files_Base (Files_Rider *r, ADDRESS *r__typ);
import void Files_ChangeDirectory (CHAR *path, ADDRESS path__len, INT16 *res);
import void Files_Close (Files_File f);
import void Files_Delete (CHAR *name, ADDRESS name__len, INT16 *res);
import void Files_GetDate (Files_File f, INT32 *t, INT32 *d);
import void Files_GetName (Files_File f, CHAR *name, ADDRESS name__len);
import INT32 Files_Length (Files_File f);
import Files_File Files_New (CHAR *name, ADDRESS name__len);
import Files_File Files_Old (CHAR *name, ADDRESS name__len);
import INT32 Files_Pos (Files_Rider *r, ADDRESS *r__typ);
import void Files_Purge (Files_File f);
import void Files_Read (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x);
import void Files_ReadBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN *x);
import void Files_ReadByte (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x);
import void Files_ReadBytes (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x, ADDRESS x__len, INT32 n);
import void Files_ReadInt (Files_Rider *R, ADDRESS *R__typ, INT16 *x);
import void Files_ReadLInt (Files_Rider *R, ADDRESS *R__typ, INT32 *x);
import void Files_ReadLReal (Files_Rider *R, ADDRESS *R__typ, LONGREAL *x);
import void Files_ReadLine (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__len);
import void Files_ReadReal (Files_Rider *R, ADDRESS *R__typ, REAL *x);
import void Files_ReadSet (Files_Rider *R, ADDRESS *R__typ, UINT32 *x);
import void Files_ReadString (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void Files_Register (Files_File f);
import void Files_Rename (CHAR *old, ADDRESS old__len, CHAR *new, ADDRESS new__len, INT16 *res);
import void Files_Set (Files_Rider *r, ADDRESS *r__typ, Files_File f, INT32 pos);
import void Files_SetSearchPath (CHAR *path, ADDRESS path__len);
import void Files_Write (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE x);
import void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x);
import void Files_WriteBytes (Files_Rider *r, ADDRESS *r__typ, SYSTEM_BYTE *x, ADDRESS x__len, INT32 n);
import void Files_WriteInt (Files_Rider *R, ADDRESS *R__typ, INT16 x);
import void Files_WriteLInt (Files_Rider *R, ADDRESS *R__typ, INT32 x);
import void Files_WriteLReal (Files_Rider *R, ADDRESS *R__typ, LONGREAL x);
import void Files_WriteNum (Files_Rider *R, ADDRESS *R__typ, INT64 x);
import void Files_WriteReal (Files_Rider *R, ADDRESS *R__typ, REAL x);
import void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x);
import void Files_WriteString (Files_Rider *R, ADDRESS *R__typ, CHAR *x, ADDRESS x__len);
import void *Files__init(void);
#endif // Files

799
bootstrap/unix-88/Heap.c Normal file
View file

@ -0,0 +1,799 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
struct Heap__1 {
CHAR ch;
SYSTEM_PTR p;
};
typedef
struct Heap_CmdDesc *Heap_Cmd;
typedef
CHAR Heap_CmdName[24];
typedef
void (*Heap_Command)(void);
typedef
struct Heap_CmdDesc {
Heap_Cmd next;
Heap_CmdName name;
Heap_Command cmd;
} Heap_CmdDesc;
typedef
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
typedef
struct Heap_FinDesc *Heap_FinNode;
typedef
void (*Heap_Finalizer)(SYSTEM_PTR);
typedef
struct Heap_FinDesc {
Heap_FinNode next;
INT64 obj;
BOOLEAN marked;
Heap_Finalizer finalize;
} Heap_FinDesc;
typedef
struct Heap_ModuleDesc *Heap_Module;
typedef
CHAR Heap_ModuleName[20];
typedef
struct Heap_ModuleDesc {
Heap_Module next;
Heap_ModuleName name;
INT32 refcnt;
Heap_Cmd cmds;
INT64 types;
Heap_EnumProc enumPtrs;
INT32 reserved1, reserved2;
} Heap_ModuleDesc;
export SYSTEM_PTR Heap_modules;
static INT64 Heap_freeList[10];
static INT64 Heap_bigBlocks;
export INT64 Heap_allocated;
static BOOLEAN Heap_firstTry;
static INT16 Heap_ldUnit;
export INT64 Heap_heap;
static INT64 Heap_heapMin, Heap_heapMax;
export INT64 Heap_heapsize, Heap_heapMinExpand;
static Heap_FinNode Heap_fin;
static INT16 Heap_lockdepth;
static BOOLEAN Heap_interrupted;
export INT16 Heap_FileCount;
export ADDRESS *Heap_ModuleDesc__typ;
export ADDRESS *Heap_CmdDesc__typ;
export ADDRESS *Heap_FinDesc__typ;
export ADDRESS *Heap__1__typ;
static void Heap_CheckFin (void);
static void Heap_ExtendHeap (INT64 blksz);
export void Heap_FINALL (void);
static void Heap_Finalize (void);
export INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len);
export void Heap_GC (BOOLEAN markStack);
static void Heap_HeapSort (INT32 n, INT64 *a, ADDRESS a__len);
export void Heap_INCREF (Heap_Module m);
export void Heap_InitHeap (void);
export void Heap_Lock (void);
static void Heap_Mark (INT64 q);
static void Heap_MarkCandidates (INT32 n, INT64 *cand, ADDRESS cand__len);
static void Heap_MarkP (SYSTEM_PTR p);
static void Heap_MarkStack (INT64 n, INT64 *cand, ADDRESS cand__len);
export SYSTEM_PTR Heap_NEWBLK (INT64 size);
export SYSTEM_PTR Heap_NEWREC (INT64 tag);
static INT64 Heap_NewChunk (INT64 blksz);
export void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
export SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
export void Heap_REGTYP (Heap_Module m, INT64 typ);
export void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
static void Heap_Scan (void);
static void Heap_Sift (INT32 l, INT32 r, INT64 *a, ADDRESS a__len);
export void Heap_Unlock (void);
extern void *Heap__init();
extern ADDRESS Modules_MainStackFrame;
extern ADDRESS Platform_OSAllocate(ADDRESS size);
#define Heap_HeapModuleInit() Heap__init()
#define Heap_ModulesHalt(code) Modules_Halt(code)
#define Heap_ModulesMainStackFrame() Modules_MainStackFrame
#define Heap_OSAllocate(size) Platform_OSAllocate(size)
#define Heap_uLE(x, y) ((size_t)x <= (size_t)y)
#define Heap_uLT(x, y) ((size_t)x < (size_t)y)
void Heap_Lock (void)
{
Heap_lockdepth += 1;
}
void Heap_Unlock (void)
{
Heap_lockdepth -= 1;
if ((Heap_interrupted && Heap_lockdepth == 0)) {
Heap_ModulesHalt(-9);
}
}
SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs)
{
Heap_Module m;
if (__STRCMP(name, "Heap") == 0) {
__SYSNEW(m, 64);
} else {
__NEW(m, Heap_ModuleDesc);
}
m->types = 0;
m->cmds = NIL;
__COPY(name, m->name, 20);
m->refcnt = 0;
m->enumPtrs = enumPtrs;
m->next = (Heap_Module)(ADDRESS)Heap_modules;
Heap_modules = (SYSTEM_PTR)m;
return (void*)m;
}
INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len)
{
Heap_Module m, p;
__DUP(name, name__len, CHAR);
m = (Heap_Module)(ADDRESS)Heap_modules;
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
p = m;
m = m->next;
}
if ((m != NIL && m->refcnt == 0)) {
if (m == (Heap_Module)(ADDRESS)Heap_modules) {
Heap_modules = (SYSTEM_PTR)m->next;
} else {
p->next = m->next;
}
__DEL(name);
return 0;
} else {
if (m == NIL) {
__DEL(name);
return -1;
} else {
__DEL(name);
return m->refcnt;
}
}
__RETCHK;
}
void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd)
{
Heap_Cmd c;
if (__STRCMP(m->name, "Heap") == 0) {
__SYSNEW(c, 40);
} else {
__NEW(c, Heap_CmdDesc);
}
__COPY(name, c->name, 24);
c->cmd = cmd;
c->next = m->cmds;
m->cmds = c;
}
void Heap_REGTYP (Heap_Module m, INT64 typ)
{
__PUT(typ, m->types, INT64);
m->types = typ;
}
void Heap_INCREF (Heap_Module m)
{
m->refcnt += 1;
}
static INT64 Heap_NewChunk (INT64 blksz)
{
INT64 chnk, blk, end;
chnk = Heap_OSAllocate(blksz + 24);
if (chnk != 0) {
blk = chnk + 24;
end = blk + blksz;
__PUT(chnk + 8, end, INT64);
__PUT(blk, blk + 8, INT64);
__PUT(blk + 8, blksz, INT64);
__PUT(blk + 16, -8, INT64);
__PUT(blk + 24, Heap_bigBlocks, INT64);
Heap_bigBlocks = blk;
Heap_heapsize += blksz;
if (Heap_uLT(blk + 8, Heap_heapMin)) {
Heap_heapMin = blk + 8;
}
if (Heap_uLT(Heap_heapMax, end)) {
Heap_heapMax = end;
}
}
return chnk;
}
static void Heap_ExtendHeap (INT64 blksz)
{
INT64 size, chnk, j, next;
if (Heap_uLT(Heap_heapMinExpand, blksz)) {
size = blksz;
} else {
size = Heap_heapMinExpand;
}
chnk = Heap_NewChunk(size);
if (chnk != 0) {
if (Heap_uLT(chnk, Heap_heap)) {
__PUT(chnk, Heap_heap, INT64);
Heap_heap = chnk;
} else {
j = Heap_heap;
__GET(j, next, INT64);
while ((next != 0 && Heap_uLT(next, chnk))) {
j = next;
__GET(j, next, INT64);
}
__PUT(chnk, next, INT64);
__PUT(j, chnk, INT64);
}
} else if (!Heap_firstTry) {
Heap_heapMinExpand = 32;
}
}
SYSTEM_PTR Heap_NEWREC (INT64 tag)
{
INT64 i, i0, di, blksz, restsize, t, adr, end, next, prev;
SYSTEM_PTR new;
Heap_Lock();
__GET(tag, blksz, INT64);
i0 = __LSH(blksz, -Heap_ldUnit, 64);
i = i0;
if (i < 9) {
adr = Heap_freeList[i];
while (adr == 0) {
i += 1;
adr = Heap_freeList[i];
}
}
if (i < 9) {
__GET(adr + 24, next, INT64);
Heap_freeList[i] = next;
if (i != i0) {
di = i - i0;
restsize = __ASHL(di, 5);
end = adr + restsize;
__PUT(end + 8, blksz, INT64);
__PUT(end + 16, -8, INT64);
__PUT(end, end + 8, INT64);
__PUT(adr + 8, restsize, INT64);
__PUT(adr + 24, Heap_freeList[di], INT64);
Heap_freeList[di] = adr;
adr += restsize;
}
} else {
adr = Heap_bigBlocks;
prev = 0;
for (;;) {
if (adr == 0) {
if (Heap_firstTry) {
Heap_GC(1);
blksz += 32;
t = __LSH(Heap_allocated + blksz, -(2 + Heap_ldUnit), 64) * 160;
if (Heap_uLT(Heap_heapsize, t)) {
Heap_ExtendHeap(t - Heap_heapsize);
}
Heap_firstTry = 0;
new = Heap_NEWREC(tag);
if (new == NIL) {
Heap_ExtendHeap(blksz);
new = Heap_NEWREC(tag);
}
Heap_firstTry = 1;
Heap_Unlock();
return new;
} else {
Heap_Unlock();
return NIL;
}
}
__GET(adr + 8, t, INT64);
if (Heap_uLE(blksz, t)) {
break;
}
prev = adr;
__GET(adr + 24, adr, INT64);
}
restsize = t - blksz;
end = adr + restsize;
__PUT(end + 8, blksz, INT64);
__PUT(end + 16, -8, INT64);
__PUT(end, end + 8, INT64);
if (Heap_uLT(288, restsize)) {
__PUT(adr + 8, restsize, INT64);
} else {
__GET(adr + 24, next, INT64);
if (prev == 0) {
Heap_bigBlocks = next;
} else {
__PUT(prev + 24, next, INT64);
}
if (restsize != 0) {
di = __ASHR(restsize, 5);
__PUT(adr + 8, restsize, INT64);
__PUT(adr + 24, Heap_freeList[di], INT64);
Heap_freeList[di] = adr;
}
}
adr += restsize;
}
i = adr + 32;
end = adr + blksz;
while (Heap_uLT(i, end)) {
__PUT(i, 0, INT64);
__PUT(i + 8, 0, INT64);
__PUT(i + 16, 0, INT64);
__PUT(i + 24, 0, INT64);
i += 32;
}
__PUT(adr + 24, 0, INT64);
__PUT(adr, tag, INT64);
__PUT(adr + 8, 0, INT64);
__PUT(adr + 16, 0, INT64);
Heap_allocated += blksz;
Heap_Unlock();
return (SYSTEM_PTR)(ADDRESS)(adr + 8);
}
SYSTEM_PTR Heap_NEWBLK (INT64 size)
{
INT64 blksz, tag;
SYSTEM_PTR new;
Heap_Lock();
blksz = __ASHL(__ASHR(size + 63, 5), 5);
new = Heap_NEWREC((ADDRESS)&blksz);
tag = ((INT64)(ADDRESS)new + blksz) - 24;
__PUT(tag - 8, 0, INT64);
__PUT(tag, blksz, INT64);
__PUT(tag + 8, -8, INT64);
__PUT((INT64)(ADDRESS)new - 8, tag, INT64);
Heap_Unlock();
return new;
}
static void Heap_Mark (INT64 q)
{
INT64 p, tag, offset, fld, n, tagbits;
if (q != 0) {
__GET(q - 8, tagbits, INT64);
if (!__ODD(tagbits)) {
__PUT(q - 8, tagbits + 1, INT64);
p = 0;
tag = tagbits + 8;
for (;;) {
__GET(tag, offset, INT64);
if (offset < 0) {
__PUT(q - 8, (tag + offset) + 1, INT64);
if (p == 0) {
break;
}
n = q;
q = p;
__GET(q - 8, tag, INT64);
tag -= 1;
__GET(tag, offset, INT64);
fld = q + offset;
__GET(fld, p, INT64);
__PUT(fld, (SYSTEM_PTR)(ADDRESS)n, SYSTEM_PTR);
} else {
fld = q + offset;
__GET(fld, n, INT64);
if (n != 0) {
__GET(n - 8, tagbits, INT64);
if (!__ODD(tagbits)) {
__PUT(n - 8, tagbits + 1, INT64);
__PUT(q - 8, tag + 1, INT64);
__PUT(fld, (SYSTEM_PTR)(ADDRESS)p, SYSTEM_PTR);
p = q;
q = n;
tag = tagbits;
}
}
}
tag += 8;
}
}
}
}
static void Heap_MarkP (SYSTEM_PTR p)
{
Heap_Mark((INT64)(ADDRESS)p);
}
static void Heap_Scan (void)
{
INT64 chnk, adr, end, start, tag, i, size, freesize;
Heap_bigBlocks = 0;
i = 1;
while (i < 9) {
Heap_freeList[i] = 0;
i += 1;
}
freesize = 0;
Heap_allocated = 0;
chnk = Heap_heap;
while (chnk != 0) {
adr = chnk + 24;
__GET(chnk + 8, end, INT64);
while (Heap_uLT(adr, end)) {
__GET(adr, tag, INT64);
if (__ODD(tag)) {
if (freesize != 0) {
start = adr - freesize;
__PUT(start, start + 8, INT64);
__PUT(start + 8, freesize, INT64);
__PUT(start + 16, -8, INT64);
i = __LSH(freesize, -Heap_ldUnit, 64);
freesize = 0;
if (Heap_uLT(i, 9)) {
__PUT(start + 24, Heap_freeList[i], INT64);
Heap_freeList[i] = start;
} else {
__PUT(start + 24, Heap_bigBlocks, INT64);
Heap_bigBlocks = start;
}
}
tag -= 1;
__PUT(adr, tag, INT64);
__GET(tag, size, INT64);
Heap_allocated += size;
adr += size;
} else {
__GET(tag, size, INT64);
freesize += size;
adr += size;
}
}
if (freesize != 0) {
start = adr - freesize;
__PUT(start, start + 8, INT64);
__PUT(start + 8, freesize, INT64);
__PUT(start + 16, -8, INT64);
i = __LSH(freesize, -Heap_ldUnit, 64);
freesize = 0;
if (Heap_uLT(i, 9)) {
__PUT(start + 24, Heap_freeList[i], INT64);
Heap_freeList[i] = start;
} else {
__PUT(start + 24, Heap_bigBlocks, INT64);
Heap_bigBlocks = start;
}
}
__GET(chnk, chnk, INT64);
}
}
static void Heap_Sift (INT32 l, INT32 r, INT64 *a, ADDRESS a__len)
{
INT32 i, j;
INT64 x;
j = l;
x = a[j];
for (;;) {
i = j;
j = __ASHL(j, 1) + 1;
if ((j < r && Heap_uLT(a[j], a[j + 1]))) {
j += 1;
}
if (j > r || Heap_uLE(a[j], x)) {
break;
}
a[i] = a[j];
}
a[i] = x;
}
static void Heap_HeapSort (INT32 n, INT64 *a, ADDRESS a__len)
{
INT32 l, r;
INT64 x;
l = __ASHR(n, 1);
r = n - 1;
while (l > 0) {
l -= 1;
Heap_Sift(l, r, (void*)a, a__len);
}
while (r > 0) {
x = a[0];
a[0] = a[r];
a[r] = x;
r -= 1;
Heap_Sift(l, r, (void*)a, a__len);
}
}
static void Heap_MarkCandidates (INT32 n, INT64 *cand, ADDRESS cand__len)
{
INT64 chnk, end, adr, tag, next, i, ptr, size;
chnk = Heap_heap;
i = 0;
while (chnk != 0) {
__GET(chnk + 8, end, INT64);
adr = chnk + 24;
while (Heap_uLT(adr, end)) {
__GET(adr, tag, INT64);
if (__ODD(tag)) {
__GET(tag - 1, size, INT64);
adr += size;
ptr = adr + 8;
while (Heap_uLT(cand[i], ptr)) {
i += 1;
if (i == (INT64)n) {
return;
}
}
} else {
__GET(tag, size, INT64);
ptr = adr + 8;
adr += size;
while (Heap_uLT(cand[i], ptr)) {
i += 1;
if (i == (INT64)n) {
return;
}
}
if (Heap_uLT(cand[i], adr)) {
Heap_Mark(ptr);
}
}
if (Heap_uLE(end, cand[i])) {
adr = end;
}
}
__GET(chnk, chnk, INT64);
}
}
static void Heap_CheckFin (void)
{
Heap_FinNode n;
INT64 tag;
n = Heap_fin;
while (n != NIL) {
__GET(n->obj - 8, tag, INT64);
if (!__ODD(tag)) {
n->marked = 0;
Heap_Mark(n->obj);
} else {
n->marked = 1;
}
n = n->next;
}
}
static void Heap_Finalize (void)
{
Heap_FinNode n, prev;
n = Heap_fin;
prev = NIL;
while (n != NIL) {
if (!n->marked) {
if (n == Heap_fin) {
Heap_fin = Heap_fin->next;
} else {
prev->next = n->next;
}
(*n->finalize)((SYSTEM_PTR)(ADDRESS)n->obj);
if (prev == NIL) {
n = Heap_fin;
} else {
n = n->next;
}
} else {
prev = n;
n = n->next;
}
}
}
void Heap_FINALL (void)
{
Heap_FinNode n;
while (Heap_fin != NIL) {
n = Heap_fin;
Heap_fin = Heap_fin->next;
(*n->finalize)((SYSTEM_PTR)(ADDRESS)n->obj);
}
}
static void Heap_MarkStack (INT64 n, INT64 *cand, ADDRESS cand__len)
{
SYSTEM_PTR frame;
INT32 nofcand;
INT64 inc, sp, p, stack0;
struct Heap__1 align;
if (n > 0) {
Heap_MarkStack(n - 1, cand, cand__len);
if (n > 100) {
return;
}
}
if (n == 0) {
nofcand = 0;
sp = (ADDRESS)&frame;
stack0 = Heap_ModulesMainStackFrame();
inc = (ADDRESS)&align.p - (ADDRESS)&align;
if (Heap_uLT(stack0, sp)) {
inc = -inc;
}
while (sp != stack0) {
__GET(sp, p, INT64);
if ((Heap_uLE(Heap_heapMin, p) && Heap_uLT(p, Heap_heapMax))) {
if (nofcand == cand__len) {
Heap_HeapSort(nofcand, (void*)cand, cand__len);
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
nofcand = 0;
}
cand[nofcand] = p;
nofcand += 1;
}
sp += inc;
}
if (nofcand > 0) {
Heap_HeapSort(nofcand, (void*)cand, cand__len);
Heap_MarkCandidates(nofcand, (void*)cand, cand__len);
}
}
}
void Heap_GC (BOOLEAN markStack)
{
Heap_Module m;
INT64 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
INT64 cand[10000];
Heap_Lock();
m = (Heap_Module)(ADDRESS)Heap_modules;
while (m != NIL) {
if (m->enumPtrs != NIL) {
(*m->enumPtrs)(Heap_MarkP);
}
m = m->next;
}
if (markStack) {
i0 = -100;
i1 = -101;
i2 = -102;
i3 = -103;
i4 = -104;
i5 = -105;
i6 = -106;
i7 = -107;
i8 = 1;
i9 = 2;
i10 = 3;
i11 = 4;
i12 = 5;
i13 = 6;
i14 = 7;
i15 = 8;
i16 = 9;
i17 = 10;
i18 = 11;
i19 = 12;
i20 = 13;
i21 = 14;
i22 = 15;
i23 = 16;
for (;;) {
i0 += 1;
i1 += 2;
i2 += 3;
i3 += 4;
i4 += 5;
i5 += 6;
i6 += 7;
i7 += 8;
i8 += 9;
i9 += 10;
i10 += 11;
i11 += 12;
i12 += 13;
i13 += 14;
i14 += 15;
i15 += 16;
i16 += 17;
i17 += 18;
i18 += 19;
i19 += 20;
i20 += 21;
i21 += 22;
i22 += 23;
i23 += 24;
if ((i0 == -99 && i15 == 24)) {
Heap_MarkStack(32, (void*)cand, 10000);
break;
}
}
if (((((((((((((((((((((((i0 + i1) + i2) + i3) + i4) + i5) + i6) + i7) + i8) + i9) + i10) + i11) + i12) + i13) + i14) + i15) + i16) + i17) + i18) + i19) + i20) + i21) + i22) + i23 > 10000) {
return;
}
}
Heap_CheckFin();
Heap_Scan();
Heap_Finalize();
Heap_Unlock();
}
void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize)
{
Heap_FinNode f;
__NEW(f, Heap_FinDesc);
f->obj = (INT64)(ADDRESS)obj;
f->finalize = finalize;
f->marked = 1;
f->next = Heap_fin;
Heap_fin = f;
}
void Heap_InitHeap (void)
{
Heap_heap = 0;
Heap_heapsize = 0;
Heap_allocated = 0;
Heap_lockdepth = 0;
Heap_heapMin = -1;
Heap_heapMax = 0;
Heap_bigBlocks = 0;
Heap_heapMinExpand = 256000;
Heap_ldUnit = 5;
Heap_heap = Heap_NewChunk(256000);
__PUT(Heap_heap, 0, INT64);
Heap_firstTry = 1;
Heap_freeList[9] = 1;
Heap_FileCount = 0;
Heap_modules = NIL;
Heap_fin = NIL;
Heap_interrupted = 0;
Heap_HeapModuleInit();
}
static void EnumPtrs(void (*P)(void*))
{
P(Heap_modules);
P(Heap_fin);
}
__TDESC(Heap_ModuleDesc, 1, 2) = {__TDFLDS("ModuleDesc", 64), {0, 32, -24}};
__TDESC(Heap_CmdDesc, 1, 1) = {__TDFLDS("CmdDesc", 40), {0, -16}};
__TDESC(Heap_FinDesc, 1, 1) = {__TDFLDS("FinDesc", 32), {0, -16}};
__TDESC(Heap__1, 1, 1) = {__TDFLDS("", 16), {8, -16}};
export void *Heap__init(void)
{
__DEFMOD;
__REGMOD("Heap", EnumPtrs);
__REGCMD("FINALL", Heap_FINALL);
__REGCMD("InitHeap", Heap_InitHeap);
__REGCMD("Lock", Heap_Lock);
__REGCMD("Unlock", Heap_Unlock);
__INITYP(Heap_ModuleDesc, Heap_ModuleDesc, 0);
__INITYP(Heap_CmdDesc, Heap_CmdDesc, 0);
__INITYP(Heap_FinDesc, Heap_FinDesc, 0);
__INITYP(Heap__1, Heap__1, 0);
/* BEGIN */
__ENDMOD;
}

73
bootstrap/unix-88/Heap.h Normal file
View file

@ -0,0 +1,73 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */
#ifndef Heap__h
#define Heap__h
#include "SYSTEM.h"
typedef
struct Heap_CmdDesc *Heap_Cmd;
typedef
CHAR Heap_CmdName[24];
typedef
void (*Heap_Command)(void);
typedef
struct Heap_CmdDesc {
Heap_Cmd next;
Heap_CmdName name;
Heap_Command cmd;
} Heap_CmdDesc;
typedef
void (*Heap_EnumProc)(void(*)(SYSTEM_PTR));
typedef
void (*Heap_Finalizer)(SYSTEM_PTR);
typedef
struct Heap_ModuleDesc *Heap_Module;
typedef
CHAR Heap_ModuleName[20];
typedef
struct Heap_ModuleDesc {
Heap_Module next;
Heap_ModuleName name;
INT32 refcnt;
Heap_Cmd cmds;
INT64 types;
Heap_EnumProc enumPtrs;
char _prvt0[8];
} Heap_ModuleDesc;
import SYSTEM_PTR Heap_modules;
import INT64 Heap_allocated;
import INT64 Heap_heap;
import INT64 Heap_heapsize, Heap_heapMinExpand;
import INT16 Heap_FileCount;
import ADDRESS *Heap_ModuleDesc__typ;
import ADDRESS *Heap_CmdDesc__typ;
import void Heap_FINALL (void);
import INT32 Heap_FreeModule (CHAR *name, ADDRESS name__len);
import void Heap_GC (BOOLEAN markStack);
import void Heap_INCREF (Heap_Module m);
import void Heap_InitHeap (void);
import void Heap_Lock (void);
import SYSTEM_PTR Heap_NEWBLK (INT64 size);
import SYSTEM_PTR Heap_NEWREC (INT64 tag);
import void Heap_REGCMD (Heap_Module m, Heap_CmdName name, Heap_Command cmd);
import SYSTEM_PTR Heap_REGMOD (Heap_ModuleName name, Heap_EnumProc enumPtrs);
import void Heap_REGTYP (Heap_Module m, INT64 typ);
import void Heap_RegisterFinalizer (SYSTEM_PTR obj, Heap_Finalizer finalize);
import void Heap_Unlock (void);
import void *Heap__init(void);
#endif // Heap

506
bootstrap/unix-88/Modules.c Normal file
View file

@ -0,0 +1,506 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#define SHORTINT INT8
#define INTEGER INT16
#define LONGINT INT32
#define SET UINT32
#include "SYSTEM.h"
#include "Heap.h"
#include "Platform.h"
export INT16 Modules_res;
export CHAR Modules_resMsg[256];
export Heap_ModuleName Modules_imported, Modules_importing;
export INT64 Modules_MainStackFrame;
export INT16 Modules_ArgCount;
export INT64 Modules_ArgVector;
export CHAR Modules_BinaryDir[1024];
static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len);
export void Modules_AssertFail (INT32 code);
static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len);
static void Modules_DisplayHaltCode (INT32 code);
static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len);
static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len);
export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all);
export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len);
export void Modules_GetIntArg (INT16 n, INT32 *val);
export void Modules_Halt (INT32 code);
export void Modules_Init (INT32 argc, INT64 argvadr);
static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len);
static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len);
static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len);
export Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len);
export Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len);
static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len);
static void Modules_errch (CHAR c);
static void Modules_errint (INT32 l);
static void Modules_errstring (CHAR *s, ADDRESS s__len);
extern void Heap_InitHeap();
extern void *Modules__init(void);
#define Modules_InitHeap() Heap_InitHeap()
#define Modules_ModulesInit() Modules__init()
#define Modules_modules() (Heap_Module)Heap_modules
void Modules_Init (INT32 argc, INT64 argvadr)
{
Modules_MainStackFrame = argvadr;
Modules_ArgCount = __VAL(INT16, argc);
__GET(argvadr, Modules_ArgVector, INT64);
Modules_InitHeap();
Modules_ModulesInit();
}
typedef
CHAR (*argptr__15)[1024];
void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len)
{
argptr__15 arg = NIL;
if (n < Modules_ArgCount) {
__GET(Modules_ArgVector + (INT64)__ASHL(n, 3), arg, argptr__15);
__COPY(*arg, val, val__len);
}
}
void Modules_GetIntArg (INT16 n, INT32 *val)
{
CHAR s[64];
INT32 k, d, i;
s[0] = 0x00;
Modules_GetArg(n, (void*)s, 64);
i = 0;
if (s[0] == '-') {
i = 1;
}
k = 0;
d = (INT16)s[__X(i, 64)] - 48;
while ((d >= 0 && d <= 9)) {
k = k * 10 + d;
i += 1;
d = (INT16)s[__X(i, 64)] - 48;
}
if (s[0] == '-') {
k = -k;
i -= 1;
}
if (i > 0) {
*val = k;
}
}
INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len)
{
INT16 i;
CHAR arg[256];
__DUP(s, s__len, CHAR);
i = 0;
Modules_GetArg(i, (void*)arg, 256);
while ((i < Modules_ArgCount && __STRCMP(s, arg) != 0)) {
i += 1;
Modules_GetArg(i, (void*)arg, 256);
}
__DEL(s);
return i;
}
static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len)
{
INT16 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
__DEL(s);
return i;
}
static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
__DUP(s, s__len, CHAR);
i = 0;
j = Modules_CharCount(d, d__len);
while (s[__X(i, s__len)] != 0x00) {
d[__X(j, d__len)] = s[__X(i, s__len)];
i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
__DEL(s);
}
static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
__DUP(s, s__len, CHAR);
i = 0;
j = Modules_CharCount(d, d__len);
if ((j > 0 && d[__X(j - 1, d__len)] != c)) {
d[__X(j, d__len)] = c;
j += 1;
}
while (s[__X(i, s__len)] != 0x00) {
d[__X(j, d__len)] = s[__X(i, s__len)];
i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
__DEL(s);
}
static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len)
{
INT16 i;
__DUP(s, s__len, CHAR);
if (c == 0x00) {
__DEL(s);
return 0;
}
i = 0;
while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) {
i += 1;
}
__DEL(s);
return s[__X(i, s__len)] == c;
}
static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len)
{
__DUP(d, d__len, CHAR);
if (d[0] == 0x00) {
__DEL(d);
return 0;
}
if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) {
__DEL(d);
return 1;
}
if (d[__X(1, d__len)] == ':') {
__DEL(d);
return 1;
}
__DEL(d);
return 0;
}
static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
__DUP(s, s__len, CHAR);
if (Modules_IsAbsolute(s, s__len)) {
__COPY(s, d, d__len);
} else {
__COPY(Platform_CWD, d, d__len);
Modules_AppendPart('/', s, s__len, (void*)d, d__len);
}
__DEL(s);
}
static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len)
{
Platform_FileIdentity identity;
__DUP(s, s__len, CHAR);
__DEL(s);
return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0;
}
static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len)
{
INT16 j;
__DUP(s, s__len, CHAR);
__DUP(p, p__len, CHAR);
j = 0;
while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) {
d[__X(j, d__len)] = s[__X(*i, s__len)];
*i += 1;
j += 1;
}
d[__X(j, d__len)] = 0x00;
while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) {
*i += 1;
}
__DEL(s);
__DEL(p);
}
static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len)
{
INT16 i, j;
CHAR part[1024];
__DUP(s, s__len, CHAR);
i = 0;
j = 0;
while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) {
i += 1;
d[__X(j, d__len)] = '/';
j += 1;
}
d[__X(j, d__len)] = 0x00;
while (s[__X(i, s__len)] != 0x00) {
Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024);
if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) {
Modules_AppendPart('/', part, 1024, (void*)d, d__len);
}
}
__DEL(s);
}
typedef
CHAR pathstring__12[4096];
static void Modules_FindBinaryDir (CHAR *binarydir, ADDRESS binarydir__len)
{
pathstring__12 arg0, pathlist, pathdir, tempstr;
INT16 i, j, k;
BOOLEAN present;
if (Modules_ArgCount < 1) {
binarydir[0] = 0x00;
return;
}
Modules_GetArg(0, (void*)arg0, 4096);
i = 0;
while ((((arg0[__X(i, 4096)] != 0x00 && arg0[__X(i, 4096)] != '/')) && arg0[__X(i, 4096)] != '\\')) {
i += 1;
}
if (arg0[__X(i, 4096)] == '/' || arg0[__X(i, 4096)] == '\\') {
Modules_Trim(arg0, 4096, (void*)tempstr, 4096);
Modules_Canonify(tempstr, 4096, (void*)binarydir, binarydir__len);
present = Modules_IsFilePresent(binarydir, binarydir__len);
} else {
Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096);
i = 0;
present = 0;
while ((!present && pathlist[__X(i, 4096)] != 0x00)) {
Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)pathdir, 4096);
Modules_AppendPart('/', arg0, 4096, (void*)pathdir, 4096);
Modules_Trim(pathdir, 4096, (void*)tempstr, 4096);
Modules_Canonify(tempstr, 4096, (void*)binarydir, binarydir__len);
present = Modules_IsFilePresent(binarydir, binarydir__len);
}
}
if (present) {
k = Modules_CharCount(binarydir, binarydir__len);
while ((k > 0 && !Modules_IsOneOf(binarydir[__X(k - 1, binarydir__len)], (CHAR*)"/\\", 3))) {
k -= 1;
}
if (k == 0) {
binarydir[__X(k, binarydir__len)] = 0x00;
} else {
binarydir[__X(k - 1, binarydir__len)] = 0x00;
}
} else {
binarydir[0] = 0x00;
}
}
Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len)
{
Heap_Module m = NIL;
CHAR bodyname[64];
Heap_Command body;
__DUP(name, name__len, CHAR);
m = Modules_modules();
while ((m != NIL && __STRCMP(m->name, name) != 0)) {
m = m->next;
}
if (m != NIL) {
Modules_res = 0;
Modules_resMsg[0] = 0x00;
} else {
Modules_res = 1;
__COPY(name, Modules_importing, 20);
__MOVE(" module \"", Modules_resMsg, 10);
Modules_Append(name, name__len, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256);
}
__DEL(name);
return m;
}
Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len)
{
Heap_Cmd c = NIL;
__DUP(name, name__len, CHAR);
c = mod->cmds;
while ((c != NIL && __STRCMP(c->name, name) != 0)) {
c = c->next;
}
if (c != NIL) {
Modules_res = 0;
Modules_resMsg[0] = 0x00;
__DEL(name);
return c->cmd;
} else {
Modules_res = 2;
__MOVE(" command \"", Modules_resMsg, 11);
__COPY(name, Modules_importing, 20);
Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256);
Modules_Append(name, name__len, (void*)Modules_resMsg, 256);
Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256);
__DEL(name);
return NIL;
}
__RETCHK;
}
void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all)
{
Heap_Module m = NIL, p = NIL;
INT32 refcount;
__DUP(name, name__len, CHAR);
m = Modules_modules();
if (all) {
Modules_res = 1;
__MOVE("unloading \"all\" not yet supported", Modules_resMsg, 34);
} else {
refcount = Heap_FreeModule(name, name__len);
if (refcount == 0) {
Modules_res = 0;
} else {
if (refcount < 0) {
__MOVE("module not found", Modules_resMsg, 17);
} else {
__MOVE("clients of this module exist", Modules_resMsg, 29);
}
Modules_res = 1;
}
}
__DEL(name);
}
static void Modules_errch (CHAR c)
{
INT16 e;
e = Platform_Write(1, (ADDRESS)&c, 1);
}
static void Modules_errstring (CHAR *s, ADDRESS s__len)
{
INT32 i;
__DUP(s, s__len, CHAR);
i = 0;
while ((i < s__len && s[__X(i, s__len)] != 0x00)) {
Modules_errch(s[__X(i, s__len)]);
i += 1;
}
__DEL(s);
}
static void Modules_errint (INT32 l)
{
if (l < 0) {
Modules_errch('-');
l = -l;
}
if (l >= 10) {
Modules_errint(__DIV(l, 10));
}
Modules_errch(__CHR((int)__MOD(l, 10) + 48));
}
static void Modules_DisplayHaltCode (INT32 code)
{
switch (code) {
case -1:
Modules_errstring((CHAR*)"Assertion failure.", 19);
break;
case -2:
Modules_errstring((CHAR*)"Index out of range.", 20);
break;
case -3:
Modules_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49);
break;
case -4:
Modules_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47);
break;
case -5:
Modules_errstring((CHAR*)"Type guard failed.", 19);
break;
case -6:
Modules_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49);
break;
case -7:
Modules_errstring((CHAR*)"Invalid case in WITH statement.", 32);
break;
case -8:
Modules_errstring((CHAR*)"Value out of range.", 20);
break;
case -9:
Modules_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60);
break;
case -10:
Modules_errstring((CHAR*)"NIL access.", 12);
break;
case -11:
Modules_errstring((CHAR*)"Alignment error.", 17);
break;
case -12:
Modules_errstring((CHAR*)"Divide by zero.", 16);
break;
case -13:
Modules_errstring((CHAR*)"Arithmetic overflow/underflow.", 31);
break;
case -14:
Modules_errstring((CHAR*)"Invalid function argument.", 27);
break;
case -15:
Modules_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52);
break;
case -20:
Modules_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60);
break;
default:
break;
}
}
void Modules_Halt (INT32 code)
{
Heap_FINALL();
Modules_errstring((CHAR*)"Terminated by Halt(", 20);
Modules_errint(code);
Modules_errstring((CHAR*)"). ", 4);
if (code < 0) {
Modules_DisplayHaltCode(code);
}
Modules_errstring(Platform_NL, 3);
Platform_Exit(code);
}
void Modules_AssertFail (INT32 code)
{
Heap_FINALL();
Modules_errstring((CHAR*)"Assertion failure.", 19);
if (code != 0) {
Modules_errstring((CHAR*)" ASSERT code ", 14);
Modules_errint(code);
Modules_errstring((CHAR*)".", 2);
}
Modules_errstring(Platform_NL, 3);
if (code > 0) {
Platform_Exit(code);
} else {
Platform_Exit(-1);
}
}
export void *Modules__init(void)
{
__DEFMOD;
__MODULE_IMPORT(Heap);
__MODULE_IMPORT(Platform);
__REGMOD("Modules", 0);
/* BEGIN */
Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024);
__ENDMOD;
}

View file

@ -0,0 +1,31 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef Modules__h
#define Modules__h
#include "SYSTEM.h"
#include "Heap.h"
import INT16 Modules_res;
import CHAR Modules_resMsg[256];
import Heap_ModuleName Modules_imported, Modules_importing;
import INT64 Modules_MainStackFrame;
import INT16 Modules_ArgCount;
import INT64 Modules_ArgVector;
import CHAR Modules_BinaryDir[1024];
import INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len);
import void Modules_AssertFail (INT32 code);
import void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all);
import void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len);
import void Modules_GetIntArg (INT16 n, INT32 *val);
import void Modules_Halt (INT32 code);
import void Modules_Init (INT32 argc, INT64 argvadr);
import Heap_Command Modules_ThisCommand (Heap_Module mod, CHAR *name, ADDRESS name__len);
import Heap_Module Modules_ThisMod (CHAR *name, ADDRESS name__len);
import void *Modules__init(void);
#endif // Modules

2592
bootstrap/unix-88/OPB.c Normal file

File diff suppressed because it is too large Load diff

48
bootstrap/unix-88/OPB.h Normal file
View file

@ -0,0 +1,48 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPB__h
#define OPB__h
#include "SYSTEM.h"
#include "OPS.h"
#include "OPT.h"
import void OPB_Assign (OPT_Node *x, OPT_Node y);
import void OPB_Call (OPT_Node *x, OPT_Node apar, OPT_Object fp);
import void OPB_CheckParameters (OPT_Object fp, OPT_Object ap, BOOLEAN checkNames);
import void OPB_Construct (INT8 class, OPT_Node *x, OPT_Node y);
import void OPB_DeRef (OPT_Node *x);
import OPT_Node OPB_EmptySet (void);
import void OPB_Enter (OPT_Node *procdec, OPT_Node stat, OPT_Object proc);
import void OPB_Field (OPT_Node *x, OPT_Object y);
import void OPB_In (OPT_Node *x, OPT_Node y);
import void OPB_Index (OPT_Node *x, OPT_Node y);
import void OPB_Inittd (OPT_Node *inittd, OPT_Node *last, OPT_Struct typ);
import void OPB_Link (OPT_Node *x, OPT_Node *last, OPT_Node y);
import void OPB_MOp (INT8 op, OPT_Node *x);
import OPT_Node OPB_NewBoolConst (BOOLEAN boolval);
import OPT_Node OPB_NewIntConst (INT64 intval);
import OPT_Node OPB_NewLeaf (OPT_Object obj);
import OPT_Node OPB_NewRealConst (LONGREAL realval, OPT_Struct typ);
import OPT_Node OPB_NewString (OPS_String str, INT64 len);
import OPT_Node OPB_Nil (void);
import void OPB_Op (INT8 op, OPT_Node *x, OPT_Node y);
import void OPB_OptIf (OPT_Node *x);
import void OPB_Param (OPT_Node ap, OPT_Object fp);
import void OPB_PrepCall (OPT_Node *x, OPT_Object *fpar);
import void OPB_Return (OPT_Node *x, OPT_Object proc);
import void OPB_SetElem (OPT_Node *x);
import void OPB_SetRange (OPT_Node *x, OPT_Node y);
import void OPB_StFct (OPT_Node *par0, INT8 fctno, INT16 parno);
import void OPB_StPar0 (OPT_Node *par0, INT16 fctno);
import void OPB_StPar1 (OPT_Node *par0, OPT_Node x, INT8 fctno);
import void OPB_StParN (OPT_Node *par0, OPT_Node x, INT16 fctno, INT16 n);
import void OPB_StaticLink (INT8 dlev);
import void OPB_TypTest (OPT_Node *x, OPT_Object obj, BOOLEAN guard);
import void *OPB__init(void);
#endif // OPB

2025
bootstrap/unix-88/OPC.c Normal file

File diff suppressed because it is too large Load diff

49
bootstrap/unix-88/OPC.h Normal file
View file

@ -0,0 +1,49 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPC__h
#define OPC__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPC_Andent (OPT_Struct typ);
import OPT_Object OPC_BaseTProc (OPT_Object obj);
import void OPC_BegBlk (void);
import void OPC_BegStat (void);
import void OPC_Case (INT64 caseVal, INT16 form);
import void OPC_Cmp (INT16 rel);
import void OPC_CompleteIdent (OPT_Object obj);
import void OPC_Constant (OPT_Const con, INT16 form);
import void OPC_DefineInter (OPT_Object proc);
import void OPC_EndBlk (void);
import void OPC_EndBlk0 (void);
import void OPC_EndStat (void);
import void OPC_EnterBody (void);
import void OPC_EnterProc (OPT_Object proc);
import void OPC_ExitBody (void);
import void OPC_ExitProc (OPT_Object proc, BOOLEAN eoBlock, BOOLEAN implicitRet);
import void OPC_GenBdy (OPT_Node n);
import void OPC_GenEnumPtrs (OPT_Object var);
import void OPC_GenHdr (OPT_Node n);
import void OPC_GenHdrIncludes (void);
import void OPC_Halt (INT32 n);
import void OPC_Ident (OPT_Object obj);
import void OPC_Increment (BOOLEAN decrement);
import void OPC_Indent (INT16 count);
import void OPC_Init (void);
import void OPC_InitTDesc (OPT_Struct typ);
import void OPC_IntLiteral (INT64 n, INT32 size);
import void OPC_Len (OPT_Object obj, OPT_Struct array, INT64 dim);
import BOOLEAN OPC_NeedsRetval (OPT_Object proc);
import INT32 OPC_NofPtrs (OPT_Struct typ);
import void OPC_SetInclude (BOOLEAN exclude);
import void OPC_TDescDecl (OPT_Struct typ);
import void OPC_TypeDefs (OPT_Object obj, INT16 vis);
import void OPC_TypeOf (OPT_Object ap);
import void *OPC__init(void);
#endif // OPC

1183
bootstrap/unix-88/OPM.c Normal file

File diff suppressed because it is too large Load diff

76
bootstrap/unix-88/OPM.h Normal file
View file

@ -0,0 +1,76 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPM__h
#define OPM__h
#include "SYSTEM.h"
import CHAR OPM_Model[10];
import INT16 OPM_AddressSize, OPM_Alignment;
import UINT32 OPM_GlobalOptions, OPM_Options;
import INT16 OPM_ShortintSize, OPM_IntegerSize, OPM_LongintSize, OPM_SetSize;
import INT64 OPM_MaxIndex;
import LONGREAL OPM_MinReal, OPM_MaxReal, OPM_MinLReal, OPM_MaxLReal;
import BOOLEAN OPM_noerr;
import INT32 OPM_curpos, OPM_errpos, OPM_breakpc;
import INT16 OPM_currFile, OPM_level, OPM_pc, OPM_entno;
import CHAR OPM_modName[32];
import CHAR OPM_objname[64];
import CHAR OPM_InstallDir[1024];
import CHAR OPM_ResourceDir[1024];
import void OPM_CloseFiles (void);
import void OPM_CloseOldSym (void);
import void OPM_DeleteObj (CHAR *modulename, ADDRESS modulename__len);
import void OPM_DeleteSym (CHAR *modulename, ADDRESS modulename__len);
import void OPM_FPrint (INT32 *fp, INT64 val);
import void OPM_FPrintLReal (INT32 *fp, LONGREAL val);
import void OPM_FPrintReal (INT32 *fp, REAL val);
import void OPM_FPrintSet (INT32 *fp, UINT64 val);
import void OPM_Get (CHAR *ch);
import void OPM_GetComment (CHAR *text, ADDRESS text__len);
import void OPM_Init (BOOLEAN *done);
import void OPM_InitOptions (void);
import INT16 OPM_Integer (INT64 n);
import void OPM_LogCompiling (CHAR *modname, ADDRESS modname__len);
import void OPM_LogVT100 (CHAR *vt100code, ADDRESS vt100code__len);
import void OPM_LogW (CHAR ch);
import void OPM_LogWLn (void);
import void OPM_LogWNum (INT64 i, INT64 len);
import void OPM_LogWStr (CHAR *s, ADDRESS s__len);
import INT32 OPM_Longint (INT64 n);
import void OPM_Mark (INT16 n, INT32 pos);
import void OPM_NewSym (CHAR *modName, ADDRESS modName__len);
import void OPM_OldSym (CHAR *modName, ADDRESS modName__len, BOOLEAN *done);
import void OPM_OpenFiles (CHAR *moduleName, ADDRESS moduleName__len);
import BOOLEAN OPM_OpenPar (void);
import void OPM_RegisterNewSym (void);
import INT64 OPM_SignedMaximum (INT32 bytecount);
import INT64 OPM_SignedMinimum (INT32 bytecount);
import void OPM_StoreComment (CHAR *text, ADDRESS text__len);
import void OPM_SymRCh (CHAR *ch);
import INT32 OPM_SymRInt (void);
import INT64 OPM_SymRInt64 (void);
import void OPM_SymRLReal (LONGREAL *lr);
import void OPM_SymRReal (REAL *r);
import void OPM_SymRSet (UINT64 *s);
import void OPM_SymWCh (CHAR ch);
import void OPM_SymWInt (INT64 i);
import void OPM_SymWLReal (LONGREAL lr);
import void OPM_SymWReal (REAL r);
import void OPM_SymWSet (UINT64 s);
import void OPM_Write (CHAR ch);
import void OPM_WriteHex (INT64 i);
import void OPM_WriteInt (INT64 i);
import void OPM_WriteLn (void);
import void OPM_WriteReal (LONGREAL r, CHAR suffx);
import void OPM_WriteString (CHAR *s, ADDRESS s__len);
import void OPM_WriteStringVar (CHAR *s, ADDRESS s__len);
import BOOLEAN OPM_eofSF (void);
import void OPM_err (INT16 n);
import void *OPM__init(void);
#endif // OPM

1881
bootstrap/unix-88/OPP.c Normal file

File diff suppressed because it is too large Load diff

16
bootstrap/unix-88/OPP.h Normal file
View file

@ -0,0 +1,16 @@
/* voc 2.1.0 [2025/06/24]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
#ifndef OPP__h
#define OPP__h
#include "SYSTEM.h"
#include "OPT.h"
import void OPP_Module (OPT_Node *prog, UINT32 opt);
import void *OPP__init(void);
#endif // OPP

Some files were not shown because too many files have changed in this diff Show more