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


Java IStrategoTerm.INT属性代码示例

本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.INT属性的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.INT属性的具体用法?Java IStrategoTerm.INT怎么用?Java IStrategoTerm.INT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.spoofax.interpreter.terms.IStrategoTerm的用法示例。


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

示例1: doSlowMatch

@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,代码行数:19,代码来源:SkeletonStrategoInt.java

示例2: dispatch

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,代码行数:26,代码来源:StrategoTermVisitee.java

示例3: getTermArguments

private IStrategoTerm getTermArguments(IContext env, IStrategoTerm t) throws InterpreterException {

        switch(t.getTermType()) {
        case IStrategoTerm.INT:
        case IStrategoTerm.REAL:
            return env.getFactory().makeList();
        case IStrategoTerm.APPL:
            IStrategoAppl a = (IStrategoAppl)t;
            if (Tools.isNil(a, env) || Tools.isCons(a, env))
                return t;
            else
                return env.getFactory().makeList(a.getAllSubterms());
        case IStrategoTerm.LIST: 
            return t;
        case IStrategoTerm.STRING:
            return env.getFactory().makeList();
        case IStrategoTerm.TUPLE:
            IStrategoTuple tup = (IStrategoTuple) t;
            IStrategoTerm[] args = new IStrategoTerm[tup.getSubtermCount()];
            for(int i = 0; i < args.length; i++) 
                args[i] = tup.get(i);
            return env.getFactory().makeList(args); 
        }
            
        throw new InterpreterException("Unknown term '" + t + "'");
    }
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:26,代码来源:Match.java

示例4: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    
    switch (tvars[0].getTermType()) {
        case IStrategoTerm.STRING:
            IStrategoString string = (IStrategoString) tvars[0];
            return makeString(env, string) || makeAppl(env, string, tvars[1]);
        case IStrategoTerm.INT:
        case IStrategoTerm.REAL:
            env.setCurrent(tvars[0]);
            return true;
        case IStrategoTerm.LIST:
            if (tvars[1].getTermType() != IStrategoTerm.LIST)
                return false;
            env.setCurrent(tvars[1]);
            return true;
        default:
            return false;
    }
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:21,代码来源:SSL_mkterm.java

示例5: call

@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,代码行数:17,代码来源:SSL_TicksToSeconds.java

示例6: match

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,代码行数:18,代码来源:StrategoTerms.java

示例7: getTermArguments

private IStrategoTerm getTermArguments(IContext env, IStrategoTerm t) throws InterpreterException {

        switch(t.getTermType()) {
        case IStrategoTerm.INT:
        case IStrategoTerm.REAL:
            return env.getFactory().makeList();
        case IStrategoTerm.APPL:
            IStrategoAppl a = (IStrategoAppl)t;
            if (Tools.isNil(a, env) || Tools.isCons(a, env))
                return t;
            else
                return env.getFactory().makeList(a.getArguments());
        case IStrategoTerm.LIST: 
            return t;
        case IStrategoTerm.STRING:
            return env.getFactory().makeList();
        case IStrategoTerm.TUPLE:
            IStrategoTuple tup = (IStrategoTuple) t;
            IStrategoTerm[] args = new IStrategoTerm[tup.getSubtermCount()];
            for(int i = 0; i < args.length; i++) 
                args[i] = tup.get(i);
            return env.getFactory().makeList(args); 
        }
            
        throw new InterpreterException("Unknown term '" + t + "'");
    }
 
开发者ID:metaborg,项目名称:jsglr,代码行数:26,代码来源:java2.java

示例8: unpackTerm

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,代码行数:14,代码来源:JFFLibrary.java

示例9: match

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,代码行数:28,代码来源:Match.java

示例10: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {

    ITermFactory factory = env.getFactory();
    switch(tvars[0].getTermType()) {
    case IStrategoTerm.APPL:
        IStrategoAppl a = (IStrategoAppl) tvars[0];
        env.setCurrent(factory.makeString(a.getConstructor().getName()));
        return true;
    case IStrategoTerm.INT:
        env.setCurrent(factory.makeInt(((IStrategoInt) tvars[0]).intValue()));
        return true;
    case IStrategoTerm.REAL:
        env.setCurrent(factory.makeReal(((IStrategoReal) tvars[0]).realValue()));
        return true;
    case IStrategoTerm.BLOB:
        env.setCurrent(factory.makeString("BLOB_" + tvars[0].toString()));
        return true;
    case IStrategoTerm.LIST:
        env.setCurrent(factory.makeList());
        return true;
    case IStrategoTerm.STRING:
        IStrategoString current = (IStrategoString) factory.annotateTerm(tvars[0], factory.makeList());
        env.setCurrent(factory.makeString(current.toString()));
        return true;
    case IStrategoTerm.TUPLE:
        env.setCurrent(factory.makeString(""));
        return true;
    case IStrategoTerm.PLACEHOLDER:
        env.setCurrent(factory.makePlaceholder(factory.makeList()));
        return true;
    default:
        throw new IllegalStateException("SSL_get_constructor failed for " + tvars[0]);
    }
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:36,代码来源:SSL_get_constructor.java

示例11: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    switch(tvars[0].getTermType()) {
    case IStrategoTerm.APPL:
        IStrategoAppl a = (IStrategoAppl) tvars[0];
        env.setCurrent(env.getFactory().makeList(a.getAllSubterms()));
        return true;
    case IStrategoTerm.INT:
    case IStrategoTerm.STRING:
    case IStrategoTerm.REAL:
    case IStrategoTerm.BLOB:
        env.setCurrent(env.getFactory().makeList());
        return true;
    case IStrategoTerm.LIST:
        env.setCurrent(tvars[0]);
        return true;
    case IStrategoTerm.TUPLE:
        IStrategoTuple tuple = (IStrategoTuple) tvars[0];
        env.setCurrent(env.getFactory().makeList(tuple.getAllSubterms()));
        return true;
    case IStrategoTerm.PLACEHOLDER:
        IStrategoPlaceholder placeholder = (IStrategoPlaceholder) tvars[0];
        env.setCurrent(env.getFactory().makeList(placeholder.getTemplate()));
        return true;
    default:
        throw new IllegalStateException("SSL_get_arguments failed for " + tvars[0]);
    }
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:29,代码来源:SSL_get_arguments.java

示例12: match

public Results match(IContext env, IStrategoTerm t, IStrategoAppl p)
throws InterpreterException {

	if (t == null) {
	    throw new InterpreterException("Null term while matching: term library 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,项目名称:jsglr,代码行数:28,代码来源:java2.java

示例13: getTermType

public int getTermType() {
    return IStrategoTerm.INT;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:3,代码来源:SkeletonStrategoInt.java

示例14: isTermInt

public static boolean isTermInt(IStrategoTerm t) {
	return t.getTermType() == IStrategoTerm.INT;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:3,代码来源:Tools.java


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