本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTuple.size方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTuple.size方法的具体用法?Java IStrategoTuple.size怎么用?Java IStrategoTuple.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoTuple
的用法示例。
在下文中一共展示了IStrategoTuple.size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的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;
}
}
示例2: matchTupleOp
import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的package包/类
private Results matchTupleOp(IContext env, IStrategoTuple t, IStrategoAppl p) throws InterpreterException {
String c = Tools.javaStringAt(p, 0);
// Check that the pattern p is really against a tuple
if(!c.equals(""))
return null;
IStrategoList ctorArgs = Tools.listAt(p, 1);
// Check that arity of pattern equals arity of tuple
if(ctorArgs.size() != t.size())
return null;
// Match subterms of tuple against subpatterns of pattern
Results r = emptyList();
for (int i = 0; i < ctorArgs.size(); i++) {
Results m = match(env, t.get(i),
(IStrategoAppl) ctorArgs
.getSubterm(i));
if (m != null)
r.addAll(m);
else
return null;
}
return r;
}