public Environment(SchemeString desc) { assemblies = new Hashtable(); assemblyList = new ArrayList(); modules = new Hashtable(); bindings = new Hashtable(); description = new SchemeString("Newmoon.Environment("+desc+")"); }
public static void ProgramEntryPoint(String[] argv, System.Type moduleType) { Newmoon.Environment e = new Newmoon.Environment(moduleType.FullName); Driver d = new Driver(); String configStr = System.Environment.GetEnvironmentVariable("NEWMOON_RUNTIME"); String[] config = (configStr == null ? new String[0] {} : configStr.Split(' ')); foreach (String arg in config) { if (arg[0] == '-') { switch (arg[1]) { case 'h': case '?': usage(0); break; default: usage(1); break; } continue; } string modpath = (Path.HasExtension(arg) ? arg : Path.ChangeExtension(arg, "dll")); string modname = Path.GetFileNameWithoutExtension(arg); if (!e.ModuleInvoked(modname)) { Module m = e.InvokeModule(modname, modpath); d.CallScheme(m, m.GetEntryPoint()); } } Module entryModule = e.InvokeModule(moduleType); SchemeString[] realArgv = new SchemeString[argv.Length]; for (int i = 0; i < realArgv.Length; i++) realArgv[i] = new SchemeString(argv[i]); Environment.InstallBinding(entryModule, "argv", "global", realArgv); Closure entryPoint = entryModule.GetEntryPoint(); d.CallScheme(entryModule, entryPoint); }
public void Assign(SchemeString s, bool m) { if (s.isNative()) { _string = s._string; _chars = null; } else { _string = null; _chars = new char[s._chars.Length]; System.Array.Copy(s._chars, _chars, _chars.Length); } _mutable = m; }
public SchemeString(SchemeString s, bool m) { Assign(s, m); }
public static SchemeString Join(List l, SchemeString sep) { StringBuilder b = new StringBuilder(); bool haveFirst = false; sep.ensureNative(); foreach (SchemeString s in l) { if (haveFirst) b.Append(sep._string); if (s.isNative()) { b.Append(s._string); } else { b.Append(s._chars); } haveFirst = true; } return new SchemeString(b, true); }