本文整理汇总了Java中org.spoofax.interpreter.core.Tools.asJavaInt方法的典型用法代码示例。如果您正苦于以下问题:Java Tools.asJavaInt方法的具体用法?Java Tools.asJavaInt怎么用?Java Tools.asJavaInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.core.Tools
的用法示例。
在下文中一共展示了Tools.asJavaInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
@Override
public final boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) {
final IStrategoTerm location = tvars[0];
if(!Tools.isTermTuple(location) && location.getSubtermCount() != 4)
return false;
final String filename = Tools.asJavaString(location.getSubterm(0));
final int line = Tools.asJavaInt(location.getSubterm(1));
final int column = Tools.asJavaInt(location.getSubterm(2));
final int startOffset = Tools.asJavaInt(location.getSubterm(3));
final int endOffset = Tools.asJavaInt(location.getSubterm(4));
final ImploderAttachment attachment =
ImploderAttachment.createCompactPositionAttachment(filename, line, column, startOffset, endOffset);
env.current().putAttachment(attachment);
return true;
}
示例2: fromStrategoTerm
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
public static L_Int fromStrategoTerm(IStrategoTerm alist) {
L_Int list = new L_Int(SourceSectionUtil.fromStrategoTerm(alist));
for (IStrategoTerm elem : alist) {
final SourceSection src = SourceSectionUtil.fromStrategoTerm(elem);
list = new L_Int(src, Tools.asJavaInt(elem), list);
}
return list;
}
示例3: 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 op = (SSLLibrary) env.getOperatorRegistry(SSLLibrary.REGISTRY_NAME);
int fd = Tools.asJavaInt(tvars[0]);
return op.getIOAgent().closeRandomAccessFile(fd);
}
示例4: 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.instance(env).getIOAgent().closeAllFiles();
int exitCode = Tools.asJavaInt(tvars[0]);
env.getStackTracer().popOnExit(exitCode == 0);
throw new InterpreterExit(exitCode);
}
示例5: call
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) {
ITermFactory factory = env.getFactory();
boolean enable = Tools.asJavaInt(tvars[0]) != 0;
if (factory instanceof OriginTermFactory){
((OriginTermFactory)env.getFactory()).setAssignDesugaredOrigins(enable);
}
else if (enable){
OriginTermFactory originFactory = new ImploderOriginTermFactory(factory);
originFactory.setAssignDesugaredOrigins(enable);
env.setFactory(originFactory);
}
return true;
}
示例6: intFromTerm
import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
public static int intFromTerm(IStrategoTerm term) {
if (Tools.isTermInt(term)) {
return Tools.asJavaInt(term);
}
throw new MalformedASTException("Malformed int: " + term);
}