Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Kill SAFE/CORE division; use is unsafe to implement safe mode
  • Loading branch information
sorear committed Mar 4, 2011
1 parent 79b33ad commit dafccd8
Show file tree
Hide file tree
Showing 9 changed files with 1,208 additions and 1,217 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -21,7 +21,7 @@ srcunits=CClass Body Unit CgOp Op OpHelpers Sig RxOp NAME Stash STD \
all: run/Niecza.exe obj/Kernel.dll obj/CORE.nam obj/CLRBackend.exe
git describe --tags > VERSION

obj/CORE.nam: run/Niecza.exe obj/CLRBackend.exe lib/SAFE.setting lib/CORE.setting
obj/CORE.nam: run/Niecza.exe obj/CLRBackend.exe lib/CORE.setting
$(RUN_CLR) run/Niecza.exe -C CORE

run/Niecza.exe: .fetch-stamp $(patsubst %,src/%.pm6,$(srcunits)) src/niecza
Expand Down
7 changes: 3 additions & 4 deletions docs/overview.pod
Expand Up @@ -16,10 +16,9 @@ lowest levels of library functionality.

=head1 Core library

C<lib/SAFE.setting> and C<lib/CORE.setting> are used automatically in Perl 6
programs and provide definitions of all Perl 6 functions. They use Niecza
extensions fairly heavily, especially inline NAM code and references into
the runtime.
C<lib/CORE.setting> is used automatically in Perl 6 programs and provides
definitions of all Perl 6 functions. It uses Niecza extensions fairly
heavily, especially inline NAM code and references into the runtime.

=head1 Other libraries

Expand Down
2 changes: 1 addition & 1 deletion lib/Builtins.cs
Expand Up @@ -317,7 +317,7 @@ public class Builtins {
}

public static Variable Make(Frame fr, Variable v) {
if (fr.info.name == "SAFE make")
if (fr.info.name == "CORE make")
fr = fr.caller;
Cursor c = (Cursor) Kernel.StatusHelper(fr, "$*/", 0).Fetch();
c.Make(v);
Expand Down
33 changes: 17 additions & 16 deletions lib/CLRBackend.cs
Expand Up @@ -553,7 +553,7 @@ class StaticSub {

public bool IsCore() {
string s = unit.name;
return (s == "SAFE" || s == "CORE");
return s == "CORE";
}

public void BindFields(int ix, Func<string,Type,FieldInfo> binder) {
Expand All @@ -572,7 +572,7 @@ class StaticSub {

public Package GetCorePackage(string name) {
StaticSub csr = this;
while (csr.unit.name != "SAFE" && csr.unit.name != "CORE")
while (csr.unit.name != "CORE")
csr = csr.outer.Resolve<StaticSub>();
while (!csr.l_lexicals.ContainsKey(name))
csr = csr.outer.Resolve<StaticSub>();
Expand Down Expand Up @@ -3646,19 +3646,6 @@ public class CLRBackend {
np.MakeBody();
});

foreach (object le in unit.log) {
object[] lea = (object[]) le;
string t = ((JScalar)lea[0]).str;
if (t == "pkg" || t == "var") {
CpsOp[] sa = new CpsOp[] { CpsOp.StringArray(false, JScalar.SA(0, lea[1])) };
if (t == "pkg") {
thaw.Add(CpsOp.MethodCall(null, Tokens.Kernel_CreatePath, sa));
} else {
thaw.Add(CpsOp.Sink(CpsOp.MethodCall(null, Tokens.Kernel_GetVar, sa)));
}
}
}

unit.VisitPackages(delegate(int ix, Package pkg) {
if (Verbose > 0) Console.WriteLine("pkg2 {0}", pkg.name);
if (!(pkg is ModuleWithTypeObject))
Expand All @@ -3667,7 +3654,7 @@ public class CLRBackend {
FieldInfo km = null;
FieldInfo kp = null;
bool existing_mo = false;
if (unit.name == "SAFE" || unit.name == "CORE") {
if (unit.name == "CORE") {
km = Tokens.Kernel.GetField(m.name + "MO");
kp = Tokens.Kernel.GetField(m.name + "P");
existing_mo = km != null && km.IsInitOnly;
Expand Down Expand Up @@ -3864,6 +3851,20 @@ public class CLRBackend {
}
});

// this needs to come late so that Array and Hash are available
foreach (object le in unit.log) {
object[] lea = (object[]) le;
string t = ((JScalar)lea[0]).str;
if (t == "pkg" || t == "var") {
CpsOp[] sa = new CpsOp[] { CpsOp.StringArray(false, JScalar.SA(0, lea[1])) };
if (t == "pkg") {
thaw.Add(CpsOp.MethodCall(null, Tokens.Kernel_CreatePath, sa));
} else {
thaw.Add(CpsOp.Sink(CpsOp.MethodCall(null, Tokens.Kernel_GetVar, sa)));
}
}
}

thaw.Add(CpsOp.MethodCall(null, Tokens.SubInfo.GetMethod("SetStringHint"), new CpsOp[] {
CpsOp.GetSField(unit.mainline_ref.Resolve<StaticSub>().subinfo),
CpsOp.StringLiteral("$?FILE"), CpsOp.StringLiteral(unit.filename ?? "(eval)") }));
Expand Down

0 comments on commit dafccd8

Please sign in to comment.