Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move most of the derived-operation logic from CodeGen to CgOp
  • Loading branch information
Stefan O'Rear committed Jul 16, 2010
1 parent acb3c4e commit 8a46a61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 57 deletions.
14 changes: 7 additions & 7 deletions CgOp.pm
Expand Up @@ -113,7 +113,7 @@ use warnings;
}

sub unwrap {
CgOp::NIL->new(ops => [ $_[1], [ 'clr_unwrap', $_[0] ] ]);
cast($_[0], getfield('val', cast('CLRImportObject', $_[1])));
}

sub sink {
Expand Down Expand Up @@ -147,7 +147,7 @@ use warnings;
}

sub getattr {
CgOp::NIL->new(ops => [ $_[1], [ 'attr_get', $_[0] ] ]);
fetch(varattr($_[0], $_[1]));
}

sub varattr {
Expand All @@ -159,15 +159,15 @@ use warnings;
}

sub newscalar {
CgOp::NIL->new(ops => [ $_[0], [ 'newscalar' ] ]);
rawscall('Kernel.NewROScalar', $_[0]);
}

sub newrwscalar {
CgOp::NIL->new(ops => [ $_[0], [ 'newrwscalar' ] ]);
rawscall('Kernel.NewRWScalar', $_[0]);
}

sub string_var {
CgOp::NIL->new(ops => [ [ 'string_var', $_[0] ] ]);
box('Str', clr_string($_[0]));
}

sub double {
Expand All @@ -179,11 +179,11 @@ use warnings;
}

sub unbox {
CgOp::NIL->new(ops => [ $_[1], [ 'unbox', $_[0] ] ]);
cast($_[0], rawscall('Kernel.UnboxAny', $_[1]));
}

sub box {
CgOp::NIL->new(ops => [ $_[1], [ 'box', $_[0] ] ]);
rawscall('Kernel.BoxAny', $_[1], fetch(scopedlex($_[0])));
}

sub bind {
Expand Down
50 changes: 0 additions & 50 deletions CodeGen.pm
Expand Up @@ -594,56 +594,6 @@ use 5.010;
}
}

sub string_var {
my ($self, $text) = @_;
$self->clr_string($text);
$self->box('Str');
}

sub newscalar {
my ($self) = @_;
$self->clr_call_direct('Kernel.NewROScalar', 1);
}

sub newrwscalar {
my ($self) = @_;
$self->clr_call_direct('Kernel.NewRWScalar', 1);
}

sub clr_unwrap {
my ($self, $ty) = @_;
$self->cast('CLRImportObject');
$self->clr_field_get('val');
$self->cast($ty);
}

sub box {
my ($self, $ty) = @_;
$self->scopelex($ty);
$self->fetch;
$self->clr_call_direct('Kernel.BoxAny', 2);
}

sub unbox {
my ($self, $ty) = @_;
$self->clr_call_direct('Kernel.UnboxAny', 1);
$self->cast($ty);
}

sub attr_get {
my ($self, $f) = @_;
$self->attr_var($f);
$self->fetch;
}

sub attr_set {
my ($self, $f) = @_;
$self->swap;
$self->attr_var($f);
$self->swap;
$self->assign;
}

sub open_protopad {
my ($self, $body) = @_;
$self->peek_aux('protopad');
Expand Down

0 comments on commit 8a46a61

Please sign in to comment.