Skip to content

Commit 0c8b573

Browse files
author
rcartwright
committed
Revised the typing of the typechecker and related classes to accommodate generic type checking. This is the first step to supporting generic gtyping in the DrJava interactions pane. No generic checking is done yet, but the checker now returns type Type instead of Class<?>.
git-svn-id: file:///tmp/test-svn/trunk@3427 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 8b62707 commit 0c8b573

36 files changed

+1160
-1185
lines changed

dynamicjava/src/koala/Version.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* This file is copied to Version.java by the build process, which also
5454
* fills in the right values of the date and time.
5555
*
56-
* This javadoc corresponds to build drjava-20050525-1601;
56+
* This javadoc corresponds to build drjava-20050822-0532;
5757
*
5858
* @version $Id$
5959
*/
@@ -62,7 +62,7 @@ public abstract class Version {
6262
* This string will be automatically expanded upon "ant commit".
6363
* Do not edit it by hand!
6464
*/
65-
private static final String BUILD_TIME_STRING = "20050525-1601";
65+
private static final String BUILD_TIME_STRING = "20050822-0532";
6666

6767
/** A {@link Date} version of the build time. */
6868
private static final Date BUILD_TIME = _getBuildDate();

dynamicjava/src/koala/build-common.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
</target>
8181

8282
<target name="make-version-stamp" depends="get-timestamp">
83-
<tstamp_gmt /> <!-- get new time stamp to use for CVS tag -->
84-
8583
<!-- Create new Version.java, filling in date and time. -->
8684
<filter token="DATE" value="${DSTAMP}" />
8785
<filter token="TIME" value="${TSTAMP}" />
@@ -92,7 +90,6 @@
9290
</target>
9391

9492

95-
9693
<!-- Commit source to CVS archive
9794
Before doing do, we update our copy with the CVS copy. This ensures that
9895
if there were any clashes, we have to resolve them now. Then we

dynamicjava/src/koala/dynamicjava/classfile/JVMUtilities.java

Lines changed: 34 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -116,102 +116,59 @@ public abstract class JVMUtilities {
116116
stypes.put("void", "V");
117117
}
118118

119-
/**
120-
* Returns the string that represents internally the given class
121-
*/
119+
/** Returns the string that represents internally the given class. */
122120
public static String getName(Class<?> c) {
123121
String s = types.get(c);
124-
if (s != null) {
125-
return s;
126-
} else {
127-
return c.getName().replace('.', '/');
128-
}
122+
if (s != null) return s;
123+
return c.getName().replace('.', '/');
129124
}
130125

131-
/**
132-
* Returns the string that represents internally the given class name
133-
*/
126+
/** Returns the string that represents internally the given class name. */
134127
public static String getName(String c) {
135128
String s = stypes.get(c);
136-
if (s != null) {
137-
return s;
138-
} else {
139-
if (c.endsWith("[]")) {
140-
if (c.endsWith("[][]")) {
141-
return "["+getName(c.substring(0, c.length()-2));
142-
} else {
143-
return "["+getReturnTypeName(c.substring(0, c.length()-2));
144-
}
145-
} else {
146-
return c.replace('.', '/');
147-
}
148-
}
129+
if (s != null) return s;
130+
if (c.endsWith("[]")) {
131+
if (c.endsWith("[][]")) return "[" + getName(c.substring(0, c.length()-2));
132+
return "["+ getReturnTypeName(c.substring(0, c.length()-2));
133+
}
134+
return c.replace('.', '/'); // What if the array class has more than two dimensions?
149135
}
150136

151-
/**
152-
* Returns the string that represents internally the given class
153-
*/
137+
/** Returns the string that represents internally the given class */
154138
public static String getReturnTypeName(Class<?> c) {
155139
String s = types.get(c);
156-
if (s != null) {
157-
return s;
158-
} else {
159-
return ((c.isArray()) ?
160-
c.getName() : "L" + c.getName() + ";").replace('.', '/');
161-
}
140+
if (s != null) return s;
141+
return ((c.isArray()) ? c.getName() : "L" + c.getName() + ";").replace('.', '/');
162142
}
163143

164-
/**
165-
* Returns the string that represents internally the given class name
166-
*/
144+
/** Returns the string that represents internally the given class name. */
167145
public static String getReturnTypeName(String c) {
168146
String s = stypes.get(c);
169-
if (s != null) {
170-
return s;
171-
} else {
172-
if (c.endsWith("[]")) {
173-
return "["+getReturnTypeName(c.substring(0, c.length()-2));
174-
} else {
175-
return ((c.startsWith("[")) ?
176-
c : "L" + c + ";").replace('.', '/');
177-
}
178-
}
147+
if (s != null) return s;
148+
if (c.endsWith("[]")) return "["+getReturnTypeName(c.substring(0, c.length()-2));
149+
return ((c.startsWith("[")) ? c : "L" + c + ";").replace('.', '/');
179150
}
180151

181-
/**
182-
* Returns the string that represents internally the given class
183-
*/
184-
public static String getParameterTypeName(Class<?> c) {
185-
return getReturnTypeName(c);
186-
}
152+
/** Returns the string that represents internally the given class. */
153+
public static String getParameterTypeName(Class c) { return getReturnTypeName(c); }
187154

188-
/**
189-
* Returns the string that represents internally the given class name
190-
*/
191-
public static String getParameterTypeName(String c) {
192-
return getReturnTypeName(c);
193-
}
194155

195-
/**
196-
* Creates a method descriptor
197-
* @param rt the return type name as returned by getReturnTypeName
198-
* @param pt the parameters type names as returned by getParameterTypeName
199-
*/
200-
public static String createMethodDescriptor(String rt, String[] pt) {
201-
if (pt != null) {
202-
String result = "(";
203-
for (int i = 0; i < pt.length; i++) {
204-
result += pt[i];
205-
}
206-
return result + ")" + rt;
207-
} else {
208-
return rt;
209-
}
210-
}
156+
/** Returns the string that represents internally the given class name. */
157+
public static String getParameterTypeName(String c) { return getReturnTypeName(c); }
211158

212-
/**
213-
* No need to create instances of this class
159+
/** Creates a method descriptor
160+
* @param rt the return type name as returned by getReturnTypeName
161+
* @param pt the parameters type names as returned by getParameterTypeName
214162
*/
215-
private JVMUtilities() {
163+
public static String createMethodDescriptor(String rt, String[] pts) {
164+
if (pts != null) {
165+
StringBuffer result = new StringBuffer("(");
166+
for (String pt: pts) result.append(pt);
167+
return result.append(')').append(rt).toString(); // Note: append operation modifies the receiver!
168+
}
169+
return rt;
216170
}
171+
172+
/** No need to create instances of this class */
173+
private JVMUtilities() { }
217174
}

dynamicjava/src/koala/dynamicjava/classinfo/ClassInfoUtilities.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,21 @@ public static MethodInfo lookupMethod(ClassInfo cl, String name, ClassInfo[] ac)
236236
* @param cl the inner class
237237
* @param name the name of the method
238238
* @param ac the arguments classes (possibly not the exact declaring classes)
239+
* @pre cl is not null
239240
*/
240241
public static MethodInfo lookupOuterMethod(ClassInfo cl, String name, ClassInfo[] ac)
241242
throws NoSuchMethodException {
243+
242244
boolean sc = Modifier.isStatic(cl.getModifiers());
243-
ClassInfo c = (cl != null) ? cl.getDeclaringClass() : null;
244-
while (c != null) {
245+
ClassInfo c = cl.getDeclaringClass();
246+
do {
245247
sc |= Modifier.isStatic(c.getModifiers());
246248
try {
247249
MethodInfo m = lookupMethod(c, name, ac);
248-
if (!sc || Modifier.isStatic(m.getModifiers())) {
249-
return m;
250-
}
251-
} catch (NoSuchMethodException e) {
252-
}
250+
if (!sc || Modifier.isStatic(m.getModifiers())) return m;
251+
} catch (NoSuchMethodException e) { /* This point is reachable! */ }
253252
c = c.getDeclaringClass();
254-
}
253+
} while (c != null);
255254
throw new NoSuchMethodException(name);
256255
}
257256

dynamicjava/src/koala/dynamicjava/gui/Main.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Main extends JFrame implements ActionMap {
5353
* The entry point of the program
5454
*/
5555
public static void main(String[] args) {
56-
new Main().show();
56+
new Main().setVisible(true);
5757
}
5858

5959
// The action names
@@ -70,7 +70,7 @@ public static void main(String[] args) {
7070
public final static String OPTIONS_ACTION = "OptionsAction";
7171
public final static String EVAL_ACTION = "EvalAction";
7272
public final static String EVAL_S_ACTION = "EvalSAction";
73-
public final static String STOP_ACTION = "StopAction";
73+
// public final static String STOP_ACTION = "StopAction";
7474
public final static String REINIT_ACTION = "ReinitAction";
7575
public final static String ABOUT_ACTION = "AboutAction";
7676

@@ -144,10 +144,10 @@ public static void main(String[] args) {
144144
*/
145145
protected EvalSelectionAction evalSelection = new EvalSelectionAction();
146146

147-
/**
148-
* The stop action
149-
*/
150-
protected StopAction stopAction = new StopAction();
147+
// /**
148+
// * The stop action
149+
// */
150+
// protected StopAction stopAction = new StopAction();
151151

152152
/**
153153
* The current interpreter thread
@@ -241,7 +241,7 @@ public void windowClosing(WindowEvent e) {
241241
listeners.put(OPTIONS_ACTION, new OptionsAction());
242242
listeners.put(EVAL_ACTION, evalAction);
243243
listeners.put(EVAL_S_ACTION, evalSelection);
244-
listeners.put(STOP_ACTION, stopAction);
244+
// listeners.put(STOP_ACTION, stopAction);
245245
listeners.put(REINIT_ACTION, new ReinitAction());
246246
listeners.put(ABOUT_ACTION, new AboutAction());
247247

@@ -604,7 +604,7 @@ public void actionPerformed(ActionEvent e) {
604604
Dimension od = options.getSize();
605605
options.setLocation(fr.x + (fr.width - od.width) / 2,
606606
fr.y + (fr.height - od.height) / 2);
607-
options.show();
607+
options.setVisible(true);
608608
}
609609
}
610610

@@ -653,7 +653,7 @@ public void run() {
653653
System.setErr(err);
654654
try {
655655
isRunning = true;
656-
stopAction.update();
656+
// stopAction.update();
657657
evalAction.update();
658658
evalSelection.update();
659659
output.append("==> " + interpreter.interpret(reader, "buffer") + "\n");
@@ -668,7 +668,7 @@ public void run() {
668668
System.setErr(olderr);
669669
}
670670
isRunning = false;
671-
stopAction.update();
671+
// stopAction.update();
672672
evalAction.update();
673673
evalSelection.update();
674674

@@ -707,35 +707,35 @@ protected void update() {
707707
}
708708
}
709709

710-
/**
711-
* To stop the interpreter thread
712-
*/
713-
protected class StopAction extends AbstractAction
714-
implements JComponentModifier {
715-
java.util.List<JComponent> components = new LinkedList<JComponent>();
716-
717-
public void actionPerformed(ActionEvent ev) {
718-
thread.stop();
719-
isRunning = false;
720-
update();
721-
evalAction.update();
722-
evalSelection.update();
723-
status.setMessage("Status.evaluation.stopped");
724-
}
725-
726-
public void addJComponent(JComponent c) {
727-
components.add(c);
728-
c.setEnabled(false);
729-
}
730-
731-
protected void update() {
732-
Iterator<JComponent> it = components.iterator();
733-
while (it.hasNext()) {
734-
it.next().setEnabled(isRunning);
735-
}
736-
}
737-
}
738-
710+
// /**
711+
// * To stop the interpreter thread
712+
// */
713+
// protected class StopAction extends AbstractAction
714+
// implements JComponentModifier {
715+
// java.util.List<JComponent> components = new LinkedList<JComponent>();
716+
//
717+
// public void actionPerformed(ActionEvent ev) {
718+
// thread.stop();
719+
// isRunning = false;
720+
// update();
721+
// evalAction.update();
722+
// evalSelection.update();
723+
// status.setMessage("Status.evaluation.stopped");
724+
// }
725+
//
726+
// public void addJComponent(JComponent c) {
727+
// components.add(c);
728+
// c.setEnabled(false);
729+
// }
730+
//
731+
// protected void update() {
732+
// Iterator<JComponent> it = components.iterator();
733+
// while (it.hasNext()) {
734+
// it.next().setEnabled(isRunning);
735+
// }
736+
// }
737+
// }
738+
//
739739
/**
740740
* Reinitializes the interpreter
741741
*/

dynamicjava/src/koala/dynamicjava/gui/OptionsDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ public void actionPerformed(ActionEvent e) {
742742
Dimension ud = urlChooser.getSize();
743743
urlChooser.setLocation(fr.x + (fr.width - ud.width) / 2,
744744
fr.y + (fr.height - ud.height) / 2);
745-
urlChooser.show();
745+
urlChooser.setVisible(true);
746746
}
747747
}
748748

0 commit comments

Comments
 (0)