本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.getStorageType方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.getStorageType方法的具体用法?Java IStrategoTerm.getStorageType怎么用?Java IStrategoTerm.getStorageType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoTerm
的用法示例。
在下文中一共展示了IStrategoTerm.getStorageType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStorageType
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
protected int getStorageType(IStrategoTerm[] terms) {
int result = defaultStorageType;
for (IStrategoTerm term : terms) {
int type = term.getStorageType();
if (type < result) {
if (type == 0) return 0;
result = type;
}
}
return result;
}
示例2: copyAttachments
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IStrategoTerm copyAttachments(IStrategoTerm from, IStrategoTerm to) {
if (to.getStorageType() != MUTABLE)
throw new IllegalArgumentException("Target term is not mutable and does not support attachments");
ITermAttachment attach = from.getAttachment(null);
while (attach != null) {
try {
to.putAttachment(attach.clone());
} catch (CloneNotSupportedException e) {
throw new IllegalArgumentException("Copying attachments of this type is not supported: " + attach.getAttachmentType(), e);
}
attach = attach.getNext();
}
return to;
}
示例3: makeLinkDesugared
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* @param origin
* The origin term. For lists, this must be the exact
* corresponding term with the same offset and length.
*/
public IStrategoTerm makeLinkDesugared(IStrategoTerm term, IStrategoTerm desugared) {
if (!term.isList() && DesugaredOriginAttachment.get(term) == null) {
if (term.getStorageType() == MUTABLE)
DesugaredOriginAttachment.setDesugaredOrigin(term, desugared);
} else if (REASSIGN_ORIGINS) {
throw new NotImplementedException("Not implemented: unwrapping of possibly already wrapped term");
}
return term;
}
示例4: match
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* Equality test.
*
* @note
* For {@link #SHARABLE} terms if a term 'x' is matched with multiple times,
* it should always appear as the argument of the match calls.
* Likewise, longer-lived terms should appear in this position.
*/
public final boolean match(IStrategoTerm second) {
if (this == second) return true;
if (second == null) return false;
int storageType = getStorageType();
switch (storageType) {
case MAXIMALLY_SHARED:
switch (second.getStorageType()) {
case MAXIMALLY_SHARED:
return false;
case SHARABLE:
// (common storage type is immutable, i.e. my subterms should not be overwritten)
return hashCode() == second.hashCode() && doSlowMatch(second, IMMUTABLE);
case IMMUTABLE:
return hashCode() == second.hashCode() && doSlowMatch(second, IMMUTABLE);
default:
return doSlowMatch(second, MUTABLE);
}
case SHARABLE:
case IMMUTABLE:
switch (second.getStorageType()) {
case MAXIMALLY_SHARED:
return hashCode() == second.hashCode() && doSlowMatch(second, storageType);
case SHARABLE:
return hashCode() == second.hashCode() && doSlowMatch(second, storageType);
case IMMUTABLE:
return hashCode() == second.hashCode() && doSlowMatch(second, IMMUTABLE);
default:
return doSlowMatch(second, MUTABLE);
}
default:
return doSlowMatch(second, MUTABLE);
}
}