summaryrefslogtreecommitdiff
path: root/sources/scalac/atree
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-11-05 16:41:01 +0000
committerpaltherr <paltherr@epfl.ch>2003-11-05 16:41:01 +0000
commit93fc1b0b638d5d374d6c51970cd5c247518fe563 (patch)
tree8bd0459212a4b8347cc7e67e32cc25a676eee3d4 /sources/scalac/atree
parent57875e803374bf38d8ff5006c76aa2bb87fc2958 (diff)
downloadscala-93fc1b0b638d5d374d6c51970cd5c247518fe563.tar.gz
scala-93fc1b0b638d5d374d6c51970cd5c247518fe563.tar.bz2
scala-93fc1b0b638d5d374d6c51970cd5c247518fe563.zip
- Added atree/ALocation.java
Diffstat (limited to 'sources/scalac/atree')
-rw-r--r--sources/scalac/atree/ALocation.java33
-rw-r--r--sources/scalac/atree/ATreePrinter.java20
2 files changed, 53 insertions, 0 deletions
diff --git a/sources/scalac/atree/ALocation.java b/sources/scalac/atree/ALocation.java
new file mode 100644
index 0000000000..0a9c440df2
--- /dev/null
+++ b/sources/scalac/atree/ALocation.java
@@ -0,0 +1,33 @@
+/* ____ ____ ____ ____ ______ *\
+** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
+** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
+** /_____/\____/\___/\____/____/ **
+\* */
+
+// $Id$
+
+package scalac.atree;
+
+import scalac.symtab.Symbol;
+
+/** This class represents an attributed value location. */
+public class ALocation {
+
+ //########################################################################
+ // Public Cases
+
+ public case Module(Symbol module); // !!! remove ?
+ public case Field(ACode object, Symbol field, boolean isStatic);
+ public case Local(Symbol local, boolean isArgument);
+ public case ArrayItem(ACode array, ACode index);
+
+ //########################################################################
+ // Public Methods
+
+ /** Returns a string representation of this location. */
+ public String toString() {
+ return new ATreePrinter().printLocation(this).toString();
+ }
+
+ //########################################################################
+}
diff --git a/sources/scalac/atree/ATreePrinter.java b/sources/scalac/atree/ATreePrinter.java
index 779a6c853e..073a58daec 100644
--- a/sources/scalac/atree/ATreePrinter.java
+++ b/sources/scalac/atree/ATreePrinter.java
@@ -344,6 +344,26 @@ public class ATreePrinter {
}
}
+ /** Prints the location. */
+ public ATreePrinter printLocation(ALocation location) {
+ switch (location) {
+ case Module(Symbol module):
+ return printSymbol(module);
+ case Field(Void, Symbol field, true):
+ return printSymbol(field.owner()).print('.').printSymbol(field);
+ case Field(ACode object, Symbol field, boolean isStatic):
+ printCode(object).print('.');
+ if (isStatic) print("<static>").space();
+ return printSymbol(field);
+ case Local(Symbol local, _):
+ return printSymbol(local);
+ case ArrayItem(ACode array, ACode index):
+ return printCode(array).print('(').printCode(index).print(')');
+ default:
+ throw Debug.abort("illegal case", location);
+ }
+ }
+
/** Prints the primitive. */
public ATreePrinter printPrimitive(APrimitive primitive) {
switch (primitive) {