Skip to content

Commit

Permalink
Add a storage class for ro names like classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Aug 17, 2010
1 parent b4ad6c2 commit a6dcd31
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Body.pm
Expand Up @@ -50,7 +50,8 @@ use CgOp ();
my $nfields_global;
for my $le (map { $_->used_slots($h{'?is_mainline'}) } @{ $self->decls }) {
# 0: cloned 1: static field 2: hint
if ($le->[2] == 1) {
# 3: readonly static field
if ($le->[2] == 1 || $le->[2] == 3) {
my $sanname = $le->[0];
$sanname =~ s/\W//g;
$le->[3] = sprintf "%s.F%d_%d_%s", Unit->csname($::UNITNAME),
Expand Down
18 changes: 15 additions & 3 deletions CodeGen.pm
Expand Up @@ -620,6 +620,13 @@ use 5.010;
sub proto_var {
my ($self, $name) = @_;
my ($type, $kind, $data) = @{ $self->bodies->[-1]->lexical->{$name} };
if ($kind == 3) {
$self->clr_sfield_set($data);
$self->clr_sfield_get($data . ":f,IP6");
$self->newscalar;
$self->clr_sfield_set($data . "_var");
return;
}
if ($kind == 1) {
$self->clr_sfield_set($data);
return;
Expand Down Expand Up @@ -663,9 +670,14 @@ use 5.010;
for my $ve (sort keys %$l) {
next unless ref $l->{$ve} eq 'ARRAY';
my ($ty, $k, $d) = @{ $l->{$ve} };
next unless $k == 1;
$d =~ s/.*\.//;
print ::NIECZA_OUT " " x 4, "public static $ty $d;\n";
if ($k == 1) {
$d =~ s/.*\.//;
print ::NIECZA_OUT " " x 4, "public static $ty $d;\n";
} elsif ($k == 3) {
$d =~ s/.*\.//;
print ::NIECZA_OUT " " x 4, "public static IP6 $d;\n";
print ::NIECZA_OUT " " x 4, "public static Variable ${d}_var;\n";
}
}
}
my $name = $self->csname;
Expand Down
17 changes: 15 additions & 2 deletions ResolveLex.pm
Expand Up @@ -42,6 +42,13 @@ sub run_cgop {
push @$btree, $arg;
} elsif ($opc eq 'close_sub') {
pop @$btree;
} elsif ($opc eq 'fetch' &&
$op->zyg->[0]->isa('CgOp::Primitive') &&
$op->zyg->[0]->op->[0] eq 'clr_sfield_get' &&
$op->zyg->[0]->op->[1] =~ /(.*)_var:f,Variable/) {
my $nn = CgOp::rawsget($1 . ":f,IP6");
%$op = %$nn;
bless $op, ref($nn);
} elsif ($opc eq 'scopelex') {
my $nn = resolve_lex($arg, $btree->[-1], $op->zyg->[0]);
#XXX
Expand All @@ -64,11 +71,17 @@ sub resolve_lex {
die "Internal error: failed to resolve lexical $name in " . $body->name;
}

if (($kind == 1 || $kind == 2) && $data =~ /(.*)\./) {
if (($kind == 1 || $kind == 2 || $kind == 3) && $data =~ /(.*)\./) {
$::UNITDEPS{$1} = 1;
}

if ($kind == 2) {
if ($kind == 3) {
if ($set_to) {
die "panic: Assigning to a kind3";
} else {
return CgOp::rawsget($data . "_var:f,Variable");
}
} elsif ($kind == 2) {
if ($set_to) {
die "panic: Assigning to a hint";
} else {
Expand Down

0 comments on commit a6dcd31

Please sign in to comment.