diff --git a/pom.xml b/pom.xml
index c54147fc..21ef1f0f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,24 +39,18 @@
0.2
-
- org.beanshell
- bsh
- 2.0b4
-
-
org.solovyev
jscl
0.0.1
-
- system
- ${additionalLibs}/jscl.jar
+
+
diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
index 5483a155..b300f15d 100644
--- a/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
+++ b/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
@@ -22,7 +22,6 @@ import android.view.*;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
-import bsh.EvalError;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.math.MathType;
@@ -257,11 +256,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
}
}
- try {
- CalculatorEngine.instance.init(this, preferences);
- } catch (EvalError evalError) {
- throw new RuntimeException("Could not initialize interpreter!");
- }
+ CalculatorEngine.instance.init(this, preferences);
initialized = true;
}
}
diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java
index 78cafe9a..dfdaf9cd 100644
--- a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java
+++ b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java
@@ -15,7 +15,6 @@ import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
-import bsh.EvalError;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.jscl.JsclOperation;
@@ -208,8 +207,6 @@ public enum CalculatorModel implements CursorControl, HistoryControl fromProcessor;
@@ -29,4 +50,7 @@ public enum JsclOperation {
public TextProcessor getFromProcessor() {
return fromProcessor;
}
+
+ @NotNull
+ public abstract String evaluate(@NotNull Expression expression);
}
diff --git a/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java b/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java
index abedd595..7affa24f 100644
--- a/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java
+++ b/src/main/java/org/solovyev/android/calculator/model/CalculatorEngine.java
@@ -7,8 +7,7 @@ package org.solovyev.android.calculator.model;
import android.content.Context;
import android.content.SharedPreferences;
-import bsh.EvalError;
-import bsh.Interpreter;
+import jscl.math.Expression;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.R;
@@ -50,9 +49,6 @@ public enum CalculatorEngine {
public static final String RESULT_PRECISION_P_KEY = "org.solovyev.android.calculator.CalculatorModel_result_precision";
public static final String RESULT_PRECISION_DEFAULT = "5";
- @NotNull
- private Interpreter interpreter;
-
@NotNull
private final Object lock = new Object();
@@ -131,13 +127,13 @@ public enum CalculatorEngine {
}
public Result evaluate(@NotNull JsclOperation operation,
- @NotNull String expression) throws EvalError, ParseException {
+ @NotNull String expression) throws ParseException {
return evaluate(operation, expression, null);
}
public Result evaluate(@NotNull JsclOperation operation,
@NotNull String expression,
- @Nullable MessageRegistry mr) throws EvalError, ParseException {
+ @Nullable MessageRegistry mr) throws ParseException {
synchronized (lock) {
final StringBuilder sb = new StringBuilder();
@@ -160,12 +156,13 @@ public enum CalculatorEngine {
}
}
- final String jsclExpression = ToJsclTextProcessor.wrap(operation, sb.toString());
+ final String jsclExpression = sb.toString();
+ final JsclOperation finalOperation = operation;
final String result;
if (!tooLongExecutionCache.contains(jsclExpression)) {
final MutableObject