forked from M-Labs/nac3
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
aebfd0a37d | |||
91d697c327 | |||
d18292dd28 | |||
29da2d1a9a | |||
34b460757b | |||
925f1c2cc4 | |||
65110a2cf2 | |||
3d39a80df6 |
@ -16,8 +16,7 @@ class EmbeddingMap:
|
|||||||
"CacheError",
|
"CacheError",
|
||||||
"SPIError",
|
"SPIError",
|
||||||
"0:ZeroDivisionError",
|
"0:ZeroDivisionError",
|
||||||
"0:IndexError",
|
"0:IndexError"])
|
||||||
"0:UnwrapNoneError"])
|
|
||||||
|
|
||||||
def preallocate_runtime_exception_names(self, names):
|
def preallocate_runtime_exception_names(self, names):
|
||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
|
@ -11,7 +11,7 @@ from embedding_map import EmbeddingMap
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Kernel", "KernelInvariant", "virtual",
|
"Kernel", "KernelInvariant", "virtual",
|
||||||
"Option", "Some", "none", "UnwrapNoneError",
|
"Option", "Some", "none",
|
||||||
"round64", "floor64", "ceil64",
|
"round64", "floor64", "ceil64",
|
||||||
"extern", "kernel", "portable", "nac3",
|
"extern", "kernel", "portable", "nac3",
|
||||||
"rpc", "ms", "us", "ns",
|
"rpc", "ms", "us", "ns",
|
||||||
@ -47,7 +47,7 @@ class Option(Generic[T]):
|
|||||||
|
|
||||||
def unwrap(self):
|
def unwrap(self):
|
||||||
if self.is_none():
|
if self.is_none():
|
||||||
raise UnwrapNoneError()
|
raise ValueError("unwrap on none")
|
||||||
return self._nac3_option
|
return self._nac3_option
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
@ -274,10 +274,5 @@ class KernelContextManager:
|
|||||||
def __exit__(self):
|
def __exit__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@nac3
|
|
||||||
class UnwrapNoneError(Exception):
|
|
||||||
"""raised when unwrapping a none value"""
|
|
||||||
artiq_builtin = True
|
|
||||||
|
|
||||||
parallel = KernelContextManager()
|
parallel = KernelContextManager()
|
||||||
sequential = KernelContextManager()
|
sequential = KernelContextManager()
|
||||||
|
@ -1319,8 +1319,8 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>(
|
|||||||
ctx.make_assert(
|
ctx.make_assert(
|
||||||
generator,
|
generator,
|
||||||
not_null,
|
not_null,
|
||||||
"0:UnwrapNoneError",
|
"0:ValueError",
|
||||||
"",
|
"unwrap on none",
|
||||||
[None, None, None],
|
[None, None, None],
|
||||||
expr.location,
|
expr.location,
|
||||||
);
|
);
|
||||||
|
@ -105,8 +105,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
|
|||||||
("__param2__".into(), int64, true),
|
("__param2__".into(), int64, true),
|
||||||
];
|
];
|
||||||
|
|
||||||
// for Option, is_some and is_none share the same type: () -> bool,
|
// for Option, is_some and is_none share the same type
|
||||||
// and they are methods under the same class `Option`
|
|
||||||
let (is_some_ty, unwrap_ty, (option_ty_var, option_ty_var_id)) =
|
let (is_some_ty, unwrap_ty, (option_ty_var, option_ty_var_id)) =
|
||||||
if let TypeEnum::TObj { fields, params, .. } =
|
if let TypeEnum::TObj { fields, params, .. } =
|
||||||
primitives.1.get_ty(primitives.0.option).as_ref()
|
primitives.1.get_ty(primitives.0.option).as_ref()
|
||||||
|
Loading…
Reference in New Issue
Block a user