| 1 | diff -ruN ../apache-couchdb-1.2.1-orig/src/etap/Makefile.in ./src/etap/Makefile.in |
| 2 | --- ../apache-couchdb-1.2.1-orig/src/etap/Makefile.in 2012-12-20 15:28:49.000000000 -0600 |
| 3 | +++ ./src/etap/Makefile.in 2013-03-16 11:10:15.000000000 -0500 |
| 4 | @@ -109,7 +109,7 @@ |
| 5 | ERL = @ERL@ |
| 6 | ERLANG_FLAGS = @ERLANG_FLAGS@ |
| 7 | ERLC = @ERLC@ |
| 8 | -ERLC_FLAGS = @ERLC_FLAGS@ |
| 9 | +ERLC_FLAGS = @ERLC_FLAGS@ -pa . |
| 10 | EXEEXT = @EXEEXT@ |
| 11 | FGREP = @FGREP@ |
| 12 | FLAGS = @FLAGS@ |
| 13 | @@ -253,6 +253,7 @@ |
| 14 | version_stage = @version_stage@ |
| 15 | etapebindir = $(localerlanglibdir)/etap/ebin |
| 16 | etap_file_collection = \ |
| 17 | + pmod_pt.erl \ |
| 18 | etap.erl \ |
| 19 | etap_application.erl \ |
| 20 | etap_can.erl \ |
| 21 | @@ -264,6 +265,7 @@ |
| 22 | etap_web.erl |
| 23 | |
| 24 | etapebin_make_generated_file_list = \ |
| 25 | + pmod_pt.beam \ |
| 26 | etap.beam \ |
| 27 | etap_application.beam \ |
| 28 | etap_can.beam \ |
| 29 | diff -ruN ../apache-couchdb-1.2.1-orig/src/etap/etap_request.erl ./src/etap/etap_request.erl |
| 30 | --- ../apache-couchdb-1.2.1-orig/src/etap/etap_request.erl 2012-12-20 15:24:07.000000000 -0600 |
| 31 | +++ ./src/etap/etap_request.erl 2013-03-16 10:47:54.000000000 -0500 |
| 32 | @@ -33,6 +33,8 @@ |
| 33 | body_has_string/2 |
| 34 | ]). |
| 35 | |
| 36 | +-compile({parse_transform, pmod_pt}). |
| 37 | + |
| 38 | % --- |
| 39 | % Tests |
| 40 | |
| 41 | diff -ruN ../apache-couchdb-1.2.1-orig/src/etap/pmod_pt.erl ./src/etap/pmod_pt.erl |
| 42 | --- ../apache-couchdb-1.2.1-orig/src/etap/pmod_pt.erl 1969-12-31 18:00:00.000000000 -0600 |
| 43 | +++ ./src/etap/pmod_pt.erl 2013-03-16 11:08:17.000000000 -0500 |
| 44 | @@ -0,0 +1,463 @@ |
| 45 | +%% |
| 46 | +%% %CopyrightBegin% |
| 47 | +%% |
| 48 | +%% Copyright Ericsson AB 2013. All Rights Reserved. |
| 49 | +%% |
| 50 | +%% The contents of this file are subject to the Erlang Public License, |
| 51 | +%% Version 1.1, (the "License"); you may not use this file except in |
| 52 | +%% compliance with the License. You should have received a copy of the |
| 53 | +%% Erlang Public License along with this software. If not, it can be |
| 54 | +%% retrieved online at http://www.erlang.org/. |
| 55 | +%% |
| 56 | +%% Software distributed under the License is distributed on an "AS IS" |
| 57 | +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
| 58 | +%% the License for the specific language governing rights and limitations |
| 59 | +%% under the License. |
| 60 | +%% |
| 61 | +%% %CopyrightEnd% |
| 62 | +%% |
| 63 | + |
| 64 | +-module(pmod_pt). |
| 65 | +-export([parse_transform/2, |
| 66 | + format_error/1]). |
| 67 | + |
| 68 | +%% Expand function definition forms of parameterized module. |
| 69 | +%% The code is based on the code in sys_expand_pmod which used to be |
| 70 | +%% included in the compiler, but details are different because |
| 71 | +%% sys_pre_expand has not been run. In particular: |
| 72 | +%% |
| 73 | +%% * Record definitions are still present and must be handled. |
| 74 | +%% |
| 75 | +%% * (Syntatic) local calls may actually be calls to an imported |
| 76 | +%% funtion or a BIF. It is a local call if and only if there |
| 77 | +%% is a definition for the function in the module. |
| 78 | +%% |
| 79 | +%% * When we introduce the module parameters and 'THIS' in each |
| 80 | +%% function, we must artificially use it to avoid a warning for |
| 81 | +%% unused variables. |
| 82 | +%% |
| 83 | +%% * On the other hand, we don't have to worry about module_info/0,1 |
| 84 | +%% because they have not been added yet. |
| 85 | + |
| 86 | +-record(pmod, {parameters, |
| 87 | + defined |
| 88 | + }). |
| 89 | + |
| 90 | +parse_transform(Forms0, _Options) -> |
| 91 | + put(?MODULE, []), |
| 92 | + Forms = transform(Forms0), |
| 93 | + case erase(?MODULE) of |
| 94 | + [] -> |
| 95 | + Forms; |
| 96 | + [_|_]=Errors -> |
| 97 | + File = get_file(Forms), |
| 98 | + {error,[{File,Errors}],[]} |
| 99 | + end. |
| 100 | + |
| 101 | +format_error(extends_self) -> |
| 102 | + "cannot extend from self"; |
| 103 | +format_error(define_instance) -> |
| 104 | + "defining instance function not allowed in parameterized module". |
| 105 | + |
| 106 | +add_error(Line, Error) -> |
| 107 | + put(?MODULE, get(?MODULE) ++ [{Line,?MODULE,Error}]). |
| 108 | + |
| 109 | +get_file([{attribute,_,file,{File,_}}|_]) -> File; |
| 110 | +get_file([_|T]) -> get_file(T). |
| 111 | + |
| 112 | +transform(Forms0) -> |
| 113 | + Def = collect_defined(Forms0), |
| 114 | + {Base,ModAs,Forms1} = attribs(Forms0, [], undefined, []), |
| 115 | + {Mod,Ps0} = case ModAs of |
| 116 | + {M0,P0} -> {M0,P0}; |
| 117 | + M0 -> {M0,undefined} |
| 118 | + end, |
| 119 | + Forms2 = case Ps0 of |
| 120 | + undefined -> |
| 121 | + Forms1; |
| 122 | + _ -> |
| 123 | + pmod_expand(Forms1, Mod, Base, Ps0, Def) |
| 124 | + end, |
| 125 | + |
| 126 | + %% Add new functions. |
| 127 | + NewFs0 = maybe_extend(Base, Mod, Ps0), |
| 128 | + NewExps = collect_defined(NewFs0), |
| 129 | + Forms3 = add_attributes(Forms2, [{attribute,0,export,NewExps}]), |
| 130 | + add_new_funcs(Forms3, NewFs0). |
| 131 | + |
| 132 | +pmod_expand(Forms0, Mod, Base, Ps0, Def) -> |
| 133 | + Ps = if is_atom(Base) -> |
| 134 | + ['BASE' | Ps0]; |
| 135 | + true -> |
| 136 | + Ps0 |
| 137 | + end, |
| 138 | + St0 = #pmod{parameters=Ps,defined=gb_sets:from_list(Def)}, |
| 139 | + {Forms1,_} = forms(Forms0, St0), |
| 140 | + Forms2 = update_exps(Forms1), |
| 141 | + Forms3 = update_forms(Forms2), |
| 142 | + NewFs0 = add_instance(Mod, Ps, []), |
| 143 | + NewFs = ensure_new(Base, Ps0, NewFs0), |
| 144 | + Forms = add_new_funcs(Forms3, NewFs), |
| 145 | + NewExps = collect_defined(NewFs), |
| 146 | + add_attributes(Forms, [{attribute,0,export,NewExps}]). |
| 147 | + |
| 148 | +add_attributes([{attribute,_,module,_}=F|Fs], Attrs) -> |
| 149 | + [F|Attrs++Fs]; |
| 150 | +add_attributes([F|Fs], Attrs) -> |
| 151 | + [F|add_attributes(Fs, Attrs)]. |
| 152 | + |
| 153 | +add_new_funcs([{eof,_}|_]=Fs, NewFs) -> |
| 154 | + NewFs ++ Fs; |
| 155 | +add_new_funcs([F|Fs], Es) -> |
| 156 | + [F|add_new_funcs(Fs, Es)]. |
| 157 | + |
| 158 | +maybe_extend([], _, _) -> |
| 159 | + %% No 'extends' attribute. |
| 160 | + []; |
| 161 | +maybe_extend(Base, _Mod, undefined) -> |
| 162 | + %% There is a an 'extends' attribute; the module is not parameterized. |
| 163 | + Name = '$handle_undefined_function', |
| 164 | + Args = [{var,0,'Func'},{var,0,'Args'}], |
| 165 | + Body = [make_apply({atom,0,Base}, {var,0,'Func'}, {var,0,'Args'})], |
| 166 | + F = {function,0,Name,2,[{clause,0,Args,[],Body}]}, |
| 167 | + [F]; |
| 168 | +maybe_extend(Base, Mod, Ps) -> |
| 169 | + %% There is a an 'extends' attribute; the module is parameterized. |
| 170 | + Name = '$handle_undefined_function', |
| 171 | + Args = [{var,0,'Func'},{var,0,'Args'}], |
| 172 | + DontCares = [{var,0,'_'} || _ <- Ps], |
| 173 | + TuplePs = {tuple,0,[{atom,0,Mod},{var,0,'BaseVars'}|DontCares]}, |
| 174 | + G = [{call,0,{atom,0,is_atom}, |
| 175 | + [{call,0,{atom,0,element}, |
| 176 | + [{integer,0,1},{var,0,'BaseVars'}]}]}], |
| 177 | + FixedArgs = make_lists_rev([{var,0,'Rs'}, |
| 178 | + {cons,0,{var,0,'BaseVars'},{nil,0}}]), |
| 179 | + Body = [{'case',0,make_lists_rev([{var,0,'Args'}]), |
| 180 | + [{clause,0,[{cons,0,TuplePs,{var,0,'Rs'}}],[G], |
| 181 | + [make_apply({atom,0,Base}, {var,0,'Func'}, FixedArgs)]}, |
| 182 | + {clause,0,[{var,0,'_'}],[], |
| 183 | + [make_apply({atom,0,Base}, {var,0,'Func'}, {var,0,'Args'})]} |
| 184 | + ]}], |
| 185 | + F = {function,0,Name,2,[{clause,0,Args,[],Body}]}, |
| 186 | + [F]. |
| 187 | + |
| 188 | +make_apply(M, F, A) -> |
| 189 | + {call,0,{remote,0,{atom,0,erlang},{atom,0,apply}},[M,F,A]}. |
| 190 | + |
| 191 | +make_lists_rev(As) -> |
| 192 | + {call,0,{remote,0,{atom,0,lists},{atom,0,reverse}},As}. |
| 193 | + |
| 194 | +ensure_new(Base, Ps, Fs) -> |
| 195 | + case has_new(Fs) of |
| 196 | + true -> |
| 197 | + Fs; |
| 198 | + false -> |
| 199 | + add_new(Base, Ps, Fs) |
| 200 | + end. |
| 201 | + |
| 202 | +has_new([{function,_L,new,_A,_Cs} | _Fs]) -> |
| 203 | + true; |
| 204 | +has_new([_ | Fs]) -> |
| 205 | + has_new(Fs); |
| 206 | +has_new([]) -> |
| 207 | + false. |
| 208 | + |
| 209 | +add_new(Base, Ps, Fs) -> |
| 210 | + Vs = [{var,0,V} || V <- Ps], |
| 211 | + As = if is_atom(Base) -> |
| 212 | + [{call,0,{remote,0,{atom,0,Base},{atom,0,new}},Vs} | Vs]; |
| 213 | + true -> |
| 214 | + Vs |
| 215 | + end, |
| 216 | + Body = [{call,0,{atom,0,instance},As}], |
| 217 | + add_func(new, Vs, Body, Fs). |
| 218 | + |
| 219 | +add_instance(Mod, Ps, Fs) -> |
| 220 | + Vs = [{var,0,V} || V <- Ps], |
| 221 | + AbsMod = [{tuple,0,[{atom,0,Mod}|Vs]}], |
| 222 | + add_func(instance, Vs, AbsMod, Fs). |
| 223 | + |
| 224 | +add_func(Name, Args, Body, Fs) -> |
| 225 | + A = length(Args), |
| 226 | + F = {function,0,Name,A,[{clause,0,Args,[],Body}]}, |
| 227 | + [F|Fs]. |
| 228 | + |
| 229 | +collect_defined(Fs) -> |
| 230 | + [{N,A} || {function,_,N,A,_} <- Fs]. |
| 231 | + |
| 232 | +attribs([{attribute,Line,module,{Mod,_}=ModAs}|T], Base, _, Acc) -> |
| 233 | + attribs(T, Base, ModAs, [{attribute,Line,module,Mod}|Acc]); |
| 234 | +attribs([{attribute,_,module,Mod}=H|T], Base, _, Acc) -> |
| 235 | + attribs(T, Base, Mod, [H|Acc]); |
| 236 | +attribs([{attribute,Line,extends,Base}|T], Base0, Ps, Acc) when is_atom(Base) -> |
| 237 | + Mod = case Ps of |
| 238 | + {Mod0,_} -> Mod0; |
| 239 | + Mod0 -> Mod0 |
| 240 | + end, |
| 241 | + case Mod of |
| 242 | + Base -> |
| 243 | + add_error(Line, extends_self), |
| 244 | + attribs(T, Base0, Ps, Acc); |
| 245 | + _ -> |
| 246 | + attribs(T, Base, Ps, Acc) |
| 247 | + end; |
| 248 | +attribs([H|T], Base, Ps, Acc) -> |
| 249 | + attribs(T, Base, Ps, [H|Acc]); |
| 250 | +attribs([], Base, Ps, Acc) -> |
| 251 | + {Base,Ps,lists:reverse(Acc)}. |
| 252 | + |
| 253 | +%% This is extremely simplistic for now; all functions get an extra |
| 254 | +%% parameter, whether they need it or not, except for static functions. |
| 255 | + |
| 256 | +update_function_name({F,A}) when F =/= new -> |
| 257 | + {F,A+1}; |
| 258 | +update_function_name(E) -> |
| 259 | + E. |
| 260 | + |
| 261 | +update_forms([{function,L,N,A,Cs}|Fs]) when N =/= new -> |
| 262 | + [{function,L,N,A+1,Cs}|update_forms(Fs)]; |
| 263 | +update_forms([F|Fs]) -> |
| 264 | + [F|update_forms(Fs)]; |
| 265 | +update_forms([]) -> |
| 266 | + []. |
| 267 | + |
| 268 | +update_exps([{attribute,Line,export,Es0}|T]) -> |
| 269 | + Es = [update_function_name(E) || E <- Es0], |
| 270 | + [{attribute,Line,export,Es}|update_exps(T)]; |
| 271 | +update_exps([H|T]) -> |
| 272 | + [H|update_exps(T)]; |
| 273 | +update_exps([]) -> |
| 274 | + []. |
| 275 | + |
| 276 | +%% Process the program forms. |
| 277 | + |
| 278 | +forms([F0|Fs0],St0) -> |
| 279 | + {F1,St1} = form(F0,St0), |
| 280 | + {Fs1,St2} = forms(Fs0,St1), |
| 281 | + {[F1|Fs1],St2}; |
| 282 | +forms([], St0) -> |
| 283 | + {[], St0}. |
| 284 | + |
| 285 | +%% Only function definitions are of interest here. State is not updated. |
| 286 | +form({function,Line,instance,_Arity,_Clauses}=F,St) -> |
| 287 | + add_error(Line, define_instance), |
| 288 | + {F,St}; |
| 289 | +form({function,Line,Name0,Arity0,Clauses0},St) when Name0 =/= new -> |
| 290 | + {Name,Arity,Clauses} = function(Name0, Arity0, Clauses0, St), |
| 291 | + {{function,Line,Name,Arity,Clauses},St}; |
| 292 | +%% Pass anything else through |
| 293 | +form(F,St) -> {F,St}. |
| 294 | + |
| 295 | +function(Name, Arity, Clauses0, St) -> |
| 296 | + Clauses1 = clauses(Clauses0,St), |
| 297 | + {Name,Arity,Clauses1}. |
| 298 | + |
| 299 | +clauses([C|Cs],#pmod{parameters=Ps}=St) -> |
| 300 | + {clause,L,H,G,B0} = clause(C,St), |
| 301 | + T = {tuple,L,[{var,L,V} || V <- ['_'|Ps]]}, |
| 302 | + B = [{match,L,{var,L,'_'},{var,L,V}} || V <- ['THIS'|Ps]] ++ B0, |
| 303 | + [{clause,L,H++[{match,L,T,{var,L,'THIS'}}],G,B}|clauses(Cs,St)]; |
| 304 | +clauses([],_St) -> []. |
| 305 | + |
| 306 | +clause({clause,Line,H,G,B0},St) -> |
| 307 | + %% We never update H and G, so we will just copy them. |
| 308 | + B1 = exprs(B0,St), |
| 309 | + {clause,Line,H,G,B1}. |
| 310 | + |
| 311 | +pattern_grp([{bin_element,L1,E1,S1,T1} | Fs],St) -> |
| 312 | + S2 = case S1 of |
| 313 | + default -> |
| 314 | + default; |
| 315 | + _ -> |
| 316 | + expr(S1,St) |
| 317 | + end, |
| 318 | + T2 = case T1 of |
| 319 | + default -> |
| 320 | + default; |
| 321 | + _ -> |
| 322 | + bit_types(T1) |
| 323 | + end, |
| 324 | + [{bin_element,L1,expr(E1,St),S2,T2} | pattern_grp(Fs,St)]; |
| 325 | +pattern_grp([],_St) -> |
| 326 | + []. |
| 327 | + |
| 328 | +bit_types([]) -> |
| 329 | + []; |
| 330 | +bit_types([Atom | Rest]) when is_atom(Atom) -> |
| 331 | + [Atom | bit_types(Rest)]; |
| 332 | +bit_types([{Atom, Integer} | Rest]) when is_atom(Atom), is_integer(Integer) -> |
| 333 | + [{Atom, Integer} | bit_types(Rest)]. |
| 334 | + |
| 335 | +exprs([E0|Es],St) -> |
| 336 | + E1 = expr(E0,St), |
| 337 | + [E1|exprs(Es,St)]; |
| 338 | +exprs([],_St) -> []. |
| 339 | + |
| 340 | +expr({var,_L,_V}=Var,_St) -> |
| 341 | + Var; |
| 342 | +expr({integer,_Line,_I}=Integer,_St) -> Integer; |
| 343 | +expr({float,_Line,_F}=Float,_St) -> Float; |
| 344 | +expr({atom,_Line,_A}=Atom,_St) -> Atom; |
| 345 | +expr({string,_Line,_S}=String,_St) -> String; |
| 346 | +expr({char,_Line,_C}=Char,_St) -> Char; |
| 347 | +expr({nil,_Line}=Nil,_St) -> Nil; |
| 348 | +expr({cons,Line,H0,T0},St) -> |
| 349 | + H1 = expr(H0,St), |
| 350 | + T1 = expr(T0,St), |
| 351 | + {cons,Line,H1,T1}; |
| 352 | +expr({lc,Line,E0,Qs0},St) -> |
| 353 | + Qs1 = lc_bc_quals(Qs0,St), |
| 354 | + E1 = expr(E0,St), |
| 355 | + {lc,Line,E1,Qs1}; |
| 356 | +expr({bc,Line,E0,Qs0},St) -> |
| 357 | + Qs1 = lc_bc_quals(Qs0,St), |
| 358 | + E1 = expr(E0,St), |
| 359 | + {bc,Line,E1,Qs1}; |
| 360 | +expr({tuple,Line,Es0},St) -> |
| 361 | + Es1 = expr_list(Es0,St), |
| 362 | + {tuple,Line,Es1}; |
| 363 | +expr({record_index,_,_,_}=RI, _St) -> |
| 364 | + RI; |
| 365 | +expr({record,Line,Name,Is0},St) -> |
| 366 | + Is = record_fields(Is0,St), |
| 367 | + {record,Line,Name,Is}; |
| 368 | +expr({record,Line,E0,Name,Is0},St) -> |
| 369 | + E = expr(E0,St), |
| 370 | + Is = record_fields(Is0,St), |
| 371 | + {record,Line,E,Name,Is}; |
| 372 | +expr({record_field,Line,E0,Name,Key},St) -> |
| 373 | + E = expr(E0,St), |
| 374 | + {record_field,Line,E,Name,Key}; |
| 375 | +expr({block,Line,Es0},St) -> |
| 376 | + Es1 = exprs(Es0,St), |
| 377 | + {block,Line,Es1}; |
| 378 | +expr({'if',Line,Cs0},St) -> |
| 379 | + Cs1 = icr_clauses(Cs0,St), |
| 380 | + {'if',Line,Cs1}; |
| 381 | +expr({'case',Line,E0,Cs0},St) -> |
| 382 | + E1 = expr(E0,St), |
| 383 | + Cs1 = icr_clauses(Cs0,St), |
| 384 | + {'case',Line,E1,Cs1}; |
| 385 | +expr({'receive',Line,Cs0},St) -> |
| 386 | + Cs1 = icr_clauses(Cs0,St), |
| 387 | + {'receive',Line,Cs1}; |
| 388 | +expr({'receive',Line,Cs0,To0,ToEs0},St) -> |
| 389 | + To1 = expr(To0,St), |
| 390 | + ToEs1 = exprs(ToEs0,St), |
| 391 | + Cs1 = icr_clauses(Cs0,St), |
| 392 | + {'receive',Line,Cs1,To1,ToEs1}; |
| 393 | +expr({'try',Line,Es0,Scs0,Ccs0,As0},St) -> |
| 394 | + Es1 = exprs(Es0,St), |
| 395 | + Scs1 = icr_clauses(Scs0,St), |
| 396 | + Ccs1 = icr_clauses(Ccs0,St), |
| 397 | + As1 = exprs(As0,St), |
| 398 | + {'try',Line,Es1,Scs1,Ccs1,As1}; |
| 399 | +expr({'fun',_,{function,_,_,_}}=ExtFun,_St) -> |
| 400 | + ExtFun; |
| 401 | +expr({'fun',Line,Body},St) -> |
| 402 | + case Body of |
| 403 | + {clauses,Cs0} -> |
| 404 | + Cs1 = fun_clauses(Cs0,St), |
| 405 | + {'fun',Line,{clauses,Cs1}}; |
| 406 | + {function,F,A} = Function -> |
| 407 | + {F1,A1} = update_function_name({F,A}), |
| 408 | + if A1 =:= A -> |
| 409 | + {'fun',Line,Function}; |
| 410 | + true -> |
| 411 | + %% Must rewrite local fun-name to a fun that does a |
| 412 | + %% call with the extra THIS parameter. |
| 413 | + As = make_vars(A, Line), |
| 414 | + As1 = As ++ [{var,Line,'THIS'}], |
| 415 | + Call = {call,Line,{atom,Line,F1},As1}, |
| 416 | + Cs = [{clause,Line,As,[],[Call]}], |
| 417 | + {'fun',Line,{clauses,Cs}} |
| 418 | + end; |
| 419 | + {function,_M,_F,_A} = Fun4 -> %This is an error in lint! |
| 420 | + {'fun',Line,Fun4} |
| 421 | + end; |
| 422 | +expr({call,Lc,{atom,_,instance}=Name,As0},St) -> |
| 423 | + %% All local functions 'instance(...)' are static by definition, |
| 424 | + %% so they do not take a 'THIS' argument when called |
| 425 | + As1 = expr_list(As0,St), |
| 426 | + {call,Lc,Name,As1}; |
| 427 | +expr({call,Lc,{atom,_,new}=Name,As0},St) -> |
| 428 | + %% All local functions 'new(...)' are static by definition, |
| 429 | + %% so they do not take a 'THIS' argument when called |
| 430 | + As1 = expr_list(As0,St), |
| 431 | + {call,Lc,Name,As1}; |
| 432 | +expr({call,Lc,{atom,_Lf,F}=Atom,As0}, #pmod{defined=Def}=St) -> |
| 433 | + As1 = expr_list(As0,St), |
| 434 | + case gb_sets:is_member({F,length(As0)}, Def) of |
| 435 | + false -> |
| 436 | + %% BIF or imported function. |
| 437 | + {call,Lc,Atom,As1}; |
| 438 | + true -> |
| 439 | + %% Local function call - needs THIS parameter. |
| 440 | + {call,Lc,Atom,As1 ++ [{var,0,'THIS'}]} |
| 441 | + end; |
| 442 | +expr({call,Line,F0,As0},St) -> |
| 443 | + %% Other function call |
| 444 | + F1 = expr(F0,St), |
| 445 | + As1 = expr_list(As0,St), |
| 446 | + {call,Line,F1,As1}; |
| 447 | +expr({'catch',Line,E0},St) -> |
| 448 | + E1 = expr(E0,St), |
| 449 | + {'catch',Line,E1}; |
| 450 | +expr({match,Line,P,E0},St) -> |
| 451 | + E1 = expr(E0,St), |
| 452 | + {match,Line,P,E1}; |
| 453 | +expr({bin,Line,Fs},St) -> |
| 454 | + Fs2 = pattern_grp(Fs,St), |
| 455 | + {bin,Line,Fs2}; |
| 456 | +expr({op,Line,Op,A0},St) -> |
| 457 | + A1 = expr(A0,St), |
| 458 | + {op,Line,Op,A1}; |
| 459 | +expr({op,Line,Op,L0,R0},St) -> |
| 460 | + L1 = expr(L0,St), |
| 461 | + R1 = expr(R0,St), |
| 462 | + {op,Line,Op,L1,R1}; |
| 463 | +%% The following are not allowed to occur anywhere! |
| 464 | +expr({remote,Line,M0,F0},St) -> |
| 465 | + M1 = expr(M0,St), |
| 466 | + F1 = expr(F0,St), |
| 467 | + {remote,Line,M1,F1}. |
| 468 | + |
| 469 | +expr_list([E0|Es],St) -> |
| 470 | + E1 = expr(E0,St), |
| 471 | + [E1|expr_list(Es,St)]; |
| 472 | +expr_list([],_St) -> []. |
| 473 | + |
| 474 | +record_fields([{record_field,L,K,E0}|T],St) -> |
| 475 | + E = expr(E0,St), |
| 476 | + [{record_field,L,K,E}|record_fields(T,St)]; |
| 477 | +record_fields([],_) -> []. |
| 478 | + |
| 479 | +icr_clauses([C0|Cs],St) -> |
| 480 | + C1 = clause(C0,St), |
| 481 | + [C1|icr_clauses(Cs,St)]; |
| 482 | +icr_clauses([],_St) -> []. |
| 483 | + |
| 484 | +lc_bc_quals([{generate,Line,P,E0}|Qs],St) -> |
| 485 | + E1 = expr(E0,St), |
| 486 | + [{generate,Line,P,E1}|lc_bc_quals(Qs,St)]; |
| 487 | +lc_bc_quals([{b_generate,Line,P,E0}|Qs],St) -> |
| 488 | + E1 = expr(E0,St), |
| 489 | + [{b_generate,Line,P,E1}|lc_bc_quals(Qs,St)]; |
| 490 | +lc_bc_quals([E0|Qs],St) -> |
| 491 | + E1 = expr(E0,St), |
| 492 | + [E1|lc_bc_quals(Qs,St)]; |
| 493 | +lc_bc_quals([],_St) -> []. |
| 494 | + |
| 495 | +fun_clauses([C0|Cs],St) -> |
| 496 | + C1 = clause(C0,St), |
| 497 | + [C1|fun_clauses(Cs,St)]; |
| 498 | +fun_clauses([],_St) -> []. |
| 499 | + |
| 500 | +make_vars(N, L) -> |
| 501 | + make_vars(1, N, L). |
| 502 | + |
| 503 | +make_vars(N, M, L) when N =< M -> |
| 504 | + V = list_to_atom("X"++integer_to_list(N)), |
| 505 | + [{var,L,V} | make_vars(N + 1, M, L)]; |
| 506 | +make_vars(_, _, _) -> |
| 507 | + []. |
| 508 | diff -ruN ../apache-couchdb-1.2.1-orig/src/mochiweb/Makefile.in ./src/mochiweb/Makefile.in |
| 509 | --- ../apache-couchdb-1.2.1-orig/src/mochiweb/Makefile.in 2012-12-20 15:28:49.000000000 -0600 |
| 510 | +++ ./src/mochiweb/Makefile.in 2013-03-16 11:16:07.000000000 -0500 |
| 511 | @@ -109,7 +109,7 @@ |
| 512 | ERL = @ERL@ |
| 513 | ERLANG_FLAGS = @ERLANG_FLAGS@ |
| 514 | ERLC = @ERLC@ |
| 515 | -ERLC_FLAGS = @ERLC_FLAGS@ |
| 516 | +ERLC_FLAGS = @ERLC_FLAGS@ -pa ../etap |
| 517 | EXEEXT = @EXEEXT@ |
| 518 | FGREP = @FGREP@ |
| 519 | FLAGS = @FLAGS@ |
| 520 | diff -ruN ../apache-couchdb-1.2.1-orig/src/mochiweb/mochifmt_records.erl ./src/mochiweb/mochifmt_records.erl |
| 521 | --- ../apache-couchdb-1.2.1-orig/src/mochiweb/mochifmt_records.erl 2012-12-20 15:24:07.000000000 -0600 |
| 522 | +++ ./src/mochiweb/mochifmt_records.erl 2013-03-16 11:13:48.000000000 -0500 |
| 523 | @@ -13,6 +13,8 @@ |
| 524 | -author('bob@mochimedia.com'). |
| 525 | -export([get_value/2]). |
| 526 | |
| 527 | +-compile({parse_transform, pmod_pt}). |
| 528 | + |
| 529 | get_value(Key, Rec) when is_tuple(Rec) and is_atom(element(1, Rec)) -> |
| 530 | try begin |
| 531 | Atom = list_to_existing_atom(Key), |
| 532 | diff -ruN ../apache-couchdb-1.2.1-orig/src/mochiweb/mochifmt_std.erl ./src/mochiweb/mochifmt_std.erl |
| 533 | --- ../apache-couchdb-1.2.1-orig/src/mochiweb/mochifmt_std.erl 2012-12-20 15:24:07.000000000 -0600 |
| 534 | +++ ./src/mochiweb/mochifmt_std.erl 2013-03-16 11:14:31.000000000 -0500 |
| 535 | @@ -7,6 +7,8 @@ |
| 536 | -author('bob@mochimedia.com'). |
| 537 | -export([format/2, get_value/2, format_field/2, get_field/2, convert_field/2]). |
| 538 | |
| 539 | +-compile({parse_transform, pmod_pt}). |
| 540 | + |
| 541 | format(Format, Args) -> |
| 542 | mochifmt:format(Format, Args, THIS). |
| 543 | |
| 544 | diff -ruN ../apache-couchdb-1.2.1-orig/src/mochiweb/mochiweb_request.erl ./src/mochiweb/mochiweb_request.erl |
| 545 | --- ../apache-couchdb-1.2.1-orig/src/mochiweb/mochiweb_request.erl 2012-12-20 15:24:07.000000000 -0600 |
| 546 | +++ ./src/mochiweb/mochiweb_request.erl 2013-03-16 11:15:19.000000000 -0500 |
| 547 | @@ -23,6 +23,8 @@ |
| 548 | -export([accepted_encodings/1]). |
| 549 | -export([accepts_content_type/1]). |
| 550 | |
| 551 | +-compile({parse_transform, pmod_pt}). |
| 552 | + |
| 553 | -define(SAVE_QS, mochiweb_request_qs). |
| 554 | -define(SAVE_PATH, mochiweb_request_path). |
| 555 | -define(SAVE_RECV, mochiweb_request_recv). |
| 556 | diff -ruN ../apache-couchdb-1.2.1-orig/src/mochiweb/mochiweb_response.erl ./src/mochiweb/mochiweb_response.erl |
| 557 | --- ../apache-couchdb-1.2.1-orig/src/mochiweb/mochiweb_response.erl 2012-12-20 15:24:07.000000000 -0600 |
| 558 | +++ ./src/mochiweb/mochiweb_response.erl 2013-03-16 11:15:32.000000000 -0500 |
| 559 | @@ -11,6 +11,8 @@ |
| 560 | -export([get_header_value/1, get/1, dump/0]). |
| 561 | -export([send/1, write_chunk/1]). |
| 562 | |
| 563 | +-compile({parse_transform, pmod_pt}). |
| 564 | + |
| 565 | %% @spec get_header_value(string() | atom() | binary()) -> string() | undefined |
| 566 | %% @doc Get the value of the given response header. |
| 567 | get_header_value(K) -> |