当前位置: 首页>>代码示例>>Java>>正文


Java IStrategoTuple.size方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:38,代码来源:StrategoTuple.java

示例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;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:29,代码来源:Match.java


注:本文中的org.spoofax.interpreter.terms.IStrategoTuple.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。