Package macromedia.asc.util

Examples of macromedia.asc.util.Context


    }
  }

  private void verifyImportDefinitions(QNameSet imports, CompilerContext context)
  {
    Context cx = context.getAscContext();

    // imports contains only definitions that are available... it doesn't mean that they are linked in.
    for (Iterator i = imports.iterator(); i.hasNext(); )
    {
      QName qName = (QName) i.next();
      // verify import statements
      cx.addValidImport(qName.toString());
    }
  }
View Full Code Here


    private void inheritSlots(CompilationUnit unit, Set<Name> types, SymbolTable symbolTable)
  {
    CompilerContext context = unit.getContext();
    ProgramNode node = (ProgramNode) unit.getSyntaxTree();
    Context cx = context.getAscContext();
       
    @SuppressWarnings("unchecked")
    Set<String> processed = (Set<String>) context.getAttribute("processed");

    for (Name name : types)
View Full Code Here

* @author Jason Williams
*/
public class ManagedExtensionError implements Extension {

  public void parse1(CompilationUnit unit, TypeTable typeTable) {
    Context cx = unit.getContext().getAscContext();
    for (Iterator iter = unit.metadata.iterator(); iter.hasNext(); )
    {
      MetaDataNode metaDataNode = (MetaDataNode)iter.next();
      if (StandardDefs.MD_MANAGED.equals(metaDataNode.getId()))
      {
        LocalizationManager l10n = ThreadLocalToolkit.getLocalizationManager();
        cx.localizedError2(metaDataNode.pos(), new ManagedOnMXMLComponentError());
      }
    }
  }
View Full Code Here

    {
        if (unit.metadata.size() > 0)
        {
            Node node = (Node) unit.getSyntaxTree();
            CompilerContext context = unit.getContext();
            Context cx = context.getAscContext();
            EmbedSkinClassEvaluator embedSkinClassEvaluator = new EmbedSkinClassEvaluator(unit);
            node.evaluate(cx, embedSkinClassEvaluator);
        }
    }
View Full Code Here

                                                               transcoders, generatedOutputDir,
                                                               checkDeprecation);
            embedEvaluator.setLocalizationManager(ThreadLocalToolkit.getLocalizationManager());
            Node node = (Node) unit.getSyntaxTree();
            CompilerContext context = unit.getContext();
            Context cx = context.getAscContext();
            node.evaluate(cx, embedEvaluator);
        }
    }
View Full Code Here

     * @param endLines
     */
    public static void metaDataOnly(CompilationUnit unit, LineNumberMap map, int[] beginLines, int[] endLines)
    {
        ProgramNode node = (ProgramNode) unit.getSyntaxTree();
        Context cx = node.cx;
        StatementListNode stmts = node.statements;
        for (int i = 0, length = stmts.items == null ? 0 : stmts.items.size(); i < length; i++)
        {
            Node n = stmts.items.get(i);
            if (n instanceof DocCommentNode || !(n instanceof MetaDataNode))
View Full Code Here

                  namespaces                  = new HashSet<String>();

        final Map<QName, Map<String, Source>> dependents = new HashMap<QName, Map<String, Source>>();

        Set<Source> swcSources = swcContext.cachedSources();
        Context ascContext = null;

        if (perCompileData != null)
        {
            ascContext = new Context(perCompileData);
        }

        // put all the Source objects together
        final Set<Source> sources = new HashSet<Source>();
        {
            sources.addAll(swcSources);
            if (fileSpec != null)
                sources.addAll(fileSpec.sources());
            if (sourceList != null)
                sources.addAll(sourceList.sources().values());
            if (sourcePath != null)
                sources.addAll(sourcePath.sources().values());
            if (bundlePath != null)
                sources.addAll(bundlePath.sources().values());
            if (includedClasses != null)
                sources.addAll(includedClasses.values());
        }

        // build a dependency graph
        for (Source source : sources)
        {
            if (source.getName() == null)
            {
                continue;
            }

            CompilationUnit u = source.getCompilationUnit();

            if (u == null)
            {
                continue;
            }

            // collect the names of all the update file includes...
            for (Iterator j = source.getUpdatedFileIncludes(); j != null && j.hasNext();)
            {
                VirtualFile f = (VirtualFile) j.next();
                includeUpdated.add(f.getNameForReporting());
            }

            // register QName --> VirtualFile.getName()
            for (QName qName : u.topLevelDefinitions)
            {
                qNames.put(qName, source);
                dependents.put(qName, new HashMap<String, Source>());
            }
        }

        for (Source source : resources.sources().values())
        {
            if (source.getName() == null)
            {
                continue;
            }

            CompilationUnit u = source.getCompilationUnit();

            if (u == null)
            {
                continue;
            }

            // register QName --> VirtualFile.getName()
            for (QName qName : u.topLevelDefinitions)
            {
                qNames.put(qName, source);
            }
        }

        // setup inheritance-based dependencies...
        for (Source source : sources)
        {
            if (source == null) continue;

            CompilationUnit u = source.getCompilationUnit();
            if (u == null) continue;

            addDependents(source, u.inheritance, dependents);
            addDependents(source, u.namespaces, dependents);
            addDependents(source, u.types, dependents);
            addDependents(source, u.expressions, dependents);
        }

        Logger logger = ThreadLocalToolkit.getLogger();

        // if any of the Source objects in ResourceContainer is bad, obsolete the originating Source.
        for (Source source : resources.sources().values())
        {
            CompilationUnit u = source.getCompilationUnit();
            if (source.hasError() ||
                (u != null && !u.isDone() && !u.hasTypeInfo) ||
                source.isUpdated() ||
                (u != null && u.hasAssets() && u.getAssets().isUpdated()))
            {
                resourceDelegates.add(source.getNameForReporting());
                source.removeCompilationUnit();
            }
        }

        reportObsoletedSwcSources(swcContext, l10n, logger);
        reportShadowedSwcSources(swcSources, sourceList, sourcePath, resources, l10n, logger, sources);

        // identify obsolete CompilationUnit
        //   - NotFullyCompiled
        //   - SourceNoLongerExists
        //   - SourceFileUpdated
        //   - AssedUpdated
        for (Iterator<Source> iterator = sources.iterator(); iterator.hasNext();)
        {
            Source s = iterator.next();
            CompilationUnit u = s.getCompilationUnit();

            // Sources for internal classes like Object never reach the done state or have typeInfo.
            if (s.hasError() ||
                (!s.isInternal() && (u != null && !u.isDone() && !u.hasTypeInfo)) ||
                resourceDelegates.contains(s.getName()))
            {
                affected.put(s.getName(), s);
                reasons.put(s.getName(), l10n.getLocalizedTextString(new NotFullyCompiled()));
                iterator.remove();
            }
            else if (!s.exists())
            {
                updated.put(s.getName(), s);
                reasons.put(s.getName(), l10n.getLocalizedTextString(new SourceNoLongerExists()));

                if (u != null)
                {
                    for (QName qName : u.topLevelDefinitions)
                    {
                        namespaces.add(qName.toString());
                        deleted.put(qName, s);
                    }
                }

                iterator.remove();
            }
            else if (s.isUpdated())
            {
                // signature optimization:
                //     read the old signature from the incremental cache
                //     generate a new signature from the current source
                //     compare -- if stable, we don't have to recompile dependencies
                boolean signatureIsStable = false;
                if ((u != null) &&
                    (!configuration.getCompilerConfiguration().getDisableIncrementalOptimizations()) &&
                    // skip MXML sources:
                    //      MXML is too complicated to parse/codegen at this point in
                    //      order to generate and compare a new checksum
                    (!s.getMimeType().equals(MimeMappings.MXML)))
                {
                    final Long persistedCRC = u.getSignatureChecksum();
                    if (persistedCRC != null)
                    {
                        assert (s.getMimeType().equals(MimeMappings.ABC) ||
                                s.getMimeType().equals(MimeMappings.AS));

                        //TODO if we calculate a new checksum that does not match,
                        //     can we store this checksum and not recompute it later?
                        final Long currentCRC = computeSignatureChecksum(configuration, s);
                        signatureIsStable = (currentCRC != null) &&
                                            (persistedCRC.compareTo(currentCRC) == 0);

                        // if (SignatureExtension.debug)
                        // {
                        //     final String name = u.getSource().getName();
                        //     SignatureExtension.debug("*** FILE UPDATED: Signature "
                        //                                    + (signatureIsStable ? "IS" : "IS NOT")
                        //                                    + " stable ***");
                        //     SignatureExtension.debug("PERSISTED CRC32: " + persistedCRC + "\t--> " + name);
                        //     SignatureExtension.debug("CURRENT   CRC32: " + currentCRC   + "\t--> " + name);
                        // }
                    }
                }

                // if the class signature is stable (it has not changed since the last compile)
                // then we can invalidate and recompile the updated unit alone
                // otherwise we default to a chain reaction, invalidating _all_ dependent units
                if (signatureIsStable)
                {
                    updatedWithStableSignature.put(s.getName(), s);
                }
                else
                {
                    updated.put(s.getName(), s);
                }

                reasons.put(s.getName(), l10n.getLocalizedTextString(new SourceFileUpdated()));
                iterator.remove();
            }
            else if (u != null && u.hasAssets() && u.getAssets().isUpdated())
            {
                updated.put(s.getName(), s);
                reasons.put(s.getName(), l10n.getLocalizedTextString(new AssetUpdated()));
                iterator.remove();
            }
        }

        // permanently remove the deleted Source objects from SourcePath
        //
        // Note: this step is currently necessary because the location-updating loop that follows iterates over
        // 'sources', which has had deleted entries remove. So here we iterate directly over the deleted
        // entries. (Note also that 'reasons' already has an entry for this source.)
        //
        for (Source source : deleted.values())
        {
            if (source.isSourcePathOwner())
            {
                SourcePath sp = (SourcePath) source.getOwner();
                sp.removeSource(source);

                if (ascContext != null)
                {
                    CompilationUnit u = source.getCompilationUnit();

                    if (u != null)
                    {
                        for (QName defName : u.topLevelDefinitions)
                        {
                            ascContext.removeUserDefined(defName.toString());
                        }
                    }
                }
            }
        }
View Full Code Here

        return result;
    }

    public Value evaluate(Context unused_cx, ProgramNode node)
    {
        final Context cx = node.cx;

        // if we don't have a package, an error will be reported downstream.
        if ((node.pkgdefs != null) && !node.pkgdefs.isEmpty())
        {
            // TODO (why?) there can be multiple packages inside of a file for some reason
View Full Code Here

//    | |/ /  __/ | | | | | | | |_| | (_) | | | | |\  | (_) | (_| |  __/\__ \
//    |___/ \___|_| |_|_| |_|_|\__|_|\___/|_| |_\_| \_/\___/ \__,_|\___||___/

    public Value evaluate(Context unused_cx, ClassDefinitionNode node)
    {
        final Context cx = node.cx;

        if (humanReadable)
        {
            out.append(indent());
        }
View Full Code Here

        return null;
    }

    public Value evaluate(Context unused_cx, FunctionDefinitionNode node)
    {
        final Context cx = node.cx;

        // ATTRIBUTES
        // if (node.attrs != null)
        //     node.attrs.evaluate(cx, this);
View Full Code Here

TOP

Related Classes of macromedia.asc.util.Context

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.