Esempio n. 1
0
        public IodineModule Compile(IodineContext context)
        {
            string moduleName = Path == null ? "__anonymous__" :
                                System.IO.Path.GetFileNameWithoutExtension(Path);

            if (HasPath)
            {
                string wd      = System.IO.Path.GetDirectoryName(Path);
                string depPath = System.IO.Path.Combine(wd, ".deps");

                if (!context.SearchPath.Contains(wd))
                {
                    context.SearchPath.Add(wd);
                }

                if (!context.SearchPath.Contains(depPath))
                {
                    context.SearchPath.Add(depPath);
                }
            }
            Parser         parser   = Parser.CreateParser(context, this);
            AstRoot        root     = parser.Parse();
            IodineCompiler compiler = IodineCompiler.CreateCompiler(context, root);

            return(compiler.Compile(moduleName));
        }
Esempio n. 2
0
        public IodineModule Compile(IodineContext context)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            context.ErrorLog.Clear();

            string moduleName = Path == null ? "__anonymous__"
                : System.IO.Path.GetFileNameWithoutExtension(Path);

            if (HasPath)
            {
                string wd      = System.IO.Path.GetDirectoryName(Path);
                string depPath = System.IO.Path.Combine(wd, ".deps");

                if (!context.SearchPath.Contains(wd))
                {
                    context.SearchPath.Add(wd);
                }

                if (!context.SearchPath.Contains(depPath))
                {
                    context.SearchPath.Add(depPath);
                }

                IodineModule cachedModule = null;

                if (LoadCachedModule(ref cachedModule))
                {
                    return(cachedModule);
                }
            }

            Parser parser = Parser.CreateParser(context, this);

            CompilationUnit root = parser.Parse();

            IodineCompiler compiler = IodineCompiler.CreateCompiler(context, root);

            IodineModule module = compiler.Compile(moduleName, Path);

            if (Path == null)
            {
                foreach (KeyValuePair <string, IodineObject> kv in module.Attributes)
                {
                    context.InteractiveLocals [kv.Key] = kv.Value;
                }
                module.Attributes = context.InteractiveLocals;
            }
            else if (context.ShouldCache)
            {
                CacheModule(module);
            }

            return(module);
        }