Revision 44622 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/DefaultOptimizer.java

View differences:

DefaultOptimizer.java
168 168
        switch (code.code()) {
169 169
            case Code.CALLER:
170 170
                Caller caller = (Caller) code;
171
                if (caller.function() == null) {
171
                Function function = caller.function();
172
                if ( function == null) {
172 173
                    // resolve and link function
173
                    caller.function(this.getSymbolTable().function(caller.name()));
174
                    function = this.getSymbolTable().function(caller.name());
175
                    caller.function(function);
174 176
                }
175
                if (caller.function() instanceof FunctionOptimizer) {
177
                if (function instanceof FunctionOptimizer) {
176 178
                    return ((FunctionOptimizer) caller.function()).optimize(this, caller);
177 179
                } else {
178 180
                    switch (caller.type()) {
179 181
                        case Caller.BINARY_OPERATOR: {
180 182
                            Code op1 = this.doOptimize(caller.parameters().get(0));
181 183
                            Code op2 = this.doOptimize(caller.parameters().get(1));
182
                            if (caller.function().allowConstantFolding()) {
184
                            if ( function.allowConstantFolding()) {
183 185
                                if (op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
184 186
                                    Object value = this.getInterpreter().run(code);
185 187
                                    Code newCode = this.getCodeBuilder().constant(value);
......
192 194

  
193 195
                        case Code.Caller.UNARY_OPERATOR: {
194 196
                            Code op1 = this.doOptimize(caller.parameters().get(0));
195
                            if (caller.function().allowConstantFolding()
197
                            if (function.allowConstantFolding()
196 198
                                    && op1.code() == Code.CONSTANT) {
197 199
                                Object value = this.getInterpreter().run(code);
198 200
                                Code newCode = this.getCodeBuilder().constant(value);
......
215 217
                                    }
216 218
                                }
217 219
                            }
218
                            if (canOptimize && caller.function()!=null && caller.function().allowConstantFolding()) {
220
                            if (canOptimize && function!=null && function.allowConstantFolding()) {
219 221
                                Object value = this.getInterpreter().run(code);
220 222
                                Code newCode = this.getCodeBuilder().constant(value);
221 223
                                return newCode;

Also available in: Unified diff