Package flex2.compiler

Examples of flex2.compiler.CompilationUnit


    /**
     * run asc.analyze1() on unit's private AS unit representing the public signature, shuttling results back to outer unit
     */
    public void analyze1(CompilationUnit unit, SymbolTable symbolTable)
    {
    CompilationUnit interfaceUnit = (CompilationUnit) unit.getContext().getAttribute(MxmlCompiler.DELEGATE_UNIT);

    Logger original = setLogAdapter(unit);
        asc.analyze1(interfaceUnit, symbolTable);
        ThreadLocalToolkit.setLogger(original);

View Full Code Here


    /**
     * run asc.analyze1() on unit's private AS unit representing the public signature, shuttling results back to outer unit
     */
    public void analyze2(CompilationUnit unit, SymbolTable symbolTable)
    {
    CompilationUnit interfaceUnit = (CompilationUnit) unit.getContext().getAttribute(MxmlCompiler.DELEGATE_UNIT);
        Source.transferDependencies(unit, interfaceUnit);
       
    Logger original = setLogAdapter(unit);
        asc.analyze2(interfaceUnit, symbolTable);
        ThreadLocalToolkit.setLogger(original);
View Full Code Here

        Source.transferDependencies(interfaceUnit, unit);
    }

    public void analyze3(CompilationUnit unit, SymbolTable symbolTable)
    {
    CompilationUnit interfaceUnit = (CompilationUnit) unit.getContext().getAttribute(MxmlCompiler.DELEGATE_UNIT);

        // C: unit.importDefinitionStatements has no bogus statements
        //    interfaceUnit.importDefinitionStatements may have bogus statements.
        QNameSet importDefinitionStatements = new QNameSet(interfaceUnit.importDefinitionStatements);
View Full Code Here

    /**
     * run asc.analyze1() on unit's private AS unit representing the public signature, shuttling results back to outer unit
     */
    public void analyze4(CompilationUnit unit, SymbolTable symbolTable)
    {
    CompilationUnit interfaceUnit = (CompilationUnit) unit.getContext().getAttribute(MxmlCompiler.DELEGATE_UNIT);

    Logger original = setLogAdapter(unit);
        asc.analyze4(interfaceUnit, symbolTable);
        ThreadLocalToolkit.setLogger(original);

View Full Code Here

    MxmlLogAdapter adapter = new MxmlLogAdapter(original, map);
    adapter.addLineNumberMaps(origSource.getSourceFragmentLineMaps());
    ThreadLocalToolkit.setLogger(adapter);
    }

    CompilationUnit interfaceUnit = asc.parse1(newSource, symbolTable);
        //  performance: strip non-signature code from parse tree; it's not needed in the Interface pass
        SyntaxTreeEvaluator.removeNonAPIContent(interfaceUnit);

        //  make sure management vars only occur once in class chain
View Full Code Here

            Map<String, SwcComponent> allClassComp = new HashMap<String, SwcComponent>();
            //Map refClassComp = new HashMap();

            for (Iterator e = m.getExportedUnits().iterator(); e.hasNext();)
            {
                CompilationUnit unit = (CompilationUnit) e.next();
                if (unit.getSource().isSwcScriptOwner())
                {
                    Swc unitswc = ((SwcScript) unit.getSource().getOwner()).getLibrary().getSwc();
                    for (Iterator ci = unitswc.getComponentIterator(); ci.hasNext();)
                    {
                        SwcComponent c = (SwcComponent) ci.next();
                        allClassComp.put( c.getClassName(), c );
                    }
                }
            }

            for (Iterator nsc = nsComponents.iterator(); nsc.hasNext();)
            {
                SwcComponent c = (SwcComponent) nsc.next();
                allClassComp.put(c.getClassName(), c);
            }

            // Now pare this down to just referenced classes (and thus components)

            for (Iterator e = m.getExportedUnits().iterator(); e.hasNext();)
            {
                CompilationUnit unit = (CompilationUnit) e.next();
                for (int i = 0, s = unit.topLevelDefinitions.size();i < s; i++)
                {
                    String def = unit.topLevelDefinitions.get(i).toString();
                    if (allClassComp.containsKey( def ))
                    {
View Full Code Here

        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.PARSE1, source.getNameForReporting());
        }

        CompilationUnit unit = source.getCompilationUnit();

        if (unit != null && unit.hasTypeInfo)
        {
            return unit;
        }
       
        // System.out.println("parse1: " + source.getNameForReporting());
        FontManager fontManager = configuration.getFontsConfiguration().getTopLevelManager();

        StyleSheet styleSheet = new StyleSheet();
        styleSheet.checkDeprecation(configuration.showDeprecationWarnings());

        InputStream in = null;
        try
        {
            in = source.getInputStream();
            styleSheet.parse(source.getName(),
                             in,
                             ThreadLocalToolkit.getLogger(),
                             fontManager);
        }
        catch (Exception exception)
        {
            if (Trace.error)
            {
                exception.printStackTrace();
            }

            ParseError parseError = new ParseError(exception.getLocalizedMessage());
            parseError.setPath(source.getName());
            ThreadLocalToolkit.log(parseError);
            return null;
        }
        finally
        {
            if (in != null)
            {
                try
                {
                    in.close();
                }
                catch (IOException ex)
                {

                }
            }
        }       

        if (styleSheet.errorsExist())
        {
            // Error
            ThreadLocalToolkit.getLogger().log(new StyleSheetParseError(source.getName()));
        }

        StyleModule styleModule = new StyleModule(source, symbolTable.perCompileData);

        // Flex3 and earlier didn't support qualified types or advanced css.
        if (configuration.getCompatibilityVersion() <= flex2.compiler.common.MxmlConfiguration.VERSION_3_0)
        {
            styleModule.setAdvanced(false);
            styleModule.setQualifiedTypeSelectors(false);
        }
        else
        {
            styleModule.setQualifiedTypeSelectors(configuration.getQualifiedTypeSelectors());
        }

        styleModule.setNameMappings(nameMappings);
        String styleName = generateStyleName(source);
        styleModule.setName(styleName);
        styleModule.extractStyles(styleSheet, false);

        CompilerContext context = new CompilerContext();

        CompilationUnit cssCompilationUnit = source.newCompilationUnit(null, context);

        VirtualFile generatedFile = generateSourceCodeFile(cssCompilationUnit, styleModule);

        Source generatedSource = new Source(generatedFile, source);

        // when building a SWC, we want to locate all the asset sources and ask compc to put them in the SWC.
        Collection<AtEmbed> atEmbeds = styleModule.getAtEmbeds();
        if (atEmbeds != null && configuration.archiveClassesAndAssets())
        {
          Map<String, LocalFile> archiveFiles = new HashMap<String, LocalFile>();
          for (Iterator<AtEmbed>  i = atEmbeds.iterator(); i.hasNext(); )
          {
            AtEmbed e = (AtEmbed) i.next();
            String src = (String) e.getAttributes().get(Transcoder.SOURCE);
            String original = (String) e.getAttributes().get(Transcoder.ORIGINAL);
            if (src != null)
            {
              archiveFiles.put(original, new LocalFile(new File(src)));
            }
          }
          if (archiveFiles.size() > 0)
          {
            context.setAttribute(CompilerContext.CSS_ARCHIVE_FILES, archiveFiles);
          }
        }
       
        // Use MxmlLogAdapter to do filtering, e.g. -generated.as -> .css, as line -> css
        // line, etc...
        Logger original = ThreadLocalToolkit.getLogger();
        LineNumberMap lineNumberMap = styleModule.getLineNumberMap();
        Logger adapter = new MxmlLogAdapter(original, lineNumberMap);
        ThreadLocalToolkit.setLogger(adapter);

        CompilationUnit ascCompilationUnit = delegateSubCompiler.parse1(generatedSource, symbolTable);

        if (ascCompilationUnit != null)
        {
            // transfer includes from the ASC unit to the CSS unit
            cssCompilationUnit.getSource().addFileIncludes(ascCompilationUnit.getSource());
            context.setAttribute(DELEGATE_UNIT, ascCompilationUnit);
            context.setAttribute(LINE_NUMBER_MAP, lineNumberMap);
            Source.transferMetaData(ascCompilationUnit, cssCompilationUnit);
            Source.transferGeneratedSources(ascCompilationUnit, cssCompilationUnit);
            Source.transferDefinitions(ascCompilationUnit, cssCompilationUnit);
View Full Code Here

        if (benchmarkHelper != null)
        {
            benchmarkHelper.startPhase(CompilerBenchmarkHelper.PARSE1, source.getNameForReporting());
        }

    CompilationUnit unit = source.getCompilationUnit();

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

    String path = source.getName();
    ProgramNode node = null;
        CompilerContext context = null;
        Context cx;

        if ((unit != null) && (unit.getSyntaxTree() != null))
        {
            node = (ProgramNode) unit.getSyntaxTree();
            cx = node.cx;
        }
        else
        {
            context = new CompilerContext();
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

        Set<String> externs = configuration.getExterns();
        ArrayList<Long> checksumList = new ArrayList<Long>(units.size());

      for (int i = 0, size = units == null ? 0 : units.size(); i < size; i++)
      {
        CompilationUnit u = (CompilationUnit) units.get(i);
        if (u != null && !PreLink.isCompilationUnitExternal(u, externs) &&
          !u.getSource().isInternal())
        {
          if (isAccessible) {
              Set<String> unitAccessibilityList = u.getAccessibilityClasses();
              if (unitAccessibilityList != null)
              {
                accessibilityList.addAll(unitAccessibilityList);
              }
          }

                if (u.hasAssets())
                {
                    // don't add font assets for definitions that have been externed.
                    List<DefineFont> fontList = u.getAssets().getFonts();
                    if (fontList != null && !fontList.isEmpty())
                    {
                        fonts.addAll(fontList);    // save for later...
                    }
                }

                if (u.getSignatureChecksum() != null)
                    checksumList.add(u.getSignatureChecksum());
        }
      }

      if (accessibilityList.size() > 0)
      {
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.