Skip to content

Commit

Permalink
Implement add-attribute metacall so has declarations can work
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 25, 2010
1 parent e569c75 commit 0357b1d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions CORE.setting
Expand Up @@ -62,6 +62,17 @@ PRE-INIT {
[null Variable])
} }
# $how.add-attribute($name)
sub add-attribute { Q:CgOp {
(prog
[setindex (unwrap String (@ (pos 1)))
(getfield local_attr (unwrap DynMetaObject (getattr meta-object
(@ (pos 0)))))
(null IP6)]

[null Variable])
} }

# $how.create-protoobject()
sub create-protoobject { Q:CgOp {
(withtypes $p DynObject $mo DynMetaObject
Expand Down Expand Up @@ -91,6 +102,8 @@ PRE-INIT {
(wrap (clr_string "new")) (l &new))]
[sink (subcall (@ (l &add-method)) (l $chch)
(wrap (clr_string "add-method")) (l &add-method))]
[sink (subcall (@ (l &add-method)) (l $chch)
(wrap (clr_string "add-attribute")) (l &add-attribute))]
[sink (subcall (@ (l &add-method)) (l $chch)
(wrap (clr_string "add-super")) (l &add-super))]
[sink (subcall (@ (l &add-method)) (l $chch)
Expand Down
1 change: 1 addition & 0 deletions CodeGen.pm
Expand Up @@ -20,6 +20,7 @@ use 5.010;
typeObject => [f => 'IP6'],
how => [f => 'IP6'],
local => [f => 'Dictionary<string,IP6>'],
local_attr => [f => 'Dictionary<string,IP6>'],
superclasses => [f => 'List<DynMetaObject>'],
name => [f => 'String'] },

Expand Down
2 changes: 2 additions & 0 deletions Kernel.cs
Expand Up @@ -155,6 +155,8 @@ public List<DynMetaObject> superclasses
= new List<DynMetaObject>();
public Dictionary<string, IP6> local
= new Dictionary<string, IP6>();
public Dictionary<string, IP6> local_attr
= new Dictionary<string, IP6>();

public List<DynMetaObject> mro;
public HashSet<DynMetaObject> isa;
Expand Down
4 changes: 2 additions & 2 deletions Niecza/Actions.pm
Expand Up @@ -561,7 +561,7 @@ sub methodop { my ($cl, $M) = @_;
my %r;
$r{name} = $cl->mangle_longname($M->{longname}, "method call") if $M->{longname};
$r{quote} = $M->{quote}{_ast} if $M->{quote};
$r{ref} = $cl->do_variable_reference($M->{variable}{_ast})
$r{ref} = $cl->do_variable_reference($M, $M->{variable}{_ast})
if $M->{variable};

$r{args} = $M->{args}[0]{_ast}[0] if $M->{args}[0];
Expand Down Expand Up @@ -682,7 +682,7 @@ sub term__S_statement_prefix { my ($cl, $M) = @_;
}

sub term__S_variable { my ($cl, $M) = @_;
$M->{_ast} = $cl->do_variable_reference($M->{variable}{_ast});
$M->{_ast} = $cl->do_variable_reference($M, $M->{variable}{_ast});
}

sub term__S_DotDotDot { my ($cl, $M) = @_;
Expand Down

0 comments on commit 0357b1d

Please sign in to comment.