Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bootstrap more methods. Add integers to NIL. NEW CLASS: Mu
  • Loading branch information
sorear committed Jul 7, 2010
1 parent 8c57de0 commit 5135541
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CodeGen.pm
Expand Up @@ -273,6 +273,11 @@ use 5.010;
$self->_push('System.String', qm($text));
}

sub clr_int {
my ($self, $val) = @_;
$self->_push('System.Int32', $val);
}

sub clr_field_get {
my ($self, $f) = @_;
my $ty = $typedata{$self->stacktype->[-1]}{$f};
Expand Down
5 changes: 5 additions & 0 deletions Niecza/Actions.pm
Expand Up @@ -315,6 +315,11 @@ sub insn__S_clr_string { my ($cl, $M) = @_;
$M->{_ast} = [[ clr_string => $M->{quote}{_ast}->text ]];
}

sub insn__S_clr_int { my ($cl, $M) = @_;
my $s = ($M->{sign}->Str eq '-') ? -1 : +1;
$M->{_ast} = [[ clr_int => $s * $M->{decint}{_ast} ]];
}

# the negatives here are somewhat of a cheat.
sub insn__S_label { my ($cl, $M) = @_;
$M->{_ast} = [[ labelhere => -$M->{decint}{_ast} ]];
Expand Down
1 change: 1 addition & 0 deletions Niecza/Grammar.pm6
Expand Up @@ -49,6 +49,7 @@ grammar NIL is STD {

token insn:string_var { "=" <?before <[ ' " ]>> [ :lang(%*LANG<MAIN>) <quote> ] }
token insn:clr_string { <?before <[ ' " ]>> [ :lang(%*LANG<MAIN>) <quote> ] }
token insn:clr_int { $<sign>=[<[ - + ]>?] <decint> }
token insn:label { ':' {} <decint> }
token insn:goto { '->' {} <decint> }

Expand Down
15 changes: 13 additions & 2 deletions setting
Expand Up @@ -67,7 +67,7 @@ PRE-INIT {
sub add-scoped-method { Q:NIL {
LEXICALS: $name : String, $index : Int32, $sub : DynObject
LEXICALS: $mo : DynProtoMetaObject
=[0] @ cast:DynObject @.slots @[meta-object] cast:DynMetaObject L!$mo
=[0] @ cast:DynObject @.slots @[meta-object] cast:DynProtoMetaObject L!$mo
=[1] @ unwrap:String L!$name
=[2] @ unwrap:Int32 L!$index
=[3] @ cast:DynObject L!$sub
Expand Down Expand Up @@ -108,11 +108,22 @@ PRE-INIT {
L@$chpmo "ClassHOW" !.name
L@$ch @.slots L@$chpmo ![meta-object]

L@&push-scope @ L@$ch wrapobj callframe wrap .call/2:v
L@&add-scoped-method @ L@$ch wrapobj ="new" 0 wrap L@&new .call/4:v
L@&add-scoped-method @ L@$ch wrapobj ="push-scope" 0 wrap
L@&push-scope .call/4:v
L@&add-scoped-method @ L@$ch wrapobj ="add-scoped-method" 0 wrap
L@&add-scoped-method .call/4:v
L@&add-scoped-method @ L@$ch wrapobj ="compose" 0 wrap
L@&compose .call/4:v
L@&add-scoped-method @ L@$ch wrapobj ="create-protoobject" 0 wrap
L@&create-protoobject .call/4:v

L@&create-protoobject @ L@$ch wrapobj callframe wrap
.call/2 L!^ClassHOW

L@$ch L@^ClassHOW @ cast:DynObject @.klass !.klass
L@$ch L!^'ClassHOW!HOW'
L@$ch wrapobj L!^'ClassHOW!HOW'

null:Variable
}
Expand Down

0 comments on commit 5135541

Please sign in to comment.