Package org.apache.flex.compiler.internal.tree.as

Examples of org.apache.flex.compiler.internal.tree.as.LiteralNode


        variableNodeBytes.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.private_));
        variableNodeBytes.addModifier(new ModifierNode(IASKeywordConstants.STATIC));
        variableNodeBytes.setType(null, new IdentifierNode("ByteArray"));
        ASToken assignToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_ASSIGNMENT, -1, -1, -1, -1, "=");
        ASToken nullToken = new ASToken(ASTokenTypes.TOKEN_KEYWORD_NULL, -1, -1, -1, -1, IASKeywordConstants.NULL);
        LiteralNode nullNode = new LiteralNode(LiteralType.NULL, nullToken);
        variableNodeBytes.setAssignedValue(assignToken, nullNode);
        classNodeMovieContents.addItem(variableNodeBytes);

        // build the constructor
        IdentifierNode constructorNameNode = new IdentifierNode(movieClassName);
        constructorNameNode.setReferenceValue(classNodeMovie.getDefinition());
        FunctionNode constructorNode = new FunctionNode(null, constructorNameNode);
        constructorNode.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_));
        ScopedBlockNode constructorContents = constructorNode.getScopedNode();

        // generate: super();
        FunctionCallNode superCall = new FunctionCallNode(LanguageIdentifierNode.buildSuper());
        constructorContents.addItem(superCall);

        // generate: initialWidth = $swfWidth;
        LiteralNode widthNode = new NumericLiteralNode(Integer.toString(swfWidth));
        BinaryOperatorNodeBase assignmentWidth = BinaryOperatorNodeBase.create(assignToken, new IdentifierNode("initialWidth"), widthNode);
        constructorContents.addItem(assignmentWidth);

        // generate: initialHeight = $swfHeight;
        LiteralNode heightNode = new NumericLiteralNode(Integer.toString(swfHeight));
        BinaryOperatorNodeBase assignmentHeight = BinaryOperatorNodeBase.create(assignToken, new IdentifierNode("initialHeight"), heightNode);
        constructorContents.addItem(assignmentHeight);

        classNodeMovieContents.addItem(constructorNode);

        // build the movieClipData() getter
        GetterNode movieClipDataGetterNode = new GetterNode(null, null, new IdentifierNode("movieClipData"));
        movieClipDataGetterNode.addModifier(new ModifierNode(IASKeywordConstants.OVERRIDE));
        movieClipDataGetterNode.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_));
        movieClipDataGetterNode.setType(null, new IdentifierNode("ByteArray"));
        ScopedBlockNode movieClipDataContents = movieClipDataGetterNode.getScopedNode();

        // generate: if (bytes == null)
        ASToken compareToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_EQUAL, -1, -1, -1, -1, "==");
        BinaryOperatorNodeBase nullCheck = BinaryOperatorNodeBase.create(compareToken, new IdentifierNode("bytes"), new LiteralNode(LiteralType.NULL, nullToken));
        IfNode ifStmt = new IfNode(null);
        ConditionalNode cNode = new ConditionalNode(null);
        cNode.setConditionalExpression(nullCheck);
        ifStmt.addBranch(cNode);
        movieClipDataContents.addItem(ifStmt);
View Full Code Here


        final Object result = evaluateConstNodeExpressionToJavaObject(node);

        if (result instanceof Boolean)
        {
            LiteralNode literalNode = new LiteralNode(LiteralType.BOOLEAN, ((Boolean)result).toString());
            literalNode.setSynthetic(true);
            return literalNode;
        }
        else if (result instanceof String)
        {
            LiteralNode literalNode = new LiteralNode(LiteralType.STRING, (String)result);
            literalNode.setSynthetic(true);
            return literalNode;
        }
        else if (result instanceof Double ||
                 result instanceof Integer ||
                 result instanceof Long)
        {
            LiteralNode literalNode = new NumericLiteralNode(result.toString());
            literalNode.setSynthetic(true);
            return literalNode;
        }
        else if (result == ABCConstants.NULL_VALUE)
        {
            // Handle 'null'
            LiteralNode literalNode = new LiteralNode(LiteralType.NULL, IASLanguageConstants.Null);
            literalNode.setSynthetic(true);
            return literalNode;
        }
        return null;
    }
View Full Code Here

     * @param problems collection storing problems that occur during parsing
     */
    private void process(String key, String value, SourceLocation keySource,
            SourceLocation valueSource, Collection<ICompilerProblem> problems)
    {
        LiteralNode keyNode = new LiteralNode(LiteralType.STRING, key, keySource);
       
        ExpressionNodeBase valueNode = null;
        Matcher matcher;
        if ((matcher = CLASS_REFERENCE_REGEX.matcher(value)).matches())
        {
            valueNode = processClassReference(matcher, valueSource, problems);
        }
        else if ((matcher = EMBED_REGEX.matcher(value)).matches())
        {
            valueNode = processEmbed(value, valueSource, problems);
        }
        else
        {
            valueNode = new LiteralNode(LiteralType.STRING, value, valueSource);
        }
       
        if(valueNode != null)
            fileNode.addItem(new ResourceBundleEntryNode(keyNode, valueNode))
    }
View Full Code Here

            List<ISourceFragment> fragmentList)
    {
        ISourceFragment[] fragments = fragmentList.toArray(new ISourceFragment[0]);
        String text = SourceFragmentsReader.concatLogicalText(fragments);

        LiteralNode stringLiteralNode = new LiteralNode(LiteralType.STRING, text);
        stringLiteralNode.setParent(parent);

        ISourceFragment firstFragment = fragments[0];
        ISourceFragment lastFragment = fragments[fragments.length - 1];
        stringLiteralNode.setSourcePath(sourceLocation.getSourcePath());
        stringLiteralNode.setStart(firstFragment.getPhysicalStart());
        stringLiteralNode.setEnd(lastFragment.getPhysicalStart() + lastFragment.getPhysicalText().length());
        stringLiteralNode.setLine(firstFragment.getPhysicalLine());
        stringLiteralNode.setColumn(firstFragment.getPhysicalColumn());

        return stringLiteralNode;
    }
View Full Code Here

        // If the parse of the databinding expression failed,
        // substitute an empty string literal node
        // (which is the result of the empty databinding expression {}).
        if (expressionNode == null)
            expressionNode = new LiteralNode(LiteralType.STRING, "");

        // ASParser creates the ExpressionNodeBase as a child of a FileNode.
        // Make it a child of the MXMLDataBindingNode.
        ((ExpressionNodeBase)expressionNode).setParent(result);
        result.setExpressionNode(expressionNode);
View Full Code Here

        // Since we are empty, we can't set our source location based on our children.
        // But in the special case we can set our location to the same thing as our parent.
        result.setSourceLocation((NodeBase)parent);

        IExpressionNode expressionNode = new LiteralNode(LiteralType.STRING, "");
        ((ExpressionNodeBase)expressionNode).setParent(result);
        result.setExpressionNode(expressionNode);
        return result;
    }
View Full Code Here

        // If we didn't get any children of the file node,
        // we must have parsed whitespace (or nothing).
        // An databinding like {} or { } represents the empty string.
        if (n == 0)
        {
            return new LiteralNode(LiteralType.STRING, "");
        }

        // If we got more than one child, report that the databinding expression
        // is invalid. It must be a single expression.
        else if (n > 1)
View Full Code Here

        variableNodeData.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_));
        variableNodeData.addModifier(new ModifierNode(IASKeywordConstants.STATIC));
        variableNodeData.setType(null, new IdentifierNode("XML"));
        ASToken assignToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_ASSIGNMENT, -1, -1, -1, -1, "=");
        String xmlContents = getXMLString(problems);
        LiteralNode xmlData = new LiteralNode(LiteralType.STRING, xmlContents);
        variableNodeData.setAssignedValue(assignToken, xmlData);
        classNode.getScopedNode().addItem(variableNodeData);

        fileNode.runPostProcess(EnumSet.of(PostProcessStep.POPULATE_SCOPE));
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.tree.as.LiteralNode

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.