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


Java IStrategoTuple.get方法代码示例

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


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

示例1: getTermArguments

import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的package包/类
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,代码行数:27,代码来源:Match.java

示例2: getTermArguments

import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的package包/类
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,代码行数:27,代码来源:java2.java

示例3: call

import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的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.get(0) instanceof IStrategoString))
		return false;
	
	IStrategoString fileName = (IStrategoString) t.get(0);

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

	IStrategoString mode = (IStrategoString) t.get(1);

	try {
		RandomAccessFile raf = new RandomAccessFile(new File(fileName.stringValue()), mode.stringValue());
		context.setCurrent(new GenericWrappedTerm("FileChannel", raf.getChannel()));
		return true;
	} catch(IOException e) {
		return JFFLibrary.invokeExceptionHandler(context, e);
	}
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:32,代码来源:JFF_open_file_channel_0_0.java

示例4: call

import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的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

示例5: fromTupleWrapped

import org.spoofax.interpreter.terms.IStrategoTuple; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T fromTupleWrapped(IStrategoTerm current, int index, Class<T> clazz) {

	if(!(current instanceof IStrategoTuple))
		return null;

	IStrategoTuple tuple = (IStrategoTuple) current;

	if(index >= tuple.getSubtermCount())
		return null;

	if(!(tuple.get(index) instanceof GenericWrappedTerm))
		return null;

	GenericWrappedTerm wrapper = (GenericWrappedTerm) tuple.get(index);

	if(wrapper.getWrappee().getClass().equals(clazz))
		return null;

	return (T) wrapper.getWrappee();

}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:23,代码来源:JFFLibrary.java


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