本文整理汇总了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 + "'");
}
示例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 + "'");
}
示例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);
}
}
示例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;
}
示例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();
}