Added address space unit size to MemorySegment and MemorySegmentSection
Some recfactoring
This commit is contained in:
@@ -127,14 +127,14 @@ class FromXmlService
|
||||
}
|
||||
|
||||
if ($childNode->nodeName === 'memory-segment') {
|
||||
$output->memorySegments[] = $this->memorySegmentFromElement($childNode);
|
||||
$output->memorySegments[] = $this->memorySegmentFromElement($childNode, $output->unitSize);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function memorySegmentFromElement(DOMElement $element): MemorySegment
|
||||
public function memorySegmentFromElement(DOMElement $element, ?int $addressSpaceUnitSize): MemorySegment
|
||||
{
|
||||
$attributes = $this->getNodeAttributesByName($element);
|
||||
|
||||
@@ -144,6 +144,7 @@ class FromXmlService
|
||||
MemorySegmentType::tryFrom($attributes['type'] ?? null),
|
||||
$this->stringService->tryStringToInt($attributes['start'] ?? null),
|
||||
$this->stringService->tryStringToInt($attributes['size'] ?? null),
|
||||
$addressSpaceUnitSize,
|
||||
$this->stringService->tryStringToInt($attributes['page-size'] ?? null),
|
||||
$attributes['access'] ?? null,
|
||||
[],
|
||||
@@ -156,14 +157,14 @@ class FromXmlService
|
||||
}
|
||||
|
||||
if ($childNode->nodeName === 'section') {
|
||||
$output->sections[] = $this->memorySegmentSectionFromElement($childNode);
|
||||
$output->sections[] = $this->memorySegmentSectionFromElement($childNode, $addressSpaceUnitSize);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function memorySegmentSectionFromElement(DOMElement $element): MemorySegmentSection
|
||||
public function memorySegmentSectionFromElement(DOMElement $element, ?int $addressSpaceUnitSize): MemorySegmentSection
|
||||
{
|
||||
$attributes = $this->getNodeAttributesByName($element);
|
||||
|
||||
@@ -172,6 +173,7 @@ class FromXmlService
|
||||
$attributes['name'] ?? null,
|
||||
$this->stringService->tryStringToInt($attributes['start'] ?? null),
|
||||
$this->stringService->tryStringToInt($attributes['size'] ?? null),
|
||||
$addressSpaceUnitSize,
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -181,7 +183,7 @@ class FromXmlService
|
||||
}
|
||||
|
||||
if ($childNode->nodeName === 'section') {
|
||||
$output->subSections[] = $this->memorySegmentSectionFromElement($childNode);
|
||||
$output->subSections[] = $this->memorySegmentSectionFromElement($childNode, $addressSpaceUnitSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,11 @@ class ToXmlService
|
||||
{
|
||||
$element = $document->createElement('address-space');
|
||||
$element->setAttribute('key', strtolower($addressSpace->key));
|
||||
$element->setAttribute('start', $this->stringService->tryIntToHex($addressSpace->startAddress, 8));
|
||||
$element->setAttribute('size', $addressSpace->size);
|
||||
$element->setAttribute(
|
||||
'start',
|
||||
$this->stringService->tryIntToHex($addressSpace->addressRange->startAddress, 8)
|
||||
);
|
||||
$element->setAttribute('size', $addressSpace->size());
|
||||
|
||||
if (!empty($addressSpace->unitSize)) {
|
||||
$element->setAttribute('unit-size', $addressSpace->unitSize);
|
||||
@@ -92,8 +95,11 @@ class ToXmlService
|
||||
$element->setAttribute('key', strtolower($memorySegment->key));
|
||||
$element->setAttribute('name', $memorySegment->name);
|
||||
$element->setAttribute('type', $memorySegment->type->value ?? '');
|
||||
$element->setAttribute('start', $this->stringService->tryIntToHex($memorySegment->startAddress, 8));
|
||||
$element->setAttribute('size', $memorySegment->size);
|
||||
$element->setAttribute(
|
||||
'start',
|
||||
$this->stringService->tryIntToHex($memorySegment->addressRange->startAddress, 8)
|
||||
);
|
||||
$element->setAttribute('size', $memorySegment->size());
|
||||
|
||||
if (!empty($memorySegment->pageSize)) {
|
||||
$element->setAttribute('page-size', $memorySegment->pageSize);
|
||||
@@ -117,8 +123,8 @@ class ToXmlService
|
||||
$element = $document->createElement('section');
|
||||
$element->setAttribute('key', strtolower($section->key));
|
||||
$element->setAttribute('name', $section->name);
|
||||
$element->setAttribute('start', $this->stringService->tryIntToHex($section->startAddress, 8));
|
||||
$element->setAttribute('size', $section->size);
|
||||
$element->setAttribute('start', $this->stringService->tryIntToHex($section->addressRange->startAddress, 8));
|
||||
$element->setAttribute('size', $section->size());
|
||||
|
||||
foreach ($section->subSections as $section) {
|
||||
$element->append($this->memorySegmentSectionToXml($section, $document));
|
||||
|
||||
Reference in New Issue
Block a user