*** sys_pre_expand.erl Wed Sep 28 10:44:12 2005 --- /home/etxuwig/OSE/otp_src_R10B-7/lib/compiler/src/sys_pre_expand.erl Mon Aug 29 15:13:49 2005 *************** *** 58,64 **** module(Fs, Opts) -> %% Set pre-defined exported functions. ! PreExp = [{module_info,0},{module_info,1},{record_info,2}], %% Set pre-defined module imports. PreModImp = [{erlang,erlang},{packages,packages}], --- 58,64 ---- module(Fs, Opts) -> %% Set pre-defined exported functions. ! PreExp = [{module_info,0},{module_info,1}], %% Set pre-defined module imports. PreModImp = [{erlang,erlang},{packages,packages}], *************** *** 82,92 **** %% Generate all functions from stored info. {Ats,St3} = module_attrs(St2#expand{exports = Exports}), {Mfs,St4} = module_predef_funcs(St3), ! io:format("Records = ~p~n", [dict:to_list(St4#expand.records)]), ! Ret = {St4#expand.module, St4#expand.exports, Ats ++ Efs ++ Mfs, ! St4#expand.compile}, ! io:format("Ret = ~p~n", [Ret]), ! Ret. expand_pmod(Fs0, St) -> case St#expand.parameters of --- 82,89 ---- %% Generate all functions from stored info. {Ats,St3} = module_attrs(St2#expand{exports = Exports}), {Mfs,St4} = module_predef_funcs(St3), ! {St4#expand.module, St4#expand.exports, Ats ++ Efs ++ Mfs, ! St4#expand.compile}. expand_pmod(Fs0, St) -> case St#expand.parameters of *************** *** 120,149 **** {[{attribute,0,Name,Val} || {Name,Val} <- St#expand.attributes],St}. module_predef_funcs(St) -> ! PreDef = [{module_info,0},{module_info,1},{record_info,2}], PreExp = PreDef, - RecNames = lists:sort(dict:fetch_keys(St#expand.records)), {[{function,0,module_info,0, [{clause,0,[],[], [{call,0,{remote,0,{atom,0,erlang},{atom,0,get_module_info}}, [{atom,0,St#expand.module}]}]}]}, {function,0,module_info,1, ! [{clause,0,[{atom,0,records}],[], ! [make_list([{atom,0,Name} || Name <- RecNames], 0)]}, ! {clause,0,[{var,0,'X'}],[], ! [{call,0,{remote,0,{atom,0,erlang},{atom,0,get_module_info}}, ! [{atom,0,St#expand.module},{var,0,'X'}]}]}]}, ! {function,0,record_info,2, ! [{clause,0,[{atom,0,size},{atom,0,Name}],[], ! [{integer, 0, 1+length(record_fields(Name, St))}]} || ! Name <- RecNames] ++ ! [{clause,0,[{atom,0,fields},{atom,0,Name}],[], ! [make_list(field_names(record_fields(Name, St)), 0)]} || ! Name <- RecNames]}], St#expand{defined=union(from_list(PreDef), St#expand.defined), exports=union(from_list(PreExp), St#expand.exports)}}. - %% forms(Forms, State) -> %% {TransformedForms,State'} %% Process the forms. Attributes are lost and just affect the state. --- 117,135 ---- {[{attribute,0,Name,Val} || {Name,Val} <- St#expand.attributes],St}. module_predef_funcs(St) -> ! PreDef = [{module_info,0},{module_info,1}], PreExp = PreDef, {[{function,0,module_info,0, [{clause,0,[],[], [{call,0,{remote,0,{atom,0,erlang},{atom,0,get_module_info}}, [{atom,0,St#expand.module}]}]}]}, {function,0,module_info,1, ! [{clause,0,[{var,0,'X'}],[], ! [{call,0,{remote,0,{atom,0,erlang},{atom,0,get_module_info}}, ! [{atom,0,St#expand.module},{var,0,'X'}]}]}]}], St#expand{defined=union(from_list(PreDef), St#expand.defined), exports=union(from_list(PreExp), St#expand.exports)}}. %% forms(Forms, State) -> %% {TransformedForms,State'} %% Process the forms. Attributes are lost and just affect the state. *************** *** 482,494 **** {yes,Mod} -> {{call,Line,{remote,La,{atom,La,Mod},{atom,La,N}},As},St1}; no -> ! {{call,Line,{atom,La,N},As},St1} ! %%% case {N,Ar} of ! %%% {record_info,2} -> ! %%% record_info_call(Line, As, St1); ! %%% _ -> ! %%% {{call,Line,{atom,La,N},As},St1} ! %%% end end end; expr({call,Line,{record_field,_,_,_}=M,As0}, St0) -> --- 468,479 ---- {yes,Mod} -> {{call,Line,{remote,La,{atom,La,Mod},{atom,La,N}},As},St1}; no -> ! case {N,Ar} of ! {record_info,2} -> ! record_info_call(Line, As, St1); ! _ -> ! {{call,Line,{atom,La,N},As},St1} ! end end end; expr({call,Line,{record_field,_,_,_}=M,As0}, St0) -> *************** *** 793,805 **** %% Expand a call to record_info/2. We have checked that it is not %% shadowed by an import. ! %%% record_info_call(Line, [{atom,_Li,Info},{atom,_Ln,Name}], St) -> ! %%% case Info of ! %%% size -> ! %%% {{integer,Line,1+length(record_fields(Name, St))},St}; ! %%% fields -> ! %%% {make_list(field_names(record_fields(Name, St)), Line),St} ! %%% end. %% Break out expressions from an record update list and bind to new %% variables. The idea is that we will evaluate all update expressions --- 778,790 ---- %% Expand a call to record_info/2. We have checked that it is not %% shadowed by an import. ! record_info_call(Line, [{atom,_Li,Info},{atom,_Ln,Name}], St) -> ! case Info of ! size -> ! {{integer,Line,1+length(record_fields(Name, St))},St}; ! fields -> ! {make_list(field_names(record_fields(Name, St)), Line),St} ! end. %% Break out expressions from an record update list and bind to new %% variables. The idea is that we will evaluate all update expressions