enums working
This commit is contained in:
parent
049bd1440d
commit
47d801cd34
3 changed files with 21 additions and 8 deletions
15
05/idents.b
15
05/idents.b
|
@ -12,7 +12,14 @@ function ident_list_add
|
||||||
argument ident
|
argument ident
|
||||||
argument value
|
argument value
|
||||||
|
|
||||||
list = memchr(list, 255)
|
; note: we can't just do list = memchr(list, 255) because values
|
||||||
|
; might have a 255 byte.
|
||||||
|
:ilist_add_go_to_end_loop
|
||||||
|
if *1list == 255 goto ilist_add_found_end
|
||||||
|
list = memchr(list, 0)
|
||||||
|
list += 9 ; skip null byte and value
|
||||||
|
goto ilist_add_go_to_end_loop
|
||||||
|
:ilist_add_found_end
|
||||||
list = strcpy(list, ident)
|
list = strcpy(list, ident)
|
||||||
list += 1
|
list += 1
|
||||||
*8list = value ; UNALIGNED
|
*8list = value ; UNALIGNED
|
||||||
|
@ -30,8 +37,9 @@ function ident_list_lookup
|
||||||
if *1list == 255 goto return_0
|
if *1list == 255 goto return_0
|
||||||
b = str_equals(list, ident)
|
b = str_equals(list, ident)
|
||||||
list = memchr(list, 0)
|
list = memchr(list, 0)
|
||||||
list += 1
|
list += 9 ; skip null byte and value
|
||||||
if b == 0 goto ilist_lookup_loop
|
if b == 0 goto ilist_lookup_loop
|
||||||
|
list -= 8 ; backtrack to value
|
||||||
return *8list ; UNALIGNED
|
return *8list ; UNALIGNED
|
||||||
|
|
||||||
; if identifier in list, sets *pvalue to its value (if pvalue is not null) and returns 1
|
; if identifier in list, sets *pvalue to its value (if pvalue is not null) and returns 1
|
||||||
|
@ -45,9 +53,10 @@ function ident_list_lookup_check
|
||||||
if *1list == 255 goto return_0
|
if *1list == 255 goto return_0
|
||||||
b = str_equals(list, ident)
|
b = str_equals(list, ident)
|
||||||
list = memchr(list, 0)
|
list = memchr(list, 0)
|
||||||
list += 1
|
list += 9 ; skip null byte and value
|
||||||
if b == 0 goto ilist_lookcheck_loop
|
if b == 0 goto ilist_lookcheck_loop
|
||||||
if pvalue == 0 goto return_1
|
if pvalue == 0 goto return_1
|
||||||
|
list -= 8 ; backtrack to value
|
||||||
*8pvalue = *8list
|
*8pvalue = *8list
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@ typedef enum {
|
||||||
HELLO,
|
HELLO,
|
||||||
THERE,
|
THERE,
|
||||||
TEST = 1-3,
|
TEST = 1-3,
|
||||||
EEE
|
EEE = TEST+4,
|
||||||
|
ASDFASDF,
|
||||||
|
FFF,
|
||||||
|
HELLO2
|
||||||
} y;
|
} y;
|
||||||
typedef int Bar[EEE];
|
typedef int Bar[FFF];
|
||||||
|
|
|
@ -489,7 +489,8 @@ function parse_type_to
|
||||||
p += 16
|
p += 16
|
||||||
depth = 0 ; parenthesis depth
|
depth = 0 ; parenthesis depth
|
||||||
q = p
|
q = p
|
||||||
; find matching comma -- yes, a comma can appear in an enumerator expression, e.g.
|
; find matching comma/right brace
|
||||||
|
; -- yes, a comma can appear in an enumerator expression, e.g.
|
||||||
; enum { X = sizeof(struct{int x, y;}) };
|
; enum { X = sizeof(struct{int x, y;}) };
|
||||||
; or enum { X = (enum {A,B})3 };
|
; or enum { X = (enum {A,B})3 };
|
||||||
|
|
||||||
|
@ -1090,7 +1091,7 @@ function parse_expression
|
||||||
*4out = TYPE_INT
|
*4out = TYPE_INT
|
||||||
out += 4
|
out += 4
|
||||||
*8out = n
|
*8out = n
|
||||||
out += 16
|
out += 8
|
||||||
return out
|
return out
|
||||||
:not_enumerator
|
:not_enumerator
|
||||||
in -= 16
|
in -= 16
|
||||||
|
@ -1914,7 +1915,7 @@ function print_expression
|
||||||
return expression
|
return expression
|
||||||
:print_expr_int
|
:print_expr_int
|
||||||
expression += 8
|
expression += 8
|
||||||
putn(*8expression)
|
putn_signed(*8expression)
|
||||||
expression += 8
|
expression += 8
|
||||||
return expression
|
return expression
|
||||||
:print_expr_float
|
:print_expr_float
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue