Skip to content

Commit d5f5bd0

Browse files
authored
more cleanup - spacing for commas and colons (#6343)
* spacing for commas and colons * code review
1 parent 91bdb8a commit d5f5bd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4603
-4503
lines changed

src/absil/il.fs

Lines changed: 75 additions & 75 deletions
Large diffs are not rendered by default.

src/absil/illib.fs

Lines changed: 136 additions & 133 deletions
Large diffs are not rendered by default.

src/absil/ilprint.fs

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,29 @@ type ppenv =
3333
{ ilGlobals: ILGlobals
3434
ppenvClassFormals: int
3535
ppenvMethodFormals: int }
36+
3637
let ppenv_enter_method mgparams env =
3738
{env with ppenvMethodFormals=mgparams}
39+
3840
let ppenv_enter_tdef gparams env =
3941
{env with ppenvClassFormals=List.length gparams; ppenvMethodFormals=0}
42+
4043
let mk_ppenv ilg = { ilGlobals = ilg; ppenvClassFormals = 0; ppenvMethodFormals = 0 }
44+
4145
let debug_ppenv = mk_ppenv
46+
4247
let ppenv_enter_modul env = { env with ppenvClassFormals=0; ppenvMethodFormals=0 }
4348

4449
// --------------------------------------------------------------------
4550
// Pretty printing - output streams
4651
// --------------------------------------------------------------------
4752

4853
let output_string (os: TextWriter) (s:string) = os.Write s
54+
4955
let output_char (os: TextWriter) (c:char) = os.Write c
56+
5057
let output_int os (i:int) = output_string os (string i)
58+
5159
let output_hex_digit os i =
5260
assert (i >= 0 && i < 16)
5361
if i > 9 then output_char os (char (int32 'A' + (i-10)))
@@ -106,14 +114,17 @@ let output_array sep f os (a:_ []) =
106114
f os (a.[a.Length - 1])
107115

108116
let output_parens f os a = output_string os "("; f os a; output_string os ")"
117+
109118
let output_angled f os a = output_string os "<"; f os a; output_string os ">"
119+
110120
let output_bracks f os a = output_string os "["; f os a; output_string os "]"
111121

112122
let output_id os n = output_sqstring os n
113123

114124
let output_label os n = output_string os n
115125

116126
let output_lid os lid = output_seq "." output_string os lid
127+
117128
let string_of_type_name (_,n) = n
118129

119130
let output_byte os i =
@@ -127,17 +138,27 @@ let output_bytes os (bytes:byte[]) =
127138

128139

129140
let bits_of_float32 (x:float32) = System.BitConverter.ToInt32(System.BitConverter.GetBytes(x),0)
141+
130142
let bits_of_float (x:float) = System.BitConverter.DoubleToInt64Bits(x)
131143

132144
let output_u8 os (x:byte) = output_string os (string (int x))
145+
133146
let output_i8 os (x:sbyte) = output_string os (string (int x))
147+
134148
let output_u16 os (x:uint16) = output_string os (string (int x))
149+
135150
let output_i16 os (x:int16) = output_string os (string (int x))
151+
136152
let output_u32 os (x:uint32) = output_string os (string (int64 x))
153+
137154
let output_i32 os (x:int32) = output_string os (string x)
155+
138156
let output_u64 os (x:uint64) = output_string os (string (int64 x))
157+
139158
let output_i64 os (x:int64) = output_string os (string x)
159+
140160
let output_ieee32 os (x:float32) = output_string os "float32 ("; output_string os (string (bits_of_float32 x)); output_string os ")"
161+
141162
let output_ieee64 os (x:float) = output_string os "float64 ("; output_string os (string (bits_of_float x)); output_string os ")"
142163

143164
let rec goutput_scoref _env os = function
@@ -155,45 +176,45 @@ and goutput_tref env os (x:ILTypeRef) =
155176

156177
and goutput_typ env os ty =
157178
match ty with
158-
| ILType.Boxed tr -> goutput_tspec env os tr
159-
| ILType.TypeVar tv ->
179+
| ILType.Boxed tr -> goutput_tspec env os tr
180+
| ILType.TypeVar tv ->
160181
// Special rule to print method type variables in Generic EE preferred form
161182
// when an environment is available to help us do this.
162183
let cgparams = env.ppenvClassFormals
163184
let mgparams = env.ppenvMethodFormals
164185
if int tv < cgparams then
165186
output_string os "!"
166187
output_tyvar os tv
167-
elif int tv - cgparams < mgparams then
188+
elif int tv - cgparams < mgparams then
168189
output_string os "!!"
169-
output_int os (int tv - cgparams)
190+
output_int os (int tv - cgparams)
170191
else
171192
output_string os "!"
172193
output_tyvar os tv
173194
output_int os (int tv)
174195

175196
| ILType.Byref typ -> goutput_typ env os typ; output_string os "&"
176-
| ILType.Ptr typ -> goutput_typ env os typ; output_string os "*"
177-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_SByte.TypeSpec.Name -> output_string os "int8"
178-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int16.TypeSpec.Name -> output_string os "int16"
179-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int32.TypeSpec.Name -> output_string os "int32"
180-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int64.TypeSpec.Name -> output_string os "int64"
181-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_IntPtr.TypeSpec.Name -> output_string os "native int"
182-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Byte.TypeSpec.Name -> output_string os "unsigned int8"
183-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt16.TypeSpec.Name -> output_string os "unsigned int16"
184-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt32.TypeSpec.Name -> output_string os "unsigned int32"
185-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt64.TypeSpec.Name -> output_string os "unsigned int64"
186-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UIntPtr.TypeSpec.Name -> output_string os "native unsigned int"
187-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Double.TypeSpec.Name -> output_string os "float64"
188-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Single.TypeSpec.Name -> output_string os "float32"
189-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Bool.TypeSpec.Name -> output_string os "bool"
190-
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Char.TypeSpec.Name -> output_string os "char"
197+
| ILType.Ptr typ -> goutput_typ env os typ; output_string os "*"
198+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_SByte.TypeSpec.Name -> output_string os "int8"
199+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int16.TypeSpec.Name -> output_string os "int16"
200+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int32.TypeSpec.Name -> output_string os "int32"
201+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int64.TypeSpec.Name -> output_string os "int64"
202+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_IntPtr.TypeSpec.Name -> output_string os "native int"
203+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Byte.TypeSpec.Name -> output_string os "unsigned int8"
204+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt16.TypeSpec.Name -> output_string os "unsigned int16"
205+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt32.TypeSpec.Name -> output_string os "unsigned int32"
206+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt64.TypeSpec.Name -> output_string os "unsigned int64"
207+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UIntPtr.TypeSpec.Name -> output_string os "native unsigned int"
208+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Double.TypeSpec.Name -> output_string os "float64"
209+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Single.TypeSpec.Name -> output_string os "float32"
210+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Bool.TypeSpec.Name -> output_string os "bool"
211+
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Char.TypeSpec.Name -> output_string os "char"
191212
| ILType.Value tspec ->
192213
output_string os "value class "
193214
goutput_tref env os tspec.TypeRef
194215
output_string os " "
195216
goutput_gactuals env os tspec.GenericArgs
196-
| ILType.Void -> output_string os "void"
217+
| ILType.Void -> output_string os "void"
197218
| ILType.Array (bounds,ty) ->
198219
goutput_typ env os ty
199220
output_string os "["
@@ -253,30 +274,28 @@ and output_arr_bounds os = function
253274
l
254275

255276
and goutput_permission _env os p =
256-
let output_security_action os x =
277+
let output_security_action os x =
257278
output_string os
258279
(match x with
259-
| ILSecurityAction.Request -> "request"
260-
| ILSecurityAction.Demand -> "demand"
261-
| ILSecurityAction.Assert-> "assert"
262-
| ILSecurityAction.Deny-> "deny"
263-
| ILSecurityAction.PermitOnly-> "permitonly"
264-
| ILSecurityAction.LinkCheck-> "linkcheck"
265-
| ILSecurityAction.InheritCheck-> "inheritcheck"
266-
| ILSecurityAction.ReqMin-> "reqmin"
267-
| ILSecurityAction.ReqOpt-> "reqopt"
268-
| ILSecurityAction.ReqRefuse-> "reqrefuse"
269-
| ILSecurityAction.PreJitGrant-> "prejitgrant"
270-
| ILSecurityAction.PreJitDeny-> "prejitdeny"
271-
| ILSecurityAction.NonCasDemand-> "noncasdemand"
272-
| ILSecurityAction.NonCasLinkDemand-> "noncaslinkdemand"
273-
| ILSecurityAction.NonCasInheritance-> "noncasinheritance"
280+
| ILSecurityAction.Request -> "request"
281+
| ILSecurityAction.Demand -> "demand"
282+
| ILSecurityAction.Assert-> "assert"
283+
| ILSecurityAction.Deny-> "deny"
284+
| ILSecurityAction.PermitOnly-> "permitonly"
285+
| ILSecurityAction.LinkCheck-> "linkcheck"
286+
| ILSecurityAction.InheritCheck-> "inheritcheck"
287+
| ILSecurityAction.ReqMin-> "reqmin"
288+
| ILSecurityAction.ReqOpt-> "reqopt"
289+
| ILSecurityAction.ReqRefuse-> "reqrefuse"
290+
| ILSecurityAction.PreJitGrant-> "prejitgrant"
291+
| ILSecurityAction.PreJitDeny-> "prejitdeny"
292+
| ILSecurityAction.NonCasDemand-> "noncasdemand"
293+
| ILSecurityAction.NonCasLinkDemand-> "noncaslinkdemand"
294+
| ILSecurityAction.NonCasInheritance-> "noncasinheritance"
274295
| ILSecurityAction.LinkDemandChoice -> "linkdemandchoice"
275296
| ILSecurityAction.InheritanceDemandChoice -> "inheritancedemandchoice"
276297
| ILSecurityAction.DemandChoice -> "demandchoice")
277298

278-
279-
280299
match p with
281300
| ILSecurityDecl (sa,b) ->
282301
output_string os " .permissionset "
@@ -459,10 +478,10 @@ let goutput_cuspec env os (IlxUnionSpec(IlxUnionRef(_,tref,_,_,_),i)) =
459478
let output_basic_type os x =
460479
output_string os
461480
(match x with
462-
| DT_I1 -> "i1"
463-
| DT_U1 -> "u1"
464-
| DT_I2 -> "i2"
465-
| DT_U2 -> "u2"
481+
| DT_I1 -> "i1"
482+
| DT_U1 -> "u1"
483+
| DT_I2 -> "i2"
484+
| DT_U2 -> "u2"
466485
| DT_I4 -> "i4"
467486
| DT_U4 -> "u4"
468487
| DT_I8 -> "i8"
@@ -505,7 +524,6 @@ let goutput_fdef _tref env os (fd: ILFieldDef) =
505524
output_string os "\n"
506525
goutput_custom_attrs env os fd.CustomAttrs
507526

508-
509527
let output_alignment os = function
510528
Aligned -> ()
511529
| Unaligned1 -> output_string os "unaligned. 1 "
@@ -528,18 +546,19 @@ let rec goutput_apps env os = function
528546
output_angled (goutput_gparam env) os (mkILSimpleTypar "T")
529547
output_string os " "
530548
goutput_apps env os cs
531-
| Apps_app(ty,cs) ->
549+
| Apps_app(ty,cs) ->
532550
output_parens (goutput_typ env) os ty
533551
output_string os " "
534552
goutput_apps env os cs
535-
| Apps_done ty ->
553+
| Apps_done ty ->
536554
output_string os "--> "
537555
goutput_typ env os ty
538556

539557
/// Print the short form of instructions
540558
let output_short_u16 os (x:uint16) =
541559
if int x < 256 then (output_string os ".s "; output_u16 os x)
542560
else output_string os " "; output_u16 os x
561+
543562
let output_short_i32 os i32 =
544563
if i32 < 256 && 0 >= i32 then (output_string os ".s "; output_i32 os i32)
545564
else output_string os " "; output_i32 os i32
@@ -553,7 +572,7 @@ let goutput_local env os (l: ILLocal) =
553572

554573
let goutput_param env os (l: ILParameter) =
555574
match l.Name with
556-
None -> goutput_typ env os l.Type
575+
None -> goutput_typ env os l.Type
557576
| Some n -> goutput_typ env os l.Type; output_string os " "; output_sqstring os n
558577

559578
let goutput_params env os ps =
@@ -624,7 +643,7 @@ let rec goutput_instr env os inst =
624643
output_string os "ldc."; output_basic_type os dt; output_string os " "; output_ieee32 os x
625644
| (AI_ldc (dt, ILConst.R8 x)) ->
626645
output_string os "ldc."; output_basic_type os dt; output_string os " "; output_ieee64 os x
627-
| I_ldftn mspec -> output_string os "ldftn "; goutput_mspec env os mspec
646+
| I_ldftn mspec -> output_string os "ldftn "; goutput_mspec env os mspec
628647
| I_ldvirtftn mspec -> output_string os "ldvirtftn "; goutput_mspec env os mspec
629648
| I_ldind (al,vol,dt) ->
630649
output_alignment os al
@@ -779,7 +798,6 @@ let goutput_ilmbody env os (il: ILMethodBody) =
779798
output_seq ",\n " (goutput_local env) os il.Locals
780799
output_string os ")\n"
781800

782-
783801
let goutput_mbody is_entrypoint env os (md: ILMethodDef) =
784802
if md.ImplAttributes &&& MethodImplAttributes.Native <> enum 0 then output_string os "native "
785803
elif md.ImplAttributes &&& MethodImplAttributes.IL <> enum 0 then output_string os "cil "
@@ -892,14 +910,15 @@ let output_type_layout_info os info =
892910

893911
let splitTypeLayout = function
894912
| ILTypeDefLayout.Auto -> "auto",(fun _os () -> ())
895-
| ILTypeDefLayout.Sequential info -> "sequential", (fun os () -> output_type_layout_info os info)
896-
| ILTypeDefLayout.Explicit info -> "explicit", (fun os () -> output_type_layout_info os info)
897-
913+
| ILTypeDefLayout.Sequential info -> "sequential", (fun os () -> output_type_layout_info os info)
914+
| ILTypeDefLayout.Explicit info -> "explicit", (fun os () -> output_type_layout_info os info)
898915

899916
let goutput_fdefs tref env os (fdefs: ILFieldDefs) =
900917
List.iter (fun f -> (goutput_fdef tref env) os f; output_string os "\n" ) fdefs.AsList
918+
901919
let goutput_mdefs env os (mdefs: ILMethodDefs) =
902920
Array.iter (fun f -> (goutput_mdef env) os f; output_string os "\n" ) mdefs.AsArray
921+
903922
let goutput_pdefs env os (pdefs: ILPropertyDefs) =
904923
List.iter (fun f -> (goutput_pdef env) os f; output_string os "\n" ) pdefs.AsList
905924

@@ -954,7 +973,7 @@ and goutput_lambdas env os lambdas =
954973
output_angled (goutput_gparam env) os gf
955974
output_string os " "
956975
(goutput_lambdas env) os l
957-
| Lambdas_lambda (ps,l) ->
976+
| Lambdas_lambda (ps,l) ->
958977
output_parens (goutput_param env) os ps
959978
output_string os " "
960979
(goutput_lambdas env) os l
@@ -1046,7 +1065,7 @@ let output_module_fragment_aux _refs os (ilg: ILGlobals) modul =
10461065
let env = ppenv_enter_modul env
10471066
goutput_tdefs false ([]) env os modul.TypeDefs
10481067
goutput_tdefs true ([]) env os modul.TypeDefs
1049-
with e ->
1068+
with e ->
10501069
output_string os "*** Error during printing : "; output_string os (e.ToString()); os.Flush()
10511070
reraise()
10521071

@@ -1078,7 +1097,7 @@ let output_module os (ilg: ILGlobals) modul =
10781097
output_module_refs os refs
10791098
goutput_module_manifest env os modul
10801099
output_module_fragment_aux refs os ilg modul
1081-
with e ->
1100+
with e ->
10821101
output_string os "*** Error during printing : "; output_string os (e.ToString()); os.Flush()
10831102
raise e
10841103

0 commit comments

Comments
 (0)