aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-25 12:20:25 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-25 12:20:25 -0500
commit7704a95a0b904d90fd5793eccdab38dfcf678ac8 (patch)
tree87453317eed9154434806a2444a9b7de47307c84
parent65f684fb6ab7791ac8641fe2682d7eb5f1c0dde2 (diff)
Implement obj[]
-rw-r--r--compile.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index b5d2b03c..6607c1b4 100644
--- a/compile.c
+++ b/compile.c
@@ -870,7 +870,11 @@ CORD compile(env_t *env, ast_t *ast)
}
case Index: {
auto indexing = Match(ast, Index);
- type_t *container_t = value_type(get_type(env, indexing->indexed));
+ type_t *indexed_type = get_type(env, indexing->indexed);
+ if (!indexing->index && indexed_type->tag == PointerType) {
+ return CORD_all("*(", compile(env, indexing->indexed), ")");
+ }
+ type_t *container_t = value_type(indexed_type);
type_t *index_t = get_type(env, indexing->index);
switch (container_t->tag) {
case ArrayType: {