Skip to content

Commit df832e9

Browse files
committed
Merge branch 'master' into fix-object-clone
2 parents 7ec1e80 + 89d2609 commit df832e9

File tree

436 files changed

+49805
-353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

436 files changed

+49805
-353
lines changed

.github/ISSUE_TEMPLATE/REQUEST_IMPLEMENTATION_IN_ENGLISH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ about: Request implementation in English
44

55
---
66

7-
# What are you want to implement?
7+
# What do you want to implement?
88

99
# Example Code
1010

composer.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "JVM emulator by PHP",
44
"type": "library",
55
"license": "MIT",
6-
"version": "0.0.6.6-dev",
6+
"version": "0.0.7.1-dev",
77
"authors": [
88
{
99
"name": "memory"
@@ -16,14 +16,9 @@
1616
"php": ">=7.2",
1717
"ext-zip": "*",
1818
"monolog/monolog": "^1.24",
19-
"php-java/java-lang-package": "*",
20-
"php-java/java-util-package": "*",
21-
"php-java/java-io-package": "*",
22-
"php-java/java-net-package": "*",
23-
"php-java/java-nio-package": "*",
24-
"gabrielelana/byte-units": "dev-master",
25-
"symfony/console": "4.2",
26-
"phpdocumentor/reflection-docblock": "4.3"
19+
"gabrielelana/byte-units": "^0.5.0",
20+
"symfony/console": "^4.2",
21+
"phpdocumentor/reflection-docblock": "^4.3"
2722
},
2823
"autoload": {
2924
"psr-4": {
@@ -42,7 +37,6 @@
4237
"friendsofphp/php-cs-fixer": "^2.14"
4338
},
4439
"scripts": {
45-
"tests": "phpunit tests --stop-on-failure && phpcs --standard=phpcs.xml src"
46-
},
47-
"minimum-stability": "dev"
40+
"tests": "phpunit tests --stop-on-failure && phpcs -n --standard=phpcs.xml src"
41+
}
4842
}

phpcs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<exclude-pattern>./src/Kernel/Mnemonics</exclude-pattern>
1313
<exclude-pattern>./src/Kernel/Structures</exclude-pattern>
1414
<exclude-pattern>./src/Packages/PHPJava/Extended/_Object.php</exclude-pattern>
15+
<exclude-pattern>./src/Packages/java/*</exclude-pattern>
1516
</rule>
1617

1718
<rule ref="Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase">
@@ -21,6 +22,7 @@
2122

2223
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
2324
<exclude-pattern>./src/Packages/PHPJava/Extended/_Object.php</exclude-pattern>
25+
<exclude-pattern>./src/Packages/java/*</exclude-pattern>
2426
</rule>
2527

2628
<arg name="colors"/>

src/Core/JVM/ActiveAttributes.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Core/JVM/ActiveInterface.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Core/JVM/ActiveMethods.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Core/JVM/AttributePool.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
namespace PHPJava\Core\JVM;
3+
4+
use PHPJava\Core\Stream\Reader\ReaderInterface;
5+
use PHPJava\Exceptions\ReadOnlyException;
6+
use PHPJava\Kernel\Attributes\AttributeInfo;
7+
use PHPJava\Utilities\DebugTool;
8+
9+
class AttributePool implements \ArrayAccess, \Countable, \IteratorAggregate
10+
{
11+
private $entries = [];
12+
private $reader;
13+
14+
public function __construct(
15+
ReaderInterface $reader,
16+
int $entries,
17+
ConstantPool $constantPool,
18+
DebugTool $debugTool
19+
) {
20+
$this->reader = $reader;
21+
for ($i = 0; $i < $entries; $i++) {
22+
// not implemented, read only
23+
$entry = (new AttributeInfo($reader))
24+
->setConstantPool($constantPool)
25+
->setDebugTool($debugTool);
26+
$entry->execute();
27+
28+
$this->entries[] = $entry;
29+
}
30+
}
31+
32+
public function getEntries()
33+
{
34+
return $this->entries;
35+
}
36+
37+
public function offsetExists($offset)
38+
{
39+
return isset($this->entries[$offset]);
40+
}
41+
42+
public function offsetGet($offset)
43+
{
44+
return $this->entries[$offset];
45+
}
46+
47+
public function count()
48+
{
49+
return count($this->entries);
50+
}
51+
52+
public function offsetSet($offset, $value)
53+
{
54+
throw new ReadOnlyException('You cannot rewrite datum. The Attribute Pool is read-only.');
55+
}
56+
57+
public function offsetUnset($offset)
58+
{
59+
throw new ReadOnlyException('You cannot rewrite datum. The Attribute Pool is read-only.');
60+
}
61+
62+
public function getIterator()
63+
{
64+
return new \ArrayIterator($this->entries);
65+
}
66+
}

src/Core/JVM/Cache/OperationCache.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33

44
class OperationCache extends Cache
55
{
6-
76
}

src/Core/JVM/ConstantPool.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
use PHPJava\Kernel\Structures\_Long;
1616
use PHPJava\Kernel\Structures\_MethodHandle;
1717
use PHPJava\Kernel\Structures\_Methodref;
18+
use PHPJava\Kernel\Structures\_MethodType;
1819
use PHPJava\Kernel\Structures\_NameAndType;
1920
use PHPJava\Kernel\Structures\_String;
2021
use PHPJava\Kernel\Structures\_Utf8;
2122
use PHPJava\Kernel\Structures\StructureInterface;
2223

23-
class ConstantPool implements \ArrayAccess
24+
class ConstantPool implements \ArrayAccess, \Countable, \IteratorAggregate
2425
{
2526
private $entries = [];
2627
private $reader;
@@ -85,6 +86,7 @@ private function read($entryTag): ?StructureInterface
8586
case ConstantPoolTag::CONSTANT_MethodHandle:
8687
return new _MethodHandle($this->reader);
8788
case ConstantPoolTag::CONSTANT_MethodType:
89+
return new _MethodType($this->reader);
8890
case ConstantPoolTag::CONSTANT_Module:
8991
case ConstantPoolTag::CONSTANT_Package:
9092
throw new ReadEntryException('Entry tag ' . sprintf('0x%04X', $entryTag) . ' is not implemented.');
@@ -102,6 +104,11 @@ public function offsetGet($offset)
102104
return $this->entries[$offset];
103105
}
104106

107+
public function count()
108+
{
109+
return count($this->entries);
110+
}
111+
105112
public function offsetSet($offset, $value)
106113
{
107114
throw new ReadOnlyException('You cannot rewrite datum. The Constant Pool is read-only.');
@@ -111,4 +118,9 @@ public function offsetUnset($offset)
111118
{
112119
throw new ReadOnlyException('You cannot rewrite datum. The Constant Pool is read-only.');
113120
}
121+
122+
public function getIterator()
123+
{
124+
return new \ArrayIterator($this->entries);
125+
}
114126
}
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
use PHPJava\Core\JavaClass;
55
use PHPJava\Core\Stream\Reader\ReaderInterface;
6+
use PHPJava\Exceptions\ReadOnlyException;
67
use PHPJava\Kernel\Structures\_FieldInfo;
78
use PHPJava\Utilities\DebugTool;
89

9-
class ActiveFields
10+
class FieldPool implements \ArrayAccess, \Countable, \IteratorAggregate
1011
{
1112
private $entries = [];
1213
private $reader;
@@ -30,4 +31,34 @@ public function getEntries()
3031
{
3132
return $this->entries;
3233
}
34+
35+
public function offsetExists($offset)
36+
{
37+
return isset($this->entries[$offset]);
38+
}
39+
40+
public function offsetGet($offset)
41+
{
42+
return $this->entries[$offset];
43+
}
44+
45+
public function count()
46+
{
47+
return count($this->entries);
48+
}
49+
50+
public function offsetSet($offset, $value)
51+
{
52+
throw new ReadOnlyException('You cannot rewrite datum. The Field Pool is read-only.');
53+
}
54+
55+
public function offsetUnset($offset)
56+
{
57+
throw new ReadOnlyException('You cannot rewrite datum. The Field Pool is read-only.');
58+
}
59+
60+
public function getIterator()
61+
{
62+
return new \ArrayIterator($this->entries);
63+
}
3364
}

0 commit comments

Comments
 (0)