Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add an option for disabling inclusion of source in compiled code
An open question is whether this should also disable line number information.
  • Loading branch information
sorear committed Apr 15, 2012
1 parent d71c0cd commit a0c3f43
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/NieczaBackendDotnet.pm6
Expand Up @@ -41,7 +41,8 @@ sub upcalled(*@args) {
$*compiler.module_finder.load_module($module);
my $trueh = gethash($src);
say "check-dated $module: was $hash now $trueh" if $v;
return "no" unless $hash eq $trueh;
# allow for source concealment
return "no" unless $hash eq $trueh || $hash eq gethash($trueh);
}
return "ok";
}
Expand Down Expand Up @@ -90,6 +91,7 @@ method cached_but($cls, $role) {
sub gethash($str) {
Q:CgOp { (box Str (rawscall Niecza.Downcaller,CompilerBlob.DoHash (obj_getstr {$str}))) }
}
method gethash($str) { gethash($str) }
sub execname() {
Q:CgOp { (box Str (rawscall Niecza.Downcaller,CompilerBlob.ExecName)) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/NieczaFrontendSTD.pm6
Expand Up @@ -271,7 +271,7 @@ method parse(:$unitname, :$filename, :$source, :$outer, :$run, :$main, :$evalmod

$*backend.push_compartment unless $evalmode;
LEAVE { $*backend.pop_compartment unless $evalmode };
my $*unit = $*backend.create_unit($unitname, $filename, $source, $main, $run);
my $*unit = $*backend.create_unit($unitname, $filename, $*no_incl_source ?? $Backend.gethash($source) !! $source, $main, $run);
my $*settingref = $*niecza_outer_ref ||
($lang ne 'NULL' ?? $*unit.need_unit($lang).bottom !! Any);

Expand Down
5 changes: 4 additions & 1 deletion src/niecza
Expand Up @@ -71,8 +71,9 @@ general options:
--safe # disable system interaction
--help # display this message

backend options:
output options:
--obj-dir=DIR # select output location (all)
--no-include-source # disable source-based introspection, etc
EOM

my $runobj = Q:CgOp { (box Str (rawcall get_BaseDirectory (rawscall System.AppDomain.get_CurrentDomain))) };
Expand All @@ -88,6 +89,7 @@ my @eval;
my $cmod = False;
my $comp = False;
my $version = False;
my $*no_incl_source = False;

GetOptions(:!permute,
"evaluate|e=s" => sub { push @eval, $_ },
Expand All @@ -103,6 +105,7 @@ GetOptions(:!permute,
"include|I=s" => sub { unshift @lib, $_.IO.realpath },
"obj-dir=s" => sub { $odir = $_ },
"help|h" => sub { say $usage; exit 0 },
"no-include-source" => sub { $*no_incl_source = True },
);

my @*INC;
Expand Down

0 comments on commit a0c3f43

Please sign in to comment.