@@ -443,8 +443,8 @@ let var_constrain_check_stmts dconstrain loc adlevel decl_id decl_var trans
443443 @ check_decl decl_var st trans loc adlevel
444444 | _ -> []
445445
446- let create_decl_with_assign decl_id declc decl_type initial_value transform
447- smeta =
446+ let create_decl_with_assign decl_id declc decl_type initial_value
447+ decl_annotations transform smeta =
448448 let rhs = Option. map ~f: trans_expr initial_value in
449449 let decl_adtype =
450450 UnsizedType. fill_adtype_for_type declc.dadlevel (Type. to_unsized decl_type)
@@ -458,7 +458,9 @@ let create_decl_with_assign decl_id declc decl_type initial_value transform
458458 () } in
459459 let decl =
460460 Stmt.
461- { Fixed. pattern= Decl {decl_adtype; decl_id; decl_type; initialize= true }
461+ { Fixed. pattern=
462+ Decl
463+ {decl_adtype; decl_id; decl_type; decl_annotations; initialize= true }
462464 ; meta= smeta } in
463465 let rhs_assignment =
464466 Option. map
@@ -583,6 +585,7 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) =
583585 { decl_adtype= Expr.Typed. adlevel_of iteratee'
584586 ; decl_id= loopvar.name
585587 ; decl_type= Unsized decl_type
588+ ; decl_annotations= []
586589 ; initialize= true } } in
587590 let assignment var =
588591 Stmt.Fixed.
@@ -598,15 +601,16 @@ let rec trans_stmt ud_dists (declc : decl_context) (ts : Ast.typed_statement) =
598601 Common.ICE. internal_compiler_error
599602 [% message
600603 " Found function definition statement outside of function block" ]
601- | Ast. VarDecl {decl_type; transformation; variables; is_global = _ } ->
604+ | Ast. VarDecl {decl_type; transformation; variables; annotations; is_global= _}
605+ ->
602606 List. concat_map
603607 ~f: (fun {identifier; initial_value} ->
604608 let transform = Transformation. map trans_expr transformation in
605609 let decl_id = identifier.Ast. name in
606610 let size_checks, dt = check_sizedtype decl_id decl_type in
607611 size_checks
608- @ create_decl_with_assign decl_id declc dt initial_value transform
609- smeta)
612+ @ create_decl_with_assign decl_id declc dt initial_value annotations
613+ transform smeta)
610614 variables
611615 | Ast. Block stmts -> Block (List. concat_map ~f: trans_stmt stmts) |> swrap
612616 | Ast. Profile (name , stmts ) ->
@@ -629,6 +633,7 @@ and trans_packed_assign loc trans_stmt lvals rhs assign_op =
629633 { decl_adtype= rhs.emeta.ad_level
630634 ; decl_id= sym
631635 ; decl_type= Unsized rhs_type
636+ ; decl_annotations= []
632637 ; initialize= false }
633638 ; meta= rhs.emeta.loc } in
634639 let assign =
@@ -696,12 +701,13 @@ and trans_single_assignment smeta assign_lhs assign_rhs assign_op =
696701
697702let trans_fun_def ud_dists (ts : Ast.typed_statement ) =
698703 match ts.stmt with
699- | Ast. FunDef {returntype; funname; arguments; body} ->
704+ | Ast. FunDef {returntype; funname; arguments; annotations; body} ->
700705 [ Program.
701706 { fdrt= returntype
702707 ; fdname= funname.name
703708 ; fdsuffix= Fun_kind. (suffix_from_name funname.name |> without_propto)
704709 ; fdargs= List. map ~f: trans_arg arguments
710+ ; fdannotations= annotations
705711 ; fdbody=
706712 trans_stmt ud_dists
707713 {transform_action= IgnoreTransform ; dadlevel= AutoDiffable }
@@ -743,6 +749,7 @@ let rec trans_sizedtype_decl declc tr name st =
743749 { decl_type= Sized SInt
744750 ; decl_id
745751 ; decl_adtype= DataOnly
752+ ; decl_annotations= []
746753 ; initialize= true }
747754 ; meta= e.meta.loc } in
748755 let assign =
@@ -821,7 +828,12 @@ let trans_block ud_dists declc block prog =
821828 let f stmt (accum1 , accum2 , accum3 ) =
822829 match stmt with
823830 | { Ast. stmt=
824- VarDecl {decl_type= type_; variables; transformation; is_global= true }
831+ VarDecl
832+ { decl_type= type_
833+ ; variables
834+ ; transformation
835+ ; annotations
836+ ; is_global= true }
825837 ; smeta } ->
826838 let outvars, sizes, stmts =
827839 List. unzip3
@@ -839,10 +851,11 @@ let trans_block ud_dists declc block prog =
839851 { out_constrained_st= type_
840852 ; out_unconstrained_st= param_size transform type_
841853 ; out_block= block
854+ ; out_annotations= annotations
842855 ; out_trans= transform } ) in
843856 let stmts =
844857 create_decl_with_assign decl_id declc (Sized type_)
845- initial_value transform smeta.loc in
858+ initial_value annotations transform smeta.loc in
846859 (outvar, size, stmts))
847860 variables in
848861 ( outvars @ accum1
0 commit comments