コード例 #1
0
        public CheckedClassDeclStatement(Token identifier,
                                         List <IDataType>?typeArguments,
                                         SymbolEnvironment environment,
                                         ModuleEnvironment module,
                                         StructType?ancestor  = null,
                                         bool shouldBeEmitted = true)
        {
            Identifier      = identifier;
            TypeArguments   = typeArguments;
            Environment     = environment;
            InheritedType   = ancestor;
            Module          = module;
            DataType        = new StructType(TypeKeyword.Identifier, typeArguments, this);
            ShouldBeEmitted = shouldBeEmitted;

            CheckedClassDeclStatement?inheritedClass = this;

            while (inheritedClass.Inherited != null)
            {
                inheritedClass = inheritedClass.Inherited;
            }

            Id = inheritedClass == this
                ? 0
                : ++inheritedClass._highestClassId;
        }
コード例 #2
0
        public void initialize()
        {
            Logger.Log($"Initializing ATS Module. Version: {Assembly.GetExecutingAssembly().GetName().Version}");

            _mainThread.AddComponent <MainThreadManager>();
            ModuleEnvironment.CheckEnvironment();
            CoreManager.Init();
            InitEvents();
        }
コード例 #3
0
        private void PrintModule(ModuleEnvironment environment)
        {
            PrintStart("Module: " + environment.Identifier, ConsoleColor.Magenta);
            foreach (var(_, child) in environment.Modules)
            {
                PrintModule(child);
            }

            _indentationLevel--;
            PrintSymbols(environment.SymbolEnvironment);
        }
コード例 #4
0
ファイル: ObjectPrinter.cs プロジェクト: PaddiM8/Caique
        public static void PrintAst(ModuleEnvironment environment)
        {
            foreach (var(_, child) in environment.Modules)
            {
                PrintAst(child);
            }

            if (environment.Ast != null)
            {
                PrintIdentifier(environment.Identifier);
                AstPrinter.Print(environment.Ast);
                Console.WriteLine();
            }
        }
コード例 #5
0
ファイル: ClassDeclStatement.cs プロジェクト: PaddiM8/Caique
 public ClassDeclStatement(Token identifier,
                           List <Token>?typeParameters,
                           BlockExpression body,
                           TextSpan span,
                           ModuleEnvironment moduleEnvironment,
                           SymbolEnvironment symbolEnvironment,
                           TypeExpression?ancestor            = null,
                           FunctionDeclStatement?initFunction = null) : base(span)
 {
     Identifier        = identifier;
     TypeParameters    = typeParameters;
     Body              = body;
     InheritedType     = ancestor;
     Module            = moduleEnvironment;
     SymbolEnvironment = symbolEnvironment;
     InitFunction      = initFunction;
 }
コード例 #6
0
ファイル: ObjectPrinter.cs プロジェクト: PaddiM8/Caique
        public static void PrintTokens(ModuleEnvironment environment)
        {
            foreach (var(_, child) in environment.Modules)
            {
                PrintTokens(child);
            }

            if (environment.Tokens == null)
            {
                return;
            }

            PrintIdentifier(environment.Identifier);
            foreach (var token in environment.Tokens)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write(token.Kind);
                Console.ResetColor();

                if (!string.IsNullOrEmpty(token.Value))
                {
                    Console.Write($": {token.Value}");
                }

                Console.Write(" | (");
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.Write(
                    "{0}:{1}",
                    token.Span.Start.Line,
                    token.Span.Start.Column
                    );
                Console.ResetColor();
                Console.Write(") -> (");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write(
                    "{0}:{1}",
                    token.Span.End.Line,
                    token.Span.End.Column
                    );
                Console.ResetColor();
                Console.WriteLine(")");
            }

            Console.WriteLine();
        }
コード例 #7
0
        public static void Print(ModuleEnvironment environment)
        {
            var printer = new EnvironmentPrinter();

            printer.PrintModule(environment);
        }
コード例 #8
0
ファイル: ObjectPrinter.cs プロジェクト: PaddiM8/Caique
 public static void PrintSymbols(ModuleEnvironment environment)
 {
     EnvironmentPrinter.Print(environment);
 }
コード例 #9
0
ファイル: Compilation.cs プロジェクト: PaddiM8/Caique
        public void Compile(string targetPath)
        {
            string preludePath = Path.Combine(_libraryPaths["core"], "../prelude/src");
            var    prelude     = new ModuleEnvironment(
                "prelude",
                preludePath,
                targetPath,
                new Dictionary <string, string>(),
                Diagnostics,
                null
                );

            prelude.CreateChildModule(
                "lib",
                Path.Combine(preludePath, "lib.cq")
                );

            var rootModule = new ModuleEnvironment(
                "root",
                _rootPath,
                targetPath,
                _libraryPaths,
                Diagnostics,
                prelude
                );

            // Parsing, type checking, and code generation is done on the fly
            // in ModuleEnvironment
            rootModule.CreateChildModule(
                "main",
                Path.Combine(_rootPath, "main.cq")
                );

            // Code generation
            prelude.GenerateSymbols();
            rootModule.GenerateSymbols();
            prelude.GenerateContent();
            rootModule.GenerateContent();

            var outputType = PrintLlvm
                ? OutputKind.IntermediateRepresentation
                : OutputKind.ObjectFile;

            prelude.Emit(outputType);
            rootModule.Emit(outputType);

            if (PrintTokens)
            {
                ObjectPrinter.PrintTokens(rootModule);
            }
            if (PrintAst)
            {
                ObjectPrinter.PrintAst(rootModule);
            }
            if (PrintEnvironment)
            {
                ObjectPrinter.PrintSymbols(rootModule);
            }

            foreach (var diagnostic in Diagnostics)
            {
                diagnostic.Print();
            }
        }
コード例 #10
0
ファイル: CheckedUseStatement.cs プロジェクト: PaddiM8/Caique
 public CheckedUseStatement(ModuleEnvironment moduleEnvironment)
 {
     ModuleEnvironment = moduleEnvironment;
 }