Skip to content

Commit 57f9293

Browse files
authored
Merge pull request #151 from php-java/recycle-same-consntat-values
Recycling same constant values
2 parents 4e79ca1 + ec842e9 commit 57f9293

79 files changed

Lines changed: 119 additions & 104 deletions

Some content is hidden

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

src/Kernel/Mnemonics/_bipush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ final class _bipush implements OperationInterface
1010

1111
public function execute(): void
1212
{
13-
$this->pushToOperandStack(new _Int($this->readByte()));
13+
$this->pushToOperandStack(_Int::get($this->readByte()));
1414
}
1515
}

src/Kernel/Mnemonics/_d2f.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public function execute(): void
1515
$this->popFromOperandStack()
1616
);
1717

18-
$this->pushToOperandStack(new _Float($value));
18+
$this->pushToOperandStack(_Float::get($value));
1919
}
2020
}

src/Kernel/Mnemonics/_d2i.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public function execute(): void
1515
$this->popFromOperandStack()
1616
);
1717

18-
$this->pushToOperandStack(new _Int($value));
18+
$this->pushToOperandStack(_Int::get($value));
1919
}
2020
}

src/Kernel/Mnemonics/_d2l.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public function execute(): void
1515
$this->popFromOperandStack()
1616
);
1717

18-
$this->pushToOperandStack(new _Long($value));
18+
$this->pushToOperandStack(_Long::get($value));
1919
}
2020
}

src/Kernel/Mnemonics/_dcmpg.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ public function execute(): void
1616

1717
if ($leftOperand > $rightOperand) {
1818
$this->pushToOperandStack(
19-
new _Int(1)
19+
_Int::get(1)
2020
);
2121
return;
2222
}
2323

2424
if ($leftOperand < $rightOperand) {
2525
$this->pushToOperandStack(
26-
new _Int(-1)
26+
_Int::get(-1)
2727
);
2828
return;
2929
}
3030

3131
$this->pushToOperandStack(
32-
new _Int(0)
32+
_Int::get(0)
3333
);
3434
}
3535
}

src/Kernel/Mnemonics/_dcmpl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ public function execute(): void
1616

1717
if ($leftOperand > $rightOperand) {
1818
$this->pushToOperandStack(
19-
new _Int(1)
19+
_Int::get(1)
2020
);
2121
return;
2222
}
2323

2424
if ($leftOperand < $rightOperand) {
2525
$this->pushToOperandStack(
26-
new _Int(-1)
26+
_Int::get(-1)
2727
);
2828
return;
2929
}
3030

3131
$this->pushToOperandStack(
32-
new _Int(0)
32+
_Int::get(0)
3333
);
3434
}
3535
}

src/Kernel/Mnemonics/_dconst_0.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class _dconst_0 implements OperationInterface
1111
public function execute(): void
1212
{
1313
$this->pushToOperandStack(
14-
new _Double(0)
14+
_Double::get(0)
1515
);
1616
}
1717
}

src/Kernel/Mnemonics/_dconst_1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class _dconst_1 implements OperationInterface
1111
public function execute(): void
1212
{
1313
$this->pushToOperandStack(
14-
new _Double(1)
14+
_Double::get(1)
1515
);
1616
}
1717
}

src/Kernel/Mnemonics/_ddiv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function execute(): void
1616
$value1 = $this->popFromOperandStack();
1717

1818
$this->pushToOperandStack(
19-
new _Double(
19+
_Double::get(
2020
BinaryTool::div(
2121
Extractor::getRealValue($value1),
2222
Extractor::getRealValue($value2)

src/Kernel/Mnemonics/_dload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function execute(): void
1515
{
1616
$index = $this->readUnsignedByte();
1717
$this->pushToOperandStack(
18-
new _Double(
18+
_Double::get(
1919
$this->getLocalStorage($index)
2020
)
2121
);

0 commit comments

Comments
 (0)