Skip to content

Commit 20d376e

Browse files
authored
Merge pull request #16934 from JuliaLang/jn/old-cleanup
cleanup some old code
2 parents 7690b37 + b2fd1c5 commit 20d376e

File tree

9 files changed

+17
-40
lines changed

9 files changed

+17
-40
lines changed

base/base.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# This file is a part of Julia. License is MIT: http://julialang.org/license
22

3-
type ErrorException <: Exception
4-
msg::AbstractString
5-
end
6-
73
type SystemError <: Exception
84
prefix::AbstractString
95
errnum::Int32

base/boot.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export
129129
# string types
130130
Char, DirectIndexString, AbstractString, String,
131131
# errors
132-
BoundsError, DivideError, DomainError, Exception, InexactError,
132+
ErrorException, BoundsError, DivideError, DomainError, Exception, InexactError,
133133
InterruptException, OutOfMemoryError, ReadOnlyMemoryError, OverflowError,
134134
StackOverflowError, SegmentationFault, UndefRefError, UndefVarError, TypeError,
135135
# AST representation
@@ -186,6 +186,10 @@ function Typeof end
186186
(f::typeof(Typeof))(x::ANY) = isa(x,Type) ? Type{x} : typeof(x)
187187

188188
abstract Exception
189+
type ErrorException <: Exception
190+
msg::AbstractString
191+
ErrorException(msg::AbstractString) = new(msg)
192+
end
189193
immutable BoundsError <: Exception
190194
a::Any
191195
i::Any

base/error.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
## native julia error handling ##
2020

21-
error(s::AbstractString) = throw(Main.Base.ErrorException(s))
22-
error(s...) = throw(Main.Base.ErrorException(Main.Base.string(s...)))
21+
error(s::AbstractString) = throw(ErrorException(s))
22+
error(s...) = throw(ErrorException(Main.Base.string(s...)))
2323

2424
rethrow() = ccall(:jl_rethrow, Bottom, ())
2525
rethrow(e) = ccall(:jl_rethrow_other, Bottom, (Any,), e)

src/builtins.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,16 +911,14 @@ JL_DLLEXPORT jl_value_t *jl_stdout_obj(void)
911911
{
912912
if (jl_base_module == NULL) return NULL;
913913
jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("STDOUT"));
914-
if (stdout_obj != NULL) return stdout_obj;
915-
return jl_get_global(jl_base_module, jl_symbol("OUTPUT_STREAM"));
914+
return stdout_obj;
916915
}
917916

918917
JL_DLLEXPORT jl_value_t *jl_stderr_obj(void)
919918
{
920919
if (jl_base_module == NULL) return NULL;
921920
jl_value_t *stderr_obj = jl_get_global(jl_base_module, jl_symbol("STDERR"));
922-
if (stderr_obj != NULL) return stderr_obj;
923-
return jl_get_global(jl_base_module, jl_symbol("OUTPUT_STREAM"));
921+
return stderr_obj;
924922
}
925923

926924
static jl_function_t *jl_show_gf=NULL;

src/gc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,6 @@ void visit_mark_stack(void)
14331433

14341434
void jl_mark_box_caches(void);
14351435

1436-
extern jl_module_t *jl_old_base_module;
14371436
extern jl_array_t *jl_module_init_order;
14381437
extern jl_typemap_entry_t *call_cache[N_CALL_CACHE];
14391438

@@ -1442,7 +1441,6 @@ void pre_mark(void)
14421441
{
14431442
// modules
14441443
gc_push_root(jl_main_module, 0);
1445-
if (jl_old_base_module) gc_push_root(jl_old_base_module, 0);
14461444
gc_push_root(jl_internal_main_module, 0);
14471445

14481446
size_t i;

src/gf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ void JL_NORETURN jl_method_error_bare(jl_function_t *f, jl_value_t *args)
954954
(jl_value_t*)f,
955955
args
956956
};
957-
if (jl_base_module) {
957+
if (fargs[0]) {
958958
jl_throw(jl_apply_generic(fargs, 3));
959959
}
960960
else {

src/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ void jl_get_builtin_hooks(void)
820820
jl_number_type = (jl_datatype_t*)core("Number");
821821
jl_signed_type = (jl_datatype_t*)core("Signed");
822822

823+
jl_errorexception_type = (jl_datatype_t*)core("ErrorException");
823824
jl_stackovf_exception = jl_new_struct_uninit((jl_datatype_t*)core("StackOverflowError"));
824825
jl_diverror_exception = jl_new_struct_uninit((jl_datatype_t*)core("DivideError"));
825826
jl_domain_exception = jl_new_struct_uninit((jl_datatype_t*)core("DomainError"));
@@ -844,9 +845,8 @@ void jl_get_builtin_hooks(void)
844845

845846
JL_DLLEXPORT void jl_get_system_hooks(void)
846847
{
847-
if (jl_errorexception_type) return; // only do this once
848+
if (jl_argumenterror_type) return; // only do this once
848849

849-
jl_errorexception_type = (jl_datatype_t*)basemod("ErrorException");
850850
jl_argumenterror_type = (jl_datatype_t*)basemod("ArgumentError");
851851
jl_methoderror_type = (jl_datatype_t*)basemod("MethodError");
852852
jl_loaderror_type = (jl_datatype_t*)basemod("LoadError");

src/jl_uv.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,13 @@ void jl_init_signal_async(void)
7878
}
7979
#endif
8080

81-
extern jl_module_t *jl_old_base_module;
82-
static jl_value_t *close_cb = NULL;
83-
8481
static void jl_uv_call_close_callback(jl_value_t *val)
8582
{
86-
jl_value_t *cb;
87-
if (!jl_old_base_module) {
88-
if (close_cb == NULL)
89-
close_cb = jl_get_global(jl_base_module, jl_symbol("_uv_hook_close"));
90-
cb = close_cb;
91-
}
92-
else {
93-
cb = jl_get_global(jl_base_relative_to(((jl_datatype_t*)jl_typeof(val))->name->module), jl_symbol("_uv_hook_close"));
94-
}
95-
assert(cb);
96-
jl_value_t *args[2] = {cb,val};
83+
jl_value_t *args[2];
84+
args[0] = jl_get_global(jl_base_relative_to(((jl_datatype_t*)jl_typeof(val))->name->module),
85+
jl_symbol("_uv_hook_close")); // topmod(typeof(val))._uv_hook_close
86+
args[1] = val;
87+
assert(args[0]);
9788
jl_apply(args, 2);
9889
}
9990

src/toplevel.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ JL_DLLEXPORT int jl_lineno = 0; // need to update jl_critical_error if this is T
2929
// current file name
3030
JL_DLLEXPORT const char *jl_filename = "no file"; // need to update jl_critical_error if this is TLS
3131

32-
jl_module_t *jl_old_base_module = NULL;
3332
// the Main we started with, in case it is switched
3433
jl_module_t *jl_internal_main_module = NULL;
3534

@@ -131,16 +130,7 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
131130

132131
if (parent_module == jl_main_module && name == jl_symbol("Base")) {
133132
// pick up Base module during bootstrap
134-
jl_old_base_module = jl_base_module;
135133
jl_base_module = newm;
136-
// reinitialize global variables
137-
// to pick up new types from Base
138-
jl_errorexception_type = NULL;
139-
jl_argumenterror_type = NULL;
140-
jl_methoderror_type = NULL;
141-
jl_loaderror_type = NULL;
142-
jl_initerror_type = NULL;
143-
jl_current_task->tls = jl_nothing; // may contain an entry for :SOURCE_FILE that is not valid in the new base
144134
}
145135
// export all modules from Main
146136
if (parent_module == jl_main_module)

0 commit comments

Comments
 (0)