Java Code Examples for org.mozilla.javascript.Token#TRUE

The following examples show how to use org.mozilla.javascript.Token#TRUE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeywordLiteral.java    From JsDroidCmd with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public String toSource(int depth) {
    StringBuilder sb = new StringBuilder();
    sb.append(makeIndent(depth));
    switch (getType()) {
    case Token.THIS:
        sb.append("this");
        break;
    case Token.NULL:
        sb.append("null");
        break;
    case Token.TRUE:
        sb.append("true");
        break;
    case Token.FALSE:
        sb.append("false");
        break;
    case Token.DEBUGGER:
        sb.append("debugger;\n");
        break;
    default:
        throw new IllegalStateException("Invalid keyword literal type: "
                                        + getType());
    }
    return sb.toString();
}
 
Example 2
Source File: KeywordLiteral.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toSource(int depth) {
    StringBuilder sb = new StringBuilder();
    sb.append(makeIndent(depth));
    switch (getType()) {
    case Token.THIS:
        sb.append("this");
        break;
    case Token.NULL:
        sb.append("null");
        break;
    case Token.TRUE:
        sb.append("true");
        break;
    case Token.FALSE:
        sb.append("false");
        break;
    case Token.DEBUGGER:
        sb.append("debugger;\n");
        break;
    default:
        throw new IllegalStateException("Invalid keyword literal type: "
                                        + getType());
    }
    return sb.toString();
}
 
Example 3
Source File: KeywordLiteral.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets node token type
 * @throws IllegalArgumentException if {@code nodeType} is unsupported
 */
@Override
public KeywordLiteral setType(int nodeType) {
    if (!(nodeType == Token.THIS
          || nodeType == Token.NULL
          || nodeType == Token.TRUE
          || nodeType == Token.FALSE
          || nodeType == Token.DEBUGGER))
        throw new IllegalArgumentException("Invalid node type: "
                                           + nodeType);
    type = nodeType;
    return this;
}
 
Example 4
Source File: KeywordLiteral.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets node token type
 * @throws IllegalArgumentException if {@code nodeType} is unsupported
 */
@Override
public KeywordLiteral setType(int nodeType) {
    if (!(nodeType == Token.THIS
          || nodeType == Token.NULL
          || nodeType == Token.TRUE
          || nodeType == Token.FALSE
          || nodeType == Token.DEBUGGER))
        throw new IllegalArgumentException("Invalid node type: "
                                           + nodeType);
    type = nodeType;
    return this;
}
 
Example 5
Source File: ExpressionParserUtility.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * process child node
 * 
 * @param parent
 * @param child
 * @param tree
 * @param columnExprList
 * @throws BirtException
 */
private void processChild( Node child, ScriptNode tree,
		List columnExprList ) throws BirtException
{
	switch ( child.getType( ) )
	{
		case Token.NUMBER :
		case Token.STRING :
		case Token.NULL :
		case Token.TRUE :
		case Token.FALSE :
			break;

		case Token.GETPROP :
		case Token.GETELEM :
		case Token.SETPROP :
		case Token.SETELEM :
		{
			compileDirectColRefExpr( child, tree, columnExprList );
			break;
		}
		case Token.CALL :
			compileAggregateExpr( child, tree, columnExprList );
			break;
		default :
			compileComplexExpr( child, tree, columnExprList );
	}

}
 
Example 6
Source File: ExpressionParserUtility.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * compile the complex expression
 * 
 * @param complexNode
 * @throws BirtException
 */
private void compileComplexExpr( Node complexNode, ScriptNode tree,
		List columnExprList ) throws BirtException
{
	Node child = complexNode.getFirstChild( );
	while ( child != null )
	{
		if ( child.getType( ) == Token.FUNCTION )
		{
			int index = getFunctionIndex( child.getString( ), tree );
			compileFunctionNode( tree.getFunctionNode( index ),
					tree,
					columnExprList );
		}
		// keep reference to next child, since subsequent steps could
		// lose
		// the reference to it
		Node nextChild = child.getNext( );

		// do not include constants into the sub-expression list
		if ( child.getType( ) == Token.NUMBER
				|| child.getType( ) == Token.STRING
				|| child.getType( ) == Token.TRUE
				|| child.getType( ) == Token.FALSE
				|| child.getType( ) == Token.NULL )
		{
			processChild( child, tree, columnExprList );
			child = nextChild;
			continue;
		}

		processChild( child, tree, columnExprList );
		child = nextChild;
	}
}
 
Example 7
Source File: AbstractExpressionCompiler.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
	 * 
	 * returns the compiled expression from processing a child node
	 * 
	 * @param context
	 * @param customerChecked
	 * @param parent
	 * @param child
	 * @return
	 * @throws DataException
	 */
protected CompiledExpression processChild( Context context,
		boolean customerChecked, Node parent, Node child, Node grandFather )
		throws DataException
{
	CompiledExpression compiledExpr = null;
	switch ( child.getType( ) )
	{
		case Token.NUMBER :
			compiledExpr = new ConstantExpression( child.getDouble( ) );
			break;

		case Token.STRING :
			compiledExpr = new ConstantExpression( child.getString( ) );
			break;

		case Token.NULL :
			compiledExpr = new ConstantExpression( );
			break;

		case Token.TRUE :
			compiledExpr = new ConstantExpression( true );
			break;

		case Token.FALSE :
			compiledExpr = new ConstantExpression( false );
			break;

		case Token.GETPROP :
		{
			ConstantExpression ce = AggregationConstantsUtil.getConstantExpression( child );
			if ( ce != null )
			{
				compiledExpr = ce;
				break;
			}
		}

		case Token.GETELEM :
			compiledExpr = compileDirectColRefExpr( parent,
					child,
					grandFather,
					customerChecked,
					context );
			break;

		case Token.CALL :
		{
			compiledExpr = compileAggregateExpr( context, parent, child );
			break;
		}
	}
	if ( compiledExpr == null )
		compiledExpr = compileComplexExpr( context, child, customerChecked );
	return compiledExpr;
}
 
Example 8
Source File: KeywordLiteral.java    From JsDroidCmd with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Returns true if the token type is {@link Token#TRUE} or
 * {@link Token#FALSE}.
 */
public boolean isBooleanLiteral() {
    return type == Token.TRUE || type == Token.FALSE;
}
 
Example 9
Source File: KeywordLiteral.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns true if the token type is {@link Token#TRUE} or
 * {@link Token#FALSE}.
 */
public boolean isBooleanLiteral() {
    return type == Token.TRUE || type == Token.FALSE;
}