本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.getAnnotations方法的具体用法?Java IStrategoTerm.getAnnotations怎么用?Java IStrategoTerm.getAnnotations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoTerm
的用法示例。
在下文中一共展示了IStrategoTerm.getAnnotations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != PLACEHOLDER)
return false;
if (!getTemplate().match(((IStrategoPlaceholder) second).getTemplate()))
return false;
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例2: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if(second.getTermType() != IStrategoTerm.INT)
return false;
if (intValue() != ((IStrategoInt) second).intValue())
return false;
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例3: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if(second.getTermType() != IStrategoTerm.REAL)
return false;
if (realValue() != ((IStrategoReal) second).realValue())
return false;
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例4: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
IStrategoTerm wrapped = getWrapped();
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
// Do nothing
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
} else {
return false;
}
if (annotations.isEmpty()) {
return wrapped.match(second);
} else {
second = factory.annotateTerm(second, TermFactory.EMPTY_LIST);
return wrapped.match(second);
}
}
示例5: icon
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private @Nullable FileObject icon(IStrategoTerm term, FileObject location) {
final IStrategoList annos = term.getAnnotations();
if(annos == null) {
return null;
}
if(annos.getSubtermCount() != 1) {
return null;
}
final IStrategoTerm iconTerm = annos.getSubterm(0);
if(!(iconTerm instanceof IStrategoString)) {
return null;
}
final IStrategoString iconTermString = (IStrategoString) iconTerm;
final String iconLocation = iconTermString.stringValue();
try {
return location.resolveFile(iconLocation);
} catch(FileSystemException e) {
logger.error("Cannot resolve icon {} in {}", e, iconLocation, location);
return null;
}
}
示例6: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
final protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if(second.getTermType() != IStrategoTerm.APPL)
return false;
final IStrategoAppl o = (IStrategoAppl) second;
if(getConstructor() != o.getConstructor())
return false;
final IStrategoTerm[] kids = getAllSubterms();
final IStrategoTerm[] secondKids = o.getAllSubterms();
if(kids != secondKids) {
for(int i = 0, sz = kids.length; i < sz; i++) {
final IStrategoTerm kid = kids[i];
final IStrategoTerm secondKid = secondKids[i];
if(kid != secondKid && !kid.match(secondKid)) {
if(commonStorageType == SHARABLE && i != 0)
System.arraycopy(secondKids, 0, kids, 0, i);
return false;
}
}
// FIXME should update sharing when possible
// if (commonStorageType == SHARABLE)
// this.kids = secondKids;
}
final IStrategoList annotations = getAnnotations();
final IStrategoList secondAnnotations = second.getAnnotations();
if(annotations == secondAnnotations) {
return true;
} else if(annotations.match(secondAnnotations)) {
if(commonStorageType == SHARABLE)
internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例7: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != IStrategoTerm.TUPLE)
return false;
IStrategoTuple snd = (IStrategoTuple) second;
if (size() != snd.size())
return false;
IStrategoTerm[] kids = this.kids;
IStrategoTerm[] secondKids = snd.getAllSubterms();
if (kids != secondKids) {
for (int i = 0, sz = kids.length; i < sz; i++) {
IStrategoTerm kid = kids[i];
IStrategoTerm secondKid = secondKids[i];
if (kid != secondKid && !kid.match(secondKid)) {
if (commonStorageType == SHARABLE && i != 0)
System.arraycopy(secondKids, 0, kids, 0, i);
return false;
}
}
if (commonStorageType == SHARABLE)
this.kids = secondKids;
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例8: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != IStrategoTerm.APPL)
return false;
IStrategoAppl o = (IStrategoAppl)second;
if (!ctor.equals(o.getConstructor()))
return false;
IStrategoTerm[] kids = getAllSubterms();
IStrategoTerm[] secondKids = o.getAllSubterms();
if (kids != secondKids) {
for (int i = 0, sz = kids.length; i < sz; i++) {
IStrategoTerm kid = kids[i];
IStrategoTerm secondKid = secondKids[i];
if (kid != secondKid && !kid.match(secondKid)) {
if (commonStorageType == SHARABLE && i != 0)
System.arraycopy(secondKids, 0, kids, 0, i);
return false;
}
}
if (commonStorageType == SHARABLE)
this.kids = secondKids;
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例9: strip
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IStrategoTerm strip(IStrategoTerm term) {
if (term == null)
return null;
// Kids
boolean isRebuildNeeded = false;
IStrategoTerm[] kids = TermFactory.EMPTY;
if (term.getSubtermCount() > 0) {
kids = term.getAllSubterms();
IStrategoTerm[] newKids = tryStripKids(kids);
if (newKids != null) {
isRebuildNeeded = true;
kids = newKids;
}
}
// Annotations
IStrategoList annos = term.getAnnotations();
IStrategoTerm[] newAnnos = tryStripAnnos(annos);
if (newAnnos != null) {
isRebuildNeeded = true;
annos = factory.makeList(newAnnos);
}
// Self
if (!isRebuildNeeded)
isRebuildNeeded = term.getAttachment(null) != null;
return isRebuildNeeded
? converter.convertShallow(term, kids, annos)
: term;
}
示例10: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if(second.getTermType() != IStrategoTerm.STRING)
return false;
String value = stringValue();
String secondValue = ((IStrategoString) second).stringValue();
if (value == secondValue) {
// Do nothing
} else if (value.equals(secondValue)) {
// Don't apply resharing here (StrategoXT/801) but maintain
// the string instance that may be in the string pool
// if (commonStorageType == SHARABLE)
// this.value = secondValue;
} else {
return false;
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
// assert annotations.isEmpty() ? this == second : true : "Maximal sharing contract broken";
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例11: get
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static Optional<TermIndex> get(IStrategoTerm term) {
for (IStrategoTerm anno : term.getAnnotations()) {
Optional<TermIndex> index = match(anno);
if (index.isPresent()) {
return index;
}
}
return Optional.empty();
}
示例12: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != IStrategoTerm.LIST)
return false;
final IStrategoList snd = (IStrategoList) second;
if (size() != snd.size())
return false;
if (!isEmpty()) {
IStrategoTerm head = head();
IStrategoTerm head2 = snd.head();
if (head != head2 && !head.match(head2))
return false;
IStrategoList tail = tail();
IStrategoList tail2 = snd.tail();
// TODO: test equality of annos on cons nodes (see BasicStrategoList)
for (IStrategoList cons = tail, cons2 = tail2; !cons.isEmpty(); cons = cons.tail(), cons2 = cons2.tail()) {
IStrategoTerm consHead = cons.head();
IStrategoTerm cons2Head = cons2.head();
if (consHead != cons2Head && !consHead.match(cons2Head))
return false;
}
if (commonStorageType == SHARABLE) {
this.head = head2;
this.tail = tail2;
}
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例13: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != IStrategoTerm.LIST)
return false;
final IStrategoList snd = (IStrategoList) second;
if (size() != snd.size())
return false;
if (!isEmpty()) {
IStrategoTerm head = head();
IStrategoTerm head2 = snd.head();
if (head != head2 && !head.match(head2))
return false;
IStrategoList tail = tail();
IStrategoList tail2 = snd.tail();
// TODO: test equality of annos on cons nodes (see BasicStrategoList)
for (IStrategoList cons = tail, cons2 = tail2; !cons.isEmpty(); cons = cons.tail(), cons2 = cons2.tail()) {
IStrategoTerm consHead = cons.head();
IStrategoTerm cons2Head = cons2.head();
if (consHead != cons2Head && !consHead.match(cons2Head))
return false;
}
if (commonStorageType == SHARABLE) {
this.head = head2;
this.tail = tail2;
}
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例14: StrategoWrapped
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* Creates a new wrapped Stratego term, copying its annotations.
*/
public StrategoWrapped(IStrategoTerm wrapped) {
this(wrapped, wrapped.getAnnotations());
}
示例15: getNextTerm
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
* Finds the next term we are going to serialize, based on the current state
* of the stack.
*
* @return The next term we are going to serialize.
*/
private IStrategoTerm getNextTerm() {
IStrategoTerm next = null;
// Make sure the stack remains large enough
ensureStackCapacity();
while (next == null && stackPosition > -1) {
ATermMapping current = stack[stackPosition];
IStrategoTerm term = current.term;
final boolean hasRemainigSubterms = current.subTermsAfter > 0
|| term.getSubtermCount() > current.subTermIndex + 1;
if (hasRemainigSubterms) {
if (term.getTermType() != IStrategoTerm.LIST) {
next = term.getSubterm(++current.subTermIndex);
} else {
IStrategoList nextList = current.nextPartOfList;
next = nextList.head();
current.nextPartOfList = nextList.tail();
current.subTermIndex++;
current.subTermsAfter--;
}
ATermMapping child = new ATermMapping();
child.term = next;
if (next.getTermType() == IStrategoTerm.LIST) {
child.subTermsAfter = next.getSubtermCount();
}
stack[++stackPosition] = child;
} else if (!current.annosDone && !term.getAnnotations().isEmpty()) {
next = term.getAnnotations();
ATermMapping annos = new ATermMapping();
annos.term = next;
stack[++stackPosition] = annos;
current.annosDone = true;
} else {
stackPosition--;
}
}
return next;
}