feat: add Exception classes

This commit is contained in:
Shunsuke Shibayama 2024-03-11 20:35:11 +09:00
parent a136d6dc18
commit 0e1c0a9a13
4 changed files with 718 additions and 3 deletions

View file

@ -3389,6 +3389,194 @@ impl Context {
Immutable,
Visibility::BUILTIN_PRIVATE,
);
let mut base_exception = Self::builtin_mono_class(BASE_EXCEPTION, 2);
base_exception.register_superclass(Obj, &obj);
base_exception.register_builtin_erg_impl(
ATTR_ARGS,
unknown_len_array_t(Str),
Immutable,
Visibility::BUILTIN_PUBLIC,
);
let EXC = type_q(TY_E);
base_exception.register_builtin_erg_impl(
FUNC_WITH_TRACEBACK,
fn1_met(EXC.clone(), mono(TRACEBACK), EXC).quantify(),
Immutable,
Visibility::BUILTIN_PUBLIC,
);
base_exception.register_builtin_erg_impl(
FUNDAMENTAL_TRACEBACK,
mono(TRACEBACK) | NoneType,
Immutable,
Visibility::BUILTIN_PUBLIC,
);
base_exception.register_builtin_erg_impl(
FUNDAMENTAL_SUPPRESS_CONTEXT,
Bool,
Immutable,
Visibility::BUILTIN_PUBLIC,
);
base_exception.register_builtin_erg_impl(
FUNDAMENTAL_CAUSE,
mono(BASE_EXCEPTION) | NoneType,
Immutable,
Visibility::BUILTIN_PUBLIC,
);
base_exception.register_builtin_erg_impl(
FUNDAMENTAL_CONTEXT,
mono(BASE_EXCEPTION) | NoneType,
Immutable,
Visibility::BUILTIN_PUBLIC,
);
let mut traceback = Self::builtin_mono_class(TRACEBACK, 2);
traceback.register_superclass(Obj, &obj);
traceback.register_builtin_erg_impl(ATTR_TB_FRAME, Frame, Immutable, vis.clone());
traceback.register_builtin_erg_impl(ATTR_TB_LASTI, Nat, Immutable, vis.clone());
traceback.register_builtin_erg_impl(ATTR_TB_LINENO, Nat, Immutable, vis.clone());
traceback.register_builtin_erg_impl(
ATTR_TB_NEXT,
mono(TRACEBACK) | NoneType,
Immutable,
Visibility::BUILTIN_PUBLIC,
);
let mut exception = Self::builtin_mono_class(EXCEPTION, 2);
exception.register_superclass(mono(BASE_EXCEPTION), &base_exception);
let mut system_exit = Self::builtin_mono_class(SYSTEM_EXIT, 2);
system_exit.register_superclass(mono(BASE_EXCEPTION), &base_exception);
system_exit.register_builtin_erg_impl(ATTR_CODE, Obj, Immutable, vis.clone());
let mut keyboard_interrupt = Self::builtin_mono_class(KEYBOARD_INTERRUPT, 1);
keyboard_interrupt.register_superclass(mono(BASE_EXCEPTION), &base_exception);
let mut generator_exit = Self::builtin_mono_class(GENERATOR_EXIT, 2);
generator_exit.register_superclass(mono(BASE_EXCEPTION), &base_exception);
let mut stop_iteration = Self::builtin_mono_class(STOP_ITERATION, 2);
stop_iteration.register_superclass(mono(EXCEPTION), &exception);
stop_iteration.register_builtin_erg_impl(ATTR_VALUE, Obj, Immutable, vis.clone());
let mut stop_async_iteration = Self::builtin_mono_class(STOP_ASYNC_ITERATION, 2);
stop_async_iteration.register_superclass(mono(EXCEPTION), &exception);
stop_async_iteration.register_builtin_erg_impl(ATTR_VALUE, Obj, Immutable, vis.clone());
let mut arithmetic_error = Self::builtin_mono_class(ARITHMETIC_ERROR, 2);
arithmetic_error.register_superclass(mono(EXCEPTION), &exception);
let mut floating_point_error = Self::builtin_mono_class(FLOATING_POINT_ERROR, 2);
floating_point_error.register_superclass(mono(ARITHMETIC_ERROR), &arithmetic_error);
let mut overflow_error = Self::builtin_mono_class(OVERFLOW_ERROR, 2);
overflow_error.register_superclass(mono(ARITHMETIC_ERROR), &arithmetic_error);
let mut zero_division_error = Self::builtin_mono_class(ZERO_DIVISION_ERROR, 2);
zero_division_error.register_superclass(mono(ARITHMETIC_ERROR), &arithmetic_error);
let mut assertion_error = Self::builtin_mono_class(ASSERTION_ERROR, 2);
assertion_error.register_superclass(mono(EXCEPTION), &exception);
let mut attribute_error = Self::builtin_mono_class(ATTRIBUTE_ERROR, 2);
attribute_error.register_superclass(mono(EXCEPTION), &exception);
let mut buffer_error = Self::builtin_mono_class(BUFFER_ERROR, 2);
buffer_error.register_superclass(mono(EXCEPTION), &exception);
let mut eof_error = Self::builtin_mono_class(EOF_ERROR, 2);
eof_error.register_superclass(mono(EXCEPTION), &exception);
let mut import_error = Self::builtin_mono_class(IMPORT_ERROR, 2);
import_error.register_superclass(mono(EXCEPTION), &exception);
import_error.register_builtin_erg_impl(ATTR_MSG, Str, Immutable, vis.clone());
import_error.register_builtin_erg_impl(ATTR_NAME, Str, Immutable, vis.clone());
import_error.register_builtin_erg_impl(ATTR_PATH, Str, Immutable, vis.clone());
let mut module_not_found_error = Self::builtin_mono_class(MODULE_NOT_FOUND_ERROR, 2);
module_not_found_error.register_superclass(mono(IMPORT_ERROR), &import_error);
let mut lookup_error = Self::builtin_mono_class(LOOKUP_ERROR, 1);
lookup_error.register_superclass(mono(EXCEPTION), &exception);
let mut index_error = Self::builtin_mono_class(INDEX_ERROR, 1);
index_error.register_superclass(mono(LOOKUP_ERROR), &lookup_error);
let mut key_error = Self::builtin_mono_class(KEY_ERROR, 1);
key_error.register_superclass(mono(LOOKUP_ERROR), &lookup_error);
let mut memory_error = Self::builtin_mono_class(MEMORY_ERROR, 1);
memory_error.register_superclass(mono(EXCEPTION), &exception);
let mut name_error = Self::builtin_mono_class(NAME_ERROR, 1);
name_error.register_superclass(mono(EXCEPTION), &exception);
let mut unbound_local_error = Self::builtin_mono_class(UNBOUND_LOCAL_ERROR, 2);
unbound_local_error.register_superclass(mono(NAME_ERROR), &name_error);
let mut os_error = Self::builtin_mono_class(OS_ERROR, 2);
os_error.register_superclass(mono(EXCEPTION), &exception);
os_error.register_builtin_erg_impl(ATTR_ERRNO, Int, Immutable, vis.clone());
os_error.register_builtin_erg_impl(ATTR_FILENAME, Str, Immutable, vis.clone());
os_error.register_builtin_erg_impl(ATTR_FILENAME2, Str, Immutable, vis.clone());
os_error.register_builtin_erg_impl(ATTR_STRERROR, Str, Immutable, vis.clone());
let mut blocking_io_error = Self::builtin_mono_class(BLOCKING_IO_ERROR, 1);
blocking_io_error.register_superclass(mono(OS_ERROR), &os_error);
let mut child_process_error = Self::builtin_mono_class(CHILD_PROCESS_ERROR, 1);
child_process_error.register_superclass(mono(OS_ERROR), &os_error);
let mut connection_error = Self::builtin_mono_class(CONNECTION_ERROR, 1);
connection_error.register_superclass(mono(OS_ERROR), &os_error);
let mut broken_pipe_error = Self::builtin_mono_class(BROKEN_PIPE_ERROR, 1);
broken_pipe_error.register_superclass(mono(CONNECTION_ERROR), &connection_error);
let mut connection_aborted_error = Self::builtin_mono_class(CONNECTION_ABORTED_ERROR, 1);
connection_aborted_error.register_superclass(mono(CONNECTION_ERROR), &connection_error);
let mut connection_refused_error = Self::builtin_mono_class(CONNECTION_REFUSED_ERROR, 1);
connection_refused_error.register_superclass(mono(CONNECTION_ERROR), &connection_error);
let mut connection_reset_error = Self::builtin_mono_class(CONNECTION_RESET_ERROR, 1);
connection_reset_error.register_superclass(mono(CONNECTION_ERROR), &connection_error);
let mut file_exists_error = Self::builtin_mono_class(FILE_EXISTS_ERROR, 1);
file_exists_error.register_superclass(mono(OS_ERROR), &os_error);
let mut file_not_found_error = Self::builtin_mono_class(FILE_NOT_FOUND_ERROR, 1);
file_not_found_error.register_superclass(mono(OS_ERROR), &os_error);
let mut interrupted_error = Self::builtin_mono_class(INTERRUPTED_ERROR, 1);
interrupted_error.register_superclass(mono(OS_ERROR), &os_error);
let mut is_a_directory_error = Self::builtin_mono_class(IS_A_DIRECTORY_ERROR, 1);
is_a_directory_error.register_superclass(mono(OS_ERROR), &os_error);
let mut not_a_directory_error = Self::builtin_mono_class(NOT_A_DIRECTORY_ERROR, 1);
not_a_directory_error.register_superclass(mono(OS_ERROR), &os_error);
let mut permission_error = Self::builtin_mono_class(PERMISSION_ERROR, 1);
permission_error.register_superclass(mono(OS_ERROR), &os_error);
let mut process_lookup_error = Self::builtin_mono_class(PROCESS_LOOKUP_ERROR, 1);
process_lookup_error.register_superclass(mono(OS_ERROR), &os_error);
let mut timeout_error = Self::builtin_mono_class(TIMEOUT_ERROR, 1);
timeout_error.register_superclass(mono(OS_ERROR), &os_error);
let mut reference_error = Self::builtin_mono_class(REFERENCE_ERROR, 1);
reference_error.register_superclass(mono(EXCEPTION), &exception);
let mut runtime_error = Self::builtin_mono_class(RUNTIME_ERROR, 2);
runtime_error.register_superclass(mono(EXCEPTION), &exception);
let mut not_implemented_error = Self::builtin_mono_class(NOT_IMPLEMENTED_ERROR, 1);
not_implemented_error.register_superclass(mono(RUNTIME_ERROR), &runtime_error);
let mut recursion_error = Self::builtin_mono_class(RECURSION_ERROR, 1);
recursion_error.register_superclass(mono(RUNTIME_ERROR), &runtime_error);
let mut syntax_error = Self::builtin_mono_class(SYNTAX_ERROR, 2);
syntax_error.register_superclass(mono(EXCEPTION), &exception);
let mut indentation_error = Self::builtin_mono_class(INDENTATION_ERROR, 2);
indentation_error.register_superclass(mono(SYNTAX_ERROR), &syntax_error);
let mut tab_error = Self::builtin_mono_class(TAB_ERROR, 2);
tab_error.register_superclass(mono(INDENTATION_ERROR), &indentation_error);
let mut system_error = Self::builtin_mono_class(SYSTEM_ERROR, 2);
system_error.register_superclass(mono(EXCEPTION), &exception);
let mut type_error = Self::builtin_mono_class(TYPE_ERROR, 2);
type_error.register_superclass(mono(EXCEPTION), &exception);
let mut value_error = Self::builtin_mono_class(VALUE_ERROR, 2);
value_error.register_superclass(mono(EXCEPTION), &exception);
let mut unicode_error = Self::builtin_mono_class(UNICODE_ERROR, 2);
unicode_error.register_superclass(mono(VALUE_ERROR), &value_error);
let mut unicode_encode_error = Self::builtin_mono_class(UNICODE_ENCODE_ERROR, 2);
unicode_encode_error.register_superclass(mono(UNICODE_ERROR), &unicode_error);
let mut unicode_decode_error = Self::builtin_mono_class(UNICODE_DECODE_ERROR, 2);
unicode_decode_error.register_superclass(mono(UNICODE_ERROR), &unicode_error);
let mut unicode_translate_error = Self::builtin_mono_class(UNICODE_TRANSLATE_ERROR, 2);
unicode_translate_error.register_superclass(mono(UNICODE_ERROR), &unicode_error);
let mut warning = Self::builtin_mono_class(WARNING, 2);
warning.register_superclass(mono(EXCEPTION), &exception);
let mut deprecation_warning = Self::builtin_mono_class(DEPRECATION_WARNING, 2);
deprecation_warning.register_superclass(mono(WARNING), &warning);
let mut pending_deprecation_warning =
Self::builtin_mono_class(PENDING_DEPRECATION_WARNING, 2);
pending_deprecation_warning
.register_superclass(mono(DEPRECATION_WARNING), &deprecation_warning);
let mut runtime_warning = Self::builtin_mono_class(RUNTIME_WARNING, 2);
runtime_warning.register_superclass(mono(WARNING), &warning);
let mut syntax_warning = Self::builtin_mono_class(SYNTAX_WARNING, 2);
syntax_warning.register_superclass(mono(WARNING), &warning);
let mut user_warning = Self::builtin_mono_class(USER_WARNING, 2);
user_warning.register_superclass(mono(WARNING), &warning);
let mut future_warning = Self::builtin_mono_class(FUTURE_WARNING, 2);
future_warning.register_superclass(mono(WARNING), &warning);
let mut import_warning = Self::builtin_mono_class(IMPORT_WARNING, 2);
import_warning.register_superclass(mono(WARNING), &warning);
let mut unicode_warning = Self::builtin_mono_class(UNICODE_WARNING, 2);
unicode_warning.register_superclass(mono(WARNING), &warning);
let mut bytes_warning = Self::builtin_mono_class(BYTES_WARNING, 2);
bytes_warning.register_superclass(mono(WARNING), &warning);
let mut resource_warning = Self::builtin_mono_class(RESOURCE_WARNING, 2);
resource_warning.register_superclass(mono(WARNING), &warning);
/* Proc */
let mut proc = Self::builtin_mono_class(PROC, 2);
proc.register_superclass(mono(SUBROUTINE), &subr);
@ -3629,6 +3817,449 @@ impl Context {
Const,
Some(GENERATOR),
);
self.register_builtin_type(
mono(BASE_EXCEPTION),
base_exception,
vis.clone(),
Const,
Some(BASE_EXCEPTION),
);
self.register_builtin_type(
mono(TRACEBACK),
traceback,
vis.clone(),
Const,
Some(TRACEBACK),
);
self.register_builtin_type(
mono(EXCEPTION),
exception,
vis.clone(),
Const,
Some(EXCEPTION),
);
self.register_builtin_type(
mono(SYSTEM_EXIT),
system_exit,
vis.clone(),
Const,
Some(SYSTEM_EXIT),
);
self.register_builtin_type(
mono(KEYBOARD_INTERRUPT),
keyboard_interrupt,
vis.clone(),
Const,
Some(KEYBOARD_INTERRUPT),
);
self.register_builtin_type(
mono(GENERATOR_EXIT),
generator_exit,
vis.clone(),
Const,
Some(GENERATOR_EXIT),
);
self.register_builtin_type(
mono(STOP_ITERATION),
stop_iteration,
vis.clone(),
Const,
Some(STOP_ITERATION),
);
self.register_builtin_type(
mono(STOP_ASYNC_ITERATION),
stop_async_iteration,
vis.clone(),
Const,
Some(STOP_ASYNC_ITERATION),
);
self.register_builtin_type(
mono(ARITHMETIC_ERROR),
arithmetic_error,
vis.clone(),
Const,
Some(ARITHMETIC_ERROR),
);
self.register_builtin_type(
mono(FLOATING_POINT_ERROR),
floating_point_error,
vis.clone(),
Const,
Some(FLOATING_POINT_ERROR),
);
self.register_builtin_type(
mono(OVERFLOW_ERROR),
overflow_error,
vis.clone(),
Const,
Some(OVERFLOW_ERROR),
);
self.register_builtin_type(
mono(ZERO_DIVISION_ERROR),
zero_division_error,
vis.clone(),
Const,
Some(ZERO_DIVISION_ERROR),
);
self.register_builtin_type(
mono(ASSERTION_ERROR),
assertion_error,
vis.clone(),
Const,
Some(ASSERTION_ERROR),
);
self.register_builtin_type(
mono(ATTRIBUTE_ERROR),
attribute_error,
vis.clone(),
Const,
Some(ATTRIBUTE_ERROR),
);
self.register_builtin_type(
mono(BUFFER_ERROR),
buffer_error,
vis.clone(),
Const,
Some(BUFFER_ERROR),
);
self.register_builtin_type(
mono(EOF_ERROR),
eof_error,
vis.clone(),
Const,
Some(EOF_ERROR),
);
self.register_builtin_type(
mono(IMPORT_ERROR),
import_error,
vis.clone(),
Const,
Some(IMPORT_ERROR),
);
self.register_builtin_type(
mono(MODULE_NOT_FOUND_ERROR),
module_not_found_error,
vis.clone(),
Const,
Some(MODULE_NOT_FOUND_ERROR),
);
self.register_builtin_type(
mono(LOOKUP_ERROR),
lookup_error,
vis.clone(),
Const,
Some(LOOKUP_ERROR),
);
self.register_builtin_type(
mono(INDEX_ERROR),
index_error,
vis.clone(),
Const,
Some(INDEX_ERROR),
);
self.register_builtin_type(
mono(KEY_ERROR),
key_error,
vis.clone(),
Const,
Some(KEY_ERROR),
);
self.register_builtin_type(
mono(MEMORY_ERROR),
memory_error,
vis.clone(),
Const,
Some(MEMORY_ERROR),
);
self.register_builtin_type(
mono(NAME_ERROR),
name_error,
vis.clone(),
Const,
Some(NAME_ERROR),
);
self.register_builtin_type(
mono(UNBOUND_LOCAL_ERROR),
unbound_local_error,
vis.clone(),
Const,
Some(UNBOUND_LOCAL_ERROR),
);
self.register_builtin_type(mono(OS_ERROR), os_error, vis.clone(), Const, Some(OS_ERROR));
self.register_builtin_type(
mono(BLOCKING_IO_ERROR),
blocking_io_error,
vis.clone(),
Const,
Some(BLOCKING_IO_ERROR),
);
self.register_builtin_type(
mono(CHILD_PROCESS_ERROR),
child_process_error,
vis.clone(),
Const,
Some(CHILD_PROCESS_ERROR),
);
self.register_builtin_type(
mono(CONNECTION_ERROR),
connection_error,
vis.clone(),
Const,
Some(CONNECTION_ERROR),
);
self.register_builtin_type(
mono(BROKEN_PIPE_ERROR),
broken_pipe_error,
vis.clone(),
Const,
Some(BROKEN_PIPE_ERROR),
);
self.register_builtin_type(
mono(CONNECTION_ABORTED_ERROR),
connection_aborted_error,
vis.clone(),
Const,
Some(CONNECTION_ABORTED_ERROR),
);
self.register_builtin_type(
mono(CONNECTION_REFUSED_ERROR),
connection_refused_error,
vis.clone(),
Const,
Some(CONNECTION_REFUSED_ERROR),
);
self.register_builtin_type(
mono(CONNECTION_RESET_ERROR),
connection_reset_error,
vis.clone(),
Const,
Some(CONNECTION_RESET_ERROR),
);
self.register_builtin_type(
mono(FILE_EXISTS_ERROR),
file_exists_error,
vis.clone(),
Const,
Some(FILE_EXISTS_ERROR),
);
self.register_builtin_type(
mono(FILE_NOT_FOUND_ERROR),
file_not_found_error,
vis.clone(),
Const,
Some(FILE_NOT_FOUND_ERROR),
);
self.register_builtin_type(
mono(INTERRUPTED_ERROR),
interrupted_error,
vis.clone(),
Const,
Some(INTERRUPTED_ERROR),
);
self.register_builtin_type(
mono(IS_A_DIRECTORY_ERROR),
is_a_directory_error,
vis.clone(),
Const,
Some(IS_A_DIRECTORY_ERROR),
);
self.register_builtin_type(
mono(NOT_A_DIRECTORY_ERROR),
not_a_directory_error,
vis.clone(),
Const,
Some(NOT_A_DIRECTORY_ERROR),
);
self.register_builtin_type(
mono(PERMISSION_ERROR),
permission_error,
vis.clone(),
Const,
Some(PERMISSION_ERROR),
);
self.register_builtin_type(
mono(PROCESS_LOOKUP_ERROR),
process_lookup_error,
vis.clone(),
Const,
Some(PROCESS_LOOKUP_ERROR),
);
self.register_builtin_type(
mono(TIMEOUT_ERROR),
timeout_error,
vis.clone(),
Const,
Some(TIMEOUT_ERROR),
);
self.register_builtin_type(
mono(REFERENCE_ERROR),
reference_error,
vis.clone(),
Const,
Some(REFERENCE_ERROR),
);
self.register_builtin_type(
mono(RUNTIME_ERROR),
runtime_error,
vis.clone(),
Const,
Some(RUNTIME_ERROR),
);
self.register_builtin_type(
mono(NOT_IMPLEMENTED_ERROR),
not_implemented_error,
vis.clone(),
Const,
Some(NOT_IMPLEMENTED_ERROR),
);
self.register_builtin_type(
mono(RECURSION_ERROR),
recursion_error,
vis.clone(),
Const,
Some(RECURSION_ERROR),
);
self.register_builtin_type(
mono(SYNTAX_ERROR),
syntax_error,
vis.clone(),
Const,
Some(SYNTAX_ERROR),
);
self.register_builtin_type(
mono(INDENTATION_ERROR),
indentation_error,
vis.clone(),
Const,
Some(INDENTATION_ERROR),
);
self.register_builtin_type(
mono(TAB_ERROR),
tab_error,
vis.clone(),
Const,
Some(TAB_ERROR),
);
self.register_builtin_type(
mono(SYSTEM_ERROR),
system_error,
vis.clone(),
Const,
Some(SYSTEM_ERROR),
);
self.register_builtin_type(
mono(TYPE_ERROR),
type_error,
vis.clone(),
Const,
Some(TYPE_ERROR),
);
self.register_builtin_type(
mono(VALUE_ERROR),
value_error,
vis.clone(),
Const,
Some(VALUE_ERROR),
);
self.register_builtin_type(
mono(UNICODE_ERROR),
unicode_error,
vis.clone(),
Const,
Some(UNICODE_ERROR),
);
self.register_builtin_type(
mono(UNICODE_ENCODE_ERROR),
unicode_encode_error,
vis.clone(),
Const,
Some(UNICODE_ENCODE_ERROR),
);
self.register_builtin_type(
mono(UNICODE_DECODE_ERROR),
unicode_decode_error,
vis.clone(),
Const,
Some(UNICODE_DECODE_ERROR),
);
self.register_builtin_type(
mono(UNICODE_TRANSLATE_ERROR),
unicode_translate_error,
vis.clone(),
Const,
Some(UNICODE_TRANSLATE_ERROR),
);
self.register_builtin_type(mono(WARNING), warning, vis.clone(), Const, Some(WARNING));
self.register_builtin_type(
mono(DEPRECATION_WARNING),
deprecation_warning,
vis.clone(),
Const,
Some(DEPRECATION_WARNING),
);
self.register_builtin_type(
mono(PENDING_DEPRECATION_WARNING),
pending_deprecation_warning,
vis.clone(),
Const,
Some(PENDING_DEPRECATION_WARNING),
);
self.register_builtin_type(
mono(RUNTIME_WARNING),
runtime_warning,
vis.clone(),
Const,
Some(RUNTIME_WARNING),
);
self.register_builtin_type(
mono(SYNTAX_WARNING),
syntax_warning,
vis.clone(),
Const,
Some(SYNTAX_WARNING),
);
self.register_builtin_type(
mono(USER_WARNING),
user_warning,
vis.clone(),
Const,
Some(USER_WARNING),
);
self.register_builtin_type(
mono(FUTURE_WARNING),
future_warning,
vis.clone(),
Const,
Some(FUTURE_WARNING),
);
self.register_builtin_type(
mono(IMPORT_WARNING),
import_warning,
vis.clone(),
Const,
Some(IMPORT_WARNING),
);
self.register_builtin_type(
mono(UNICODE_WARNING),
unicode_warning,
vis.clone(),
Const,
Some(UNICODE_WARNING),
);
self.register_builtin_type(
mono(BYTES_WARNING),
bytes_warning,
vis.clone(),
Const,
Some(BYTES_WARNING),
);
self.register_builtin_type(
mono(RESOURCE_WARNING),
resource_warning,
vis.clone(),
Const,
Some(RESOURCE_WARNING),
);
self.register_builtin_type(mono(PROC), proc, vis.clone(), Const, Some(PROC));
self.register_builtin_type(mono(FUNC), func, vis.clone(), Const, Some(FUNC));
self.register_builtin_type(range_t, range, vis.clone(), Const, Some(FUNC_RANGE));

View file

@ -122,7 +122,7 @@ const ITER: &str = "Iter";
const CONTEXT_MANAGER: &str = "ContextManager";
const EXC_TYPE: &str = "exc_type";
const EXC_VALUE: &str = "exc_value";
const TRACEBACK: &str = "traceback";
const ATTR_TRACEBACK: &str = "traceback";
const ADD: &str = "Add";
const SUB: &str = "Sub";
const MUL: &str = "Mul";
@ -384,6 +384,86 @@ const FUNC_ZIP: &str = "zip";
const FILE: &str = "File";
const CALLABLE: &str = "Callable";
const GENERATOR: &str = "Generator";
const BASE_EXCEPTION: &str = "BaseException";
const ATTR_ARGS: &str = "args";
const FUNC_WITH_TRACEBACK: &str = "with_traceback";
const TRACEBACK: &str = "Traceback";
const ATTR_TB_FRAME: &str = "tb_frame";
const ATTR_TB_LASTI: &str = "tb_lasti";
const ATTR_TB_LINENO: &str = "tb_lineno";
const ATTR_TB_NEXT: &str = "tb_next";
const SYSTEM_EXIT: &str = "SystemExit";
const ATTR_CODE: &str = "code";
const KEYBOARD_INTERRUPT: &str = "KeyboardInterrupt";
const GENERATOR_EXIT: &str = "GeneratorExit";
const EXCEPTION: &str = "Exception";
const STOP_ITERATION: &str = "StopIteration";
const ATTR_VALUE: &str = "value";
const STOP_ASYNC_ITERATION: &str = "StopAsyncIteration";
const ARITHMETIC_ERROR: &str = "ArithmeticError";
const FLOATING_POINT_ERROR: &str = "FloatingPointError";
const OVERFLOW_ERROR: &str = "OverflowError";
const ZERO_DIVISION_ERROR: &str = "ZeroDivisionError";
const ASSERTION_ERROR: &str = "AssertionError";
const ATTRIBUTE_ERROR: &str = "AttributeError";
const BUFFER_ERROR: &str = "BufferError";
const EOF_ERROR: &str = "EOFError";
const IMPORT_ERROR: &str = "ImportError";
const ATTR_MSG: &str = "msg";
const ATTR_NAME: &str = "name";
const ATTR_PATH: &str = "path";
const MODULE_NOT_FOUND_ERROR: &str = "ModuleNotFoundError";
const LOOKUP_ERROR: &str = "LookupError";
const INDEX_ERROR: &str = "IndexError";
const KEY_ERROR: &str = "KeyError";
const MEMORY_ERROR: &str = "MemoryError";
const NAME_ERROR: &str = "NameError";
const UNBOUND_LOCAL_ERROR: &str = "UnboundLocalError";
const OS_ERROR: &str = "OSError";
const ATTR_ERRNO: &str = "errno";
const ATTR_FILENAME: &str = "filename";
const ATTR_FILENAME2: &str = "filename2";
const ATTR_STRERROR: &str = "strerror";
const BLOCKING_IO_ERROR: &str = "BlockingIOError";
const CHILD_PROCESS_ERROR: &str = "ChildProcessError";
const CONNECTION_ERROR: &str = "ConnectionError";
const BROKEN_PIPE_ERROR: &str = "BrokenPipeError";
const CONNECTION_ABORTED_ERROR: &str = "ConnectionAbortedError";
const CONNECTION_REFUSED_ERROR: &str = "ConnectionRefusedError";
const CONNECTION_RESET_ERROR: &str = "ConnectionResetError";
const FILE_EXISTS_ERROR: &str = "FileExistsError";
const FILE_NOT_FOUND_ERROR: &str = "FileNotFoundError";
const INTERRUPTED_ERROR: &str = "InterruptedError";
const IS_A_DIRECTORY_ERROR: &str = "IsADirectoryError";
const NOT_A_DIRECTORY_ERROR: &str = "NotADirectoryError";
const PERMISSION_ERROR: &str = "PermissionError";
const PROCESS_LOOKUP_ERROR: &str = "ProcessLookupError";
const TIMEOUT_ERROR: &str = "TimeoutError";
const REFERENCE_ERROR: &str = "ReferenceError";
const RUNTIME_ERROR: &str = "RuntimeError";
const NOT_IMPLEMENTED_ERROR: &str = "NotImplementedError";
const RECURSION_ERROR: &str = "RecursionError";
const SYNTAX_ERROR: &str = "SyntaxError";
const INDENTATION_ERROR: &str = "IndentationError";
const TAB_ERROR: &str = "TabError";
const SYSTEM_ERROR: &str = "SystemError";
const TYPE_ERROR: &str = "TypeError";
const VALUE_ERROR: &str = "ValueError";
const UNICODE_ERROR: &str = "UnicodeError";
const UNICODE_DECODE_ERROR: &str = "UnicodeDecodeError";
const UNICODE_ENCODE_ERROR: &str = "UnicodeEncodeError";
const UNICODE_TRANSLATE_ERROR: &str = "UnicodeTranslateError";
const WARNING: &str = "Warning";
const BYTES_WARNING: &str = "BytesWarning";
const DEPRECATION_WARNING: &str = "DeprecationWarning";
const FUTURE_WARNING: &str = "FutureWarning";
const IMPORT_WARNING: &str = "ImportWarning";
const PENDING_DEPRECATION_WARNING: &str = "PendingDeprecationWarning";
const RESOURCE_WARNING: &str = "ResourceWarning";
const RUNTIME_WARNING: &str = "RuntimeWarning";
const SYNTAX_WARNING: &str = "SyntaxWarning";
const UNICODE_WARNING: &str = "UnicodeWarning";
const USER_WARNING: &str = "UserWarning";
const FUNC_RANGE: &str = "range";
const FUNC_ALL: &str = "all";
const FUNC_ANY: &str = "any";
@ -509,6 +589,10 @@ const PROC_FUNDAMENTAL_DELITEM: &str = "__delitem__!";
const FUNDAMENTAL_IMPORT: &str = "__import__";
const FUNDAMENTAL_ENTER: &str = "__enter__";
const FUNDAMENTAL_EXIT: &str = "__exit__";
const FUNDAMENTAL_TRACEBACK: &str = "__traceback__";
const FUNDAMENTAL_CAUSE: &str = "__cause__";
const FUNDAMENTAL_CONTEXT: &str = "__context__";
const FUNDAMENTAL_SUPPRESS_CONTEXT: &str = "__suppress_context__";
const LICENSE: &str = "license";
const CREDITS: &str = "credits";

View file

@ -355,7 +355,7 @@ impl Context {
vec![
kw(EXC_TYPE, ClassType),
kw(EXC_VALUE, Obj),
kw(TRACEBACK, Obj), // TODO:
kw(ATTR_TRACEBACK, mono(TRACEBACK)),
],
vec![],
NoneType,