Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public Module InvokeModule(Type t)
        {
            Newmoon.Environment[] cArgs = new Newmoon.Environment[1] { this };
            Type[] cTypes = Type.GetTypeArray(cArgs);

            Newmoon.Module m = (Newmoon.Module) t.GetConstructor(cTypes).Invoke(cArgs);
            return m;
        }