Permalink
Browse files

Check whether modules are loaded or not in the dispatcher rather than…

… in Module.re
  • Loading branch information...
Tony Arcieri
Tony Arcieri committed Dec 26, 2010
1 parent e8b74b6 commit 08f87dc5fa9dcd2a4547102126de8061a263b505
Showing with 9 additions and 9 deletions.
  1. +1 −7 src/builtins/module.re
  2. +8 −2 src/core/reia_dispatch.erl
View
@@ -10,13 +10,7 @@ module Module
def call(receiver, :to_s, args, block)
(:reia_module, name) = receiver
- case erl.code.ensure_loaded(name)
- when (:module, name)
- name.to_string()
- when _
- throw(NameError, "undefined module #{name}")
- :error
- end
+ name.to_string()
end
def call(receiver, :inspect, args, block)
View
@@ -26,8 +26,14 @@ call(#reia_regexp{} = Receiver, Method, Arguments, Block) ->
'Regexp':call({Receiver, Method, Arguments}, Block);
call(#reia_range{} = Receiver, Method, Arguments, Block) ->
'Range':call({Receiver, Method, Arguments}, Block);
-call(#reia_module{} = Receiver, Method, Arguments, Block) ->
- 'Module':call({Receiver, Method, Arguments, Block}, nil);
+call(#reia_module{name=Name} = Receiver, Method, Arguments, Block) ->
+ case code:ensure_loaded(Name) of
+ {module, Name} ->
+ 'Module':call({Receiver, Method, Arguments, Block}, nil);
+ _ ->
+ Message = lists:flatten(io_lib:format("undefined module ~s", [Name])),
+ reia:throw('NameError', Message)
+ end;
call(#reia_funref{} = Receiver, Method, Arguments, Block) ->
'Funref':call({Receiver, Method, Arguments}, Block);
call(Receiver, Method, Arguments, Block) when is_tuple(Receiver) ->

0 comments on commit 08f87dc

Please sign in to comment.