Skip to content

Commit

Permalink
resolve conflict in opsc
Browse files Browse the repository at this point in the history
  • Loading branch information
luben authored and Reini Urban committed Oct 2, 2012
1 parent 2ee457e commit c59b533
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 58 deletions.
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ compilers/opsc/src/Ops/Op.pm [opsc]
compilers/opsc/src/Ops/OpLib.pm [opsc] compilers/opsc/src/Ops/OpLib.pm [opsc]
compilers/opsc/src/Ops/Trans.pm [opsc] compilers/opsc/src/Ops/Trans.pm [opsc]
compilers/opsc/src/Ops/Trans/C.pm [opsc] compilers/opsc/src/Ops/Trans/C.pm [opsc]
compilers/opsc/src/Ops/Util.pm [opsc]
compilers/opsc/src/builtins.pir [opsc] compilers/opsc/src/builtins.pir [opsc]
compilers/pct/Defines.mak [pct] compilers/pct/Defines.mak [pct]
compilers/pct/PCT.pir [pct] compilers/pct/PCT.pir [pct]
Expand Down
54 changes: 7 additions & 47 deletions compilers/opsc/ops2c.nqp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,54 +58,17 @@ sub MAIN() {
) )
!! undef; !! undef;


my $f; my $f := Ops::File.new(|@files, :oplib($lib), :core($core), :quiet($quiet));
my $do_dump_file := 0;
my $do_load := 1;
my $dump_file := $core ?? 'src/ops/ops.dump' !! @files[0] ~ ".dump";
if $opts<dump> {
try {
my $fh := open($dump_file, :r, :bin);
my $dump := $fh.readall;
$fh.close();

$f := pir::thaw__ps($dump);
$do_load := 0;

CATCH {
$quiet || pir::say("# Caught $!");
$do_dump_file := 1;
$f := undef;
};
}
}

if $do_load {
$f := Ops::File.new(|@files,
:oplib($lib),
:core($core),
:quiet($quiet),
);
}

if $do_dump_file {
$quiet || say("Dumping");
my $capture := Ops::Util::strip_source($f);
my $frozen := pir::freeze__sp($capture);

my $fh := open($dump_file, :w, :bin);
$fh.print($frozen);
$fh.close();
}


$quiet || say("# Ops parsed in { pir::sprintf__ssp("%.3f", [pir::time__N() - $start_time] ) } seconds."); $quiet || say("# Ops parsed in { pir::sprintf__ssp("%.3f", [pir::time__N() - $start_time] ) } seconds.");

my $emitter := Ops::Emitter.new(
:ops_file($f), :trans($trans),
:script('ops2c.nqp'), :file(@files[0]),
:flags( hash( core => $core, quiet => $quiet ) ),
);


unless $debug { unless $debug {
my $emitter := Ops::Emitter.new(
:ops_file($f), :trans($trans),
:script('ops2c.nqp'), :file(@files[0]),
:flags( hash( core => $core, quiet => $quiet ) ),
);

$emitter.print_ops_num_files() if $core; $emitter.print_ops_num_files() if $core;
$emitter.print_c_header_files(); $emitter.print_c_header_files();
$emitter.print_c_source_file(); $emitter.print_c_source_file();
Expand Down Expand Up @@ -135,9 +98,6 @@ sub get_options() {
# suppress timing and debug output on stdout # suppress timing and debug output on stdout
$getopts.add_option('quiet', 'q'); $getopts.add_option('quiet', 'q');


# Use .dump files with parsed ops.
$getopts.add_option('dump', 'D');

$getopts.get_options(pir::getinterp__p()[2]); $getopts.get_options(pir::getinterp__p()[2]);
} }


Expand Down
10 changes: 1 addition & 9 deletions compilers/opsc/src/Ops/Compiler/Actions.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ method op ($/, $key?) {
my @variants := expand_args(pir::clone__PP($OP<normalized_args>)); my @variants := expand_args(pir::clone__PP($OP<normalized_args>));
if @variants { if @variants {
for @variants { for @variants {
my $new_op := deep_clone($OP); my $new_op := pir::clone__PP($OP);
$new_op<arg_types> := $_; $new_op<arg_types> := $_;
$past.push($new_op); $past.push($new_op);
} }
Expand All @@ -117,12 +117,6 @@ method op ($/, $key?) {
} }
} }


sub deep_clone($thingy) {
Ops::Util::process_recursive($thingy, -> $_ {
$_.WHAT.new;
});
}

# Normalize args # Normalize args
# For each arg produce LoL of all available variants # For each arg produce LoL of all available variants
# E.g. "in" will produce "i" and "ic" variants # E.g. "in" will produce "i" and "ic" variants
Expand Down Expand Up @@ -173,8 +167,6 @@ sub normalize_args(@args) {
$res<direction> := 'o'; $res<direction> := 'o';
} }


#$arg<type> := $res<type>;

@result.push($res); @result.push($res);
} }
@result; @result;
Expand Down
2 changes: 1 addition & 1 deletion compilers/opsc/src/Ops/File.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ops file.


=end =end


method new(*@files, :$oplib, :$core, :$nolines, :$quiet? = 0) { method new(*@files, :$oplib, :$core!, :$nolines, :$quiet? = 0) {
self<files> := @files; self<files> := @files;
self<core> := $core; self<core> := $core;
self<ops> := list(); # Ops self<ops> := list(); # Ops
Expand Down

0 comments on commit c59b533

Please sign in to comment.