private Boolean createClient()

in compiler/src/main/java/org/apache/royale/compiler/clients/ASC.java [1291:1501]


    private Boolean createClient(final CommandLine line) throws ParseException
    {
        // First, process parsed command line options.
        final Option[] options = line.getOptions();

        if (options == null)
            return false;

        for (int i = 0; i < options.length; i++)
        {
            final Option option = options[i];
            final String shortName = option.getOpt();

            if ("import".equals(shortName))
            {
                String[] imports = option.getValues();
                for (int j = 0; j < imports.length; j++)
                {
                    this.addImportFilename(imports[j]);
                }
            }
            else if ("in".equals(shortName))
            {
                String[] includes = option.getValues();
                for (int j = 0; j < includes.length; j++)
                {
                    this.addIncludeFilename(includes[j]);
                }
            }
            else if ("swf".equals(shortName))
            {
                String[] swfValues = option.getValue().split(",");
                if (swfValues.length < 3)
                    throw new MissingArgumentException("The swf option requires three arguments, only " + swfValues.length + " were found.");
                
                for (int j = 0; j < swfValues.length; j++)
                {
                    String value = swfValues[j];
                    if (j == 0)
                        this.setSymbolClass(value);
                    else if (j == 1)
                        this.setWidth(value);
                    else if (j == 2)
                        this.setHeight(value);
                    else if (j == 3)
                        this.setFrameRate(value);
                }
            }
            else if ("use".equals(shortName))
            {
                String[] namespaces = option.getValues();
                for (String namespace : namespaces)
                {
                    this.addNamespace(namespace);
                }
            }
            else if ("config".equals(shortName))
            {
                String[] config = option.getValues();
                if( config.length == 2 )
                {
                    // The config option will have been split around '='
                    // e.g. CONFIG::Foo='hi' will be split into
                    // 2 values - 'CONFIG::Foo' and 'hi'
                    String name = config[0];
                    String value = config[1];
                    value = fixupMissingQuote(value);
                    this.putConfigVar(name, value);
                }
            }
            else if ("strict".equals(shortName) || "!".equals(shortName))
            {
                this.setUseStaticSemantics(true);
            }
            else if ("d".equals(shortName))
            {
                this.setEmitDebugInfo(true);
            }
            else if ("warnings".equals(shortName) || "coach".equals(shortName))
            {
                if ("coach".equals(shortName))
                    err.println("'coach' has been deprecated. Please use 'warnings' instead.");
                this.setShowWarnings(true);
            }
            else if ("log".equals(shortName))
            {
                this.setShowLog(true);
            }
            else if ("md".equals(shortName))
            {
                this.setEmitMetadata(true);
            }
            else if ("merge".equals(shortName))
            {
                this.setMergeABCs(true);
            }
            else if ("language".equals(shortName))
            {
                String value = option.getValue();
                this.setLocale(getLocaleForLanguage(value));
            }
            else if ("doc".equals(shortName))
            {
                this.setEmitDocInfo(true);
            }
            else if ("avmtarget".equals(shortName))
            {
                String value = option.getValue();
                this.setTargetAVM(value);
            }
            else if ("AS3".equals(shortName))
            {
                this.setDialect("AS3");
            }
            else if ("ES".equals(shortName))
            {
                this.setDialect("ES");
            }
            else if ("o".equalsIgnoreCase(shortName) || "optimize".equalsIgnoreCase(shortName))
            {
                this.setOptimize(true);
            }
            else if ("o2".equalsIgnoreCase(shortName))
            {
                this.setOptimize(true);
            }
            else if ("out".equalsIgnoreCase(shortName))
            {
                this.setOutputBasename(option.getValue());
            }
            else if ("outdir".equalsIgnoreCase(shortName))
            {
                this.setOutputDirectory(option.getValue());
            }
            else if ("abcfuture".equals(shortName))
            {
                this.setABCFuture(true);
            }
            else if ("p".equals(shortName))
            {
                this.setShowParseTrees(true);
            }
            else if ("i".equals(shortName))
            {
                this.setShowInstructions(true);
            }
            else if ("m".equals(shortName))
            {
                this.setShowMachineCode(true);
            }
            else if ("f".equals(shortName))
            {
                this.setShowFlowGraph(true);
            }
            else if ("exe".equals(shortName))
            {
                String exe = option.getValue();
                this.setAvmplusFilename(exe);
            }
            else if ("movieclip".equals(shortName))
            {
                this.setMakeMovieClip(true);
            }
            else if ("ES4".equals(shortName))
            {
                this.setDialect("ES4");
            }
            else if ("li".equals(shortName))
            {
                this.internalLibraries.add(option.getValue());
            }
            else if ("le".equals(shortName))
            {
                this.externalLibraries.add(option.getValue());
            }
            else if ("parallel".equals(shortName))
            {
                this.setParallel(true);
            }
            else if ("inline".equals(shortName))
            {
                this.setMergeABCs(true); // inlining requires merging of ABCs
                this.setEnableInlining(true);
            }
            else if ( "removedeadcode".equals(shortName) )
            {
                this.setRemoveDeadCode(true);
            }
            else
            {
                throw new UnrecognizedOptionException("Unrecognized option '" + shortName + "'", shortName);
            }
        }

        // Then any remaining arguments that were not options are interpreted as
        // source files to compile.
        final String[] remainingArgs = line.getArgs();
        if (remainingArgs != null)
        {
            for (int i = 0; i < remainingArgs.length; i++)
            {
                this.addSourceFilename(remainingArgs[i]);
            }
        }
        else
        {
            throw new MissingArgumentException("At least one source file must be specified after the list of options.");
        }

        return true;
    }