コード例 #1
0
ファイル: heapsnapshot.c プロジェクト: zoffixznet/MoarVM
MVMObject * string_heap_array(MVMThreadContext *tc, MVMHeapSnapshotCollection *col) {
    MVMObject *arr = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTStrArray);
    MVMuint64 i;
    for (i = 0; i < col->num_strings; i++)
        MVM_repr_bind_pos_s(tc, arr, i, vmstr(tc, col->strings[i]));
    return arr;
}
コード例 #2
0
ファイル: sys.c プロジェクト: MasterDuke17/MoarVM
MVMObject * MVM_platform_uname(MVMThreadContext *tc) {
    int error;
    uv_utsname_t uname;
    MVMObject *result;

    if ((error = uv_os_uname(&uname)) != 0)
        MVM_exception_throw_adhoc(tc, "Unable to uname: %s", uv_strerror(error));

    MVMROOT(tc, result, {
        MVMString *sysname = MVM_string_utf8_decode(tc, tc->instance->VMString, uname.sysname, strlen((char *)uname.sysname));
        MVMString *release = MVM_string_utf8_decode(tc, tc->instance->VMString, uname.release, strlen((char *)uname.release));
        MVMString *version = MVM_string_utf8_decode(tc, tc->instance->VMString, uname.version, strlen((char *)uname.version));
        MVMString *machine = MVM_string_utf8_decode(tc, tc->instance->VMString, uname.machine, strlen((char *)uname.machine));
        result = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTStrArray);
        MVM_repr_bind_pos_s(tc, result, 0, sysname);
        MVM_repr_bind_pos_s(tc, result, 1, release);
        MVM_repr_bind_pos_s(tc, result, 2, version);
        MVM_repr_bind_pos_s(tc, result, 3, machine);
    });