incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject svn commit: r1413061 [12/14] - in /incubator/flex/falcon/trunk/compiler.js: ./ bin/ build/ in/ intermediates/ localization/ localization/src/ localization/src/org/ localization/src/org/apache/ localization/src/org/apache/flex/ localization/src/org/apac...
Date Fri, 23 Nov 2012 20:58:56 GMT
Added: incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSCompilationUnit.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSCompilationUnit.java?rev=1413061&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSCompilationUnit.java
(added)
+++ incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSCompilationUnit.java
Fri Nov 23 20:58:50 2012
@@ -0,0 +1,239 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.driver;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.flex.compiler.common.DependencyType;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.as.codegen.JSGeneratingReducer;
+import org.apache.flex.compiler.internal.as.codegen.JSGenerator;
+import org.apache.flex.compiler.internal.as.codegen.JSSharedData;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.DefinitionPriority;
+import org.apache.flex.compiler.internal.scopes.ASProjectScope;
+import org.apache.flex.compiler.internal.units.ASCompilationUnit;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.units.requests.IABCBytesRequestResult;
+import org.apache.flex.compiler.units.requests.IOutgoingDependenciesRequestResult;
+import org.apache.flex.compiler.units.requests.ISyntaxTreeRequestResult;
+
+/**
+ * JSCompilationUnit is the CompilationUnit for compiling ActionScript source
+ * files to JavasScript. JSCompilationUnit is derived from ASCompilationUnit and
+ * overrides the parts that generate the code. JSCompilationUnit also supports
+ * requests for two-pass compilation (see m_needsSecondPass).
+ * JSSourceFileHandler provides JSCompilationUnit for *.as files. JSDriver
+ * registers JSSourceFileHandler at FlexApplicationProject. This implementation
+ * is part of FalconJS. For more details on FalconJS see
+ * org.apache.flex.compiler.JSDriver
+ */
+
+public class JSCompilationUnit extends ASCompilationUnit
+{
+    private IABCBytesRequestResult m_abcBytes = null;
+    private Boolean m_needsSecondPass = false;
+    private Boolean m_inCodeGen = false;
+
+    /**
+     * Create a compilation unit from an ABC file.
+     * 
+     * @param project compiler project
+     * @param path ABC file path
+     * @throws IOException error
+     */
+    public JSCompilationUnit(CompilerProject project, String path) throws IOException
+    {
+        this(project, path, DefinitionPriority.BasePriority.LIBRARY_PATH);
+    }
+
+    public JSCompilationUnit(CompilerProject project, String path, DefinitionPriority.BasePriority
basePriority)
+    {
+        super(project, path, basePriority);
+    }
+
+    public JSCompilationUnit(CompilerProject project, String path, DefinitionPriority.BasePriority
basePriority, String qname)
+    {
+        super(project, path, basePriority, 0, qname);
+    }
+
+    protected IABCBytesRequestResult _handleABCBytesRequest(Operation buildPhase) throws
InterruptedException
+    {
+        // If JSEmitter.needsSecondPass() returns true, JSGenerator.generate() will return
null during scanning, 
+        // which will result in JSCompilationUnit::handleSemanticProblemsRequest not caching
any abcBytes for 
+        // handleABCBytesRequest. The net result is that JSGenerator.generate() will be called
again in handleABCBytesRequest. 
+        // This mechanic will ensure selective two-pass compilation. 
+        if (m_abcBytes != null &&
+            !JSSharedData.instance.hasSymbols() && // Symbol support
+            !JSSharedData.instance.hasAnyClassInit()) // support for class inits 
+            return m_abcBytes;
+
+        JSGenerator jsGenerator = new JSGenerator();
+        jsGenerator.m_compilationUnit = this;
+        jsGenerator.setBuildPhase(buildPhase);
+
+        // Need to force the file scope request to happen first to get the ASFileScope
+        // for this compilation unit registered with the project.
+        // ** TODO this is a hack!
+        getFileScopeRequest().get();
+
+        // This is also a hack!  If there are embed directives, need to ensure
+        // semantic pass has finished, as that is what will generate the embed classes
+        // which are needed by codegen
+        if (buildPhase != Operation.GET_SEMANTIC_PROBLEMS)
+        {
+        	// AJH this was deadlocking as getOutgoingDependencies calls handleABCBytes
+        	if (buildPhase != Operation.GET_ABC_BYTES)
+        		getOutgoingDependenciesRequest().get();
+        }
+
+        final ISyntaxTreeRequestResult fsr = getSyntaxTreeRequest().get();
+        final IASNode rootNode = fsr.getAST();
+
+        startProfile(buildPhase);
+        IABCBytesRequestResult result = jsGenerator.generate(getFilenameNoPath(), rootNode,
this.getProject());
+        stopProfile(buildPhase);
+
+        m_needsSecondPass = jsGenerator.needsSecondPass();
+
+        return result;
+    }
+
+    @Override
+    protected IABCBytesRequestResult handleABCBytesRequest() throws InterruptedException
+    {
+        final IABCBytesRequestResult result = _handleABCBytesRequest(Operation.GET_ABC_BYTES);
+
+        /*
+         * // explicitly reference all classes this class depends on if(
+         * result.getProblems() == null || result.getProblems().length == 0 ) {
+         * final String code = new String( result.getABCBytes() ); if(
+         * code.contains(JSSharedData.REQUIRED_TAG_MARKER) ) { final
+         * ICompilationUnit cu = this; final Set<ICompilationUnit> deps = new
+         * HashSet<ICompilationUnit>(); deps.addAll(
+         * getProject().getDependencies(cu) ); if( !deps.isEmpty() ) { String
+         * depNames = ""; Boolean separator = false; final List<IDefinition>
+         * defs = MXMLJSC.getClassDefinitions( cu ); for( IDefinition def: defs
+         * ) { if( def instanceof ClassDefinition ) { final String defName =
+         * JSGeneratingReducer.createFullNameFromDefinition(def); if( defName !=
+         * null && !defName.isEmpty() ) { if( separator ) depNames += ":"; else
+         * separator = true; depNames += defName; } } }
+         * code.replaceFirst(JSSharedData.REQUIRED_TAG_MARKER, depNames); return
+         * new ABCBytesRequestResult(code.getBytes(), result.getProblems()); } }
+         * }
+         */
+        return result;
+    }
+
+    @Override
+    protected IOutgoingDependenciesRequestResult handleOutgoingDependenciesRequest() throws
InterruptedException
+    {
+        // Every CU is dependent on the class glue, which is implemented in browser.adobe.
+        // Add dependency from this JSCompilationUnit to browser.adobe's JSCompilationUnit.
+        addDependency(JSSharedData.JS_FRAMEWORK_NAME, DependencyType.INHERITANCE);
+        addDependency(JSSharedData.FRAMEWORK_CLASS, DependencyType.INHERITANCE);
+
+        IOutgoingDependenciesRequestResult result = super.handleOutgoingDependenciesRequest();
+
+        // SWFTarget::startBuildAndFindAllCompilationUnits() is called by SWFTarget::collectProblems(),
which is called by SWFTarget::addToSWF() in JSDriver::main().
+        // This is our first pass. jsGenerator.generate() will return null if JSGeneratingReducer.getMember

+        // If JSEmitter.needsSecondPass() returns true, JSGenerator.generate() will return
null during scanning, 
+        // which will result in JSCompilationUnit::handleSemanticProblemsRequest not caching
any abcBytes for 
+        // handleABCBytesRequest. The net result is that JSGenerator.generate() will be called
again in handleABCBytesRequest. 
+        // This mechanic will ensure selective two-pass compilation. 
+        if (result.getProblems().length == 0)
+        {
+            m_needsSecondPass = false;
+            m_abcBytes = _handleABCBytesRequest(Operation.GET_SEMANTIC_PROBLEMS);
+            if (m_needsSecondPass)
+                m_abcBytes = null;
+        }
+
+        return result;
+    }
+
+    public Boolean addDependency(String className, DependencyType dt)
+    {
+        if (JSGeneratingReducer.isReservedDataType(className))
+            return false;
+
+        final ICompilationUnit fromCU = this;
+        final CompilerProject compilerProject = this.getProject();
+        final ASProjectScope projectScope = compilerProject.getScope();
+
+        final IDefinition classDef = projectScope.findDefinitionByName(className);
+        if (classDef == null)
+            return false;
+
+        final ICompilationUnit toCU = projectScope.getCompilationUnitForDefinition(classDef);
+        if (fromCU == toCU)
+            return false;
+
+        // sharedData.verboseMessage( "Adding dependency: " + className );
+        compilerProject.addDependency(fromCU, toCU, dt);
+
+        return true;
+    }
+
+    @Override
+    public void startBuildAsync(TargetType targetType)
+    {
+        // super.startBuildAsync(targetType);
+
+        getSyntaxTreeRequest();
+        getFileScopeRequest();
+        getOutgoingDependenciesRequest();
+
+        // scanning and code generating phases need to be separated
+        // in order to create two distinct passes for m_needSecondPass.
+        if (m_inCodeGen)
+        {
+            getABCBytesRequest();
+            getSWFTagsRequest();
+        }
+    }
+
+    @Override
+    public void waitForBuildFinish(final Collection<ICompilerProblem> problems, TargetType
targetType) throws InterruptedException
+    {
+        m_inCodeGen = true;
+        super.waitForBuildFinish(problems, targetType);
+        m_inCodeGen = false;
+        /*
+         * assert problems != null :
+         * "Expected 'problems'. Do not ignore problems."; //$NON-NLS-1$
+         * Collections.addAll(problems,
+         * getSyntaxTreeRequest().get().getProblems());
+         * Collections.addAll(problems,
+         * getFileScopeRequest().get().getProblems());
+         * Collections.addAll(problems,
+         * getSemanticProblemsRequest().get().getProblems());
+         * Collections.addAll(problems,
+         * getABCBytesRequest().get().getProblems());
+         * Collections.addAll(problems,
+         * getSWFTagsRequest().get().getProblems());
+         */
+    }
+
+}

Propchange: incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSCompilationUnit.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSSourceFileHandler.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSSourceFileHandler.java?rev=1413061&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSSourceFileHandler.java
(added)
+++ incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSSourceFileHandler.java
Fri Nov 23 20:58:50 2012
@@ -0,0 +1,82 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.driver;
+
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.DefinitionPriority;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.units.ICompilationUnit;
+
+/**
+ * Implementation of ISourceFileHandler that constructs
+ * {@link ASCompilationUnit}'s. JSSourceFileHandler is the SourceFileHandler
+ * that provides JSCompilationUnit for *.as files. JSDriver registers
+ * JSSourceFileHandler at FlexApplicationProject. This implementation is part of
+ * FalconJS. For more details on FalconJS see org.apache.flex.compiler.JSDriver
+ */
+public final class JSSourceFileHandler implements ISourceFileHandler
+{
+
+    public static final String EXTENSION = "as"; //$NON-NLS-1$
+    public static final JSSourceFileHandler INSTANCE = new JSSourceFileHandler();
+
+    private JSSourceFileHandler()
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getExtensions()
+    {
+        return new String[] {EXTENSION};
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ICompilationUnit createCompilationUnit(CompilerProject proj,
+                                                  String path,
+                                                  DefinitionPriority.BasePriority basePriority,
+                                                  int order,
+                                                  String qname,
+                                                  String locale)
+    {
+        return new JSCompilationUnit(proj, path, basePriority, qname);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean needCompilationUnit(CompilerProject project, String path, String qname,
String locale)
+    {
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean canCreateInvisibleCompilationUnit()
+    {
+        return false;
+    }
+}

Propchange: incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSSourceFileHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSTarget.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSTarget.java?rev=1413061&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSTarget.java
(added)
+++ incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSTarget.java
Fri Nov 23 20:58:50 2012
@@ -0,0 +1,322 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.driver;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.flex.abc.ABCLinker.ABCLinkerSettings;
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.exceptions.BuildCanceledException;
+import org.apache.flex.compiler.internal.as.codegen.JSGeneratingReducer;
+import org.apache.flex.compiler.internal.as.codegen.JSSharedData;
+import org.apache.flex.compiler.internal.definitions.DefinitionBase;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.targets.AppSWFTarget;
+import org.apache.flex.compiler.internal.targets.Target;
+import org.apache.flex.compiler.internal.units.ResourceBundleCompilationUnit;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.UnableToBuildSWFTagProblem;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.swf.ISWF;
+import org.apache.flex.swf.SWFFrame;
+import org.apache.flex.swf.tags.DoABCTag;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Concrete implementation of ITarget for building a collection of source files
+ * into a SWF.
+ */
+
+public class JSTarget extends AppSWFTarget
+{
+    private ICompilationUnit mainCU;
+    
+    /**
+     * Initialize a SWF target with the owner project and root compilation
+     * units.
+     * 
+     * @param project the owner project
+     */
+
+    public JSTarget(CompilerProject project, ITargetSettings targetSettings, ITargetProgressMonitor
progressMonitor)
+    {
+        super(project, targetSettings, progressMonitor);
+    }
+
+    /*
+     * private void printDefinitionsFromCompilationUnit( ICompilationUnit cu )
+     * throws InterruptedException { final List<IDefinition> defs =
+     * MXMLJSC.getDefinitions(cu, true); String s = cu.toString() + ": " +
+     * cu.getShortNames(); JSSharedData.instance.verboseMessage(s); }
+     */
+
+    protected void buildAndCollectProblems(
+            final Set<ICompilationUnit> compilationUnits,
+            final Collection<ICompilerProblem> problems)
+            throws InterruptedException
+    {
+        final JSSharedData sharedData = JSSharedData.instance;
+        sharedData.beginCodeGen();
+
+        BuiltCompilationUnitSet builtCompilationUnits = getBuiltCompilationUnitSet();
+
+        if (JSSharedData.OUTPUT_ISOLATED)
+        {
+            final ICompilationUnit rootCU = getRootClassCompilationUnit();
+            compilationUnits.clear();
+            compilationUnits.add(rootCU);
+        }
+        else
+        {
+            final List<ICompilationUnit> allUnits = new ArrayList<ICompilationUnit>();
+            allUnits.addAll(project.getReachableCompilationUnitsInSWFOrder(builtCompilationUnits.compilationUnits));
+            final List<ICompilationUnit> cuList = sortCompilationUnits(allUnits);
+            compilationUnits.clear();
+            for (ICompilationUnit cu : cuList)
+                compilationUnits.add(cu);
+        }
+        sharedData.endCodeGen();
+    }
+
+    public ISWF build(ICompilationUnit mainCU, Collection<ICompilerProblem> problems)
+    {
+        this.mainCU = mainCU;
+        return build(problems);
+    }
+    
+    @Override
+    public ISWF build(Collection<ICompilerProblem> problems)
+    {
+        buildStarted();
+        try
+        {
+            Iterable<ICompilerProblem> fatalProblems = getFatalProblems();
+            if (!Iterables.isEmpty(fatalProblems))
+            {
+                Iterables.addAll(problems, fatalProblems);
+                return null;
+            }
+
+            Set<ICompilationUnit> compilationUnitSet = new HashSet<ICompilationUnit>();
+            Target.RootedCompilationUnits rootedCompilationUnits = getRootedCompilationUnits();
+            Iterables.addAll(problems, rootedCompilationUnits.getProblems());
+
+            compilationUnitSet.addAll(rootedCompilationUnits.getUnits());
+
+            buildAndCollectProblems(compilationUnitSet, problems);
+
+            List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(rootedCompilationUnits.getUnits());
+            ISWF swf = initializeSWF(reachableCompilationUnits);
+
+            // make main frame for DoABC tags
+            final SWFFrame mainFrame = new SWFFrame();
+            swf.addFrame(mainFrame);
+
+            // Add definitions.
+            for (final ICompilationUnit cu : compilationUnitSet)
+            {
+                // ignore externals
+                if (isLinkageExternal(cu, targetSettings))
+                    continue;
+
+                // ignore any resource bundles
+                if (cu instanceof ResourceBundleCompilationUnit)
+                    continue;
+
+                // Create a DoABC tag per compilation unit.
+
+                // Please add this API to SWFTarget. Thx.
+                // protected Boolean addToFrame(ICompilationUnit cu, SWFFrame mainFrame)
throws InterruptedException
+                // final boolean tagsAdded = cu.getSWFTagsRequest().get().addToFrame(mainFrame);
+                final boolean tagsAdded = addToFrame(cu, mainFrame);
+                if (!tagsAdded)
+                {
+                    ICompilerProblem problem = new UnableToBuildSWFTagProblem(cu.getAbsoluteFilename());
+                    problems.add(problem);
+                }
+            }
+
+            createLinkReport(problems);
+
+            return swf;
+        }
+        catch (BuildCanceledException bce)
+        {
+            return null;
+        }
+        catch (InterruptedException ie)
+        {
+            return null;
+        }
+        finally
+        {
+            buildFinished();
+        }
+    }
+
+    // Please add this API to SWFTarget. Thx.
+    protected Boolean addToFrame(ICompilationUnit cu, SWFFrame mainFrame) throws InterruptedException
+    {
+        // SWFTarget's implementation:
+        // return cu.getSWFTagsRequest().get().addToFrame(mainFrame);
+
+        final JSSharedData sharedData = JSSharedData.instance;
+
+        String code = "";
+        final List<IDefinition> defs = MXMLJSC.getDefinitions(cu, false);
+        for (IDefinition def : defs)
+        {
+            final String fullName = def.getQualifiedName();
+            if (sharedData.hasJavaScript(fullName))
+            {
+                final String jsCode = sharedData.getJavaScript(fullName);
+                code += jsCode;
+            }
+        }
+
+        if (!code.isEmpty())
+        {
+            final DoABCTag abcTag = new DoABCTag();
+            abcTag.setABCData(code.getBytes());
+            mainFrame.addTag(abcTag);
+        }
+        else
+        {
+            return cu.getSWFTagsRequest().get().addToFrame(mainFrame);
+        }
+        sharedData.registerSWFFrame(mainFrame, cu);
+        return true;
+    }
+
+    /**
+     * sortCompilationUnits() is a workaround for DependencyGraph bugs. There
+     * are three problem areas: 1. The order of the CUs is somewhat random
+     * depending on the thread that compiled a CU. 2. Dependencies through
+     * static initializers are not always correctly detected. 3. Dependencies to
+     * classes provided by SWCs are not correctly detected.
+     */
+    public static List<ICompilationUnit> sortCompilationUnits(List<ICompilationUnit>
frameCompilationUnits) throws InterruptedException
+    {
+        ICompilationUnit frameWorkCU = null;
+        ICompilationUnit xmlCU = null;
+        ICompilationUnit xmlListCU = null;
+
+        // extract framework CU, AS3XML CU, and AS3XMLList CU from frameCompilationUnits
+        Iterator<ICompilationUnit> it = frameCompilationUnits.iterator();
+        while (it.hasNext())
+        {
+            // get class name for compilation unit.
+            ICompilationUnit cu = it.next();
+            final List<IDefinition> defs = MXMLJSC.getDefinitions(cu, false);
+            for (IDefinition def : defs)
+            {
+                final String fullName = JSGeneratingReducer.createFullNameFromDefinition(cu.getProject(),
def);
+                if (frameWorkCU == null && fullName.equals(JSSharedData.JS_FRAMEWORK_NAME))
+                {
+                    frameWorkCU = cu;
+                    it.remove();
+                }
+                else if (xmlCU == null && fullName.equals(JSSharedData.AS3XML))
+                {
+                    xmlCU = cu;
+                    it.remove();
+                }
+                else if (xmlListCU == null && fullName.equals(JSSharedData.AS3XMLList))
+                {
+                    xmlListCU = cu;
+                    it.remove();
+                }
+
+                if (def instanceof DefinitionBase)
+                {
+                    JSSharedData.instance.registerReferencedDefinition(def.getQualifiedName());
+                }
+
+                JSSharedData.instance.registerPackage(def.getPackageName());
+            }
+        }
+
+        // insist on framework CU
+        if (frameWorkCU == null)
+            throw JSSharedData.backend.createException("JSTarget: cannot find " + JSSharedData.JS_FRAMEWORK_NAME
+ " compilation unit.");
+
+        // add the framework CU at pos 0
+        frameCompilationUnits.add(0, frameWorkCU);
+
+        // add AS3XML and AS3XMLList framework CUs if necessary
+        if (xmlCU != null)
+        {
+            // add the AS3XML CU at pos 1
+            frameCompilationUnits.add(1, xmlCU);
+
+            // insist on AS3XMLList CU
+            if (xmlListCU == null)
+                throw JSSharedData.backend.createException("JSTarget: cannot find " + JSSharedData.AS3XMLList
+ " compilation unit.");
+
+            // add the AS3XMLList CU at pos 2
+            frameCompilationUnits.add(2, xmlListCU);
+        }
+
+        return frameCompilationUnits;
+    }
+
+    @Override
+    public Target.RootedCompilationUnits computeRootedCompilationUnits() throws InterruptedException
+    {
+        if (mainCU != null)
+        {
+            return new Target.RootedCompilationUnits(ImmutableSet.of(mainCU), Collections.<ICompilerProblem>
emptyList());
+        }
+        
+        assert false;
+        return new Target.RootedCompilationUnits(Collections.<ICompilationUnit> emptySet(),
Collections.<ICompilerProblem> emptyList());
+    }
+
+    @Override
+    protected FramesInformation computeFramesInformation() throws InterruptedException
+    {
+        assert false;
+        return null;
+    }
+
+    @Override
+    protected void addLinkedABCToFrame(SWFFrame targetFrame, Iterable<DoABCTag> inputABCs,
ABCLinkerSettings linkSettings) throws Exception
+    {
+        assert false;
+    }
+
+    @Override
+    protected void setKeepAS3MetadataLinkerSetting(ABCLinkerSettings linkSettings)
+    {
+        assert false;
+    }
+
+}

Propchange: incubator/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/driver/JSTarget.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message