Revision 43809 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultInterpreter.java
DefaultInterpreter.java | ||
---|---|---|
75 | 75 |
private SymbolTable symbolTable = null; |
76 | 76 |
private Double accuracy; |
77 | 77 |
private Code currentCode; |
78 |
private final Cache cache;
|
|
78 |
private Cache cache; |
|
79 | 79 |
|
80 | 80 |
public DefaultInterpreter() { |
81 |
this.symbolTable = SQLSymbolTable.getInstance(); |
|
82 | 81 |
this.cache = new DefaultCache(); |
83 | 82 |
} |
84 | 83 |
|
85 | 84 |
@Override |
85 |
public Interpreter clone() throws CloneNotSupportedException { |
|
86 |
DefaultInterpreter other = (DefaultInterpreter) super.clone(); |
|
87 |
other.cache = new DefaultCache(); |
|
88 |
if( this.symbolTable!=null ) { |
|
89 |
other.symbolTable = this.symbolTable.clone(); |
|
90 |
} |
|
91 |
|
|
92 |
return other; |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
86 | 96 |
public Cache getCache() { |
87 | 97 |
return this.cache; |
88 | 98 |
} |
... | ... | |
94 | 104 |
|
95 | 105 |
@Override |
96 | 106 |
public SymbolTable getSymbolTable() { |
107 |
if( this.symbolTable==null ) { |
|
108 |
this.symbolTable = SQLSymbolTable.getInstance(); |
|
109 |
} |
|
97 | 110 |
return this.symbolTable; |
98 | 111 |
} |
99 | 112 |
@Override |
... | ... | |
124 | 137 |
if( code instanceof Caller ) { |
125 | 138 |
Caller caller = (Caller) code; |
126 | 139 |
if( caller.function() == null ) { |
127 |
caller.function(this.symbolTable.function(caller.name()));
|
|
140 |
caller.function(this.getSymbolTable().function(caller.name()));
|
|
128 | 141 |
} |
129 | 142 |
if( caller.args() != null ) { |
130 | 143 |
for( Code arg : caller.args() ) { |
... | ... | |
144 | 157 |
|
145 | 158 |
case Code.IDENTIFIER: |
146 | 159 |
String name = ((Identifier) code).name(); |
147 |
if( !symbolTable.exists(name) ) {
|
|
160 |
if( !this.getSymbolTable().exists(name) ) {
|
|
148 | 161 |
throw new RuntimeException("Variable '" + name + "' not found."); |
149 | 162 |
} |
150 |
value = symbolTable.value(name);
|
|
163 |
value = this.getSymbolTable().value(name);
|
|
151 | 164 |
break; |
152 | 165 |
|
153 | 166 |
case Code.CALLER: |
154 | 167 |
Caller caller = (Caller) code; |
155 | 168 |
Function function = caller.function(); |
156 | 169 |
if( function == null ) { |
157 |
function = this.symbolTable.function(caller.name());
|
|
170 |
function = this.getSymbolTable().function(caller.name());
|
|
158 | 171 |
if( function == null ) { |
159 | 172 |
throw new RuntimeException("Function '" + caller.name() + "' not found."); |
160 | 173 |
} |
Also available in: Unified diff