• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IStrategoInt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoInt的典型用法代码示例。如果您正苦于以下问题:Java IStrategoInt类的具体用法?Java IStrategoInt怎么用?Java IStrategoInt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IStrategoInt类属于org.spoofax.interpreter.terms包,在下文中一共展示了IStrategoInt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: convert

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
public static ITTerm convert(IStrategoTerm t) {
	if (t instanceof IStrategoAppl)
		return convert((IStrategoAppl) t);

	if (t instanceof IStrategoTuple)
		return convert((IStrategoTuple) t);

	if (t instanceof IStrategoList)
		return convert((IStrategoList) t);

	if (t instanceof IStrategoString)
		return convert((IStrategoString) t);

	if (t instanceof IStrategoInt)
		return convert((IStrategoInt) t);

	throw new UnsupportedOperationException("Unsupported aterm " + t);
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:19,代码来源:TermConverter.java


示例2: doSlowMatch

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的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;
    }
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:20,代码来源:SkeletonStrategoInt.java


示例3: dispatch

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
private static boolean dispatch(IStrategoTermVisitor visitor, IStrategoTerm term) {
    switch(term.getTermType()) {
        case IStrategoTerm.APPL:
            return visitor.visit((IStrategoAppl) term);
        case IStrategoTerm.LIST:
            return visitor.visit((IStrategoList) term);
        case IStrategoTerm.TUPLE:
            return visitor.visit((IStrategoTuple) term);
        case IStrategoTerm.INT:
            visitor.visit((IStrategoInt) term);
            return false;
        case IStrategoTerm.REAL:
            visitor.visit((IStrategoReal) term);
            return false;
        case IStrategoTerm.STRING:
            visitor.visit((IStrategoString) term);
            return false;
        case IStrategoTerm.REF:
            visitor.visit((IStrategoRef) term);
            return false;
        case IStrategoTerm.PLACEHOLDER:
            return visitor.visit((IStrategoPlaceholder) term);
        default:
            return visitor.visit(term);
    }
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:27,代码来源:StrategoTermVisitee.java


示例4: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) throws InterpreterException {
    double a, b;
    
    if(Tools.isTermReal(tvars[0])) {
        a = ((IStrategoReal) tvars[0]).realValue();     
    } else if (Tools.isTermInt(tvars[0])) {
        a = ((IStrategoInt) tvars[0]).intValue();
    } else {
        return false;
    }
    
    if(Tools.isTermReal(tvars[1])) {
        b = ((IStrategoReal) tvars[1]).realValue();
    } else if (Tools.isTermInt(tvars[1])) {
        b = ((IStrategoInt) tvars[1]).intValue();
    } else {
        return false;
    }

    env.setCurrent(env.getFactory().makeReal(a + b));
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:24,代码来源:SSL_addr.java


示例5: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    
    if(!Tools.isTermString(tvars[0]))
        return false;
    if(!Tools.isTermString(tvars[1]))
        return false;
    
    String fn = Tools.javaString(tvars[0]);
    String mode = Tools.javaString(tvars[1]);
    
    IStrategoInt result = call(env, fn, mode);
    if (result == null) return false;
    
    env.setCurrent(result);
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:19,代码来源:SSL_fopen.java


示例6: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) throws InterpreterException {
    double a, b;
    
    // TODO: Factor out syntactic noise
    // TODO: Apply this pattern to other primitives; many (all?) real operations also work on ints
    
    if(Tools.isTermReal(tvars[0])) {
        a = ((IStrategoReal) tvars[0]).realValue();     
    } else if (Tools.isTermInt(tvars[0])) {
        a = ((IStrategoInt) tvars[0]).intValue();
    } else {
        return false;
    }
    
    if(Tools.isTermReal(tvars[1])) {
        b = ((IStrategoReal) tvars[1]).realValue();
    } else if (Tools.isTermInt(tvars[1])) {
        b = ((IStrategoInt) tvars[1]).intValue();
    } else {
        return false;
    }

    env.setCurrent(env.getFactory().makeReal(a / b));
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:27,代码来源:SSL_divr.java


示例7: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] sargs, IStrategoTerm[] tvars) throws InterpreterException {
    double a, b;
    
    if(Tools.isTermReal(tvars[0])) {
        a = ((IStrategoReal) tvars[0]).realValue();     
    } else if (Tools.isTermInt(tvars[0])) {
        a = ((IStrategoInt) tvars[0]).intValue();
    } else {
        return false;
    }
    
    if(Tools.isTermReal(tvars[1])) {
        b = ((IStrategoReal) tvars[1]).realValue();
    } else if (Tools.isTermInt(tvars[1])) {
        b = ((IStrategoInt) tvars[1]).intValue();
    } else {
        return false;
    }

    env.setCurrent(env.getFactory().makeReal(a * b));
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:24,代码来源:SSL_mulr.java


示例8: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] sargs, IStrategoTerm[] targs) throws InterpreterException {

    if(!(Tools.isTermInt(targs[0])))
        return false;
    if(!(Tools.isTermInt(targs[1])))
        return false;

    int initialSize = ((IStrategoInt)targs[0]).intValue();
    int maxLoad = ((IStrategoInt)targs[1]).intValue();

    IStrategoTerm result = new StrategoSet(initialSize, maxLoad);
    env.setCurrent(result);
    
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:17,代码来源:SSL_indexedSet_create.java


示例9: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] sargs, IStrategoTerm[] targs)
        throws InterpreterException {

    if (!(Tools.isTermInt(targs[0])))
        return false;
    if (!(Tools.isTermInt(targs[1])))
        return false;

    int initialSize = ((IStrategoInt)targs[0]).intValue();
    int maxLoad = ((IStrategoInt)targs[1]).intValue();

    IStrategoTerm table = new StrategoHashMap(initialSize, maxLoad);
    
    env.setCurrent(table);
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:18,代码来源:SSL_hashtable_create.java


示例10: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    
    IStrategoTerm time = tvars[0];
    int timeValue; 
    
    if (time.getTermType() == IStrategoTerm.REAL)
        timeValue = (int) ((IStrategoReal) time).realValue();
    else if (time.getTermType() == IStrategoTerm.INT)
        timeValue = ((IStrategoInt) time).intValue();
    else
        return false;
    
    env.setCurrent(env.getFactory().makeReal(timeValue / (double) SSL_times.TICKS_PER_SECOND));
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:18,代码来源:SSL_TicksToSeconds.java


示例11: create

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
public static @Nullable OutlineFacet create(IStrategoAppl esv) {
    final IStrategoAppl outlineTerm = ESVReader.findTerm(esv, "OutlineView");
    if(outlineTerm == null) {
        return null;
    }
    final String strategyName = ESVReader.termContents(outlineTerm.getSubterm(0));

    final int expandTo;
    final IStrategoAppl expandToTerm = ESVReader.findTerm(esv, "ExpandToLevel");
    if(expandToTerm == null) {
        expandTo = 0;
    } else {
        final IStrategoTerm expandToNumberTerm = expandToTerm.getSubterm(0);
        if(expandToNumberTerm instanceof IStrategoInt) {
            final IStrategoInt expandToNumberIntTerm = (IStrategoInt) expandToNumberTerm;
            expandTo = expandToNumberIntTerm.intValue();
        } else if(expandToNumberTerm instanceof IStrategoString) {
            final IStrategoString expandToNumberStringTerm = (IStrategoString) expandToNumberTerm;
            expandTo = Integer.parseInt(expandToNumberStringTerm.stringValue());
        } else {
            expandTo = 0;
        }
    }

    return new OutlineFacet(strategyName, expandTo);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:27,代码来源:OutlineFacetFromESV.java


示例12: match

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
public static <T> T match(IStrategoTerm term, ICases<T> cases) {
    switch(term.getTermType()) {
        case IStrategoTerm.APPL:
            return cases.caseAppl((IStrategoAppl) term);
        case IStrategoTerm.LIST:
            return cases.caseList((IStrategoList) term);
        case IStrategoTerm.TUPLE:
            return cases.caseTuple((IStrategoTuple) term);
        case IStrategoTerm.INT:
            return cases.caseInt((IStrategoInt) term);
        case IStrategoTerm.REAL:
            return cases.caseReal((IStrategoReal) term);
        case IStrategoTerm.STRING:
            return cases.caseString((IStrategoString) term);
        default:
            throw new IllegalArgumentException("Unsupported Stratego term type " + term.getTermType());
    }
}
 
开发者ID:metaborg,项目名称:nabl,代码行数:19,代码来源:StrategoTerms.java


示例13: toNode

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
private TNode toNode(IStrategoTerm term, String sort) {
	switch (term.getTermType()) {
		case PLACEHOLDER:
			return placeholderToNode(term, sort);
			
		case APPL: case STRING:
			return namedToNode(term, sort);
			
		case LIST:
			return listToNode(term, sort);
			
		case INT:
			IStrategoInt i = (IStrategoInt) term;
			return factory.createIntTerminal(sort, leftToken, i.intValue());
			
		case REAL:
			IStrategoReal r = (IStrategoReal) term;
			return factory.createRealTerminal(sort, leftToken, r.realValue());
			
		default:
			throw new IllegalStateException("Unexpected term type encountered in {ast} attribute");
	}
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:24,代码来源:AstAnnoImploder.java


示例14: recreateNode

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
public IStrategoTerm recreateNode(IStrategoTerm oldNode, IToken leftToken, IToken rightToken,
    List<IStrategoTerm> children) {
    ImploderAttachment it = oldNode.getAttachment(ImploderAttachment.TYPE);


    switch(oldNode.getTermType()) {
        case INT:
            return createIntTerminal(getSort(oldNode), leftToken, ((IStrategoInt) oldNode).intValue());
        case APPL:
            return createNonTerminal(getSort(oldNode), ((IStrategoAppl) oldNode).getName(), leftToken, rightToken,
                children, it.isCompletion(), it.isNestedCompletion(), it.isSinglePlaceholderCompletion());
        case LIST:
            return createList(getElementSort(oldNode), leftToken, rightToken, children);
        case STRING:
            return createStringTerminal(getSort(oldNode), leftToken, rightToken,
                ((IStrategoString) oldNode).stringValue(), !(((IStrategoString) oldNode).stringValue().equals(it.toString())));
        case TUPLE:
            return createTuple(getElementSort(oldNode), leftToken, rightToken, children);
        case REAL:
            return createRealTerminal(getElementSort(oldNode), leftToken, ((IStrategoReal) oldNode).realValue());
        default:
            throw new NotImplementedException(
                "Recreating term of type " + oldNode.getTermType() + " (" + oldNode + ") not supported");
    }
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:26,代码来源:TermTreeFactory.java


示例15: visit

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
/**
 * nathan: added
 */
protected void visit(IStrategoTerm term) {

    switch (term.getTermType()) {
    	case APPL:
    		voidVisitAppl((IStrategoAppl) term);
    		break;
    	case INT:
    		voidVisitInt((IStrategoInt) term);
    		break;
    	case LIST:
    		voidVisitList((IStrategoList) term);
    		break;
    	case REAL:
    		voidVisitReal((IStrategoReal) term);
    		break;
    	case STRING:
    		voidVisitString((IStrategoString) term);
    		break;
    	case TUPLE:
    		voidVisitTuple((IStrategoTuple) term);
    		break;
    	default:
    		throw new RuntimeException("Could not serializate term of type "
                + term.getClass().getName() + " to SAF format.");
    }

}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:31,代码来源:SAFWriter.java


示例16: unpackTerm

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
public Object unpackTerm(IStrategoTerm term) {
	switch(term.getTermType()) {
	case IStrategoTerm.INT:
		return ((IStrategoInt)term).intValue();
	case IStrategoTerm.REAL:
		return ((IStrategoReal)term).realValue();
	case IStrategoTerm.STRING:
		return ((IStrategoString)term).stringValue();
	case IStrategoTerm.APPL:
		return unwrapObject((IStrategoAppl)term);
	default:
		return null;
	}
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:15,代码来源:JFFLibrary.java


示例17: call

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
@Override
public boolean call(IContext context, Strategy[] svars, IStrategoTerm[] tvars) {

	IStrategoTerm current = context.current();
	
	if (!(current instanceof IStrategoTuple))
		return false;

	IStrategoTuple t = (IStrategoTuple) current;

	if (t.getSubtermCount() < 2)
		return false;
	if (t.getSubtermCount() < 2)
		return false;

	if (!(t.get(0) instanceof IStrategoInt))
		return false;

	IStrategoInt bufferSize = (IStrategoInt) t.get(0);

	if (!(t.get(1) instanceof IStrategoInt))
		return false;

	IStrategoInt direct = (IStrategoInt) t.get(1);

	ByteBuffer buf = null;
	
	if (direct.intValue() == 1)
		buf = ByteBuffer.allocateDirect(bufferSize.intValue());
	else
		buf = ByteBuffer.allocate(bufferSize.intValue());
	
	context.setCurrent(new GenericWrappedTerm("ByteBuffer", buf));
	return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:36,代码来源:JFF_make_byte_buffer_0_0.java


示例18: matchInt

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
protected Results matchInt(IContext env, IStrategoInt t,
        IStrategoAppl p) throws InterpreterException {

    if (DebugUtil.isDebugging()) {
        debug("term is Int");
    }

    if (Tools.isAnno(p, env)) {
        return matchAnyAnno(env, t, p);
    }
    else if (Tools.isInt(p, env)) {
        return matchIntInt(t, p);
    }
    else if (Tools.isReal(p, env)) {
        return null;
    }
    else if (Tools.isVar(p, env)) {
        return matchAnyVar(t, p);
    }
    else if (Tools.isOp(p, env)) {
        return null;
    }
    else if (Tools.isExplode(p, env)) {
        return matchAnyExplode(env, t, p);
    }
    else if (Tools.isWld(p, env)) {
        return matchAnyWld(p);
    }
    else if (Tools.isAs(p, env)) {
        return matchCompoundAs(env, t, p);
    } else if(Tools.isStr(p, env)) {
        return null;
    }

    throw new InterpreterException("Unknown Int case '" + p + "'");
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:37,代码来源:Match.java


示例19: matchIntInt

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
protected Results matchIntInt(IStrategoInt t, IStrategoAppl p) {
    Integer intVal = new Integer(Tools.javaStringAt(p, 0));
    if (intVal == t.intValue())
        return emptyList();

    return null;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:8,代码来源:Match.java


示例20: match

import org.spoofax.interpreter.terms.IStrategoInt; //导入依赖的package包/类
public Results match(IContext env, IStrategoTerm t, IStrategoAppl p)
throws InterpreterException {

	if (t == null) {
	    throw new InterpreterException("Null term while matching: term library or one of the primitives is defective");
	}
    switch (t.getTermType()) {
    case IStrategoTerm.APPL:
        return matchAppl(env, (IStrategoAppl) t, p);
    case IStrategoTerm.INT:
        return matchInt(env, (IStrategoInt) t, p);
    case IStrategoTerm.REAL:
        return matchReal(env, (IStrategoReal) t, p);
    case IStrategoTerm.STRING:
        return matchString(env, (IStrategoString) t, p);
    case IStrategoTerm.LIST:
        return matchList(env, (IStrategoList) t, p);
    case IStrategoTerm.TUPLE:
        return matchTuple(env, (IStrategoTuple) t, p);
    case IStrategoTerm.REF:
        return matchRef(env, (IStrategoRef)t, p);
    case IStrategoTerm.BLOB:
        return matchBlob(env, t, p);
    default:
        throw new InterpreterException("Unsupported term type : "
                                       + t.getClass().toString() + " [" + t.getTermType() + "]");
    }
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:29,代码来源:Match.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertySheetTableModel类代码示例发布时间:2022-05-22
下一篇:
Java SelectDirectoryDialog类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap