Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reimplement eval. Currently breaks stash merging when used
  • Loading branch information
sorear committed Oct 23, 2011
1 parent a3850e3 commit d0a95e5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
8 changes: 4 additions & 4 deletions lib/Builtins.cs
Expand Up @@ -1624,8 +1624,8 @@ public partial class Builtins {
System.Diagnostics.Process.Start(file, args).WaitForExit();
}

public static AppDomain up_domain;
public static DynBlockDelegate eval_result;
internal static AppDomain up_domain;
internal static RuntimeUnit eval_result;
static System.Collections.IDictionary upcall_receiver;
internal static object UpCall(object[] args) {
if (upcall_receiver == null)
Expand All @@ -1643,8 +1643,8 @@ public partial class Builtins {
});
if (msg != null && msg != "")
return Kernel.Die(th, msg);
return th.MakeChild(null, new SubInfo("boot-" +
eval_result.Method.DeclaringType, eval_result), Kernel.AnyP);
P6any sub = Kernel.MakeSub(eval_result.mainline, th.caller);
return sub.Invoke(th, Variable.None, null);
}

public static Variable pair(Variable key, Variable value) {
Expand Down
3 changes: 2 additions & 1 deletion lib/CodeGen.cs
Expand Up @@ -4243,6 +4243,7 @@ public class DowncallReceiver : CallReceiver {
Array.Copy(args, 3, Kernel.commandArgs, 0, args.Length - 3);
Kernel.currentGlobals = ru.globals;
ru.PrepareEval();
Builtins.eval_result = ru;
if (!evalmode)
Kernel.RunMain(ru);
return null;
Expand All @@ -4258,7 +4259,7 @@ public class DowncallReceiver : CallReceiver {
// hack to simulate a settingish environment
Variable r = Kernel.RunInferior(
Kernel.GetInferiorRoot().MakeChild(null,
new SubInfo("<repl>", Builtins.eval_result),
new SubInfo("<repl>", null),//Builtins.eval_result),
Kernel.AnyP));
if (!b.v.Fetch().mo.mro_raw_Bool.Get(b.v)) {
Variable pl = Kernel.RunInferior(
Expand Down
10 changes: 5 additions & 5 deletions src/CompilerBlob.cs
Expand Up @@ -29,12 +29,12 @@ public class UpcallReceiver : CallReceiver {
set { }
get {
object[] ia = (object[]) i;
string[] sa = new string[ia.Length];
Array.Copy(ia, sa, ia.Length);
Variable[] va = new Variable[ia.Length];
for (int ix = 0; ix < ia.Length; ix++)
va[ix] = Downcaller.DCResult(ia[ix]);
Variable vr = Kernel.RunInferior(
Downcaller.upcall_cb.Fetch().Invoke(
Kernel.GetInferiorRoot(),
new Variable[] { Builtins.BoxLoS(sa) }, null));
Kernel.GetInferiorRoot(), va, null));
return vr.Fetch().mo.mro_raw_Str.Get(vr);
}
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public class Downcaller {
return DCResult(RawDowncall(lo.ToArray()));
}

static Variable DCResult(object r) {
internal static Variable DCResult(object r) {
if (r == null) return Kernel.AnyMO.typeVar;
else if (r is string) return Kernel.BoxAnyMO((string)r, Kernel.StrMO);
else if (r is int) return Builtins.MakeInt((int)r);
Expand Down
4 changes: 2 additions & 2 deletions src/NieczaBackendDotnet.pm6
Expand Up @@ -31,14 +31,14 @@ method save_unit($name, $unit) {
$file.spew(NAMOutput.run($unit));
}

sub upcalled(@strings) {
sub upcalled(*@strings) {
given @strings[0] {
when "eval" {
my $*IN_EVAL = True;
# XXX NieczaException is eaten by boundary
try {
$*compiler.compile_string(@strings[1], True, :evalmode,
:outer([@strings[2], +@strings[3]]));
:outer(@strings[2]));
return "";
}
return $!;
Expand Down
4 changes: 0 additions & 4 deletions src/NieczaCompiler.pm6
Expand Up @@ -13,8 +13,6 @@ has $!discount-time = 0;
has %.units;

method !compile($unitname, $filename, $modtime, $source, $main, $run, $end, $evalmode, $outer, $repl) {
my %*units := %.units;

# FIXME this is a bit of a fudge
$unitname := 'CORE' if $!frontend.lang eq 'NULL';

Expand All @@ -31,8 +29,6 @@ method !compile($unitname, $filename, $modtime, $source, $main, $run, $end, $eva
my $ast = $!frontend.parse(:$unitname, :$filename, :$modtime,
:$source, :$outer, :$main, :$run);

%!units{$unitname} = $ast;

$!backend.accept($unitname, $ast, :$main, :$run, :$evalmode, :$repl);

my $time = times[0] - $!discount-time - $start;
Expand Down
3 changes: 1 addition & 2 deletions src/NieczaFrontendSTD.pm6
Expand Up @@ -245,10 +245,9 @@ method parse(:$unitname, :$filename, :$modtime, :$source, :$outer, :$run, :$main
my $*CCSTATE; my $*BORG; my %*RX; my $*XACT; my $*VAR; my $*IN_REDUCE;

my $*unit = $*backend.create_unit($unitname, $filename, $source, $main, $run);
%*units{$unitname} = $*unit;
$*unit.set_current;
my $*settingref = $*niecza_outer_ref ||
$lang ne 'NULL' ?? $*unit.need_unit($lang).bottom !! Any;
($lang ne 'NULL' ?? $*unit.need_unit($lang).bottom !! Any);

$*unit.abs_pkg('GLOBAL', :auto);
$*unit.abs_pkg('PROCESS', :auto);
Expand Down

0 comments on commit d0a95e5

Please sign in to comment.