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; }
public void initialize() { Logger.Log($"Initializing ATS Module. Version: {Assembly.GetExecutingAssembly().GetName().Version}"); _mainThread.AddComponent <MainThreadManager>(); ModuleEnvironment.CheckEnvironment(); CoreManager.Init(); InitEvents(); }
private void PrintModule(ModuleEnvironment environment) { PrintStart("Module: " + environment.Identifier, ConsoleColor.Magenta); foreach (var(_, child) in environment.Modules) { PrintModule(child); } _indentationLevel--; PrintSymbols(environment.SymbolEnvironment); }
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(); } }
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; }
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(); }
public static void Print(ModuleEnvironment environment) { var printer = new EnvironmentPrinter(); printer.PrintModule(environment); }
public static void PrintSymbols(ModuleEnvironment environment) { EnvironmentPrinter.Print(environment); }
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(); } }
public CheckedUseStatement(ModuleEnvironment moduleEnvironment) { ModuleEnvironment = moduleEnvironment; }