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

The following examples show how to use org.mozilla.javascript.Token#CONST . 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: VariableInitializer.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets the node type.
 * @throws IllegalArgumentException if {@code nodeType} is not one of
 * {@link Token#VAR}, {@link Token#CONST}, or {@link Token#LET}
 */
public void setNodeType(int nodeType) {
    if (nodeType != Token.VAR
        && nodeType != Token.CONST
        && nodeType != Token.LET)
        throw new IllegalArgumentException("invalid node type");
    setType(nodeType);
}
 
Example 2
Source File: VariableDeclaration.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets the node type and returns this node.
 * @throws IllegalArgumentException if {@code declType} is invalid
 */
@Override
public org.mozilla.javascript.Node setType(int type) {
    if (type != Token.VAR
        && type != Token.CONST
        && type != Token.LET)
        throw new IllegalArgumentException("invalid decl type: " + type);
    return super.setType(type);
}
 
Example 3
Source File: Symbol.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets symbol declaration type
 */
public void setDeclType(int declType) {
    if (!(declType == Token.FUNCTION
          || declType == Token.LP
          || declType == Token.VAR
          || declType == Token.LET
          || declType == Token.CONST))
        throw new IllegalArgumentException("Invalid declType: " + declType);
    this.declType = declType;
}
 
Example 4
Source File: VariableInitializer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the node type.
 * @throws IllegalArgumentException if {@code nodeType} is not one of
 * {@link Token#VAR}, {@link Token#CONST}, or {@link Token#LET}
 */
public void setNodeType(int nodeType) {
    if (nodeType != Token.VAR
        && nodeType != Token.CONST
        && nodeType != Token.LET)
        throw new IllegalArgumentException("invalid node type");
    setType(nodeType);
}
 
Example 5
Source File: VariableDeclaration.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the node type and returns this node.
 * @throws IllegalArgumentException if {@code declType} is invalid
 */
@Override
public org.mozilla.javascript.Node setType(int type) {
    if (type != Token.VAR
        && type != Token.CONST
        && type != Token.LET)
        throw new IllegalArgumentException("invalid decl type: " + type);
    return super.setType(type);
}
 
Example 6
Source File: Symbol.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets symbol declaration type
 */
public void setDeclType(int declType) {
    if (!(declType == Token.FUNCTION
          || declType == Token.LP
          || declType == Token.VAR
          || declType == Token.LET
          || declType == Token.CONST))
        throw new IllegalArgumentException("Invalid declType: " + declType);
    this.declType = declType;
}
 
Example 7
Source File: AstNode.java    From JsDroidCmd with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public boolean hasSideEffects()
{
    switch (getType()) {
      case Token.ASSIGN:
      case Token.ASSIGN_ADD:
      case Token.ASSIGN_BITAND:
      case Token.ASSIGN_BITOR:
      case Token.ASSIGN_BITXOR:
      case Token.ASSIGN_DIV:
      case Token.ASSIGN_LSH:
      case Token.ASSIGN_MOD:
      case Token.ASSIGN_MUL:
      case Token.ASSIGN_RSH:
      case Token.ASSIGN_SUB:
      case Token.ASSIGN_URSH:
      case Token.BLOCK:
      case Token.BREAK:
      case Token.CALL:
      case Token.CATCH:
      case Token.CATCH_SCOPE:
      case Token.CONST:
      case Token.CONTINUE:
      case Token.DEC:
      case Token.DELPROP:
      case Token.DEL_REF:
      case Token.DO:
      case Token.ELSE:
      case Token.ENTERWITH:
      case Token.ERROR:         // Avoid cascaded error messages
      case Token.EXPORT:
      case Token.EXPR_RESULT:
      case Token.FINALLY:
      case Token.FUNCTION:
      case Token.FOR:
      case Token.GOTO:
      case Token.IF:
      case Token.IFEQ:
      case Token.IFNE:
      case Token.IMPORT:
      case Token.INC:
      case Token.JSR:
      case Token.LABEL:
      case Token.LEAVEWITH:
      case Token.LET:
      case Token.LETEXPR:
      case Token.LOCAL_BLOCK:
      case Token.LOOP:
      case Token.NEW:
      case Token.REF_CALL:
      case Token.RETHROW:
      case Token.RETURN:
      case Token.RETURN_RESULT:
      case Token.SEMI:
      case Token.SETELEM:
      case Token.SETELEM_OP:
      case Token.SETNAME:
      case Token.SETPROP:
      case Token.SETPROP_OP:
      case Token.SETVAR:
      case Token.SET_REF:
      case Token.SET_REF_OP:
      case Token.SWITCH:
      case Token.TARGET:
      case Token.THROW:
      case Token.TRY:
      case Token.VAR:
      case Token.WHILE:
      case Token.WITH:
      case Token.WITHEXPR:
      case Token.YIELD:
        return true;

      default:
        return false;
    }
}
 
Example 8
Source File: VariableDeclaration.java    From JsDroidCmd with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Returns true if this is a {@link Token#CONST} declaration.
 */
public boolean isConst() {
    return type == Token.CONST;
}
 
Example 9
Source File: AstNode.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasSideEffects()
{
    switch (getType()) {
      case Token.ASSIGN:
      case Token.ASSIGN_ADD:
      case Token.ASSIGN_BITAND:
      case Token.ASSIGN_BITOR:
      case Token.ASSIGN_BITXOR:
      case Token.ASSIGN_DIV:
      case Token.ASSIGN_LSH:
      case Token.ASSIGN_MOD:
      case Token.ASSIGN_MUL:
      case Token.ASSIGN_RSH:
      case Token.ASSIGN_SUB:
      case Token.ASSIGN_URSH:
      case Token.BLOCK:
      case Token.BREAK:
      case Token.CALL:
      case Token.CATCH:
      case Token.CATCH_SCOPE:
      case Token.CONST:
      case Token.CONTINUE:
      case Token.DEC:
      case Token.DELPROP:
      case Token.DEL_REF:
      case Token.DO:
      case Token.ELSE:
      case Token.ENTERWITH:
      case Token.ERROR:         // Avoid cascaded error messages
      case Token.EXPORT:
      case Token.EXPR_RESULT:
      case Token.FINALLY:
      case Token.FUNCTION:
      case Token.FOR:
      case Token.GOTO:
      case Token.IF:
      case Token.IFEQ:
      case Token.IFNE:
      case Token.IMPORT:
      case Token.INC:
      case Token.JSR:
      case Token.LABEL:
      case Token.LEAVEWITH:
      case Token.LET:
      case Token.LETEXPR:
      case Token.LOCAL_BLOCK:
      case Token.LOOP:
      case Token.NEW:
      case Token.REF_CALL:
      case Token.RETHROW:
      case Token.RETURN:
      case Token.RETURN_RESULT:
      case Token.SEMI:
      case Token.SETELEM:
      case Token.SETELEM_OP:
      case Token.SETNAME:
      case Token.SETPROP:
      case Token.SETPROP_OP:
      case Token.SETVAR:
      case Token.SET_REF:
      case Token.SET_REF_OP:
      case Token.SWITCH:
      case Token.TARGET:
      case Token.THROW:
      case Token.TRY:
      case Token.VAR:
      case Token.WHILE:
      case Token.WITH:
      case Token.WITHEXPR:
      case Token.YIELD:
        return true;

      default:
        return false;
    }
}
 
Example 10
Source File: VariableDeclaration.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if this is a {@link Token#CONST} declaration.
 */
public boolean isConst() {
    return type == Token.CONST;
}