Skip to content

Commit

Permalink
Start venturing into augment-land with Mu.Str, Mu.Bool, and Mu.defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan O'Rear committed Jul 14, 2010
1 parent d87ab4c commit 2d8120f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions setting
Expand Up @@ -313,4 +313,29 @@ sub prefix:<?>($v) { $v.Bool }

sub prefix:<!>($v) { if $v { ?0 } else { ?1 } }

# XXX: We can't use augment syntax because we don't have use working, so
# no MONKEY_TYPING.

PRE-INIT {
my $i := Mu.HOW.push-scope(Q:NIL { callframe wrap });
Mu.HOW.add-scoped-method(Q:NIL { "defined" wrap }, $i,
anon method defined {
Q:NIL { =[0] @ cast:DynObject @.slots
null:Dictionary<string,object> != box:Bool }
});
Mu.HOW.add-scoped-method(Q:NIL { "Bool" wrap }, $i,
anon method Bool { (Q:NIL { =[0] }).defined });
Mu.HOW.add-scoped-method(Q:NIL { "Str" wrap }, $i,
anon method Str {
my $tn := Q:NIL {
=[0] @ cast:DynObject @.klass @.proto @.name box:Str
};
if (Q:NIL { =[0] }).defined {
$tn ~ "()<instance>"
} else {
$tn ~ "()"
}
});
}
YOU_ARE_HERE;

0 comments on commit 2d8120f

Please sign in to comment.