}
// Local variable management
- List scopeStack = new ArrayList();
+ Basket.Array scopeStack = new Basket.Array();
static class ScopeInfo {
int base;
int end;
JS scopeKey(String name) {
if(globalCache.get(name) != null) return null;
for(int i=scopeStack.size()-1;i>=0;i--) {
- JS key = (JS)((ScopeInfo) scopeStack.elementAt(i)).mapping.get(name);
+ JS key = (JS)((ScopeInfo) scopeStack.get(i)).mapping.get(name);
if(key != null) return key;
}
globalCache.put(name,Boolean.TRUE);
return null;
}
void scopeDeclare(String name) throws IOException {
- ScopeInfo si = (ScopeInfo) scopeStack.lastElement();
+ ScopeInfo si = (ScopeInfo) scopeStack.peek();
if(si.mapping.get(name) != null) throw pe("" + name + " already declared in this scope");
si.mapping.put(name,JS.N(si.end++));
globalCache.put(name,null);
}
void scopePush(JSFunction b) {
- ScopeInfo prev = (ScopeInfo) scopeStack.lastElement();
+ ScopeInfo prev = (ScopeInfo) scopeStack.peek();
ScopeInfo si = new ScopeInfo();
si.base = prev.end;
si.end = si.base;
JSFunction ret = new JSFunction(sourceName, firstLine, null);
if (sourceCode == null) return ret;
Parser p = new Parser(sourceCode, sourceName, firstLine);
- p.scopeStack.setSize(0);
+ p.scopeStack.clear();
p.scopeStack.push(new ScopeInfo());
p.scopePush(ret);
while(true) {
int catchJMPDistance = -1;
if (peekToken() == CATCH) {
- Vec catchEnds = new Vec();
+ Basket.List catchEnds = new Basket.Array();
boolean catchAll = false;
catchJMPDistance = b.size - tryInsn;
scopePop(b);
b.add(parserLine, JMP);
- catchEnds.addElement(new Integer(b.size-1));
+ catchEnds.add(new Integer(b.size-1));
for(int i=0; i<3; i++) if (writebacks[i] != -1) b.set(writebacks[i], JS.N(b.size-writebacks[i]));
b.add(parserLine, POP); // pop the element thats on the stack from the compare
b.add(parserLine, THROW);
for(int i=0;i<catchEnds.size();i++) {
- int n = ((Integer)catchEnds.elementAt(i)).intValue();
+ int n = ((Integer)catchEnds.get(i)).intValue();
b.set(n, JS.N(b.size-n));
}