示例#1
0
        public static void ValidateResult(int result)
        {
            if (result != 0)
            {
                var msg = vcpu_result_get_description(result, out var desc) == 0
                    ? Utf8Marshal.PtrToString(desc)
                    : "Unknown error";

                throw new VcpuException(result, msg);
            }
        }
示例#2
0
        public Executable(string source, int dataOffset = 0)
        {
            var result = vcpu_executable_assemble(source, dataOffset, out _inner, out var sourceMap, out var error);

            if (result != 0)
            {
                throw new VcpuException(result, Utf8Marshal.PtrToString(error));
            }

            vcpu_source_map_get_data(sourceMap, out var sourceMapData, out var sourceMapLength);

            _sourceMap = new int[sourceMapLength];
            Marshal.Copy(sourceMapData, _sourceMap, 0, sourceMapLength);

            vcpu_source_map_destroy(sourceMap);
        }
示例#3
0
 public static string GetName(int index)
 {
     Validation.ValidateResult(vcpu_register_get_name(index, out var name));
     return(Utf8Marshal.PtrToString(name));
 }