Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now only nodes capable of holding children get a slot for them and an array allocated, reducing memory. Also take the time to optimize the new methods so we get away with a lot of the late-bound method calls.
- Loading branch information
Showing
22 changed files
with
192 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
class QAST::BVal is QAST::Node { | ||
has $!value; | ||
|
||
method new(:$value, *%options) { | ||
my $node := nqp::create(self); | ||
nqp::bindattr($node, QAST::BVal, '$!value', $value); | ||
$node.set(%options) if %options; | ||
$node | ||
} | ||
|
||
method value($value = NO_VALUE) { $!value := $value unless $value =:= NO_VALUE; $!value } | ||
|
||
method evaluate_unquotes(@unquotes) { | ||
self | ||
} | ||
|
||
method dump_extra_node_info() { ~$!value.cuid } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
role QAST::Children { | ||
has @!children is positional_delegate; | ||
|
||
method list() { @!children } | ||
method pop() { nqp::pop(@!children) } | ||
method push($value) { nqp::push(@!children, $value) } | ||
method shift() { nqp::shift(@!children) } | ||
method unshift($value) { nqp::unshift(@!children, $value) } | ||
|
||
method shallow_clone() { | ||
my $clone := nqp::clone(self); | ||
$clone.set_children(nqp::clone(@!children)); | ||
$clone | ||
} | ||
|
||
method set_children(@children) { | ||
@!children := @children; | ||
} | ||
|
||
method dump_children(int $indent, @onto) { | ||
for @!children { | ||
if nqp::istype($_, QAST::Node) { | ||
nqp::push(@onto, $_.dump($indent)); | ||
} | ||
else { | ||
nqp::push(@onto, nqp::x(' ', $indent)); | ||
nqp::push(@onto, '- '); | ||
nqp::push(@onto, nqp::istype($_, NQPMu) ?? '(NQPMu)' !! ~$_); | ||
nqp::push(@onto, "\n"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
class QAST::NodeList is QAST::Node { | ||
class QAST::NodeList is QAST::Node does QAST::Children { | ||
method new(*@children, *%options) { | ||
my $node := nqp::create(self); | ||
nqp::bindattr($node, QAST::NodeList, '@!children', @children); | ||
$node.set(%options) if %options; | ||
$node | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
class QAST::ParamTypeCheck is QAST::Node { | ||
class QAST::ParamTypeCheck is QAST::Node does QAST::Children { | ||
method new(*@children, *%options) { | ||
my $node := nqp::create(self); | ||
nqp::bindattr($node, QAST::ParamTypeCheck, '@!children', @children); | ||
$node.set(%options) if %options; | ||
$node | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.