Charj: Fixed array element access.
authorJonathan Lifflander <jliffl2@illinois.edu>
Tue, 6 Jul 2010 01:41:24 +0000 (20:41 -0500)
committerJonathan Lifflander <jliffl2@illinois.edu>
Tue, 6 Jul 2010 01:41:24 +0000 (20:41 -0500)
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/SymbolResolver.g

index f1517608400238ba9caae5c35145335ec8112c3e..99c63c387cd1d90576b0c5227e625e87cd25b01d 100644 (file)
@@ -854,7 +854,9 @@ primaryExpression
     |   explicitConstructorCall
         -> {$explicitConstructorCall.st}
     |   ^(ARRAY_ELEMENT_ACCESS pe=primaryExpression ex=expression)
-        -> template(pe={$pe.st}, ex={$ex.st}) "(*(<pe>))[<ex>]"
+        -> {$pe.start.symbolType != null && $pe.start.symbolType instanceof PointerType}?
+               template(pe={$pe.st}, ex={$ex.st}) "(*(<pe>))[<ex>]"
+        -> template(pe={$pe.st}, ex={$ex.st}) "(<pe>)[<ex>]"
     |   literal
         -> {$literal.st}
     |   newExpression[null]
index 3b8fa7af75c444bbcdac4864ae86a89ad71bbbf9..9abbb0498f1302e577cac8afda74a2d7fadf57c2 100644 (file)
@@ -338,6 +338,14 @@ type returns [Type sym]
     //System.out.println("symbolType: " + $start.symbolType);
     if (proxy && $start.symbolType != null) $start.symbolType = new ProxyType(symtab, $start.symbolType);
     if (pointer && $start.symbolType != null) $start.symbolType = new PointerType(symtab, $start.symbolType);
+
+    // TODO: Special case for Arrays, should be fixed
+    if (typeText.equals("Array") && $start.symbolType == null) {
+        System.out.println("found Array XXXX");
+        ClassSymbol cs = new ClassSymbol(symtab, "Array");
+        $start.symbolType = new PointerType(symtab, cs);
+    }
+
     $sym = $start.symbolType;
     if ($sym == null) System.out.println("Couldn't resolve type: " + typeText);
 }