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


Java CompilerDirectives.TruffleBoundary方法代码示例

本文整理汇总了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");
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:28,代码来源:Open.java

示例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));
    }
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:30,代码来源:Equals.java

示例3: str

import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization
@CompilerDirectives.TruffleBoundary
public String str(long n) {
    return Long.toString(n);
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:6,代码来源:Str.java

示例4: intern

import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization
@CompilerDirectives.TruffleBoundary
public Symbol intern(String name) {
    return Symbol.intern(name);
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:6,代码来源:Intern.java


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