Пример #1
0
        internal OsloCodeGeneratorInfo(OsloCodeGeneratorInfo root, string fileName)
        {
            this.CodeParser = root.CodeParser;
            this.TemplateParser = root.TemplateParser;
            this.CodePrinter = root.CodePrinter;
            this.ErrorReporter = root.ErrorReporter;

            this.References = new SortedSet<string>();
            this.Usings = new SortedSet<string>();
            this.Imports = new SortedSet<string>();
            this.Includes = new List<OsloCodeGeneratorInfo>();

            this.IgnoreIncludes = root.IgnoreIncludes;

            this.FileName = Path.GetFullPath(fileName);
            if (!File.Exists(this.FileName))
            {
                this.ErrorReporter.Error("File not found: {0}", fileName);
            }
            this.Program = this.CodeParser.Parse(new StreamReader(this.FileName), this.ErrorReporter);
        }
Пример #2
0
 public void Process_Include(dynamic node)
 {
     if (this.codeGenerator.IgnoreIncludes) return;
     string includeFileName = node.FileName;
     if (includeFileName.Length < 2)
     {
         this.rootCodeGenerator.ErrorReporter.Error("Invalid include '{0}' in '{1}'.", includeFileName, this.codeGenerator.FileName);
     }
     includeFileName = includeFileName.Substring(1, includeFileName.Length - 2);
     string includeFilePath = Path.Combine(Path.GetDirectoryName(this.codeGenerator.FileName), includeFileName);
     bool includedAlready = this.rootCodeGenerator.Includes.Where(imp => imp.FileName == includeFilePath).Count() > 0;
     if (!includedAlready)
     {
         OsloCodeGeneratorInfo include = new OsloCodeGeneratorInfo(this.rootCodeGenerator, includeFilePath);
         this.rootCodeGenerator.Includes.Add(include);
         new OsloCodeGeneratorUsingProcessor(this.rootCodeGenerator, include).Process(include.Program);
     }
 }
Пример #3
0
        public OsloCodeGeneratorPrintProcessor(OsloCodeGeneratorInfo rootCodeGenerator, OsloCodeGeneratorInfo codeGenerator)
        {
            this.rootCodeGenerator = rootCodeGenerator;
            this.codeGenerator = codeGenerator;
            this.CodePrinter = this.rootCodeGenerator.CodePrinter;
            if (this.codeGenerator != null && this.codeGenerator.FileName != null)
            {
                this.fileName = Path.GetFileName(this.codeGenerator.FileName);
            }

            this.loopStack = new Stack<LoopScope>();
            this.nameStack = new Stack<NameScope>();
            this.functionNames = new NameScope();

            this.functionCounter = 0;
        }
Пример #4
0
 public OsloCodeGeneratorUsingProcessor(OsloCodeGeneratorInfo rootCodeGenerator, OsloCodeGeneratorInfo codeGenerator)
 {
     this.rootCodeGenerator = rootCodeGenerator;
     this.codeGenerator = codeGenerator;
 }