• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IdentNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jdk.nashorn.internal.ir.IdentNode的典型用法代码示例。如果您正苦于以下问题:Java IdentNode类的具体用法?Java IdentNode怎么用?Java IdentNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: checkValidLValue

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private boolean checkValidLValue(final Expression init, final String contextString) {
    if (init instanceof IdentNode) {
        if (!checkIdentLValue((IdentNode)init)) {
            return false;
        }
        verifyIdent((IdentNode)init, contextString);
        return true;
    } else if (init instanceof AccessNode || init instanceof IndexNode) {
        return true;
    } else if (isDestructuringLhs(init)) {
        verifyDestructuringAssignmentPattern(init, contextString);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Parser.java


示例2: getIdentifierName

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
/**
 * Create an IdentNode from the current token
 *
 * @return an IdentNode representing the current token
 */
protected final IdentNode getIdentifierName() {
    if (type == IDENT) {
        return getIdent();
    } else if (isIdentifierName()) {
        // Fake out identifier.
        final long identToken = Token.recast(token, IDENT);
        // Get IDENT.
        final String ident = (String)getValue(identToken);
        next();
        // Create IDENT node.
        return createIdentNode(identToken, finish, ident);
    } else {
        expect(IDENT);
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:AbstractParser.java


示例3: verifyStrictIdent

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
/**
 * Make sure that in strict mode, the identifier name used is allowed.
 *
 * @param ident         Identifier that is verified
 * @param contextString String used in error message to give context to the user
 */
private void verifyStrictIdent(final IdentNode ident, final String contextString) {
    if (isStrictMode) {
        switch (ident.getName()) {
        case "eval":
        case "arguments":
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        default:
            break;
        }

        if (ident.isFutureStrictName()) {
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Parser.java


示例4: execString

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
/**
 * Convert execString to a call to $EXEC.
 *
 * @param primaryToken Original string token.
 * @return callNode to $EXEC.
 */
CallNode execString(final int primaryLine, final long primaryToken) {
    // Synthesize an ident to call $EXEC.
    final IdentNode execIdent = new IdentNode(primaryToken, finish, ScriptingFunctions.EXEC_NAME);
    // Skip over EXECSTRING.
    next();
    // Set up argument list for call.
    // Skip beginning of edit string expression.
    expect(LBRACE);
    // Add the following expression to arguments.
    final List<Expression> arguments = Collections.singletonList(expression());
    // Skip ending of edit string expression.
    expect(RBRACE);

    return new CallNode(primaryLine, primaryToken, finish, execIdent, arguments, false);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Parser.java


示例5: propertySetterFunction

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private PropertyFunction propertySetterFunction(final long getSetToken, final int functionLine) {
    final PropertyKey setIdent = propertyName();
    final String setterName = setIdent.getPropertyName();
    final IdentNode setNameNode = createIdentNode(((Node)setIdent).getToken(), finish, NameCodec.encode("set " + setterName));
    expect(LPAREN);
    // be sloppy and allow missing setter parameter even though
    // spec does not permit it!
    final IdentNode argIdent;
    if (type == IDENT || isNonStrictModeIdent()) {
        argIdent = getIdent();
        verifyStrictIdent(argIdent, "setter argument");
    } else {
        argIdent = null;
    }
    expect(RPAREN);
    final List<IdentNode> parameters = new ArrayList<>();
    if (argIdent != null) {
        parameters.add(argIdent);
    }
    final FunctionNode functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER, functionLine);

    return new PropertyFunction(setIdent, functionNode);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:Parser.java


示例6: enterCatchNode

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
@Override
public boolean enterCatchNode(final CatchNode catchNode) {
    final IdentNode exception = catchNode.getExceptionIdentifier();
    final Block     block     = lc.getCurrentBlock();

    start(catchNode);

    // define block-local exception variable
    final String exname = exception.getName();
    // If the name of the exception starts with ":e", this is a synthetic catch block, likely a catch-all. Its
    // symbol is naturally internal, and should be treated as such.
    final boolean isInternal = exname.startsWith(EXCEPTION_PREFIX.symbolName());
    // IS_LET flag is required to make sure symbol is not visible outside catch block. However, we need to
    // clear the IS_LET flag after creation to allow redefinition of symbol inside the catch block.
    final Symbol symbol = defineSymbol(block, exname, catchNode, IS_VAR | IS_LET | (isInternal ? IS_INTERNAL : 0) | HAS_OBJECT_VALUE);
    symbol.clearFlag(IS_LET);

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:AssignSymbols.java


示例7: evaluateSafely

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private Object evaluateSafely(final Expression expr) {
    if (expr instanceof IdentNode) {
        return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName());
    }

    if (expr instanceof AccessNode) {
        final AccessNode accessNode = (AccessNode)expr;
        final Object     base       = evaluateSafely(accessNode.getBase());
        if (!(base instanceof ScriptObject)) {
            return null;
        }
        return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty());
    }

    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:TypeEvaluator.java


示例8: verifyParameterList

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private void verifyParameterList(final List<IdentNode> parameters, final ParserContextFunctionNode functionNode) {
    final IdentNode duplicateParameter = functionNode.getDuplicateParameterBinding();
    if (duplicateParameter != null) {
        if (functionNode.isStrict() || functionNode.getKind() == FunctionNode.Kind.ARROW || !functionNode.isSimpleParameterList()) {
            throw error(AbstractParser.message("strict.param.redefinition", duplicateParameter.getName()), duplicateParameter.getToken());
        }

        final int arity = parameters.size();
        final HashSet<String> parametersSet = new HashSet<>(arity);

        for (int i = arity - 1; i >= 0; i--) {
            final IdentNode parameter = parameters.get(i);
            String parameterName = parameter.getName();

            if (parametersSet.contains(parameterName)) {
                // redefinition of parameter name, rename in non-strict mode
                parameterName = functionNode.uniqueName(parameterName);
                final long parameterToken = parameter.getToken();
                parameters.set(i, new IdentNode(parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName)));
            }
            parametersSet.add(parameterName);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Parser.java


示例9: leaveIdentNode

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
@Override
public Node leaveIdentNode(final IdentNode identNode) {
    if (identNode.isPropertyName()) {
        return identNode;
    }

    final Symbol symbol = nameIsUsed(identNode.getName(), identNode);

    if (!identNode.isInitializedHere()) {
        symbol.increaseUseCount();
    }

    IdentNode newIdentNode = identNode.setSymbol(symbol);

    // If a block-scoped var is used before its declaration mark it as dead.
    // We can only statically detect this for local vars, cross-function symbols require runtime checks.
    if (symbol.isBlockScoped() && !symbol.hasBeenDeclared() && !identNode.isDeclaredHere() && isLocal(lc.getCurrentFunction(), symbol)) {
        newIdentNode = newIdentNode.markDead();
    }

    return end(newIdentNode);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:AssignSymbols.java


示例10: nameIsUsed

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private Symbol nameIsUsed(final String name, final IdentNode origin) {
    final Block block = lc.getCurrentBlock();

    Symbol symbol = findSymbol(block, name);

    //If an existing symbol with the name is found, use that otherwise, declare a new one
    if (symbol != null) {
        log.info("Existing symbol = ", symbol);
        if (symbol.isFunctionSelf()) {
            final FunctionNode functionNode = lc.getDefiningFunction(symbol);
            assert functionNode != null;
            assert lc.getFunctionBody(functionNode).getExistingSymbol(CALLEE.symbolName()) != null;
            lc.setFlag(functionNode, FunctionNode.USES_SELF_SYMBOL);
        }

        // if symbol is non-local or we're in a with block, we need to put symbol in scope (if it isn't already)
        maybeForceScope(symbol);
    } else {
        log.info("No symbol exists. Declare as global: ", name);
        symbol = defineSymbol(block, name, origin, IS_GLOBAL | IS_SCOPE);
    }

    functionUsesSymbol(symbol);
    return symbol;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:AssignSymbols.java


示例11: leaveTYPEOF

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add((Expression)LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName()).accept(this)); //null
    } else {
        args.add(rhs);
        args.add((Expression)LiteralNode.newInstance(unaryNode).accept(this)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args).accept(this);

    end(unaryNode);

    return runtimeNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:AssignSymbols.java


示例12: enterBinaryNode

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    if(binaryNode.isAssignment()) {
        final Expression lhs = binaryNode.lhs();
        if(!binaryNode.isSelfModifying()) {
            tagNeverOptimistic(lhs);
        }
        if(lhs instanceof IdentNode) {
            final Symbol symbol = ((IdentNode)lhs).getSymbol();
            // Assignment to internal symbols is never optimistic, except for self-assignment expressions
            if(symbol.isInternal() && !binaryNode.rhs().isSelfModifying()) {
                tagNeverOptimistic(binaryNode.rhs());
            }
        }
    } else if(binaryNode.isTokenType(TokenType.INSTANCEOF)) {
        tagNeverOptimistic(binaryNode.lhs());
        tagNeverOptimistic(binaryNode.rhs());
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:OptimisticTypesCalculator.java


示例13: leaveIdentNode

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
@Override
public Node leaveIdentNode(final IdentNode identNode) {
    final Symbol symbol = identNode.getSymbol();
    if(symbol == null) {
        assert identNode.isPropertyName();
        return identNode;
    } else if(symbol.isBytecodeLocal()) {
        // Identifiers accessing bytecode local variables will never be optimistic, as type calculation phase over
        // them will always assign them statically provable types. Note that access to function parameters can still
        // be optimistic if the parameter needs to be in scope as it's used by a nested function.
        return identNode;
    } else if(symbol.isParam() && lc.getCurrentFunction().isVarArg()) {
        // Parameters in vararg methods are not optimistic; we always access them using Object getters.
        return identNode.setType(identNode.getMostPessimisticType());
    } else {
        assert symbol.isScope();
        return leaveOptimistic(identNode);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:OptimisticTypesCalculator.java


示例14: enterBinaryNode

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
    if(binaryNode.isAssignment()) {
        final Expression lhs = binaryNode.lhs();
        if(!binaryNode.isSelfModifying()) {
            tagNeverOptimistic(lhs);
        }
        if(lhs instanceof IdentNode) {
            final Symbol symbol = ((IdentNode)lhs).getSymbol();
            // Assignment to internal symbols is never optimistic, except for self-assignment expressions
            if(symbol.isInternal() && !binaryNode.rhs().isSelfModifying()) {
                tagNeverOptimistic(binaryNode.rhs());
            }
        }
    } else if(binaryNode.isTokenType(TokenType.INSTANCEOF)
            || binaryNode.isTokenType(TokenType.EQ_STRICT)
            || binaryNode.isTokenType(TokenType.NE_STRICT)) {
        tagNeverOptimistic(binaryNode.lhs());
        tagNeverOptimistic(binaryNode.rhs());
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:OptimisticTypesCalculator.java


示例15: initializeMethodParameters

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
/**
 * Incoming method parameters are always declared on method entry; declare them in the local variable table.
 * @param function function for which code is being generated.
 */
private void initializeMethodParameters(final FunctionNode function) {
    final Label functionStart = new Label("fn_start");
    method.label(functionStart);
    int nextSlot = 0;
    if(function.needsCallee()) {
        initializeInternalFunctionParameter(CALLEE, function, functionStart, nextSlot++);
    }
    initializeInternalFunctionParameter(THIS, function, functionStart, nextSlot++);
    if(function.isVarArg()) {
        initializeInternalFunctionParameter(VARARGS, function, functionStart, nextSlot++);
    } else {
        for(final IdentNode param: function.getParameters()) {
            final Symbol symbol = param.getSymbol();
            if(symbol.isBytecodeLocal()) {
                method.initializeMethodParameter(symbol, param.getType(), functionStart);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:CodeGenerator.java


示例16: parseFunctionBody

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
/**
 * Execute parse and return the resulting function node.
 * Errors will be thrown and the error manager will contain information
 * if parsing should fail. This method is used to check if code String
 * passed to "Function" constructor is a valid function body or not.
 *
 * @return function node resulting from successful parse
 */
public FunctionNode parseFunctionBody() {
    try {
        stream = new TokenStream();
        lexer  = new Lexer(source, stream, scripting && !env._no_syntax_extensions);
        final int functionLine = line;

        // Set up first token (skips opening EOL.)
        k = -1;
        next();

        // Make a fake token for the function.
        final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength());
        // Set up the function to append elements.

        FunctionNode function = newFunctionNode(
            functionToken,
            new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()),
            new ArrayList<IdentNode>(),
            FunctionNode.Kind.NORMAL,
            functionLine);

        functionDeclarations = new ArrayList<>();
        sourceElements(false);
        addFunctionDeclarations(function);
        functionDeclarations = null;

        expect(EOF);

        function.setFinish(source.getLength() - 1);
        function = restoreFunctionNode(function, token); //commit code
        function = function.setBody(lc, function.getBody().setNeedsScope(lc));

        printAST(function);
        return function;
    } catch (final Exception e) {
        handleParseException(e);
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:Parser.java


示例17: replaceCompileTimeProperty

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
void replaceCompileTimeProperty() {
    final IdentNode identNode = (IdentNode)expression;
    final String name = identNode.getSymbol().getName();
    if (CompilerConstants.__FILE__.name().equals(name)) {
        replaceCompileTimeProperty(getCurrentSource().getName());
    } else if (CompilerConstants.__DIR__.name().equals(name)) {
        replaceCompileTimeProperty(getCurrentSource().getBase());
    } else if (CompilerConstants.__LINE__.name().equals(name)) {
        replaceCompileTimeProperty(getCurrentSource().getLine(identNode.position()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CodeGenerator.java


示例18: propertyGetterFunction

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
private PropertyFunction propertyGetterFunction(final long getSetToken, final int functionLine) {
    final PropertyKey getIdent = propertyName();
    final String getterName = getIdent.getPropertyName();
    final IdentNode getNameNode = createIdentNode(((Node)getIdent).getToken(), finish, NameCodec.encode("get " + getterName));
    expect(LPAREN);
    expect(RPAREN);
    final FunctionNode functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER, functionLine);

    return new PropertyFunction(getIdent, functionNode);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Parser.java


示例19: enterIdentNode

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
@Override
public boolean enterIdentNode(final IdentNode identNode) {
    if (identNode.isInternal()) {
        noProgramPoint.add(identNode);
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ProgramPoints.java


示例20: quickLocalVariable

import jdk.nashorn.internal.ir.IdentNode; //导入依赖的package包/类
/**
 * Generates an extra local variable, always using the same slot, one that is available after the end of the
 * frame.
 *
 * @param type the type of the variable
 *
 * @return the quick variable
 */
private IdentNode quickLocalVariable(final Type type) {
    final String name = lc.getCurrentFunction().uniqueName(QUICK_PREFIX.symbolName());
    final Symbol symbol = new Symbol(name, IS_INTERNAL | HAS_SLOT);
    symbol.setHasSlotFor(type);
    symbol.setFirstSlot(lc.quickSlot(type));

    final IdentNode quickIdent = IdentNode.createInternalIdentifier(symbol).setType(type);

    return quickIdent;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:CodeGenerator.java



注:本文中的jdk.nashorn.internal.ir.IdentNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AndroidDevMetrics类代码示例发布时间:2022-05-22
下一篇:
Java Page类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap