Browse Source

Merge pull request #361 from basho/r19-jrd-typed_records

Support typed records newly exposed in OTP 19

Reviewed-by: macintux
2.x
Bishop Bors 9 years ago
parent
commit
07206a658a
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      src/lager_transform.erl

+ 8
- 5
src/lager_transform.erl View File

@ -57,16 +57,19 @@ walk_ast(Acc, [{function, Line, Name, Arity, Clauses}|T]) ->
walk_ast([{function, Line, Name, Arity, walk_ast([{function, Line, Name, Arity,
walk_clauses([], Clauses)}|Acc], T); walk_clauses([], Clauses)}|Acc], T);
walk_ast(Acc, [{attribute, _, record, {Name, Fields}}=H|T]) -> walk_ast(Acc, [{attribute, _, record, {Name, Fields}}=H|T]) ->
FieldNames = lists:map(fun({record_field, _, {atom, _, FieldName}}) ->
FieldName;
({record_field, _, {atom, _, FieldName}, _Default}) ->
FieldName
end, Fields),
FieldNames = lists:map(fun record_field_name/1, Fields),
stash_record({Name, FieldNames}), stash_record({Name, FieldNames}),
walk_ast([H|Acc], T); walk_ast([H|Acc], T);
walk_ast(Acc, [H|T]) -> walk_ast(Acc, [H|T]) ->
walk_ast([H|Acc], T). walk_ast([H|Acc], T).
record_field_name({record_field, _, {atom, _, FieldName}}) ->
FieldName;
record_field_name({record_field, _, {atom, _, FieldName}, _Default}) ->
FieldName;
record_field_name({typed_record_field, Field, _Type}) ->
record_field_name(Field).
walk_clauses(Acc, []) -> walk_clauses(Acc, []) ->
lists:reverse(Acc); lists:reverse(Acc);
walk_clauses(Acc, [{clause, Line, Arguments, Guards, Body}|T]) -> walk_clauses(Acc, [{clause, Line, Arguments, Guards, Body}|T]) ->

Loading…
Cancel
Save