Skip to content

Commit

Permalink
add basic definitions for compilation units
Browse files Browse the repository at this point in the history
  • Loading branch information
sj-i committed Aug 16, 2021
1 parent 3fc9c1c commit cd626d6
Show file tree
Hide file tree
Showing 24 changed files with 492 additions and 7 deletions.
28 changes: 28 additions & 0 deletions src/Lib/Dwarf/Abbreviation/AbbreviationDeclaration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\Abbreviation;

use PhpProfiler\Lib\Dwarf\Tag;

final class AbbreviationDeclaration
{
/** @param AttributeSpecification[] $attribute_specifications */
public function __construct(
public int $abbreviation_code,
public Tag $tag,
public bool $has_children,
public array $attribute_specifications,
) {
}
}
27 changes: 27 additions & 0 deletions src/Lib/Dwarf/Abbreviation/AttributeSpecification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\Abbreviation;

use PhpProfiler\Lib\Dwarf\Attribute;
use PhpProfiler\Lib\Dwarf\Form;

final class AttributeSpecification
{
public function __construct(
public Attribute $attribute,
public Form $form,
public ?int $implicit_const,
) {
}
}
1 change: 0 additions & 1 deletion src/Lib/Dwarf/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class Attribute

public function __construct(
public int $name,
public Form $form,
) {
}
}
22 changes: 22 additions & 0 deletions src/Lib/Dwarf/Attribute/IdentifierCaseCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\Attribute;

final class IdentifierCaseCode
{
public const DW_ID_case_sensitive = 0x00;
public const DW_ID_up_case = 0x01;
public const DW_ID_down_case = 0x02;
public const DW_ID_case_insensitive = 0x03;
}
29 changes: 29 additions & 0 deletions src/Lib/Dwarf/CompilationUnit/CompilationUnit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\CompilationUnit;

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitHeader\TypeUnitHeader;
use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitHeader\UnitHeader;
use PhpProfiler\Lib\Dwarf\DebuggingInformationEntry\CompileUnitDIE;
use PhpProfiler\Lib\Dwarf\DebuggingInformationEntry\PartialUnitDIE;

final class CompilationUnit
{
public function __construct(
public UnitHeader $unit_header,
public CompileUnitDIE|PartialUnitDIE $unit_die,
public ?TypeUnitHeader $type_unit_header,
) {
}
}
4 changes: 3 additions & 1 deletion src/Lib/Dwarf/CompilationUnit/UnitHeader/FullUnitHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

final class FullUnitHeader
final class FullUnitHeader implements UnitHeader
{
use UnitHeaderTrait;

public function __construct(
public int $unit_length,
public int $version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

final class PartialUnitHeader
final class PartialUnitHeader implements UnitHeader
{
use UnitHeaderTrait;

public function __construct(
public int $unit_length,
public int $version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

final class SkeletonUnitHeader
final class SkeletonUnitHeader implements UnitHeader
{
use UnitHeaderTrait;

public function __construct(
public int $unit_length,
public int $version,
Expand Down
4 changes: 3 additions & 1 deletion src/Lib/Dwarf/CompilationUnit/UnitHeader/SplitUnitHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

final class SplitUnitHeader
final class SplitUnitHeader implements UnitHeader
{
use UnitHeaderTrait;

public function __construct(
public int $unit_length,
public int $version,
Expand Down
4 changes: 3 additions & 1 deletion src/Lib/Dwarf/CompilationUnit/UnitHeader/TypeUnitHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

final class TypeUnitHeader
final class TypeUnitHeader implements UnitHeader
{
use UnitHeaderTrait;

public function __construct(
public int $unit_length,
public int $version,
Expand Down
25 changes: 25 additions & 0 deletions src/Lib/Dwarf/CompilationUnit/UnitHeader/UnitHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\CompilationUnit\UnitHeader;

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

interface UnitHeader
{
public function getUnitLength(): int;
public function getVersion(): int;
public function getUnitType(): UnitType;
public function getAddressSize(): int;
public function getDebugAbbrevOffset(): int;
}
44 changes: 44 additions & 0 deletions src/Lib/Dwarf/CompilationUnit/UnitHeader/UnitHeaderTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\CompilationUnit\UnitHeader;

use PhpProfiler\Lib\Dwarf\CompilationUnit\UnitType;

trait UnitHeaderTrait
{
public function getUnitLength(): int
{
return $this->unit_length;
}

public function getVersion(): int
{
return $this->version;
}

public function getUnitType(): UnitType
{
return $this->unit_type;
}

public function getAddressSize(): int
{
return $this->address_size;
}

public function getDebugAbbrevOffset(): int
{
return $this->debug_abbrev_offset;
}
}
19 changes: 19 additions & 0 deletions src/Lib/Dwarf/DebuggingInformationEntry/AddressRange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\DebuggingInformationEntry;

class AddressRange
{

}
22 changes: 22 additions & 0 deletions src/Lib/Dwarf/DebuggingInformationEntry/AddressRanges.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PhpProfiler\Lib\Dwarf\DebuggingInformationEntry;

final class AddressRanges
{
public function isInRanges(int $address): bool
{
return false;
}
}
Loading

0 comments on commit cd626d6

Please sign in to comment.