Exemplo n.º 1
0
        //Implementations must have this property:
        //public static string Keyword { abstract get; }
        //
        //The default expression returns null.

        public abstract void EmitIL(_ATHProgram program, Colour expressionColour, ILGenerator ilGenerator, Dictionary <string, ImportHandle> importHandles, Dictionary <Tuple <string, Colour>, ImportHandle> objects);
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var importPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            importPath = Path.Combine(importPath, "./Imports/");

            if (!Directory.Exists(importPath))
            {
                Directory.CreateDirectory(importPath);
            }

            var importFiles     = Directory.GetFiles(importPath, "*.dll", SearchOption.AllDirectories);
            var externalImports = importFiles.SelectMany(file => Assembly.LoadFrom(file).GetTypes().Where(type => typeof(_ATHImport).IsAssignableFrom(type))).ToArray();

            var internalImports = new[] { typeof(ProcessImport) };

            var imports = externalImports.Concat(internalImports).ToArray();

            bool run = false;

            foreach (var arg in args)
            {
                if (arg == "-r")
                {
                    run = true;
                    continue;
                }

                if (arg == "-c")
                {
                    run = false;
                    continue;
                }

                if (arg.EndsWith(".~ATH"))
                {
                    try
                    {
                        var program = new _ATHProgram(File.ReadAllText(arg));
                        program.Compile(Path.GetFileName(arg), imports);
                        if (run)
                        {
                            program.Run();
                        }
                        else
                        {
                            program.Save(arg + ".exe");
                        }
                    }
                    catch (Exception ex)
                    {
                        while (ex.InnerException != null)
                        {
                            Console.WriteLine(ex);
                            Console.WriteLine();
                            ex = ex.InnerException;
                        }
                        Console.WriteLine(ex.ToString());
                        Console.ReadLine();
                    }
                    break;
                }

                Console.WriteLine("Invalid argument: " + arg);
                Console.ReadLine();
                break;
            }
        }