org.mozilla.javascript.ast.UnaryExpression.setOperator()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 JavaScript  
字(6.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.mozilla.javascript.ast.UnaryExpression.setOperator()方法的一些代码示例,展示了UnaryExpression.setOperator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UnaryExpression.setOperator()方法的具体详情如下:
包路径:org.mozilla.javascript.ast.UnaryExpression
类名称:UnaryExpression
方法名:setOperator

UnaryExpression.setOperator介绍

[英]Sets operator – same as #setType, but throws an exception if the operator is invalid
[中]Sets运算符–与#setType相同,但如果运算符无效,则会引发异常

代码示例

代码示例来源:origin: io.apigee/rhino

/**
 * Constructs a new UnaryExpression with the specified operator
 * and operand.  It sets the parent of the operand, and sets its own bounds
 * to encompass the operator and operand.
 * @param operator the node type
 * @param operatorPosition the absolute position of the operator.
 * @param operand the operand expression
 * @param postFix true if the operator follows the operand.  Int
 * @throws IllegalArgumentException} if {@code operand} is {@code null}
 */
public UnaryExpression(int operator, int operatorPosition,
            AstNode operand, boolean postFix) {
  assertNotNull(operand);
  int beg = postFix ? operand.getPosition() : operatorPosition;
  // JavaScript only has ++ and -- postfix operators, so length is 2
  int end = postFix
       ? operatorPosition + 2
       : operand.getPosition() + operand.getLength();
  setBounds(beg, end);
  setOperator(operator);
  setOperand(operand);
  isPostfix = postFix;
}

代码示例来源:origin: geogebra/geogebra

/**
 * Constructs a new UnaryExpression with the specified operator
 * and operand.  It sets the parent of the operand, and sets its own bounds
 * to encompass the operator and operand.
 * @param operator the node type
 * @param operatorPosition the absolute position of the operator.
 * @param operand the operand expression
 * @param postFix true if the operator follows the operand.  Int
 * @throws IllegalArgumentException} if {@code operand} is {@code null}
 */
public UnaryExpression(int operator, int operatorPosition,
            AstNode operand, boolean postFix) {
  assertNotNull(operand);
  int beg = postFix ? operand.getPosition() : operatorPosition;
  // JavaScript only has ++ and -- postfix operators, so length is 2
  int end = postFix
       ? operatorPosition + 2
       : operand.getPosition() + operand.getLength();
  setBounds(beg, end);
  setOperator(operator);
  setOperand(operand);
  isPostfix = postFix;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Constructs a new UnaryExpression with the specified operator
 * and operand.  It sets the parent of the operand, and sets its own bounds
 * to encompass the operator and operand.
 * @param operator the node type
 * @param operatorPosition the absolute position of the operator.
 * @param operand the operand expression
 * @param postFix true if the operator follows the operand.  Int
 * @throws IllegalArgumentException} if {@code operand} is {@code null}
 */
public UnaryExpression(int operator, int operatorPosition,
            AstNode operand, boolean postFix) {
  assertNotNull(operand);
  int beg = postFix ? operand.getPosition() : operatorPosition;
  // JavaScript only has ++ and -- postfix operators, so length is 2
  int end = postFix
       ? operatorPosition + 2
       : operand.getPosition() + operand.getLength();
  setBounds(beg, end);
  setOperator(operator);
  setOperand(operand);
  isPostfix = postFix;
}

代码示例来源:origin: com.github.tntim96/rhino

/**
 * Constructs a new UnaryExpression with the specified operator
 * and operand.  It sets the parent of the operand, and sets its own bounds
 * to encompass the operator and operand.
 * @param operator the node type
 * @param operatorPosition the absolute position of the operator.
 * @param operand the operand expression
 * @param postFix true if the operator follows the operand.  Int
 * @throws IllegalArgumentException} if {@code operand} is {@code null}
 */
public UnaryExpression(int operator, int operatorPosition,
            AstNode operand, boolean postFix) {
  assertNotNull(operand);
  int beg = postFix ? operand.getPosition() : operatorPosition;
  // JavaScript only has ++ and -- postfix operators, so length is 2
  int end = postFix
       ? operatorPosition + 2
       : operand.getPosition() + operand.getLength();
  setBounds(beg, end);
  setOperator(operator);
  setOperand(operand);
  isPostfix = postFix;
}

代码示例来源:origin: com.github.tntim96/rhino

private AstNode defaultXmlNamespace()
  throws IOException
{
  if (currentToken != Token.DEFAULT) codeBug();
  consumeToken();
  mustHaveXML();
  setRequiresActivation();
  int lineno = ts.lineno, pos = ts.tokenBeg;
  if (!(matchToken(Token.NAME) && "xml".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!(matchToken(Token.NAME) && "namespace".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!matchToken(Token.ASSIGN)) {
    reportError("msg.bad.namespace");
  }
  AstNode e = expr();
  UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos);
  dxmln.setOperator(Token.DEFAULTNAMESPACE);
  dxmln.setOperand(e);
  dxmln.setLineno(lineno);
  ExpressionStatement es = new ExpressionStatement(dxmln, true);
  return es;
}

代码示例来源:origin: io.apigee/rhino

private AstNode defaultXmlNamespace()
  throws IOException
{
  if (currentToken != Token.DEFAULT) codeBug();
  consumeToken();
  mustHaveXML();
  setRequiresActivation();
  int lineno = ts.lineno, pos = ts.tokenBeg;
  if (!(matchToken(Token.NAME) && "xml".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!(matchToken(Token.NAME) && "namespace".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!matchToken(Token.ASSIGN)) {
    reportError("msg.bad.namespace");
  }
  AstNode e = expr();
  UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos);
  dxmln.setOperator(Token.DEFAULTNAMESPACE);
  dxmln.setOperand(e);
  dxmln.setLineno(lineno);
  ExpressionStatement es = new ExpressionStatement(dxmln, true);
  return es;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

private AstNode defaultXmlNamespace()
  throws IOException
{
  if (currentToken != Token.DEFAULT) codeBug();
  consumeToken();
  mustHaveXML();
  setRequiresActivation();
  int lineno = ts.lineno, pos = ts.tokenBeg;
  if (!(matchToken(Token.NAME) && "xml".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!(matchToken(Token.NAME) && "namespace".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!matchToken(Token.ASSIGN)) {
    reportError("msg.bad.namespace");
  }
  AstNode e = expr();
  UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos);
  dxmln.setOperator(Token.DEFAULTNAMESPACE);
  dxmln.setOperand(e);
  dxmln.setLineno(lineno);
  ExpressionStatement es = new ExpressionStatement(dxmln, true);
  return es;
}

代码示例来源:origin: geogebra/geogebra

private AstNode defaultXmlNamespace()
  throws IOException
{
  if (currentToken != Token.DEFAULT) codeBug();
  consumeToken();
  mustHaveXML();
  setRequiresActivation();
  int lineno = ts.lineno, pos = ts.tokenBeg;
  if (!(matchToken(Token.NAME) && "xml".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!(matchToken(Token.NAME) && "namespace".equals(ts.getString()))) {
    reportError("msg.bad.namespace");
  }
  if (!matchToken(Token.ASSIGN)) {
    reportError("msg.bad.namespace");
  }
  AstNode e = expr();
  UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos);
  dxmln.setOperator(Token.DEFAULTNAMESPACE);
  dxmln.setOperand(e);
  dxmln.setLineno(lineno);
  ExpressionStatement es = new ExpressionStatement(dxmln, true);
  return es;
}

相关文章