Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dotnet] Eliminate DNST::Temp.
  • Loading branch information
jnthn committed Dec 4, 2010
1 parent 45d5376 commit cd7a4ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
28 changes: 3 additions & 25 deletions dotnet/compiler/DNST.pm
Expand Up @@ -341,29 +341,6 @@ class DNST::Goto is DNST::Node {
}
}

class DNST::Temp is DNST::Node {
has $!name;
has $!type;

method name($set?) {
if $set { $!name := $set }
$!name
}

method type($set?) {
if $set { $!type := $set }
$!type
}

method new(:$name!, :$type!, *@children) {
my $obj := self.CREATE;
$obj.name($name);
$obj.type($type);
$obj.set_children(@children);
$obj;
}
}

class DNST::Bind is DNST::Node {
method new(*@children) {
my $obj := self.CREATE;
Expand Down Expand Up @@ -443,7 +420,7 @@ class DNST::JumpTable is DNST::Node {
$!label
}

# DNST::Temp - int register in which to store the target
# DNST::Local - int register in which to store the target
# branch's index in the jumptable
method register($set?) {
if pir::defined($set) { $!register := $set }
Expand Down Expand Up @@ -483,8 +460,9 @@ class DNST::JumpTable is DNST::Node {
my $obj := self.CREATE;
$obj.set_children(@children);
$obj.label(DNST::Label.new(:name(get_unique_id('jump_table'))));
$obj.register(DNST::Temp.new(
$obj.register(DNST::Local.new(
:name(get_unique_id('jump_table_int_register')),
:isdecl(1),
:type('int'),
DNST::Literal.new( :value('0'), :escape(0))
));
Expand Down
9 changes: 0 additions & 9 deletions dotnet/compiler/DNST2CSharp.pm
Expand Up @@ -232,15 +232,6 @@ our multi sub cs_for(DNST::Goto $gt) {
return " goto " ~ $gt.label ~ ";\n";
}

our multi sub cs_for(DNST::Temp $tmp) {
unless +@($tmp) == 1 { pir::die('A DNST::Temp must have exactly one child') }
my $code := cs_for((@($tmp))[0]);
my $name := $tmp.name;
$code := $code ~ " " ~ $tmp.type ~ " $name = $*LAST_TEMP;\n";
$*LAST_TEMP := $name;
return $code;
}

our multi sub cs_for(DNST::Bind $bind) {
unless +@($bind) == 2 { pir::die('DNST::Bind nodes must have 2 children') }
my $code := cs_for((@($bind))[0]);
Expand Down

0 comments on commit cd7a4ff

Please sign in to comment.