Skip to content

Commit 52a3e17

Browse files
committed
Add tracking of src class names
1 parent dc5d537 commit 52a3e17

File tree

14 files changed

+30
-0
lines changed

14 files changed

+30
-0
lines changed

jskparser/jskparser/jskparser.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88

99
from ast.compilationunit import CompilationUnit
10+
from ast.body.classorinterfacedeclaration import ClassOrInterfaceDeclaration
1011
from ast.utils import utils
1112
from ast.dataflow.dataflow import DataFlow
1213
from ast.visit.sourcevisitor import SourcePrinter
@@ -31,6 +32,17 @@ def parse(path, **kwargs):
3132
d.update({u'GSYMTAB':'RESET'})
3233
logging.info('parsing file...')
3334
program = CompilationUnit(d)
35+
top_class_names = []
36+
def find_classes(node):
37+
if type(node) == ClassOrInterfaceDeclaration and \
38+
not node.isinner():
39+
for annotation in node.annotations:
40+
if annotation.name.name == u"JSketchStdLib":
41+
return
42+
top_class_names.append(node.name)
43+
class_finder = GenericVisitor(find_classes)
44+
program.accept(class_finder)
45+
program.src_class_names = top_class_names
3446

3547
s = SymtabGen(lib=lib)
3648
logging.info('generating symbol table...')

model/lang/Character.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.lang;
22

3+
@JSketchStdLib
34
public class Character {
45
// public static final int MIN_RADIX = 2;
56
// public static final int MAX_RADIX = 36;

model/lang/Integer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.lang;
22

3+
@JSketchStdLib
34
public class Integer extends Number {
45
public static final int MIN_VALUE;
56

model/lang/Iterable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Iterator;
44

5+
@JSketchStdLib
56
public interface Iterable <T> {
67
public Iterator<T> iterator();
78
}

model/lang/Number.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// }
88

9+
@JSketchStdLib
910
public class Number {
1011

1112
}

model/lang/Object.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@JSketchStdLib
12
public class Object {
23
// public static boolean equals(Object a, Object b) {
34
// if (a == null) {

model/lang/String.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.lang;
22

3+
@JSketchStdLib
34
public class String implements CharSequence{
45
char[] _value;
56
int _count;

model/util/ArrayList.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.util;
22

3+
@JSketchStdLib
34
private class ArrayListIterator<E> implements Iterator<E> {
45
private ArrayList<E> es = null;
56
private int index = -1;
@@ -28,6 +29,7 @@ public void remove() {
2829
}
2930
}
3031

32+
@JSketchStdLib
3133
public class ArrayList<E> implements List<E>{
3234

3335
Object[] elementData;

model/util/Arrays.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.util;
22

3+
@JSketchStdLib
34
private class ArrayAsListIterator<E> implements Iterator<E> {
45
private E[] es = null;
56
private int index = -1;
@@ -24,6 +25,7 @@ public void remove() {
2425
}
2526
}
2627

28+
@JSketchStdLib
2729
private class ArrayAsList<E> implements List<E> {
2830
private E[] es = null;
2931
public AsList(E[] es) {
@@ -61,6 +63,7 @@ public Iterator<E> iterator() {
6163
}
6264
}
6365

66+
@JSketchStdLib
6467
public class Arrays {
6568

6669
public static byte[] copyOf(byte[] in, int len) {

model/util/HashMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// public class HashMap<K,V> extends Map {
2+
@JSketchStdLib
23
public class HashMap<K,V> {
34
static final int DEFAULT_INITIAL_CAPACITY;// = 1 << 4; // aka 16
45
Node[] elementData;

0 commit comments

Comments
 (0)