| ... | @@ -18,14 +18,9 @@ const CallingConvention = builtin.TypeInfo.CallingConvention; | ... | @@ -18,14 +18,9 @@ const CallingConvention = builtin.TypeInfo.CallingConvention; |
| 18 | | 18 | |
| 19 | pub const ClangErrMsg = Stage2ErrorMsg; | 19 | pub const ClangErrMsg = Stage2ErrorMsg; |
| 20 | | 20 | |
| 21 | pub const Error = error{ | 21 | pub const Error = error{OutOfMemory}; |
| 22 | OutOfMemory, | 22 | const TypeError = Error || error{UnsupportedType}; |
| 23 | UnsupportedType, | 23 | const TransError = Error || error{UnsupportedTranslation}; |
| 24 | }; | | |
| 25 | pub const TransError = error{ | | |
| 26 | OutOfMemory, | | |
| 27 | UnsupportedTranslation, | | |
| 28 | }; | | |
| 29 | | 24 | |
| 30 | const DeclTable = std.HashMap(usize, void, addrHash, addrEql); | 25 | const DeclTable = std.HashMap(usize, void, addrHash, addrEql); |
| 31 | | 26 | |
| ... | @@ -276,7 +271,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { | ... | @@ -276,7 +271,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 276 | error.UnsupportedType => { | 271 | error.UnsupportedType => { |
| 277 | return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function"); | 272 | return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function"); |
| 278 | }, | 273 | }, |
| 279 | error.OutOfMemory => return error.OutOfMemory, | 274 | error.OutOfMemory => |e| return e, |
| 280 | }; | 275 | }; |
| 281 | }, | 276 | }, |
| 282 | .FunctionNoProto => blk: { | 277 | .FunctionNoProto => blk: { |
| ... | @@ -285,7 +280,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { | ... | @@ -285,7 +280,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 285 | error.UnsupportedType => { | 280 | error.UnsupportedType => { |
| 286 | return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function"); | 281 | return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function"); |
| 287 | }, | 282 | }, |
| 288 | error.OutOfMemory => return error.OutOfMemory, | 283 | error.OutOfMemory => |e| return e, |
| 289 | }; | 284 | }; |
| 290 | }, | 285 | }, |
| 291 | else => unreachable, | 286 | else => unreachable, |
| ... | @@ -299,7 +294,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { | ... | @@ -299,7 +294,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 299 | // actual function definition with body | 294 | // actual function definition with body |
| 300 | const body_stmt = ZigClangFunctionDecl_getBody(fn_decl); | 295 | const body_stmt = ZigClangFunctionDecl_getBody(fn_decl); |
| 301 | const result = transStmt(rp, scope, body_stmt, .unused, .r_value) catch |err| switch (err) { | 296 | const result = transStmt(rp, scope, body_stmt, .unused, .r_value) catch |err| switch (err) { |
| 302 | error.OutOfMemory => return error.OutOfMemory, | 297 | error.OutOfMemory => |e| return e, |
| 303 | error.UnsupportedTranslation => return failDecl(c, fn_decl_loc, fn_name, "unable to translate function"), | 298 | error.UnsupportedTranslation => return failDecl(c, fn_decl_loc, fn_name, "unable to translate function"), |
| 304 | }; | 299 | }; |
| 305 | assert(result.node.id == ast.Node.Id.Block); | 300 | assert(result.node.id == ast.Node.Id.Block); |
| ... | @@ -377,7 +372,7 @@ fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: *ast.Node) !void { | ... | @@ -377,7 +372,7 @@ fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: *ast.Node) !void { |
| 377 | try c.tree.root_node.decls.push(decl_node); | 372 | try c.tree.root_node.decls.push(decl_node); |
| 378 | } | 373 | } |
| 379 | | 374 | |
| 380 | fn transQualType(rp: RestorePoint, qt: ZigClangQualType, source_loc: ZigClangSourceLocation) Error!*ast.Node { | 375 | fn transQualType(rp: RestorePoint, qt: ZigClangQualType, source_loc: ZigClangSourceLocation) TypeError!*ast.Node { |
| 381 | return transType(rp, ZigClangQualType_getTypePtr(qt), source_loc); | 376 | return transType(rp, ZigClangQualType_getTypePtr(qt), source_loc); |
| 382 | } | 377 | } |
| 383 | | 378 | |
| ... | @@ -405,7 +400,7 @@ fn makeRestorePoint(c: *Context) RestorePoint { | ... | @@ -405,7 +400,7 @@ fn makeRestorePoint(c: *Context) RestorePoint { |
| 405 | }; | 400 | }; |
| 406 | } | 401 | } |
| 407 | | 402 | |
| 408 | fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSourceLocation) Error!*ast.Node { | 403 | fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSourceLocation) TypeError!*ast.Node { |
| 409 | switch (ZigClangType_getTypeClass(ty)) { | 404 | switch (ZigClangType_getTypeClass(ty)) { |
| 410 | .Builtin => { | 405 | .Builtin => { |
| 411 | const builtin_ty = @ptrCast(*const ZigClangBuiltinType, ty); | 406 | const builtin_ty = @ptrCast(*const ZigClangBuiltinType, ty); |
| ... | @@ -535,7 +530,7 @@ fn finishTransFnProto( | ... | @@ -535,7 +530,7 @@ fn finishTransFnProto( |
| 535 | try emitWarning(rp.c, source_loc, "unsupported function proto return type"); | 530 | try emitWarning(rp.c, source_loc, "unsupported function proto return type"); |
| 536 | return err; | 531 | return err; |
| 537 | }, | 532 | }, |
| 538 | error.OutOfMemory => return error.OutOfMemory, | 533 | error.OutOfMemory => |e| return e, |
| 539 | }; | 534 | }; |
| 540 | } | 535 | } |
| 541 | } | 536 | } |