Package flex2.compiler

Examples of flex2.compiler.CompilationUnit


        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.PARSE2, unit.getSource().getNameForReporting());
        }

      CompilationUnit ascUnit = (CompilationUnit) unit.getContext().getAttribute("ascUnit");
      Source.transferInheritance(unit, ascUnit);

      asc.parse2(ascUnit, symbolTable);     

    Source.transferAssets(ascUnit, unit);
View Full Code Here


        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.ANALYZE1, unit.getSource().getNameForReporting());
        }
       
      CompilationUnit ascUnit = (CompilationUnit) unit.getContext().getAttribute("ascUnit");
      asc.analyze1(ascUnit, symbolTable);

      Source.transferTypeInfo(ascUnit, unit);
      Source.transferNamespaces(ascUnit, unit);
View Full Code Here

        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.ANALYZE2, unit.getSource().getNameForReporting());
        }

        CompilationUnit ascUnit = (CompilationUnit) unit.getContext().getAttribute("ascUnit");
        Source.transferDependencies(unit, ascUnit);
        asc.analyze2(ascUnit, symbolTable);
        Source.transferDependencies(ascUnit, unit);

        if (benchmarkHelper != null)
View Full Code Here

        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.ANALYZE3, unit.getSource().getNameForReporting());
        }

        CompilationUnit ascUnit = (CompilationUnit) unit.getContext().getAttribute("ascUnit");
        Source.transferDependencies(unit, ascUnit);
        asc.analyze3(ascUnit, symbolTable);

        if (benchmarkHelper != null)
        {
View Full Code Here

        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.ANALYZE4, unit.getSource().getNameForReporting());
        }

        CompilationUnit ascUnit = (CompilationUnit) unit.getContext().getAttribute("ascUnit");
        asc.analyze4(ascUnit, symbolTable);
        Source.transferExpressions(ascUnit, unit);
      // Source.transferLoaderClassBase(ascUnit, unit);
      // Source.transferGeneratedSources(ascUnit, unit);
      // Source.transferClassTable(ascUnit, unit);
View Full Code Here

        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.GENERATE, unit.getSource().getNameForReporting());
        }

        CompilationUnit ascUnit = (CompilationUnit) unit.getContext().getAttribute("ascUnit");
        asc.generate(ascUnit, symbolTable);

        unit.bytes.clear();
        unit.bytes.addAll(ascUnit.bytes);
View Full Code Here

  public CompilationUnit parse1(Source source, SymbolTable symbolTable)
  {
        if (benchmarkHelper != null)
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.PARSE1, source.getNameForReporting());

    CompilationUnit unit = source.getCompilationUnit();

    if (unit != null && unit.hasTypeInfo)
    {
            if (unit.bytes.isEmpty())
            {
                copyBytecodes(source, unit);
            }

      return unit;
    }

    if ((unit != null) && (unit.getSyntaxTree() != null))
    {
      return unit;
    }

    final String path = source.getName();
    ProgramNode node = null;

    CompilerContext context = new CompilerContext();

    Context cx = new Context(symbolTable.perCompileData);

    cx.setScriptName(source.getName());
    cx.setPath(source.getParent());

    cx.setEmitter(symbolTable.emitter);
    cx.setHandler(new As3Compiler.CompilerHandler()
    {
      public void error2(String filename, int ln, int col, Object msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.log((flex2.compiler.util.CompilerMessage) msg, filename);
      }

      public void warning2(String filename, int ln, int col, Object msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.log((CompilerMessage) msg, filename);
      }

      public void error(String filename, int ln, int col, String msg, String source, int errorCode)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        if (errorCode != -1)
        {
          ThreadLocalToolkit.logError(filename, msg, errorCode);
        }
        else
        {
          ThreadLocalToolkit.logError(filename, msg);
        }
      }

      public void warning(String filename, int ln, int col, String msg, String source, int errorCode)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        if (errorCode != -1)
        {
          ThreadLocalToolkit.logWarning(filename, msg, errorCode);
        }
        else
        {
          ThreadLocalToolkit.logWarning(filename, msg);
        }
      }

      public void error(String filename, int ln, int col, String msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.logError(filename, msg);
      }

      public void warning(String filename, int ln, int col, String msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.logWarning(filename, msg);
      }

      public FileInclude findFileInclude(String parentPath, String filespec)
      {
        return null;
      }
    });
    symbolTable.perCompileData.handler = cx.getHandler();

    context.setAscContext(cx);

    byte[] abc = null;
    try
    {
      abc = source.toByteArray();

      if (abc == null)
      {
        abc = FileUtils.toByteArray(source.getInputStream());
      }

      if (abc == null || abc.length == 0)
      {
        ThreadLocalToolkit.log(new NoBytecodeIsAvailable(), source);
      }
      else
      {
          AbcParser parser = new AbcParser(cx, abc);
          node = parser.parseAbc();

                if (node == null && ThreadLocalToolkit.errorCount() == 0)
                {
                    ThreadLocalToolkit.log(new BytecodeDecodingFailed(), source);
                }

                As3Compiler.cleanNodeFactory(cx.getNodeFactory());
      }
    }
    catch (IOException ex)
    {
      ThreadLocalToolkit.logError(source.getNameForReporting(), ex.getLocalizedMessage());
    }

    if (ThreadLocalToolkit.errorCount() > 0)
    {
      return null;
    }

        if (unit == null)
        {
            unit = source.newCompilationUnit(node, context);
        }
        else
        {
            unit.setSyntaxTree(node);
            unit.getContext().setAttributes(context);
        }

    unit.bytes.set(abc, abc.length);

    SyntaxTreeEvaluator treeEvaluator = new SyntaxTreeEvaluator(unit);
View Full Code Here

      if (name instanceof flex2.compiler.util.QName)
      {
        flex2.compiler.util.QName qName = (flex2.compiler.util.QName) name;

        Source s = symbolTable.findSourceByQName(qName);
        CompilationUnit u = s.getCompilationUnit();
        if (unit == u)
        {
          continue;
        }
       
View Full Code Here

    CompilerContext context = new CompilerContext();

        // 1. parse/analyze MXML, or retrieve preparsed DOM
        // 2. add MXML syntax tree to a new CompilationUnit
        DocumentNode app;
        CompilationUnit unit;

        Object preparsedSyntaxTree = source.getSourceFragment(AttrInlineComponentSyntaxTree);
        if (preparsedSyntaxTree == null)
        {
            app = parseMXML(source);
            if (app == null)
            {
                return null;
            }

            unit = source.newCompilationUnit(app, context);

            // do more syntax checking, chase includes, etc.
            app.analyze(new SyntaxAnalyzer(unit, mxmlConfiguration));
            if (ThreadLocalToolkit.errorCount() > 0)
            {
                return null;
            }
        }
        else
        {
            assert preparsedSyntaxTree instanceof DocumentNode : "bogus preparsed root node passed to InterfaceCompiler";
            app = (DocumentNode) preparsedSyntaxTree;
            unit = source.newCompilationUnit(app, context);
        }

        unit.getContext().setAttribute(DOCUMENT_NODE, app);

        //  start a new DocumentInfo. this will accumulate document state as compilation proceeds
        DocumentInfo docInfo = createDocumentInfo(unit, app, source);
        if (ThreadLocalToolkit.errorCount() > 0)
        {
            return null;
        }

        unit.getContext().setAttribute(MxmlCompiler.DOCUMENT_INFO, docInfo);
        unit.topLevelDefinitions.add(new QName(docInfo.getPackageName(), docInfo.getClassName()));
        transferDependencies(docInfo, unit.inheritance, unit.inheritanceHistory);

        return unit;
    }
View Full Code Here

      map.setNewName(newSource.getName());
    }

    //  use ASC to produce new CU for generated interface source. Will be managed by "outer" MXML CU
    CompilationUnit interfaceUnit = compileInterface(newSource, source, docInfo, map, symbolTable);

    if (interfaceUnit != null)
    {
      //  transfer includes from the interface unit to the real MXML unit
      unit.getSource().addFileIncludes(interfaceUnit.getSource());

            //  InterfaceUnit, LineNumberMap are used in subsequent phases of InterfaceCompiler
            unit.getContext().setAttribute(MxmlCompiler.LINE_NUMBER_MAP, map);
            unit.getContext().setAttribute(MxmlCompiler.DELEGATE_UNIT, interfaceUnit);
View Full Code Here

TOP

Related Classes of flex2.compiler.CompilationUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.