Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dotnet] a descriptive commit message. some changes/additions.
  • Loading branch information
diakopter committed Dec 4, 2010
1 parent 710c75e commit 8fbb45c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
9 changes: 6 additions & 3 deletions dotnet/compiler/DNST2CSharp.pm
Expand Up @@ -121,8 +121,11 @@ our multi sub cs_for(DNST::MethodCall $mc) {
}

# What're we calling it on?
#$code := $code ~ "Console.WriteLine(\"arg_names count was " ~ +@arg_names ~ "\");\n";
#$code := $code ~ "Console.WriteLine(\"mc.on was " ~ ($mc.on ?? 'true' !! 'false' ) ~ "\");\n";
my $invocant := $mc.on || @arg_names.shift;

#$code := $code ~ "Console.WriteLine(\"arg_names count was " ~ +@arg_names ~ "\");\n";
# Code-gen the call.
$code := $code ~ ' ';
unless $mc.void {
Expand Down Expand Up @@ -339,16 +342,16 @@ our multi sub cs_for(DNST::BXOR $ops) {
}

our multi sub cs_for(DNST::NOT $ops) {
my $code := cs_for((@(ops))[0]);
my $code := cs_for((@($ops))[0]);
my $lhs := $*LAST_TEMP;
$*LAST_TEMP := get_unique_id('expr_result_negated');
return "$code bool $*LAST_TEMP = !$lhs;\n";
}

our multi sub cs_for(DNST::XOR $ops) {
my $code := cs_for((@(ops))[0]);
my $code := cs_for((@($ops))[0]);
my $lhs := $*LAST_TEMP;
$code := $code ~ cs_for((@(ops))[0]);
$code := $code ~ cs_for((@($ops))[1]);
my $rhs := $*LAST_TEMP;
$*LAST_TEMP := get_unique_id('expr_result');
return "$code bool $*LAST_TEMP = $lhs ? ! $rhs : $rhs;\n";
Expand Down
4 changes: 2 additions & 2 deletions dotnet/compiler/Makefile
@@ -1,6 +1,6 @@
# This works provided you have a parrot-nqp and csc somewhere in your path.

all: gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_dnst.pir gen_past2dnst.pir gen_dnst2csharp.pir NQPSetting.dll P6Objects.dll
all: compile.pir gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_dnst.pir gen_past2dnst.pir gen_dnst2csharp.pir NQPSetting.dll P6Objects.dll

gen_actions.pir: Actions.pm
parrot-nqp --target=pir Actions.pm > gen_actions.pir
Expand Down Expand Up @@ -29,7 +29,7 @@ NQPSetting.dll: ../../common/NQP/NQPSetting.pm RakudoRuntime.dll
parrot compile.pir ../../common/NQP/NQPSetting.pm --setting > NQPSetting.cs
csc /nologo /warn:0 /target:library /debug /out:NQPSetting.dll /reference:RakudoRuntime.dll NQPSetting.cs

P6Objects.dll: gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_dnst.pir gen_past2dnst.pir gen_dnst2csharp.pir ../../common/NQP/P6Objects.pm NQPSetting.dll
P6Objects.dll: compile.pir gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_dnst.pir gen_past2dnst.pir gen_dnst2csharp.pir ../../common/NQP/P6Objects.pm NQPSetting.dll
parrot compile.pir ../../common/NQP/P6Objects.pm --no-core-libs > P6Objects.cs
csc /nologo /warn:0 /target:library /debug /out:P6Objects.dll /reference:RakudoRuntime.dll P6Objects.cs

Expand Down
38 changes: 37 additions & 1 deletion dotnet/compiler/PAST2DNSTCompiler.pm
Expand Up @@ -1633,14 +1633,49 @@ our multi sub dnst_regex(PAST::Regex $r) {
$stmts.push($q2label);
}
} elsif $pasttype eq 'subrule' {
my $name := dnst_for($r, :rtype('*'));
my $name := $r.name;
my $cdnst := dnst_for((@($r))[0]);
my $posargs := dnst_for((@($r))[1]);
my $namedargs := pir::defined((@($r))[2])
?? dnst_for((@($r))[2]) !! '';

my $subdnst := $posargs.shift;

my $negate := $r.negate;
my $testop := $negate ?? 'if' !! 'unless';

my $subtype := $r.subtype;
my $backtrack := $r.backtrack;

$stmts.push(cursorop('pos', box('int', $*re_pos_lit)));

$stmts.push($cdnst);

$stmts.push(if_then(:bool(0),
unbox('int', $namedargs eq ''
?? cursorop($subdnst, $posargs)
!! cursorop($subdnst, $posargs, $namedargs)),
$*re_fail
));

if $subtype ne 'zerowidth' {

}
}
else {
pir::die("Don't know how to compile regex pasttype $pasttype.");
}
dnst_for($stmts)
}

# Emits a cursor operation
sub cursorop($name, *@args) {
dnst_for(PAST::Op.new(
:pasttype('callmethod'), :name($name),
$*re_cur, |@args
))
}

# Emits a lookup of a lexical.
sub emit_lexical_lookup($name) {
my $lookup := emit_op(($*BIND_CONTEXT ?? 'bind_lex' !! 'get_lex'),
Expand Down Expand Up @@ -1863,6 +1898,7 @@ sub emit_op($name, *@args) {
}

# Build op call.
#pir::say("name is $name; type is $type; dnst_arg count is " ~ +@dnst_args);
my $call := DNST::MethodCall.new(
:on('Ops'), :name($name),
:type(vm_type_for($type)),
Expand Down

0 comments on commit 8fbb45c

Please sign in to comment.