Exemple #1
0
        private void ImportSymbolsIntoUnit(TranslationUnit unit)
        {
            foreach (var name in unit.Source.Imports)
            {
                unit.AddTask(() =>
                {
                    var sym = GlobalScope.FindNamedSymbol(name, Type.ModuleType, true);
                    if (sym == null)
                    {
                        return(Error.UnknownImport(name));
                    }
                    var mod = sym.GetValue <Module>();
                    if (mod == null)
                    {
                        throw new InvalidOperationException("imported module is not a constant!");
                    }

                    unit.Imports.Push(mod.Symbols);

                    return(CompilerError.None);
                });
            }
        }