From 8edf213492238a51b544d8dcddfe75ab6a14095a Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sun, 15 May 2016 22:59:28 -0400 Subject: [PATCH 1/2] Remove LeafSearchScript.runAsFloat(): Nothing calls it. --- .../script/AbstractDoubleSearchScript.java | 5 -- .../script/AbstractFloatSearchScript.java | 45 ------------- .../script/AbstractLongSearchScript.java | 5 -- .../script/AbstractSearchScript.java | 7 +- .../script/LeafSearchScript.java | 2 - .../script/NativeScriptFactory.java | 1 - .../function/ScriptScoreFunctionTests.java | 66 ++++++++----------- .../search/aggregations/metrics/AvgIT.java | 10 --- .../search/aggregations/metrics/SumIT.java | 10 --- .../aggregations/metrics/ValueCountIT.java | 5 -- .../support/ScriptValuesTests.java | 5 -- .../modules/scripting/native.asciidoc | 12 ++-- .../expression/ExpressionSearchScript.java | 3 - .../groovy/GroovyScriptEngineService.java | 5 -- .../elasticsearch/painless/ScriptImpl.java | 9 --- .../JavaScriptScriptEngineService.java | 5 -- .../python/PythonScriptEngineService.java | 5 -- 17 files changed, 33 insertions(+), 167 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java diff --git a/core/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java b/core/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java index 6a803ba8571..66eb0f3684d 100644 --- a/core/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java +++ b/core/src/main/java/org/elasticsearch/script/AbstractDoubleSearchScript.java @@ -37,9 +37,4 @@ public abstract class AbstractDoubleSearchScript extends AbstractSearchScript { public long runAsLong() { return (long) runAsDouble(); } - - @Override - public float runAsFloat() { - return (float) runAsDouble(); - } } \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java b/core/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java deleted file mode 100644 index 21db0b05501..00000000000 --- a/core/src/main/java/org/elasticsearch/script/AbstractFloatSearchScript.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.script; - -/** - * A simpler base class instead of {@link AbstractSearchScript} for computations - * that return a float number. - */ -public abstract class AbstractFloatSearchScript extends AbstractSearchScript { - - @Override - public Object run() { - return runAsFloat(); - } - - @Override - public abstract float runAsFloat(); - - @Override - public double runAsDouble() { - return runAsFloat(); - } - - @Override - public long runAsLong() { - return (long) runAsFloat(); - } -} \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java b/core/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java index 53a24002d3d..226984e0697 100644 --- a/core/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java +++ b/core/src/main/java/org/elasticsearch/script/AbstractLongSearchScript.java @@ -37,9 +37,4 @@ public abstract class AbstractLongSearchScript extends AbstractSearchScript { public double runAsDouble() { return runAsLong(); } - - @Override - public float runAsFloat() { - return runAsLong(); - } } \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/script/AbstractSearchScript.java b/core/src/main/java/org/elasticsearch/script/AbstractSearchScript.java index 98e5ab11fb7..929046d4dd8 100644 --- a/core/src/main/java/org/elasticsearch/script/AbstractSearchScript.java +++ b/core/src/main/java/org/elasticsearch/script/AbstractSearchScript.java @@ -34,7 +34,7 @@ import java.util.Map; * A base class for any script type that is used during the search process (custom score, aggs, and so on). *

* If the script returns a specific numeric type, consider overriding the type specific base classes - * such as {@link AbstractDoubleSearchScript}, {@link AbstractFloatSearchScript} and {@link AbstractLongSearchScript} + * such as {@link AbstractDoubleSearchScript} and {@link AbstractLongSearchScript} * for better performance. *

* The use is required to implement the {@link #run()} method. @@ -120,11 +120,6 @@ public abstract class AbstractSearchScript extends AbstractExecutableScript impl lookup.source().setSource(source); } - @Override - public float runAsFloat() { - return ((Number) run()).floatValue(); - } - @Override public long runAsLong() { return ((Number) run()).longValue(); diff --git a/core/src/main/java/org/elasticsearch/script/LeafSearchScript.java b/core/src/main/java/org/elasticsearch/script/LeafSearchScript.java index cff0e42e5cf..0bf9e0d50e0 100644 --- a/core/src/main/java/org/elasticsearch/script/LeafSearchScript.java +++ b/core/src/main/java/org/elasticsearch/script/LeafSearchScript.java @@ -44,8 +44,6 @@ public interface LeafSearchScript extends ScorerAware, ExecutableScript { setNextVar("_value", value); } - float runAsFloat(); - long runAsLong(); double runAsDouble(); diff --git a/core/src/main/java/org/elasticsearch/script/NativeScriptFactory.java b/core/src/main/java/org/elasticsearch/script/NativeScriptFactory.java index 1625afe97c9..6768bc4f87a 100644 --- a/core/src/main/java/org/elasticsearch/script/NativeScriptFactory.java +++ b/core/src/main/java/org/elasticsearch/script/NativeScriptFactory.java @@ -29,7 +29,6 @@ import java.util.Map; * * @see AbstractExecutableScript * @see AbstractSearchScript - * @see AbstractFloatSearchScript * @see AbstractLongSearchScript * @see AbstractDoubleSearchScript */ diff --git a/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java b/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java index 17fbc882ba9..861476b9d47 100644 --- a/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java +++ b/core/src/test/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunctionTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.common.lucene.search.function; import org.apache.lucene.index.LeafReaderContext; -import org.elasticsearch.script.AbstractFloatSearchScript; +import org.elasticsearch.script.AbstractDoubleSearchScript; import org.elasticsearch.script.LeafSearchScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptException; @@ -29,51 +29,37 @@ import org.elasticsearch.test.ESTestCase; import java.io.IOException; -import static org.hamcrest.Matchers.equalTo; - public class ScriptScoreFunctionTests extends ESTestCase { /** * Tests https://github.com/elastic/elasticsearch/issues/2426 */ public void testScriptScoresReturnsNaN() throws IOException { - ScoreFunction scoreFunction = new ScriptScoreFunction(new Script("Float.NaN"), new FloatValueScript(Float.NaN)); + // script that always returns NaN + ScoreFunction scoreFunction = new ScriptScoreFunction(new Script("Double.NaN"), new SearchScript() { + @Override + public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException { + return new AbstractDoubleSearchScript() { + @Override + public double runAsDouble() { + return Double.NaN; + } + + @Override + public void setDocument(int doc) { + // do nothing: we are a fake with no lookup + } + }; + } + + @Override + public boolean needsScores() { + return false; + } + }); LeafScoreFunction leafScoreFunction = scoreFunction.getLeafScoreFunction(null); - try { + ScriptException expected = expectThrows(ScriptException.class, () -> { leafScoreFunction.score(randomInt(), randomFloat()); - fail("should have thrown an exception about the script_score returning NaN"); - } catch (ScriptException e) { - assertThat("message contains error about script_score returning NaN: " + e.getMessage(), - e.getMessage().contains("NaN"), equalTo(true)); - } - } - - static class FloatValueScript implements SearchScript { - - private final float value; - - FloatValueScript(float value) { - this.value = value; - } - - @Override - public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException { - return new AbstractFloatSearchScript() { - - @Override - public float runAsFloat() { - return value; - } - - @Override - public void setDocument(int doc) { - // nothing here - } - }; - } - - @Override - public boolean needsScores() { - return false; - } + }); + assertTrue(expected.getMessage().contains("returned NaN")); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java index 5b233a9690d..a01797ccf49 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java @@ -455,11 +455,6 @@ public class AvgIT extends AbstractNumericTestCase { throw new UnsupportedOperationException(); } - @Override - public float runAsFloat() { - throw new UnsupportedOperationException(); - } - @Override public double runAsDouble() { throw new UnsupportedOperationException(); @@ -578,11 +573,6 @@ public class AvgIT extends AbstractNumericTestCase { return ((Number) vars.get("_value")).longValue() + inc; } - @Override - public float runAsFloat() { - throw new UnsupportedOperationException(); - } - @Override public double runAsDouble() { return ((Number) vars.get("_value")).doubleValue() + inc; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java index d0538973173..c636508bbe1 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java @@ -452,11 +452,6 @@ public class SumIT extends AbstractNumericTestCase { throw new UnsupportedOperationException(); } - @Override - public float runAsFloat() { - throw new UnsupportedOperationException(); - } - @Override public double runAsDouble() { throw new UnsupportedOperationException(); @@ -583,11 +578,6 @@ public class SumIT extends AbstractNumericTestCase { return ((Number) vars.get("_value")).longValue() + inc; } - @Override - public float runAsFloat() { - throw new UnsupportedOperationException(); - } - @Override public double runAsDouble() { return ((Number) vars.get("_value")).doubleValue() + inc; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java index 2b957188663..86f531ce3e9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java @@ -314,11 +314,6 @@ public class ValueCountIT extends ESIntegTestCase { throw new UnsupportedOperationException(); } - @Override - public float runAsFloat() { - throw new UnsupportedOperationException(); - } - @Override public double runAsDouble() { throw new UnsupportedOperationException(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java index 4f3b3db7c94..dcf6cfdb0ba 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java @@ -75,11 +75,6 @@ public class ScriptValuesTests extends ESTestCase { public void setSource(Map source) { } - @Override - public float runAsFloat() { - throw new UnsupportedOperationException(); - } - @Override public long runAsLong() { throw new UnsupportedOperationException(); diff --git a/docs/reference/modules/scripting/native.asciidoc b/docs/reference/modules/scripting/native.asciidoc index 1b99673a90f..9580720d967 100644 --- a/docs/reference/modules/scripting/native.asciidoc +++ b/docs/reference/modules/scripting/native.asciidoc @@ -12,8 +12,8 @@ To register the actual script you'll need to implement `NativeScriptFactory` to construct the script. The actual script will extend either `AbstractExecutableScript` or `AbstractSearchScript`. The second one is likely the most useful and has several helpful subclasses you can extend like -`AbstractLongSearchScript`, `AbstractDoubleSearchScript`, and -`AbstractFloatSearchScript`. Finally, your plugin should register the native +`AbstractLongSearchScript` and `AbstractDoubleSearchScript`. +Finally, your plugin should register the native script by declaring the `onModule(ScriptModule)` method. If you squashed the whole thing into one class it'd look like: @@ -44,11 +44,11 @@ public class MyNativeScriptPlugin extends Plugin { } } - public static class MyNativeScript extends AbstractFloatSearchScript { + public static class MyNativeScript extends AbstractDoubleSearchScript { @Override - public float runAsFloat() { - float a = (float) source().get("a"); - float b = (float) source().get("b"); + public double runAsDouble() { + double a = (double) source().get("a"); + double b = (double) source().get("b"); return a * b; } } diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionSearchScript.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionSearchScript.java index cb99c879058..54553565bcb 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionSearchScript.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionSearchScript.java @@ -80,9 +80,6 @@ class ExpressionSearchScript implements SearchScript { @Override public Object run() { return new Double(evaluate()); } - @Override - public float runAsFloat() { return (float)evaluate();} - @Override public long runAsLong() { return (long)evaluate(); } diff --git a/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java b/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java index 23f1b409359..700a1aecbc2 100644 --- a/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java +++ b/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java @@ -316,11 +316,6 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri } } - @Override - public float runAsFloat() { - return ((Number) run()).floatValue(); - } - @Override public long runAsLong() { return ((Number) run()).longValue(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ScriptImpl.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ScriptImpl.java index 23be345ed1c..04d5a8d3d60 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ScriptImpl.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ScriptImpl.java @@ -126,15 +126,6 @@ final class ScriptImpl implements ExecutableScript, LeafSearchScript { return ((Number)run()).doubleValue(); } - /** - * Run the script. - * @return The script result as a float. - */ - @Override - public float runAsFloat() { - return ((Number)run()).floatValue(); - } - /** * Run the script. * @return The script result as a long. diff --git a/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java b/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java index d4f713d9cb5..4dd24454b96 100644 --- a/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java +++ b/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java @@ -319,11 +319,6 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements } } - @Override - public float runAsFloat() { - return ((Number) run()).floatValue(); - } - @Override public long runAsLong() { return ((Number) run()).longValue(); diff --git a/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java b/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java index 3f6ceb4a1b6..df7e9c07394 100644 --- a/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java +++ b/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java @@ -243,11 +243,6 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri return ret.__tojava__(Object.class); } - @Override - public float runAsFloat() { - return ((Number) run()).floatValue(); - } - @Override public long runAsLong() { return ((Number) run()).longValue(); From 2fc7ca46e1d2e433cc1d9295fc228b9412074297 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 16 May 2016 09:56:29 -0400 Subject: [PATCH 2/2] expand whitelist for basic types --- .../elasticsearch/painless/Definition.java | 79 +++++++++++++++---- 1 file changed, 64 insertions(+), 15 deletions(-) diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java index e2f312be7b4..b13702a67c8 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java @@ -646,50 +646,106 @@ public final class Definition { } private void addElements() { - addMethod("Object", "toString", null, false, stringType, new Type[] {}, null, null); addMethod("Object", "equals", null, false, booleanType, new Type[] {objectType}, null, null); addMethod("Object", "hashCode", null, false, intType, new Type[] {}, null, null); + addMethod("Object", "toString", null, false, stringType, new Type[] {}, null, null); - addMethod("def", "toString", null, false, stringType, new Type[] {}, null, null); addMethod("def", "equals", null, false, booleanType, new Type[] {objectType}, null, null); addMethod("def", "hashCode", null, false, intType, new Type[] {}, null, null); + addMethod("def", "toString", null, false, stringType, new Type[] {}, null, null); addConstructor("Boolean", "new", new Type[] {booleanType}, null); - addMethod("Boolean", "valueOf", null, true, booleanobjType, new Type[] {booleanType}, null, null); addMethod("Boolean", "booleanValue", null, false, booleanType, new Type[] {}, null, null); + addMethod("Boolean", "compare", null, true, intType, new Type[] {booleanType,booleanType}, null, null); + addMethod("Boolean", "compareTo", null, false, intType, new Type[] {booleanobjType}, null, null); + addMethod("Boolean", "parseBoolean", null, true, booleanType, new Type[] {stringType}, null, null); + addMethod("Boolean", "valueOf", null, true, booleanobjType, new Type[] {booleanType}, null, null); + addField("Boolean", "FALSE", null, true, booleanobjType, null); + addField("Boolean", "TRUE", null, true, booleanobjType, null); addConstructor("Byte", "new", new Type[] {byteType}, null); + addMethod("Byte", "compare", null, true, intType, new Type[] {byteType,byteType}, null, null); + addMethod("Byte", "compareTo", null, false, intType, new Type[] {byteobjType}, null, null); + addMethod("Byte", "parseByte", null, true, byteType, new Type[] {stringType}, null, null); addMethod("Byte", "valueOf", null, true, byteobjType, new Type[] {byteType}, null, null); addField("Byte", "MIN_VALUE", null, true, byteType, null); addField("Byte", "MAX_VALUE", null, true, byteType, null); addConstructor("Short", "new", new Type[] {shortType}, null); + addMethod("Short", "compare", null, true, intType, new Type[] {shortType,shortType}, null, null); + addMethod("Short", "compareTo", null, false, intType, new Type[] {shortobjType}, null, null); + addMethod("Short", "parseShort", null, true, shortType, new Type[] {stringType}, null, null); addMethod("Short", "valueOf", null, true, shortobjType, new Type[] {shortType}, null, null); addField("Short", "MIN_VALUE", null, true, shortType, null); addField("Short", "MAX_VALUE", null, true, shortType, null); addConstructor("Character", "new", new Type[] {charType}, null); - addMethod("Character", "valueOf", null, true, charobjType, new Type[] {charType}, null, null); + addMethod("Character", "charCount", null, true, intType, new Type[] {intType}, null, null); addMethod("Character", "charValue", null, false, charType, new Type[] {}, null, null); + addMethod("Character", "compare", null, true, intType, new Type[] {charType,charType}, null, null); + addMethod("Character", "compareTo", null, false, intType, new Type[] {charobjType}, null, null); + addMethod("Character", "digit", null, true, intType, new Type[] {intType,intType}, null, null); + addMethod("Character", "forDigit", null, true, charType, new Type[] {intType,intType}, null, null); + addMethod("Character", "getName", null, true, stringType, new Type[] {intType}, null, null); + addMethod("Character", "getNumericValue", null, true, intType, new Type[] {intType}, null, null); + addMethod("Character", "isAlphabetic", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isDefined", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isDigit", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isIdeographic", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isLetter", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isLetterOrDigit", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isLowerCase", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isMirrored", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isSpaceChar", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isTitleCase", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isUpperCase", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "isWhitespace", null, true, booleanType, new Type[] {intType}, null, null); + addMethod("Character", "valueOf", null, true, charobjType, new Type[] {charType}, null, null); addField("Character", "MIN_VALUE", null, true, charType, null); addField("Character", "MAX_VALUE", null, true, charType, null); addConstructor("Integer", "new", new Type[] {intType}, null); + addMethod("Integer", "compare", null, true, intType, new Type[] {intType,intType}, null, null); + addMethod("Integer", "compareTo", null, false, intType, new Type[] {intobjType}, null, null); + addMethod("Integer", "min", null, true, intType, new Type[] {intType,intType}, null, null); + addMethod("Integer", "max", null, true, intType, new Type[] {intType,intType}, null, null); + addMethod("Integer", "parseInt", null, true, intType, new Type[] {stringType}, null, null); + addMethod("Integer", "signum", null, true, intType, new Type[] {intType}, null, null); + addMethod("Integer", "toHexString", null, true, stringType, new Type[] {intType}, null, null); addMethod("Integer", "valueOf", null, true, intobjType, new Type[] {intType}, null, null); addField("Integer", "MIN_VALUE", null, true, intType, null); addField("Integer", "MAX_VALUE", null, true, intType, null); addConstructor("Long", "new", new Type[] {longType}, null); + addMethod("Long", "compare", null, true, intType, new Type[] {longType,longType}, null, null); + addMethod("Long", "compareTo", null, false, intType, new Type[] {longobjType}, null, null); + addMethod("Long", "min", null, true, longType, new Type[] {longType,longType}, null, null); + addMethod("Long", "max", null, true, longType, new Type[] {longType,longType}, null, null); + addMethod("Long", "parseLong", null, true, longType, new Type[] {stringType}, null, null); + addMethod("Long", "signum", null, true, intType, new Type[] {longType}, null, null); + addMethod("Long", "toHexString", null, true, stringType, new Type[] {longType}, null, null); addMethod("Long", "valueOf", null, true, longobjType, new Type[] {longType}, null, null); addField("Long", "MIN_VALUE", null, true, longType, null); addField("Long", "MAX_VALUE", null, true, longType, null); addConstructor("Float", "new", new Type[] {floatType}, null); + addMethod("Float", "compare", null, true, intType, new Type[] {floatType,floatType}, null, null); + addMethod("Float", "compareTo", null, false, intType, new Type[] {floatobjType}, null, null); + addMethod("Float", "min", null, true, floatType, new Type[] {floatType,floatType}, null, null); + addMethod("Float", "max", null, true, floatType, new Type[] {floatType,floatType}, null, null); + addMethod("Float", "parseFloat", null, true, floatType, new Type[] {stringType}, null, null); + addMethod("Float", "toHexString", null, true, stringType, new Type[] {floatType}, null, null); addMethod("Float", "valueOf", null, true, floatobjType, new Type[] {floatType}, null, null); addField("Float", "MIN_VALUE", null, true, floatType, null); addField("Float", "MAX_VALUE", null, true, floatType, null); addConstructor("Double", "new", new Type[] {doubleType}, null); + addMethod("Double", "compare", null, true, intType, new Type[] {doubleType,doubleType}, null, null); + addMethod("Double", "compareTo", null, false, intType, new Type[] {doubleobjType}, null, null); + addMethod("Double", "min", null, true, doubleType, new Type[] {doubleType,doubleType}, null, null); + addMethod("Double", "max", null, true, doubleType, new Type[] {doubleType,doubleType}, null, null); + addMethod("Double", "parseDouble", null, true, doubleType, new Type[] {stringType}, null, null); + addMethod("Double", "toHexString", null, true, stringType, new Type[] {doubleType}, null, null); addMethod("Double", "valueOf", null, true, doubleobjType, new Type[] {doubleType}, null, null); addField("Double", "MIN_VALUE", null, true, doubleType, null); addField("Double", "MAX_VALUE", null, true, doubleType, null); @@ -830,9 +886,6 @@ public final class Definition { addMethod("Utility", "StringToCharacter", null, true, charobjType, new Type[] {stringType}, null, null); addMethod("Math", "abs", null, true, doubleType, new Type[] {doubleType}, null, null); - addMethod("Math", "fabs", "abs", true, floatType, new Type[] {floatType}, null, null); - addMethod("Math", "labs", "abs", true, longType, new Type[] {longType}, null, null); - addMethod("Math", "iabs", "abs", true, intType, new Type[] {intType}, null, null); addMethod("Math", "acos", null, true, doubleType, new Type[] {doubleType}, null, null); addMethod("Math", "asin", null, true, doubleType, new Type[] {doubleType}, null, null); addMethod("Math", "atan", null, true, doubleType, new Type[] {doubleType}, null, null); @@ -848,14 +901,8 @@ public final class Definition { addMethod("Math", "log", null, true, doubleType, new Type[] {doubleType}, null, null); addMethod("Math", "log10", null, true, doubleType, new Type[] {doubleType}, null, null); addMethod("Math", "log1p", null, true, doubleType, new Type[] {doubleType}, null, null); - addMethod("Math", "max", "max", true, doubleType, new Type[] {doubleType, doubleType}, null, null); - addMethod("Math", "fmax", "max", true, floatType, new Type[] {floatType, floatType}, null, null); - addMethod("Math", "lmax", "max", true, longType, new Type[] {longType, longType}, null, null); - addMethod("Math", "imax", "max", true, intType, new Type[] {intType, intType}, null, null); - addMethod("Math", "min", "min", true, doubleType, new Type[] {doubleType, doubleType}, null, null); - addMethod("Math", "fmin", "min", true, floatType, new Type[] {floatType, floatType}, null, null); - addMethod("Math", "lmin", "min", true, longType, new Type[] {longType, longType}, null, null); - addMethod("Math", "imin", "min", true, intType, new Type[] {intType, intType}, null, null); + addMethod("Math", "max", null, true, doubleType, new Type[] {doubleType, doubleType}, null, null); + addMethod("Math", "min", null, true, doubleType, new Type[] {doubleType, doubleType}, null, null); addMethod("Math", "pow", null, true, doubleType, new Type[] {doubleType, doubleType}, null, null); addMethod("Math", "random", null, true, doubleType, new Type[] {}, null, null); addMethod("Math", "rint", null, true, doubleType, new Type[] {doubleType}, null, null); @@ -867,6 +914,8 @@ public final class Definition { addMethod("Math", "tanh", null, true, doubleType, new Type[] {doubleType}, null, null); addMethod("Math", "toDegrees", null, true, doubleType, new Type[] {doubleType}, null, null); addMethod("Math", "toRadians", null, true, doubleType, new Type[] {doubleType}, null, null); + addField("Math", "E", null, true, doubleType, null); + addField("Math", "PI", null, true, doubleType, null); addMethod("Def", "DefToboolean", null, true, booleanType, new Type[] {defType}, null, null); addMethod("Def", "DefTobyte", null, true, byteType, new Type[] {defType}, null, null);