本文整理汇总了Java中org.spoofax.interpreter.core.Tools.isTermInt方法的典型用法代码示例。如果您正苦于以下问题:Java Tools.isTermInt方法的具体用法?Java Tools.isTermInt怎么用?Java Tools.isTermInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.core.Tools
的用法示例。
在下文中一共展示了Tools.isTermInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTermConstructor
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
private IStrategoTerm getTermConstructor(IContext env, IStrategoTerm t) throws InterpreterException {
if (Tools.isTermInt(t) || Tools.isTermReal(t)) {
return t;
} else if (Tools.isTermString(t)) {
return env.getFactory().makeString("\"" + ((IStrategoString)t).stringValue() + "\"");
} else if (Tools.isTermAppl(t)) {
IStrategoAppl a = (IStrategoAppl)t;
if (Tools.isCons(a, env) || Tools.isNil(a, env))
return env.getFactory().makeAppl(env.getStrategoSignature().getNil());
else
return env.getFactory().makeString(((IStrategoAppl)t).getConstructor().getName());
} else if (Tools.isTermList(t)) {
return env.getFactory().makeList();
} else if (Tools.isTermTuple(t)) {
return env.getFactory().makeString("");
}
throw new InterpreterException("Unknown term '" + t + "'");
}
示例2: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
throws InterpreterException {
if(!Tools.isTermInt(tvars[0]))
return false;
SSLLibrary or = (SSLLibrary) env.getOperatorRegistry(SSLLibrary.REGISTRY_NAME);
Reader in = or.getIOAgent().getReader(Tools.asJavaInt(tvars[0]));
int r = -1;
try {
r = in.read();
} catch(IOException e) {
throw new InterpreterException(e);
}
if(r == -1)
return false;
env.setCurrent(env.getFactory().makeInt(r));
return true;
}
示例3: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
}
示例4: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
}
示例5: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] sargs, IStrategoTerm[] targs) throws InterpreterException {
if(!Tools.isTermInt(targs[0]))
return false;
SSLLibrary or = (SSLLibrary) env.getOperatorRegistry(SSLLibrary.REGISTRY_NAME);
Writer out = or.getIOAgent().getWriter(Tools.asJavaInt(targs[0]));
if(out == null)
return false;
try {
new TermReader(env.getFactory()).unparseToFile(targs[1], out);
out.flush();
} catch(IOException e) {
throw new InterpreterException(e);
}
env.setCurrent(targs[0]);
return true;
}
示例6: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
}
示例7: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
env.setCurrent(env.getFactory().makeInt(a.intValue() * b.intValue()));
return true;
}
示例8: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
env.setCurrent(env.getFactory().makeInt(a.intValue() ^ b.intValue()));
return true;
}
示例9: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] sargs, IStrategoTerm[] targs) throws InterpreterException {
if (Tools.isTermInt(targs[0]))
return new SSL_int_to_string().call(env, sargs, targs);
if (!(Tools.isTermReal(targs[0])))
return false;
IStrategoReal a = (IStrategoReal) targs[0];
String s = String.format("%.17g", a.realValue());
env.setCurrent(env.getFactory().makeString(s));
return true;
}
示例10: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
env.setCurrent(env.getFactory().makeInt(a.intValue() & b.intValue()));
return true;
}
示例11: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
env.setCurrent(env.getFactory().makeInt(a.intValue() | b.intValue()));
return true;
}
示例12: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] sargs, IStrategoTerm[] targs) throws InterpreterException {
if(!(Tools.isTermReal(targs[0])))
return false;
if(!(Tools.isTermInt(targs[1])))
return false;
IStrategoReal a = (IStrategoReal) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
String s = String.format("%." + b.intValue() + "f", a.realValue());
env.setCurrent(env.getFactory().makeString(s));
return true;
}
示例13: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
return a.intValue() > b.intValue();
}
示例14: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
env.setCurrent(env.getFactory().makeInt(a.intValue() >> b.intValue()));
return true;
}
示例15: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的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;
IStrategoInt a = (IStrategoInt) targs[0];
IStrategoInt b = (IStrategoInt) targs[1];
env.setCurrent(env.getFactory().makeInt(a.intValue() % b.intValue()));
return true;
}