| ... | ... | @@ -18,14 +18,9 @@ const CallingConvention = builtin.TypeInfo.CallingConvention; |
| 18 | 18 | |
| 19 | 19 | pub const ClangErrMsg = Stage2ErrorMsg; |
| 20 | 20 | |
| 21 | | pub const Error = error{ |
| 22 | | OutOfMemory, |
| 23 | | UnsupportedType, |
| 24 | | }; |
| 25 | | pub const TransError = error{ |
| 26 | | OutOfMemory, |
| 27 | | UnsupportedTranslation, |
| 28 | | }; |
| 21 | pub const Error = error{OutOfMemory}; |
| 22 | const TypeError = Error || error{UnsupportedType}; |
| 23 | const TransError = Error || error{UnsupportedTranslation}; |
| 29 | 24 | |
| 30 | 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 | 271 | error.UnsupportedType => { |
| 277 | 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 | 277 | .FunctionNoProto => blk: { |
| ... | ... | @@ -285,7 +280,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 285 | 280 | error.UnsupportedType => { |
| 286 | 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 | 286 | else => unreachable, |
| ... | ... | @@ -299,7 +294,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 299 | 294 | // actual function definition with body |
| 300 | 295 | const body_stmt = ZigClangFunctionDecl_getBody(fn_decl); |
| 301 | 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 | 298 | error.UnsupportedTranslation => return failDecl(c, fn_decl_loc, fn_name, "unable to translate function"), |
| 304 | 299 | }; |
| 305 | 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 | 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 | 376 | return transType(rp, ZigClangQualType_getTypePtr(qt), source_loc); |
| 382 | 377 | } |
| 383 | 378 | |
| ... | ... | @@ -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 | 404 | switch (ZigClangType_getTypeClass(ty)) { |
| 410 | 405 | .Builtin => { |
| 411 | 406 | const builtin_ty = @ptrCast(*const ZigClangBuiltinType, ty); |
| ... | ... | @@ -535,7 +530,7 @@ fn finishTransFnProto( |
| 535 | 530 | try emitWarning(rp.c, source_loc, "unsupported function proto return type"); |
| 536 | 531 | return err; |
| 537 | 532 | }, |
| 538 | | error.OutOfMemory => return error.OutOfMemory, |
| 533 | error.OutOfMemory => |e| return e, |
| 539 | 534 | }; |
| 540 | 535 | } |
| 541 | 536 | } |