commit e9aa475699b83ff9d30fcbb1e92f4e84e5adb745
parent 0fa1aa68c00e91c087b2cafd445b0360fc66891b
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sun, 25 Sep 2022 09:12:27 -0400
cc: support arrays in structs
Diffstat:
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs
@@ -257,11 +257,13 @@ ASTIDCNT wordtbl gentbl ( node -- )
Node nextsibling ( loop' node ) dup _assert gennode \ control
vmjnz, ops$ r> resolvebreaks ;
:w ( Arrow )
+ \ TODO: harmonize with decl>op
dup Node firstchild dup _assert gennode
vmop type dup typestruct? _assert type*lvl 1 = _assert ( arrownode )
Arrow name vmop type typestruct' findDecl ( dnode )
dup Declare address vmop^ :>const vmadd, vmop :*op ( dnode )
- Declare type to vmop type ;
+ dup Declare type to vmop type
+ Declare nbelem 1 > if vmop :&op then ;
'w drop ( Struct )
: _ ( node -- ) gentbl over Node id wexec ;
diff --git a/fs/tests/cc/cc.fs b/fs/tests/cc/cc.fs
@@ -57,7 +57,7 @@ S" foobar" dup 6 'X' set8b S" foobaX" #s=
42 unaryopmut 42 #eq
create mydata 42 , $12345678 , $23456789 ,
mydata structget $5678 #eq
-mydata $42 structset mydata 4 + @ $12425678 #eq
+mydata $42 structset mydata 4 + @ $42345678 #eq
mydata sysstructget $23456789 #eq
mydata 42 sysstructset mydata 8 + @ 42 #eq
2 3 binop1 1 #eq
diff --git a/fs/tests/cc/test.c b/fs/tests/cc/test.c
@@ -210,14 +210,14 @@ extern int unaryopmut(int n) {
struct MyStruct {
int foo;
short bar;
- char baz;
+ char baz[2];
};
extern short structget(struct MyStruct *s) {
return s->bar;
}
extern void structset(struct MyStruct *s, char val) {
- s->baz = val;
+ s->baz[1] = val;
}
extern int sysstructget(struct Field *f) {
return f->size;
diff --git a/posix/dis.c b/posix/dis.c
@@ -143,12 +143,16 @@ struct call {
int arg;
};
-#define CALLCNT 4
+#define CALLCNT 8
struct call calls[CALLCNT] = {
{0x9e, "(br)", ARGINT},
{0xae, "(?br)", ARGINT},
- {0x1e2, "@", ARGNONE},
- {0x204, "!", ARGNONE}
+ {0x138, "swap", ARGNONE},
+ {0x1c7, "@", ARGNONE},
+ {0x1d7, "8b @", ARGNONE},
+ {0x1e9, "!", ARGNONE},
+ {0x1f9, "8b !", ARGNONE},
+ {0x36e, "+", ARGNONE}
};
static int offset = 0;