Skip to content

Commit

Permalink
More misc fixes, can now run q[ say "Hello, world" ]
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Oct 6, 2011
1 parent 4648202 commit febfdd9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/CodeGen.cs
Expand Up @@ -5394,9 +5394,13 @@ public class DowncallReceiver : CallReceiver {
nst.typeVar = Kernel.NewRWListVar(nst.typeObject);
}

if (pf != null)
pf.SetValue(null, nst.typeObject);

nst.initVar = nst.typeVar;
nst.initObject = nst.typeObject;
nst.who = Kernel.BoxRaw(who, Kernel.StashMO);
nst.how = Kernel.BoxRaw<STable>(nst, Kernel.ClassHOWMO);
nst.mo.rtype = type;
nst.mo.isPackage = (type == "package");
nst.mo.isRole = (type == "role" || type == "prole");
Expand Down
18 changes: 11 additions & 7 deletions lib/Kernel.cs
Expand Up @@ -315,7 +315,6 @@ class IdentityComparer : IEqualityComparer<object> {
ths[i].FillSubInfo(type);
if ((our_subs[i].special & SUB_IS_UNSAFE) != 0)
Kernel.CheckUnsafe(our_subs[i]);
Console.WriteLine("{0} | {1}", our_subs[i].name, our_subs[i].code);
}

if (Environment.GetEnvironmentVariable("NIECZA_DEFER_TRACE") != null) {
Expand Down Expand Up @@ -2029,8 +2028,12 @@ public class Frame: P6any {
public string ExecutingFile() {
BValue l;
SubInfo i = info;
if (i.GetHint("$?FILE", out l))
return l.v.Fetch().mo.mro_raw_Str.Get(l.v);
try {
if (i.GetHint("$?FILE", out l))
return l.v.Fetch().mo.mro_raw_Str.Get(l.v);
} catch (Exception e) {
return "<exception>";
}
return "";
}

Expand Down Expand Up @@ -2129,7 +2132,7 @@ public class Frame: P6any {
return;
csr = csr.outer;
}
if (name == "$!") return;
if (name == "$!" || name == "$/") return;
throw new NieczaException("cannot bind " + name + " in " + info.name);
}

Expand Down Expand Up @@ -4806,8 +4809,8 @@ class ExitRunloopException : Exception {
private static void DoTrace(Frame cur) {
TraceCount = TraceFreq;
if ((TraceFlags & TRACE_CUR) != 0)
Console.WriteLine("{0}|{1} @ {2} [{3}/{4:X}]",
cur.DepthMark(), cur.info.name, cur.ip, cur.info.code, cur.info.GetHashCode());
Console.WriteLine("{0}|{1} @ {2}",
cur.DepthMark(), cur.info.name, cur.ip);
if ((TraceFlags & TRACE_ALL) != 0) {
Console.WriteLine("Context:" + DescribeBacktrace(cur, null));
}
Expand Down Expand Up @@ -5313,7 +5316,8 @@ class LastFrameNode {
} else {
if (csr.caller == null) Panic(csr.info.name + " has no caller?");
// TODO: catch generated exceptions and add to @!
csr.caller.resultSlot = Kernel.NilP.mo.typeVar;
csr.caller.resultSlot = Kernel.NilP == null ? null :
Kernel.NilP.mo.typeVar;
Kernel.SetTopFrame(csr);
csr = csr.Return();
}
Expand Down
13 changes: 13 additions & 0 deletions lib/ObjModel.cs
Expand Up @@ -602,6 +602,19 @@ public class DispatchSet {
if (err != null)
return "C3 MRO generation failed for " + stable.name + ": " + err;
SetMRO(nmro.ToArray());

List<string> all_slot_l = new List<string>();
foreach (STable m in mro)
foreach (AttrInfo ai in m.mo.local_attr)
all_slot_l.Add(ai.name);
butCache = new Dictionary<STable, STable>();
stable.all_slot = all_slot_l.ToArray();
local_does = new STable[0];

stable.nslots = 0;
foreach (string an in stable.all_slot) {
stable.slotMap[an] = stable.nslots++;
}
return null;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/niecza
Expand Up @@ -116,9 +116,10 @@ method add_attribute($/, $name, $sigil, $accessor, $type) {
if $accessor {
$ns.add_method(0, $name, $nb, |mnode($/));
}
$at = True;
});

$at ?? ::Op::Attribute.new(name => $name, initializer => $type) !!
$at ?? ::Op::Attribute.new(name => $name, initializer => $ns) !!
::Op::StatementList.new;
}
method install_sub($/, $sub, :$multiness is copy, :$scope is copy, :$class,
Expand Down Expand Up @@ -565,13 +566,13 @@ method INFIX($/) {
$fn.with_args($/, $ll, $rhs)),
$ll]) });
}
elsif $lhs.^isa(::Op::Attribute) && !defined($lhs.initializer.ivar) {
elsif $lhs.^isa(::Op::Attribute) {
my $init = self.thunk_sub($rhs,
:name($lhs.initializer.name ~ " init"));
$init.set_outervar(my $ov = self.gensym);
$*CURLEX<!sub>.add_my_sub($ov, $init);
$lhs.initializer.add_initializer($lhs.name, $init);
make $lhs;
make ::Op::StatementList.new;
}
elsif $lhs.^isa(::Op::ConstantDecl) && !$lhs.init {
my $sig = substr($lhs.name, 0, 1);
Expand Down

0 comments on commit febfdd9

Please sign in to comment.