當前位置: 首頁>>代碼示例>>Java>>正文


Java Assignment類代碼示例

本文整理匯總了Java中jdk.nashorn.internal.ir.Assignment的典型用法代碼示例。如果您正苦於以下問題:Java Assignment類的具體用法?Java Assignment怎麽用?Java Assignment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Assignment類屬於jdk.nashorn.internal.ir包,在下文中一共展示了Assignment類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: specialize

import jdk.nashorn.internal.ir.Assignment; //導入依賴的package包/類
<T extends Expression> SpecializedNode specialize(final Assignment<T> assignment) {
    final Node node = ((Node)assignment);
    final T lhs = assignment.getAssignmentDest();
    final Expression rhs = assignment.getAssignmentSource();

    if (!canHaveCallSiteType(lhs)) {
        return new SpecializedNode(node, null);
    }

    final Type to;
    if (node.isSelfModifying()) {
        to = node.getWidestOperationType();
    } else {
        to = rhs.getType();
    }

    if (!isSupportedCallSiteType(to)) {
        //meaningless to specialize to boolean or object
        return new SpecializedNode(node, null);
    }

    final Node newNode = assignment.setAssignmentDest(setTypeOverride(lhs, to));
    final Node typePropagatedNode;
    if(newNode instanceof Expression) {
        typePropagatedNode = propagateType((Expression)newNode, to);
    } else if(newNode instanceof VarNode) {
        // VarNode, being a statement, doesn't have its own symbol; it uses the symbol of its name instead.
        final VarNode varNode = (VarNode)newNode;
        typePropagatedNode = varNode.setName((IdentNode)propagateType(varNode.getName(), to));
    } else {
        throw new AssertionError();
    }
    return new SpecializedNode(typePropagatedNode, to);
}
 
開發者ID:wro4j,項目名稱:nashorn-backport,代碼行數:35,代碼來源:FinalizeTypes.java


注:本文中的jdk.nashorn.internal.ir.Assignment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。