dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit ecadd6f6a4f2a201c80e9e5f04bae954309ed5eb
parent bfbec45b4c181994f85bfff7e85b101162ca8a56
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Thu,  6 Oct 2022 09:03:15 -0400

cc: update docs

Mfs/doc/cc.txt | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/fs/doc/cc.txt b/fs/doc/cc.txt @@ -58,6 +58,7 @@ Example: * string literals are not null-terminated, but "counted strings". The exact same format as system strings. * Added pspop() and pspush() built-in functions. +* No "varargs". pspop() and pspush() replace that functionality. * "struct MyStruct {...};" automatically creates a "typedef" to the struct. * The "struct" keyword can't be used to reference structs, only to define them. * There's a maximum of 3 indirection levels for types. "int ***i;" is fine, @@ -218,12 +219,9 @@ it looks: #[ 42 const FOOBAR ]# int foo() { - return #[ FOOBAR Constant ]#; + return #[ FOOBAR c]#; // c]# means "Constant :new ]#" } -AST nodes are created with "createnode" accompanied with one of the AST_* -constants, or with the use of a "node helper" word, such as "Constant". - Because macros can modify the AST, they can only be inserted at certain designated places, known as "hash (#) bars". These are: @@ -233,6 +231,7 @@ designated places, known as "hash (#) bars". These are: * A Lvalue (AST_IDENT) * A function call * An expression +* Inside an array length [] definition. In any other place, "#[" will be a parse error. @@ -245,6 +244,9 @@ the factor was expected. It will even have postfix AST rules applied to it, which opens nice doors. For example, if your macro returns a simple AST_IDENT, then right after the macro you can add parens to make it into a function call. +The third case has a signature ( -- number ), with "number" being the number of +elements that the array being defined will have. + When a macro begins, PS level is recorded. If it doesn't end with the correct PS size, an error is raised. @@ -253,9 +255,9 @@ Macro opening symbol, "#[", obeys C tokenization rules, but the closing one, There are "shortcut words" for closing a macro: -c]# --> Constant ]# -i]# --> Ident ]# -+]# --> over addnode ]# +c]# --> Constant :new ]# +i]# --> Ident :new ]# ++]# --> over Node :add ]# ## Linkage @@ -271,8 +273,8 @@ unit or from Forth. "bar()" can. ## The compiler VM -The goal of this VM is to provide a unified API for code generation of a C AST -across CPU architecture. +The goal of this VM, which lives in /cc/vm, is to provide a unified API for code +generation of a C AST across CPU architecture. Computation done by this generated code is centered around two operands, Op1 and Op2. Those operands can "live" in different places depending on the context: in