Skip to content

Commit 29c42c1

Browse files
committed
Change int *a[] type to Array(Pointer(Int())) instead of Pointer(Array(..))
See #23 for more info.
1 parent 7c187c9 commit 29c42c1

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

basec/trans/BaseC/desugar/__tests__/types.spt

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module types
22

33
language MetaC
44

5-
65
test 8 bit int [[
76
char x;
87
]] run strip-annos to Program(_, [
@@ -84,13 +83,13 @@ test array type with a size [[
8483
test pointer of array type [[
8584
int *a[];
8685
]] run strip-annos to Program(_, [
87-
VarDeclaration([], Type([], Pointer(Array(Int32(), None()))), _, _)
86+
VarDeclaration([], Type([], Array(Pointer(Int32()), None())), _, _)
8887
])
8988

9089
test pointers of arrays type [[
9190
int ***a[][];
9291
]] run strip-annos to Program(_, [
93-
VarDeclaration([], Type([], Pointer(Pointer(Pointer(Array(Array(Int32(), None()), None()))))), _, _)
92+
VarDeclaration([], Type([], Array(Array(Pointer(Pointer(Pointer(Int32()))), None()), None())), _, _)
9493
])
9594

9695
test const modifier [[

basec/trans/BaseC/desugar/types.str

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ rules
5353
desugar-array-size: None() -> None()
5454
desugar-array-size: Some(value) -> Some(<number-to-int> value)
5555

56-
merge-types:
57-
(Type(mods, type), ptr, ArrayDecl(d, size)) -> t
58-
where
59-
t := <merge-types> (Type(mods, Array(type, <desugar-array-size> size)), ptr, d)
60-
6156
merge-types:
6257
(base-type@Type(mods, type), Some(Pointer(qualifiers, ptr)), decl) -> t
6358
where
6459
mods* := <conc> (mods, qualifiers)
6560
; t := <merge-types> (Type(mods*, Pointer(type)), ptr, decl)
6661

62+
merge-types:
63+
(Type(mods, type), ptr, ArrayDecl(d, size)) -> t
64+
where
65+
t := <merge-types> (Type(mods, Array(type, <desugar-array-size> size)), ptr, d)
66+
6767
merge-types:
6868
(Type(mods, type), ptr, FuncDecl(d, params)) -> t
6969
where

basec/trans/BaseC/types/__tests__/typedefs.spt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test typedef pointer of a base type with array [[
3434
typedef int32 *** a[];
3535
a y;
3636
a z = [[(0,y)]];
37-
]] run get-type to Pointer(Pointer(Pointer(Array(Int32(), None()))))
37+
]] run get-type to Array(Pointer(Pointer(Pointer(Int32()))), None())
3838

3939
test typedef of another typedef with pointer [[
4040
typedef int32 a;

basec/trans/BaseC/types/__tests__/types.spt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ test multi dimensional array type [[
1717
int32 b[][] = [[a]];
1818
]] run get-type to Array(Array(Int32, None()), None())
1919

20-
test pointer to array type [[
20+
test array or pointers type [[
2121
int32 *a[];
2222
int32 *b[] = [[a]];
23-
]] run get-type to Pointer(Array(Int32, None()))
23+
]] run get-type to Array(Pointer(Int32), None())
2424

2525
test function type [[
2626
int32 a();

0 commit comments

Comments
 (0)