当前位置: 首页>>代码示例>>Java>>正文


Java Token.GETPROP属性代码示例

本文整理汇总了Java中org.mozilla.javascript.Token.GETPROP属性的典型用法代码示例。如果您正苦于以下问题:Java Token.GETPROP属性的具体用法?Java Token.GETPROP怎么用?Java Token.GETPROP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.mozilla.javascript.Token的用法示例。


在下文中一共展示了Token.GETPROP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

@Override
public boolean visit(AstNode node) {
	switch (node.getType()) {
	case Token.GETPROP: // foo.bar (firstChild="foo", lastChild="bar")
		PropertyGet propertyGet = (PropertyGet)node;
		int propType = propertyGet.getProperty().getType();
		if(propertyGet.getTarget().getType()==Token.NAME
				&& (propType == Token.STRING || propType == Token.NAME)
				&& objectName.equals(safeGetString(propertyGet.getTarget()))
		){
			resultSoFar.add(safeGetString(propertyGet.getProperty()));
		}
		break;
	case Token.GETELEM: // foo["bar"]
		ElementGet elemGet = (ElementGet)node;
		int elemType = elemGet.getElement().getType();
		if(elemGet.getTarget().getType()==Token.NAME
			&&  (elemType == Token.STRING || elemType==Token.NAME)
			&& objectName.equals(safeGetString(elemGet.getTarget()))
		){
			resultSoFar.add(safeGetString(elemGet.getElement()));
		}
		break;
	default:
		break;
	}
	return true;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:28,代码来源:FormulaInfo.java

示例2: getAggregationFunction

/**
 * An aggregation expression in the form of Total.xxx for example Total.sum(
 * row.x ) This means the first child is a GETPROP node, and its left child
 * is "Total" and its right child is "sum"
 * 
 * @param callNode
 * @return @throws
 *         DataException
 */
protected IAggrFunction getAggregationFunction( Node callNode )
		throws DataException
{

	Node firstChild = callNode.getFirstChild( );
	if ( firstChild.getType( ) != Token.GETPROP )
		return null;

	Node getPropLeftChild = firstChild.getFirstChild( );
	if ( getPropLeftChild.getType( ) != Token.NAME
			|| !getPropLeftChild.getString( ).equals( TOTAL ) )
		return null;

	Node getPropRightChild = firstChild.getLastChild( );
	if ( getPropRightChild.getType( ) != Token.STRING )
		return null;

	String aggrFuncName = getPropRightChild.getString( );
	IAggrFunction agg = AggregationManager.getInstance( )
			.getAggregation( aggrFuncName );
	if ( agg == null )
	{
		// Aggr function name after Total is invalid; this will eventuall
		// cause
		// an error. Report error now
		throw new DataException( ResourceConstants.INVALID_TOTAL_NAME,
				aggrFuncName );
	}
	return agg;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:39,代码来源:AbstractExpressionCompiler.java

示例3: getDirectColRefExpr

/**
 * if the Node is row Node, return true
 * 
 * @param refNode
 * @return
 */
private static boolean getDirectColRefExpr( Node refNode, boolean mode )
{
	assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );

	Node rowName = refNode.getFirstChild( );
	assert ( rowName != null );
	if ( rowName.getType( ) != Token.NAME )
		return false;

	String str = rowName.getString( );
	assert ( str != null );
	if ( mode && !str.equals( STRING_ROW ) )
		return false;
	else if ( !mode && !str.equals( STRING_DATASET_ROW ) )
		return false;

	Node rowColumn = rowName.getNext( );
	assert ( rowColumn != null );

	if ( refNode.getType( ) == Token.GETPROP
			&& rowColumn.getType( ) == Token.STRING )
	{
		return true;
	}
	else if ( refNode.getType( ) == Token.GETELEM )
	{
		if ( rowColumn.getType( ) == Token.NUMBER
				|| rowColumn.getType( ) == Token.STRING )
			return true;
	}

	return false;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:39,代码来源:ExpressionUtility.java

示例4: getDirectColRefExpr

/**
 * if the Node is row Node, return true
 * 
 * @param refNode
 * @return
 */
private static boolean getDirectColRefExpr( Node refNode )
{
	assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );

	Node rowName = refNode.getFirstChild( );
	assert ( rowName != null );
	if ( rowName.getType( ) != Token.NAME )
		return false;

	String str = rowName.getString( );
	assert ( str != null );
	if ( !str.equals( STRING_ROW ) )
		return false;

	Node rowColumn = rowName.getNext( );
	assert ( rowColumn != null );

	if ( refNode.getType( ) == Token.GETPROP
			&& rowColumn.getType( ) == Token.STRING )
	{
		return true;
	}
	else if ( refNode.getType( ) == Token.GETELEM )
	{
		if ( rowColumn.getType( ) == Token.NUMBER
				|| rowColumn.getType( ) == Token.STRING )
			return true;
	}

	return false;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:37,代码来源:ExpressionUtility.java

示例5: processChild

/**
 * 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 );
	}

}
 
开发者ID:eclipse,项目名称:birt,代码行数:37,代码来源:ExpressionParserUtility.java

示例6: compileDirectColRefExpr

/**
 * compile column reference expression
 * 
 * @param refNode
 * @throws BirtException
 */
private void compileDirectColRefExpr( Node refNode, ScriptNode tree,
		List columnExprList ) throws BirtException
{
	assert ( refNode.getType( ) == Token.GETPROP
			|| refNode.getType( ) == Token.GETELEM
			|| refNode.getType( ) == Token.SETELEM || refNode.getType( ) == Token.SETPROP );

	Node rowName = refNode.getFirstChild( );
	assert ( rowName != null );
	if ( rowName.getType( ) != Token.NAME )
	{
		if ( refNode.getType( ) == Token.GETPROP
				|| refNode.getType( ) == Token.GETELEM
				|| refNode.getType( ) == Token.SETELEM
				|| refNode.getType( ) == Token.SETPROP )
		{
			compileOuterColRef( refNode, tree, columnExprList );
			compileRowPositionRef( refNode, tree, columnExprList );
			return;
		}
		compileComplexExpr( refNode, tree, columnExprList );
		return;
	}
	else
		compileSimpleColumnRefExpr( refNode, tree, columnExprList );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:32,代码来源:ExpressionParserUtility.java

示例7: PropertyGet

public PropertyGet(AstNode target, Name property, int dotPosition) {
    super(Token.GETPROP, target, property, dotPosition);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:3,代码来源:PropertyGet.java

示例8: processInfixExpression

/**
 *  for infix expressions, we ignore implicit coercions for now. For arithmetic
 *  operators, we assume the type of the entire expression to be the same as that
 *  of either operand. For comparison operators, we require operands to have
 *  the same type, and assume that the result is a boolean. Note that Assignments
 *  are also InfixExpressions and that some property-get operations show up as
 *  InfixExpressions for which the operator is GETPROP.
 */
private ITypeTerm processInfixExpression(InfixExpression i) throws Error {
	int operator = i.getOperator();
	AstNode leftOperand = i.getLeft();
	AstNode rightOperand = i.getRight();
	ITypeTerm iTerm = findOrCreateExpressionTerm(i);
	switch (operator){
		case Token.GETPROP:
			return processPropertyGet(i, leftOperand, rightOperand);
		case Token.ASSIGN:
		case Token.ASSIGN_ADD:
		case Token.ASSIGN_SUB:
		case Token.ASSIGN_MUL:
		case Token.ASSIGN_DIV:
		case Token.ASSIGN_BITAND:
		case Token.ASSIGN_BITOR:
		case Token.ASSIGN_BITXOR:
		case Token.ASSIGN_RSH:
			processAssignment((Assignment)i);
		return iTerm;
		case Token.ADD:
           case Token.SUB:
           case Token.MUL:
           case Token.DIV:
           case Token.MOD:
           case Token.BITOR:
           case Token.EQ:
           case Token.LE:
           case Token.LT:
           case Token.NE:
           case Token.GT:
           case Token.GE:
           case Token.SHNE:
           case Token.SHEQ:
           case Token.AND:
           case Token.OR:
           case Token.BITAND:
           case Token.BITXOR:
           case Token.LSH:
           case Token.RSH:
           case Token.URSH:
           case Token.IN:
			ITypeTerm leftTerm = processExpression(leftOperand);
			ITypeTerm rightTerm = processExpression(rightOperand);
			OperatorTerm opTerm = findOrCreateOperatorTerm(RhinoToIR.decodeRhinoOperator(operator), leftTerm, rightTerm, i.getLineno());
			addTypeEqualityConstraint(iTerm, opTerm, i.getLineno(), (solution) -> binaryOperatorMisuse(i, solution.typeOfTerm(leftTerm), solution.typeOfTerm(rightTerm), solution.typeOfTerm(opTerm)));
			break;
		default:
			error("unexpected infix operator: " + operator + "(" + RhinoToIR.decodeRhinoOperator(operator) + ") in " + i.toSource(), i);
	}
	theMap.put(i, iTerm);
	return iTerm;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:60,代码来源:ConstraintVisitor.java

示例9: findFeaturePathsUnder

protected static Set<String> findFeaturePathsUnder(Node node, List<String> pathSoFar) {
	Set<String> resultSoFar = new TreeSet<String>();
	switch (node.getType()) {
	case Token.NAME: // e.g. the x in x + 42
		if (pathSoFar != null) {
			pathSoFar.add(node.getString());
		} else {
			resultSoFar.add(node.getString());
		}
		break;
	case Token.STRING:
		if (pathSoFar != null) {
			pathSoFar.add(node.getString());
		}
		break;
	case Token.GETPROP: // e.g. foo.bar
		boolean topLevel = pathSoFar == null;
		if (topLevel) {
			pathSoFar = new ArrayList<String>();
		}
		for (Node child = node.getFirstChild(); child != null; child = child.getNext()) {
			resultSoFar.addAll(findFeaturePathsUnder(child, pathSoFar));
		}
		if (topLevel) {
			resultSoFar.add(getPathString(pathSoFar));
		}
		return resultSoFar;
	case Token.SETNAME: // Left-hand variable being written:  x in x = y;
	case Token.VAR:
	case Token.CALL:
		// ignore the left side and process the right side now
		resultSoFar.addAll(findFeaturePathsWithinRightSide(node));
		break;
	default:
		break;
	}
	// Now do the nested subexpressions, for all cases that said break instead of return.
	for (Node child = node.getFirstChild(); child != null; child = child.getNext()) {
		resultSoFar.addAll(findFeaturePathsUnder(child, pathSoFar));
	}
	return resultSoFar;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:42,代码来源:FormulaInfo.java

示例10: compileDirectColRefExpr

protected CompiledExpression compileDirectColRefExpr( Node parent, Node refNode,
		Node grandFather, boolean customerChecked, Context context )
		throws DataException
{
	// if it's a GETPROP or GETELEM with row on the left side,
	// and either a STRING or NUMBER on the right side, then it's
	// a direct column reference
	assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );

	Node rowName = refNode.getFirstChild( );
	assert ( rowName != null );
	if ( rowName.getType( ) != Token.NAME )
		return null;

	String str = rowName.getString( );
	assert ( str != null );
	if ( !str.equals( rowIndicator ) )
		return null;

	Node rowColumn = rowName.getNext( );
	assert ( rowColumn != null );

	if ( refNode.getType( ) == Token.GETPROP
			&& rowColumn.getType( ) == Token.STRING )
	{
		if ( ScriptConstants.OUTER_RESULT_KEYWORD.equals( rowColumn.getString( ) )
				|| ScriptConstants.ROW_NUM_KEYWORD.equals( rowColumn.getString( ) )
				|| "0".equals( rowColumn.getString( ) ) )
			return null;

		return new ColumnReferenceExpression( getDataSetMode( )
				? STRING_ROW : STRING_DATASETROW, rowColumn.getString( ) );
	}
	if ( refNode.getType( ) == Token.GETELEM )
	{
		if ( rowColumn.getType( ) == Token.NUMBER )
		{
			if ( 0 == rowColumn.getDouble( ) )
				return null;
			return new ColumnReferenceExpression( getDataSetMode( )
					? STRING_ROW : STRING_DATASETROW,
					(int) rowColumn.getDouble( ) );
		}
		else if ( rowColumn.getType( ) == Token.STRING )
		{
			if ( "_rownum".equals( rowColumn.getString( ) ) )
				return null;
			return new ColumnReferenceExpression( getDataSetMode( )
					? STRING_ROW : STRING_DATASETROW, rowColumn.getString( ) );
		}
	}

	// right side is not a STRING or a NUMBER, which is what is needed for
	// a direct column reference. so it could be something
	// like row[getColumnIndex()] and that would be a complex expression
	return null;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:57,代码来源:ExpressionCompiler.java

示例11: processChild

/**
	 * 
	 * 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;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:66,代码来源:AbstractExpressionCompiler.java

示例12: compileColRefExpr

/**
 * Check if the expression is a direct column reference type. If so, returns
 * an instance of DirectColRefExpr that represents it; otherwise returns
 * null.
 * 
 * @param refNode
 * @param customerChecked
 * @return
 * @throws DataException
 */
protected ColumnReferenceExpression compileColRefExpr( Node refNode,
		boolean customerChecked ) throws DataException
{
	// if it's a GETPROP or GETELEM with row on the left side,
	// and either a STRING or NUMBER on the right side, then it's
	// a direct column reference
	assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );

	Node rowName = refNode.getFirstChild( );
	assert ( rowName != null );
	if ( rowName.getType( ) != Token.NAME )
		return null;

	String str = rowName.getString( );
	assert ( str != null );
	if ( !str.equals( rowIndicator ) )
		return null;

	Node rowColumn = rowName.getNext( );
	assert ( rowColumn != null );

	if ( refNode.getType( ) == Token.GETPROP
			&& rowColumn.getType( ) == Token.STRING )
	{
		return new ColumnReferenceExpression(
				this.isDataSetMode ? STRING_ROW : STRING_DATASETROW,
				rowColumn.getString());
	}
	if ( refNode.getType( ) == Token.GETELEM )
	{
		if ( rowColumn.getType( ) == Token.NUMBER )
		{
			return new ColumnReferenceExpression(
					this.isDataSetMode ? STRING_ROW : STRING_DATASETROW,
					(int) rowColumn.getDouble());
		}
		else if ( rowColumn.getType( ) == Token.STRING )
		{
			return new ColumnReferenceExpression(
					this.isDataSetMode ? STRING_ROW : STRING_DATASETROW,
					rowColumn.getString());
		}
	}
	// right side is not a STRING or a NUMBER, which is what is needed for
	// a direct column reference. so it could be something
	// like row[getColumnIndex()] and that would be a complex expression
	return null;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:58,代码来源:AbstractExpressionCompiler.java

示例13: isColumnExpression

/**
 * whether the expression is column reference
 * @param expression
 * @return
 */
public static boolean isColumnExpression( String expression, boolean mode )
{
	boolean isColumn = false;
	if ( expression == null || expression.trim( ).length( ) == 0 )
		return isColumn;
	if ( getCompiledExpCacheMap( mode ).containsKey( expression ) )
	{
		return ( (Boolean)  getCompiledExpCacheMap( mode ).get( expression ) ).booleanValue( );
	}
	Context context = Context.enter( );
	ScriptNode tree;
	try
	{
		CompilerEnvirons m_compilerEnv = new CompilerEnvirons( );
		m_compilerEnv.initFromContext( context );
		Parser p = new Parser( m_compilerEnv, context.getErrorReporter( ) );
		AstRoot root = p.parse( expression, null, 0 );
		IRFactory ir = new IRFactory( m_compilerEnv );
		tree = ir.transformTree( root );
	}
	catch ( Exception e )
	{
		getCompiledExpCacheMap( mode ).put( expression,
				Boolean.valueOf( false ) );
		return false;
	}
	finally
	{
		Context.exit( );
	}

	if ( tree.getFirstChild( ) == tree.getLastChild( ) )
	{
		// A single expression
		if ( tree.getFirstChild( ).getType( ) != Token.EXPR_RESULT
				&& tree.getFirstChild( ).getType( ) != Token.EXPR_VOID
				&& tree.getFirstChild( ).getType( ) != Token.BLOCK )
		{
			isColumn = false;
		}
		Node exprNode = tree.getFirstChild( );
		Node child = exprNode.getFirstChild( );
		assert ( child != null );
		if ( child.getType( ) == Token.GETELEM
				|| child.getType( ) == Token.GETPROP )
			isColumn = getDirectColRefExpr( child, mode );
		else
			isColumn = false;
	}
	else
	{
		isColumn = false;
	}
	getCompiledExpCacheMap( mode ).put( expression,
			Boolean.valueOf( isColumn ) );
	return isColumn;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:62,代码来源:ExpressionUtility.java

示例14: isColumnExpression

/**
 * whether the expression is column reference
 * 
 * @param expression
 * @return
 */
public static boolean isColumnExpression( String expression )
{
	boolean isColumn = false;
	if ( expression == null || expression.trim( ).length( ) == 0 )
		return isColumn;
	if ( compiledExprCache.containsKey( expression ) )
		return ( (Boolean) compiledExprCache.get( expression ) ).booleanValue( );
	Context context = Context.enter( );
	ScriptNode tree;
	try
	{
		CompilerEnvirons m_compilerEnv = new CompilerEnvirons( );
		m_compilerEnv.initFromContext( context );
		Parser p = new Parser( m_compilerEnv, context.getErrorReporter( ) );
		AstRoot root = p.parse( expression, null, 0 );
		IRFactory ir = new IRFactory( m_compilerEnv );
		tree = ir.transformTree( root );
	}
	catch ( Exception e )
	{
		compiledExprCache.put( expression, Boolean.valueOf( false ) );
		return false;
	}
	finally
	{
		Context.exit( );
	}

	if ( tree.getFirstChild( ) == tree.getLastChild( ) )
	{
		// A single expression
		if ( tree.getFirstChild( ).getType( ) != Token.EXPR_RESULT
				&& tree.getFirstChild( ).getType( ) != Token.EXPR_VOID
				&& tree.getFirstChild( ).getType( ) != Token.BLOCK )
		{
			isColumn = false;
		}
		Node exprNode = tree.getFirstChild( );
		Node child = exprNode.getFirstChild( );
		assert ( child != null );
		if ( child.getType( ) == Token.GETELEM
				|| child.getType( ) == Token.GETPROP )
			isColumn = getDirectColRefExpr( child );
		else
			isColumn = false;
	}
	else
	{
		isColumn = false;
	}

	compiledExprCache.put( expression, Boolean.valueOf( isColumn ) );
	return isColumn;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:60,代码来源:ExpressionUtility.java

示例15: compileOuterColRefExpr

/**
 * 
 * @param refNode
 * @return
 */
private int compileOuterColRefExpr( Node refNode )
{
	int count = 0;
	Node rowFirstNode = refNode.getFirstChild( );
	if ( refNode.getType( ) == Token.GETPROP
			|| refNode.getType( ) == Token.GETELEM
			|| refNode.getType( ) == Token.SETPROP
			|| refNode.getType( ) == Token.SETELEM )
	{
		if ( rowFirstNode.getType( ) == Token.NAME
				&& rowFirstNode.getString( ).equals( ROW_INDICATOR ) )
		{
			Node rowColumn = rowFirstNode.getNext( );
			if ( rowColumn.getType( ) == Token.STRING )
			{
				if ( "_outer".equals( rowColumn.getString( ) ) )
					count++;
			}
			return count;
		}
		else if ( rowFirstNode.getType( ) == Token.GETPROP
				|| rowFirstNode.getType( ) == Token.SETPROP )
		{
			if ( compileOuterColRefExpr( rowFirstNode ) == -1 )
				return -1;
			else
				count = count + compileOuterColRefExpr( rowFirstNode );
			Node nextChild = rowFirstNode.getNext( );
			if ( nextChild.getType( ) == Token.STRING )
			{
				if ( "_outer".equals( nextChild.getString( ) ) )
					count++;
			}
		}
		else
			return -1;
		return count;
	}
	else
		return -1;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:46,代码来源:ExpressionParserUtility.java


注:本文中的org.mozilla.javascript.Token.GETPROP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。