Skip to content

Commit 30c71e7

Browse files
committed
Fix duplicated processing attributes
1 parent 5a98d81 commit 30c71e7

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

src/Compiler/Builder/Attributes/Code.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ public function getValue(): string
192192
->getResult(false)
193193
->getEntryIndex()
194194
);
195-
$writer->writeUnsignedInt(strlen($attribute->getValue()));
196-
$writer->write($attribute->getValue());
195+
$value = $attribute->getValue();
196+
$writer->writeUnsignedInt(strlen($value));
197+
$writer->write($value);
197198
}
198199

199200
return $writer->getStreamContents();

src/Compiler/Builder/Attributes/StackMapTable.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,6 @@ public function getValue(): string
126126
$emulatedAccumulator = new Accumulator();
127127
$currentOffset = 0;
128128

129-
// foreach ($this->localVariables as $variableName => $variable) {
130-
// [$index, $classType] = $variable;
131-
// $emulatedAccumulator
132-
// ->setDefaultLocal(
133-
// $index,
134-
// [
135-
// VerificationTypeTag::ITEM_Object,
136-
// $this->getEnhancedConstantPool()
137-
// ->findClass($classType),
138-
// ]
139-
// );
140-
// }
141-
142129
foreach ($this->operations as $operation) {
143130
$programCounter = $this->calculateProgramCounterByOperationCodes(
144131
$this->operations,

src/Compiler/Builder/Segments/Attributes/Attributes.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,13 @@ public function build(): void
1414
// Write attribute_name_index
1515
$this->binaryWriter->writeUnsignedShort($attribute->getConstantPoolIndex());
1616

17+
$value = $attribute->getValue();
18+
1719
// Write attribute_length
18-
$this->binaryWriter->writeUnsignedInt(strlen($attribute->getValue()));
20+
$this->binaryWriter->writeUnsignedInt(strlen($value));
1921

2022
// Write attribute
21-
$this->binaryWriter->write($attribute->getValue());
22-
23-
if (!$attribute->hasAttribute()) {
24-
continue;
25-
}
26-
27-
// Write attributes_count
28-
AttributesCount::init($attribute->getAttributes(), $this->constantPool, $this->binaryWriter);
29-
30-
// Write attributes
31-
Attributes::init($attribute->getAttributes(), $this->constantPool, $this->binaryWriter);
23+
$this->binaryWriter->write($value);
3224
}
3325
}
3426
}

0 commit comments

Comments
 (0)