Permalink
Browse files

Begin factoring apart transform_initialize_methods

  • Loading branch information...
1 parent 42d156b commit f7f85ab04d8f0a3928dacc1c8089881b8d8b58ca Tony Arcieri committed Mar 7, 2011
Showing with 17 additions and 15 deletions.
  1. +17 −15 src/compiler/reia_classes.erl
@@ -80,23 +80,25 @@ transform_initialize_methods(_Name, MethodTable) ->
end,
lists:map(fun(Method) ->
- Initialize = prepare_mutable_method(Method),
-
- Line = Initialize#function.line,
- Result = #native_call{
- line = Line,
- module = erlang,
- function = setelement,
- args = [
- #integer{line=Line, value=3},
- ?self(Line),
- ?ivars(Line)
- ]
- },
-
- Initialize#function{body = Initialize#function.body ++ [Result]}
+ transform_initialize_method_return(prepare_mutable_method(Method))
end, Methods).
+% Return the new immutable object from the initialize function
+transform_initialize_method_return(Initialize) ->
+ Line = Initialize#function.line,
+ Result = #native_call{
+ line = Line,
+ module = erlang,
+ function = setelement,
+ args = [
+ #integer{line=Line, value=3},
+ ?self(Line),
+ ?ivars(Line)
+ ]
+ },
+
+ Initialize#function{body = Initialize#function.body ++ [Result]}.
+
% Transform the method_missing method or create it if it wasn't defined
transform_method_missings(Parent, MethodTable) ->
case orddict:find(method_missing, MethodTable) of

0 comments on commit f7f85ab

Please sign in to comment.