Package org.apache.flex.compiler.codegen.as

Examples of org.apache.flex.compiler.codegen.as.IASEmitter


    public void writeTo(OutputStream out)
    {
        JSFilterWriter writer = (JSFilterWriter) JSSharedData.backend
                .createWriterBuffer(project);

        IASEmitter asEmitter = JSSharedData.backend.createEmitter(writer);
        IASBlockWalker asBlockWalker = JSSharedData.backend.createWalker(
                project, problems, asEmitter);

        IMXMLEmitter mxmlEmitter = JSSharedData.backend
                .createMXMLEmitter(writer);
View Full Code Here


    @Override
    public void writeTo(OutputStream out)
    {
        JSFilterWriter writer = (JSFilterWriter) JSSharedData.backend
                .createWriterBuffer(project);
        IASEmitter emitter = JSSharedData.backend.createEmitter(writer);
        IASBlockWalker walker = JSSharedData.backend.createWalker(project,
                problems, emitter);

        walker.visitCompilationUnit(compilationUnit);
View Full Code Here

        eventCounter = 0;
        idCounter = 0;

        // visit MXML
        IClassDefinition cdef = node.getClassDefinition();
        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                .getASEmitter();
        ((JSFlexJSEmitter) asEmitter).thisClass = cdef;

        // visit tags
        final int len = node.getChildCount();
View Full Code Here

        oldIdCounter = idCounter;
        idCounter = 0;

        // visit MXML
        IClassDefinition cdef = node.getContainedClassDefinition();
        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                .getASEmitter();
        ((JSFlexJSEmitter) asEmitter).thisClass = cdef;

        IASNode classNode = node.getContainedClassDefinitionNode();
        // visit tags
View Full Code Here

        outputBindingInfoAsData(cname, bd);
    }

    private void outputBindingInfoAsData(String cname, BindingDatabase bindingDataBase)
    {
        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
        .getASEmitter();

        writeNewline("/**");
        writeNewline(" * @expose");
        writeNewline(" */");
        writeNewline(cname
                + ".prototype._bindings = [");
       
        Set<BindingInfo> bindingInfo = bindingDataBase.getBindingInfo();
        writeNewline(bindingInfo.size() + ","); // number of bindings
       
        for (BindingInfo bi : bindingInfo)
        {
            String s;
            s = bi.getSourceString();
            if (s == null)
                s = getSourceStringFromGetter(bi.getExpressionNodesForGetter());
            if (s.contains("."))
            {
                String[] parts = s.split("\\.");
                write(ASEmitterTokens.SQUARE_OPEN.getToken() + ASEmitterTokens.DOUBLE_QUOTE.getToken() +
                        parts[0] + ASEmitterTokens.DOUBLE_QUOTE.getToken());
                int n = parts.length;
                for (int i = 1; i < n; i++)
                {
                    String part = parts[i];
                    write(", " +  ASEmitterTokens.DOUBLE_QUOTE.getToken() + part + ASEmitterTokens.DOUBLE_QUOTE.getToken());
                }
                writeNewline(ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
            }
            else if (s == null || s.length() == 0)
            {
                List<IExpressionNode> getterNodes = bi.getExpressionNodesForGetter();
                StringBuilder sb = new StringBuilder();
                sb.append("function() { return ");
                for (IExpressionNode getterNode : getterNodes)
                {
                    sb.append(asEmitter.stringifyNode(getterNode));
                }
                sb.append("; },");
                writeNewline(sb.toString());
            }
            else
                writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + s +
                        ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
           
            IExpressionNode destNode = bi.getExpressionNodeForDestination();
            if (destNode != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.append(asEmitter.stringifyNode(destNode));
                writeNewline(sb.toString());
            }
            else
                writeNewline(ASEmitterTokens.NULL.getToken() + ASEmitterTokens.COMMA.getToken());
           
View Full Code Here

        writeNewline("null" + ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.SEMICOLON.getToken());
    }

    private void encodeWatcher(WatcherInfoBase watcherInfoBase)
    {
        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
        .getASEmitter();

        writeNewline(watcherInfoBase.getIndex() + ASEmitterTokens.COMMA.getToken());
        WatcherType type = watcherInfoBase.getType();
        if (type == WatcherType.FUNCTION)
        {
            writeNewline("0" + ASEmitterTokens.COMMA.getToken());

            FunctionWatcherInfo functionWatcherInfo = (FunctionWatcherInfo)watcherInfoBase;
          
            writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + functionWatcherInfo.getFunctionName() +
                    ASEmitterTokens.DOUBLE_QUOTE.getToken());
            IExpressionNode params[] = functionWatcherInfo.params;
            StringBuilder sb = new StringBuilder();
            sb.append("function() { return [");
            boolean firstone = true;
            for (IExpressionNode param : params)
            {
                if (firstone)
                    firstone = false;
                sb.append(ASEmitterTokens.COMMA.getToken());
                sb.append(asEmitter.stringifyNode(param));  
            }
            sb.append("]; },");
            outputEventNames(functionWatcherInfo.getEventNames());
            outputBindings(functionWatcherInfo.getBindings());
        }
View Full Code Here

                .getToken() + eventCounter++;
        eventSpecifier.name = cdef.getBaseName();
        eventSpecifier.type = node.getEventParameterDefinition()
                .getTypeAsDisplayString();

        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                .getASEmitter();

        StringBuilder sb = null;
        int len = node.getChildCount();
        if (len > 0)
        {
            sb = new StringBuilder();
            for (int i = 0; i < len; i++)
            {
                sb.append(getIndent((i > 0) ? 1 : 0)
                        + asEmitter.stringifyNode(node.getChild(i)));
                if (i < len - 1)
                {
                    sb.append(ASEmitterTokens.SEMICOLON.getToken());
                    sb.append(ASEmitterTokens.NEW_LINE.getToken());
                }
View Full Code Here

    }

    @Override
    public void emitScript(IMXMLScriptNode node)
    {
        IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
                .getASEmitter();

        String nl = ASEmitterTokens.NEW_LINE.getToken();

        StringBuilder sb = null;
        MXMLScriptSpecifier scriptSpecifier = null;

        int len = node.getChildCount();
        if (len > 0)
        {
            for (int i = 0; i < len; i++)
            {
                IASNode cnode = node.getChild(i);

                if (!(cnode instanceof IImportNode))
                {
                    sb = new StringBuilder();
                    scriptSpecifier = new MXMLScriptSpecifier();

                    sb.append(asEmitter.stringifyNode(cnode));

                    sb.append(ASEmitterTokens.SEMICOLON.getToken());

                    if (i == len - 1)
                        indentPop();
View Full Code Here

    @Override
    public void writeTo(OutputStream out)
    {
        ASFilterWriter writer = JSSharedData.backend
                .createWriterBuffer(project);
        IASEmitter emitter = JSSharedData.backend.createEmitter(writer);
        IASBlockWalker walker = JSSharedData.backend.createWalker(project,
                problems, emitter);

        walker.visitCompilationUnit(compilationUnit);
View Full Code Here

                    final File outputClassFile = getOutputClassFile(qname
                            + "_output", outputRootDir);

                    ASFilterWriter writer = backend.createWriterBuffer(project);
                    IASEmitter emitter = backend.createEmitter(writer);
                    IASBlockWalker walker = backend.createWalker(project,
                            errors, emitter);

                    walker.visitCompilationUnit(cu);
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.codegen.as.IASEmitter

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.