本文整理汇总了Java中com.oracle.truffle.api.CompilerDirectives.TruffleBoundary方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerDirectives.TruffleBoundary方法的具体用法?Java CompilerDirectives.TruffleBoundary怎么用?Java CompilerDirectives.TruffleBoundary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.oracle.truffle.api.CompilerDirectives
的用法示例。
在下文中一共展示了CompilerDirectives.TruffleBoundary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization(rewriteOn = FrameSlotTypeException.class)
@CompilerDirectives.TruffleBoundary
public Closeable open(String path, Symbol direction) throws FrameSlotTypeException {
File file = new File(path);
if (!file.isAbsolute()) {
MaterializedFrame globals = this.getContext().getGlobalFrame();
FrameSlot homeDirectorySlot = globals.getFrameDescriptor().findFrameSlot("*home-directory*");
String homeDirectory = (String) globals.getObject(homeDirectorySlot);
file = new File(homeDirectory, path);
//throw new RuntimeException("not implemented");
}
//System.out.println(file.getAbsoluteFile());
try {
switch (direction.getName()) {
case "in":
return new BufferedInputStream(new FileInputStream(file));
case "out":
return new BufferedOutputStream(new FileOutputStream(file));
}
} catch (FileNotFoundException e) {
throw new RuntimeException("file not found:" + e);
}
throw new IllegalArgumentException("invalid direction");
}
示例2: equals
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization
@CompilerDirectives.TruffleBoundary
public static Symbol equals(Object x, Object y) {
if (x == null && y == null) {
return Symbol.TRUE;
} else if (x instanceof Long) {
if (y instanceof Long) {
return Symbol.fromBoolean(x.equals(y));
} else if (y instanceof Double) {
return Symbol.fromBoolean(y.equals(((Long)x).doubleValue()));
} else {
return Symbol.FALSE;
}
} else if (y instanceof Long) {
if (x instanceof Long) {
return Symbol.fromBoolean(y.equals(x));
} else if (x instanceof Double) {
return Symbol.fromBoolean(x.equals(((Long)y).doubleValue()));
} else {
return Symbol.FALSE;
}
} else if (x instanceof Object[] && y instanceof Object[]) {
return absvectorEquality((Object[])x, (Object[])y);
} else if (x instanceof Cons && y instanceof Cons) {
return listEquality((Cons)x, (Cons)y);
} else {
return Symbol.fromBoolean(x != null && x.equals(y));
}
}
示例3: str
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization
@CompilerDirectives.TruffleBoundary
public String str(long n) {
return Long.toString(n);
}
示例4: intern
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization
@CompilerDirectives.TruffleBoundary
public Symbol intern(String name) {
return Symbol.intern(name);
}