@Test void testGetArray() { var parentScope = new Scope(null); var childScope = parentScope.createChild(); parentScope.declareArray("parent_array", PrimitiveType.INT); assertNotNull(childScope.getArray("parent_array")); childScope.declareArray("child_array", PrimitiveType.INT); assertNull(parentScope.getArray("child_array")); assertNotNull(childScope.getArray("child_array")); assertEquals(PrimitiveType.INT, childScope.getArray("parent_array").getType()); assertEquals(PrimitiveType.INT, childScope.getArray("child_array").getType()); }
public ArrayInfo getArray(String name) { var array = arrays.lookup.get(name); if (array == null && parent != null) { array = parent.getArray(name); } return array; }
Scope { public ArrayInfo getArray(String name) { var array = arrays.lookup.get(name); if (array == null && parent != null) { array = parent.getArray(name); } return array; } }
Scope { public ArrayInfo getArray(String name) { var array = arrays.lookup.get(name); if (array == null && parent != null) { array = parent.getArray(name); } return array; } Scope(Scope parent); }
Scope { public ArrayInfo getArray(String name) { var array = arrays.lookup.get(name); if (array == null && parent != null) { array = parent.getArray(name); } return array; } Scope(Scope parent); Local declareLocalVariable(String name, Type type); Local getLocalVariable(String name); ArrayInfo declareArray(String name, PrimitiveType type); ArrayInfo declareArray(int index, String name, PrimitiveType type); ArrayInfo getArray(String name); Scope createChild(); }
Scope { public ArrayInfo getArray(String name) { var array = arrays.lookup.get(name); if (array == null && parent != null) { array = parent.getArray(name); } return array; } Scope(Scope parent); Local declareLocalVariable(String name, Type type); Local getLocalVariable(String name); ArrayInfo declareArray(String name, PrimitiveType type); ArrayInfo declareArray(int index, String name, PrimitiveType type); ArrayInfo getArray(String name); Scope createChild();  }