Repository: flex-falcon Updated Branches: refs/heads/develop b306ffe9a -> 1130f934b
make factory class generated code not have all of Flex SDK dependencies if they don't exist so factory classes can be used in FlexJS Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/1130f934 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/1130f934 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/1130f934 Branch: refs/heads/develop Commit: 1130f934b851ae08571254ff5e4ebcd600504e03 Parents: b306ffe Author: Alex Harui <[email protected]> Authored: Fri Jul 29 10:40:37 2016 -0700 Committer: Alex Harui <[email protected]> Committed: Fri Jul 29 10:40:48 2016 -0700 ---------------------------------------------------------------------- .../internal/targets/FlexAppSWFTarget.java | 41 +++++++++++++------- .../compiler/internal/targets/FlexTarget.java | 26 +++++++------ 2 files changed, 42 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1130f934/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java index 59e3c6a..bed094c 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java @@ -201,15 +201,21 @@ public class FlexAppSWFTarget extends AppSWFTarget final FlexDelegate delegate = getDelegate(); - resolveReferenceToCompilationUnit(delegate.iModuleFactoryReference, - projectScope, - compilationUnits, - problems); + if (delegate.iModuleFactoryReference.resolve(flexProject) != null) + { + resolveReferenceToCompilationUnit(delegate.iModuleFactoryReference, + projectScope, + compilationUnits, + problems); + } - resolveReferenceToCompilationUnit(delegate.iSWFContextReference, - projectScope, - compilationUnits, - problems); + if (delegate.iSWFContextReference.resolve(flexProject) != null) + { + resolveReferenceToCompilationUnit(delegate.iSWFContextReference, + projectScope, + compilationUnits, + problems); + } resolveReferenceToCompilationUnit(delegate.getPreloaderClassReference(), projectScope, @@ -1767,10 +1773,16 @@ public class FlexAppSWFTarget extends AppSWFTarget Name generatedSystemManagerName = new Name(generatedSystemManagerClassNameString); - Collection<Name> implementedInterfaces = new ImmutableList.Builder<Name>() - .add(iModuleFactoryReference.getMName()) - .add(iSWFContextReference.getMName()) - .build(); + ImmutableList.Builder<Name> listOfInterfaces = new ImmutableList.Builder<Name>(); + if (iModuleFactoryReference.resolve(flexProject) != null) + { + listOfInterfaces.add(iModuleFactoryReference.getMName()); + } + if (iSWFContextReference.resolve(flexProject) != null) + { + listOfInterfaces.add(iSWFContextReference.getMName()); + } + Collection<Name> implementedInterfaces = listOfInterfaces.build(); // Generate code for the constructor: // public function ClassName() @@ -1780,7 +1792,7 @@ public class FlexAppSWFTarget extends AppSWFTarget // } final String compatibilityVersion = flexProject.getCompatibilityVersionString(); final InstructionList classITraitsInit = new InstructionList(); - if (compatibilityVersion != null) + if (compatibilityVersion != null && flexVersionReference.resolve(flexProject) != null) { Name flexVersionSlotName = flexVersionReference.getMName(); classITraitsInit.addInstruction(ABCConstants.OP_getlex, flexVersionSlotName); @@ -1797,7 +1809,8 @@ public class FlexAppSWFTarget extends AppSWFTarget final FlexSplashScreenImage splashScreenImage = getSplashScreenImage(); // Codegen various methods - codegenCallInContextMethod(classGen, true); + if (iSWFContextReference.resolve(flexProject) != null) + codegenCallInContextMethod(classGen, true); codegenCreateMethod(classGen, ((DefinitionBase)mainApplicationClassDefinition).getMName(flexProject)); codegenInfoMethod(classGen, flexProject.getCompatibilityVersion(), http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1130f934/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java index 52348fb..4809d09 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexTarget.java @@ -169,6 +169,7 @@ public abstract class FlexTarget ReferenceFactory.packageQualifiedReference(flexProject.getWorkspace(), IASLanguageConstants.getDefinitionByName); IResolvedQualifiersReference iFlexModule = ReferenceFactory.packageQualifiedReference(flexProject.getWorkspace(), IMXMLTypeConstants.IFlexModule); + boolean codegenIFlexModule = iFlexModule.resolve(flexProject) != null; Name getDefinitionByName = getDefinitionByNameReference.getMName(); InstructionList create = new InstructionList(); create.addInstruction(ABCConstants.OP_getlocal1); @@ -204,15 +205,18 @@ public abstract class FlexTarget Label createL5 = new Label(); create.addInstruction(ABCConstants.OP_iffalse, createL5); create.addInstruction(ABCConstants.OP_construct, 0); - create.addInstruction(ABCConstants.OP_dup); - create.addInstruction(ABCConstants.OP_istype, iFlexModule.getMName()); - Label createL4 = new Label(); - create.addInstruction(ABCConstants.OP_iffalse, createL4); - create.addInstruction(ABCConstants.OP_dup); - create.addInstruction(ABCConstants.OP_getlocal0); - create.addInstruction(ABCConstants.OP_setproperty, new Name("moduleFactory")); - create.labelNext(createL4); - create.addInstruction(ABCConstants.OP_returnvalue); + if (codegenIFlexModule) + { + create.addInstruction(ABCConstants.OP_dup); + create.addInstruction(ABCConstants.OP_istype, iFlexModule.getMName()); + Label createL4 = new Label(); + create.addInstruction(ABCConstants.OP_iffalse, createL4); + create.addInstruction(ABCConstants.OP_dup); + create.addInstruction(ABCConstants.OP_getlocal0); + create.addInstruction(ABCConstants.OP_setproperty, new Name("moduleFactory")); + create.labelNext(createL4); + create.addInstruction(ABCConstants.OP_returnvalue); + } create.labelNext(createL5); create.addInstruction(ABCConstants.OP_returnvalue); classGen.addITraitsMethod(new Name("create"), Collections.<Name> emptyList(), @@ -346,7 +350,7 @@ public abstract class FlexTarget if (!isAppFlexInfo) { // preloader: - if (preloaderReference != null) + if (preloaderReference != null && preloaderReference.resolve(flexProject) != null) { info.addInstruction(ABCConstants.OP_pushstring, ATTRIBUTE_PRELOADER); info.addInstruction(ABCConstants.OP_getlex, preloaderReference.getMName()); @@ -354,7 +358,7 @@ public abstract class FlexTarget } // runtimeDPIProvider: - if (runtimeDPIProviderReference != null) + if (runtimeDPIProviderReference != null && runtimeDPIProviderReference.resolve(flexProject) != null) { info.addInstruction(ABCConstants.OP_pushstring, ATTRIBUTE_RUNTIME_DPI_PROVIDER); info.addInstruction(ABCConstants.OP_getlex, runtimeDPIProviderReference.getMName());
