From 1b0db7c0c2ae4daf833ce3ad27e94f4cb4934131 Mon Sep 17 00:00:00 2001 From: Dmitriy Zayceff Date: Sat, 22 Feb 2020 20:14:17 +0300 Subject: [PATCH] Clean up memory classes. --- jphp-runtime/src/php/runtime/Memory.java | 4 +- .../src/php/runtime/memory/DoubleMemory.java | 55 ------------------ .../src/php/runtime/memory/FalseMemory.java | 20 ------- .../src/php/runtime/memory/LongMemory.java | 55 ------------------ .../src/php/runtime/memory/NativeMemory.java | 10 ---- .../src/php/runtime/memory/ObjectMemory.java | 35 ------------ .../src/php/runtime/memory/StringMemory.java | 55 ------------------ .../src/php/runtime/memory/TrueMemory.java | 56 ------------------- .../memory/helper/ClassConstantMemory.java | 5 -- .../memory/helper/UndefinedMemory.java | 5 -- packager/package.php.yml | 5 +- 11 files changed, 5 insertions(+), 300 deletions(-) diff --git a/jphp-runtime/src/php/runtime/Memory.java b/jphp-runtime/src/php/runtime/Memory.java index 58bcb6ea6..eda537284 100644 --- a/jphp-runtime/src/php/runtime/Memory.java +++ b/jphp-runtime/src/php/runtime/Memory.java @@ -252,8 +252,8 @@ public int getPointer(){ public boolean isObject() { return type == Type.OBJECT; } public boolean isClosure() { return false; } public boolean isResource() { return false; } - public boolean isArray(){ return type == Type.ARRAY; } - public boolean isTraversable() { return isArray() || instanceOf("Traversable", "traversable"); } + public boolean isArray() { return type == Type.ARRAY; } + public boolean isTraversable() { return isArray() || (isObject() && instanceOf("Traversable", "traversable")); } public boolean isString() { return type == Type.STRING; } public boolean isNumber() { return type == Type.INT || type == Type.DOUBLE; } public boolean isBoolean() { return type == Type.BOOL; } diff --git a/jphp-runtime/src/php/runtime/memory/DoubleMemory.java b/jphp-runtime/src/php/runtime/memory/DoubleMemory.java index ce7e25d41..ed0247d82 100644 --- a/jphp-runtime/src/php/runtime/memory/DoubleMemory.java +++ b/jphp-runtime/src/php/runtime/memory/DoubleMemory.java @@ -337,59 +337,4 @@ public int hashCode() { public byte[] getBinaryBytes(Charset charset) { return MemoryStringUtils.getBinaryBytes(this); } - - @Override - public boolean isArray() { - return false; - } - - @Override - public Memory toValue() { - return this; - } - - @Override - public Memory toImmutable() { - return this; - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isUndefined() { - return false; - } - - @Override - public boolean isString() { - return false; - } - - @Override - public boolean isTraversable() { - return false; - } - - @Override - public boolean isReference() { - return false; - } - - @Override - public boolean isObject() { - return false; - } - - @Override - public boolean isClosure() { - return false; - } - - @Override - public boolean isNumber() { - return true; - } } diff --git a/jphp-runtime/src/php/runtime/memory/FalseMemory.java b/jphp-runtime/src/php/runtime/memory/FalseMemory.java index ea54d9496..3c8d52bc7 100644 --- a/jphp-runtime/src/php/runtime/memory/FalseMemory.java +++ b/jphp-runtime/src/php/runtime/memory/FalseMemory.java @@ -283,24 +283,4 @@ public boolean identical(String value) { public Invoker toInvoker(Environment env) { return null; } - - @Override - public boolean isArray() { - return false; - } - - @Override - public Memory toValue() { - return this; - } - - @Override - public Memory toImmutable() { - return this; - } - - @Override - public boolean isNumber() { - return false; - } } diff --git a/jphp-runtime/src/php/runtime/memory/LongMemory.java b/jphp-runtime/src/php/runtime/memory/LongMemory.java index 132f97c56..2050867a2 100644 --- a/jphp-runtime/src/php/runtime/memory/LongMemory.java +++ b/jphp-runtime/src/php/runtime/memory/LongMemory.java @@ -305,63 +305,8 @@ public byte[] getBinaryBytes(Charset charset) { return MemoryStringUtils.getBinaryBytes(this); } - @Override - public boolean isNull() { - return false; - } - @Override public boolean isNotNull() { return true; } - - @Override - public boolean isArray() { - return false; - } - - @Override - public Memory toValue() { - return this; - } - - @Override - public Memory toImmutable() { - return this; - } - - @Override - public boolean isUndefined() { - return false; - } - - @Override - public boolean isString() { - return false; - } - - @Override - public boolean isTraversable() { - return false; - } - - @Override - public boolean isReference() { - return false; - } - - @Override - public boolean isObject() { - return false; - } - - @Override - public boolean isClosure() { - return false; - } - - @Override - public boolean isNumber() { - return true; - } } diff --git a/jphp-runtime/src/php/runtime/memory/NativeMemory.java b/jphp-runtime/src/php/runtime/memory/NativeMemory.java index a4f1875e0..c231a037c 100644 --- a/jphp-runtime/src/php/runtime/memory/NativeMemory.java +++ b/jphp-runtime/src/php/runtime/memory/NativeMemory.java @@ -13,14 +13,4 @@ public NativeMemory(T object) { public T getObject() { return object; } - - @Override - public Memory toImmutable() { - return this; - } - - @Override - public Memory toValue() { - return this; - } } diff --git a/jphp-runtime/src/php/runtime/memory/ObjectMemory.java b/jphp-runtime/src/php/runtime/memory/ObjectMemory.java index cdb6fbd4e..df59e32f9 100644 --- a/jphp-runtime/src/php/runtime/memory/ObjectMemory.java +++ b/jphp-runtime/src/php/runtime/memory/ObjectMemory.java @@ -1259,39 +1259,4 @@ public boolean equals(Object o) { return value != null ? value.equals(that.value) : that.value == null; } - - @Override - public Memory toValue() { - return this; - } - - @Override - public Memory toImmutable() { - return this; - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isUndefined() { - return false; - } - - @Override - public boolean isString() { - return false; - } - - @Override - public boolean isReference() { - return false; - } - - @Override - public boolean isNumber() { - return false; - } } diff --git a/jphp-runtime/src/php/runtime/memory/StringMemory.java b/jphp-runtime/src/php/runtime/memory/StringMemory.java index 87b21c914..373090b2f 100644 --- a/jphp-runtime/src/php/runtime/memory/StringMemory.java +++ b/jphp-runtime/src/php/runtime/memory/StringMemory.java @@ -674,61 +674,6 @@ public int hashCode() { return toString() == null ? 0 : toString().hashCode(); } - @Override - public boolean isArray() { - return false; - } - - @Override - public Memory toValue() { - return this; - } - - @Override - public Memory toImmutable() { - return this; - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isUndefined() { - return false; - } - - @Override - public boolean isString() { - return true; - } - - @Override - public boolean isTraversable() { - return false; - } - - @Override - public boolean isReference() { - return false; - } - - @Override - public boolean isObject() { - return false; - } - - @Override - public boolean isClosure() { - return false; - } - - @Override - public boolean isNumber() { - return false; - } - protected static StringMemory getChar(char ch) { int i = (int) ch; diff --git a/jphp-runtime/src/php/runtime/memory/TrueMemory.java b/jphp-runtime/src/php/runtime/memory/TrueMemory.java index ddb1c571e..98f3f154c 100644 --- a/jphp-runtime/src/php/runtime/memory/TrueMemory.java +++ b/jphp-runtime/src/php/runtime/memory/TrueMemory.java @@ -285,60 +285,4 @@ public boolean identical(boolean value) { public boolean identical(String value) { return false; } - - @Override - public boolean isArray() { - return false; - } - - @Override - public Memory toValue() { - return this; - } - - @Override - public Memory toImmutable() { - return this; - } - - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isUndefined() { - return false; - } - - @Override - public boolean isString() { - return false; - } - - @Override - public boolean isTraversable() { - return false; - } - - @Override - public boolean isReference() { - return false; - } - - @Override - public boolean isObject() { - return false; - } - - @Override - public boolean isClosure() { - return false; - } - - @Override - public boolean isNumber() { - return false; - } } diff --git a/jphp-runtime/src/php/runtime/memory/helper/ClassConstantMemory.java b/jphp-runtime/src/php/runtime/memory/helper/ClassConstantMemory.java index 3cc27bdbc..3df15eea7 100644 --- a/jphp-runtime/src/php/runtime/memory/helper/ClassConstantMemory.java +++ b/jphp-runtime/src/php/runtime/memory/helper/ClassConstantMemory.java @@ -48,9 +48,4 @@ public String getName() { public String getClassName() { return className; } - - @Override - public Memory toValue() { - return this; - } } diff --git a/jphp-runtime/src/php/runtime/memory/helper/UndefinedMemory.java b/jphp-runtime/src/php/runtime/memory/helper/UndefinedMemory.java index 13c5bd159..2f875a83a 100644 --- a/jphp-runtime/src/php/runtime/memory/helper/UndefinedMemory.java +++ b/jphp-runtime/src/php/runtime/memory/helper/UndefinedMemory.java @@ -11,9 +11,4 @@ public class UndefinedMemory extends NullMemory { public Memory toImmutable() { return UNDEFINED; } - - @Override - public boolean isUndefined() { - return true; - } } diff --git a/packager/package.php.yml b/packager/package.php.yml index cbf614250..86d4b59e9 100644 --- a/packager/package.php.yml +++ b/packager/package.php.yml @@ -1,5 +1,5 @@ name: jppm -version: 0.5.9 +version: 0.5.10 plugins: [GitHub, Hub, Doc] @@ -14,7 +14,8 @@ github: > JPHP Package Manager v%version% **What's new** - + Improve Gradle plugin, add implDeps. + + New JPHP runtime & core (boost performance). + + Fix loading empty yml config files. **Downloads** + For Windows: [JPPM Windows Installer](%github.address%/releases/download/jppm-%version%/jppm-setup-%version%.exe)