Skip to content

Commit bc0529d

Browse files
committed
precompute SpecificCall patterns
1 parent 479891a commit bc0529d

File tree

1 file changed

+78
-39
lines changed

1 file changed

+78
-39
lines changed

src/ProvidedTypes.fs

Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13797,6 +13797,45 @@ namespace ProviderImplementation.ProvidedTypes
1379713797
| _ ->
1379813798
invalidArg "templateParameter" "The parameter is not a recognized method name"
1379913799

13800+
let (|LessThan|_|) = (|SpecificCall|_|) <@ (<) @>
13801+
let (|GreaterThan|_|) = (|SpecificCall|_|) <@ (>) @>
13802+
let (|LessThanOrEqual|_|) = (|SpecificCall|_|) <@ (<=) @>
13803+
let (|GreaterThanOrEqual|_|) = (|SpecificCall|_|) <@ (>=) @>
13804+
let (|Equals|_|) = (|SpecificCall|_|) <@ (=) @>
13805+
let (|NotEquals|_|) = (|SpecificCall|_|) <@ (<>) @>
13806+
let (|Multiply|_|) = (|SpecificCall|_|) <@ (*) @>
13807+
let (|Addition|_|) = (|SpecificCall|_|) <@ (+) @>
13808+
let (|Subtraction|_|) = (|SpecificCall|_|) <@ (-) @>
13809+
let (|UnaryNegation|_|) = (|SpecificCall|_|) <@ (~-) @>
13810+
let (|Division|_|) = (|SpecificCall|_|) <@ (/) @>
13811+
let (|UnaryPlus|_|) = (|SpecificCall|_|) <@ (~+) @>
13812+
let (|Modulus|_|) = (|SpecificCall|_|) <@ (%) @>
13813+
let (|LeftShift|_|) = (|SpecificCall|_|) <@ (<<<) @>
13814+
let (|RightShift|_|) = (|SpecificCall|_|) <@ (>>>) @>
13815+
let (|And|_|) = (|SpecificCall|_|) <@ (&&&) @>
13816+
let (|Or|_|) = (|SpecificCall|_|) <@ (|||) @>
13817+
let (|Xor|_|) = (|SpecificCall|_|) <@ (^^^) @>
13818+
let (|Not|_|) = (|SpecificCall|_|) <@ (~~~) @>
13819+
let (|CallByte|_|) = (|SpecificCall|_|) <@ byte @>
13820+
let (|CallSByte|_|) = (|SpecificCall|_|) <@ sbyte @>
13821+
let (|CallUInt16|_|) = (|SpecificCall|_|) <@ uint16 @>
13822+
let (|CallInt16|_|) = (|SpecificCall|_|) <@ int16 @>
13823+
let (|CallUInt32|_|) = (|SpecificCall|_|) <@ uint32 @>
13824+
let (|CallInt|_|) = (|SpecificCall|_|) <@ int @>
13825+
let (|CallInt32|_|) = (|SpecificCall|_|) <@ int32 @>
13826+
let (|CallUInt64|_|) = (|SpecificCall|_|) <@ uint64 @>
13827+
let (|CallInt64|_|) = (|SpecificCall|_|) <@ int64 @>
13828+
let (|CallSingle|_|) = (|SpecificCall|_|) <@ single @>
13829+
let (|CallFloat32|_|) = (|SpecificCall|_|) <@ float32 @>
13830+
let (|CallDouble|_|) = (|SpecificCall|_|) <@ double @>
13831+
let (|CallFloat|_|) = (|SpecificCall|_|) <@ float @>
13832+
let (|CallDecimal|_|) = (|SpecificCall|_|) <@ decimal @>
13833+
let (|CallChar|_|) = (|SpecificCall|_|) <@ char @>
13834+
let (|Ignore|_|) = (|SpecificCall|_|) <@ ignore @>
13835+
let (|GetArray|_|) = (|SpecificCall|_|) <@ LanguagePrimitives.IntrinsicFunctions.GetArray @>
13836+
let (|GetArray2D|_|) = (|SpecificCall|_|) <@ LanguagePrimitives.IntrinsicFunctions.GetArray2D @>
13837+
let (|GetArray3D|_|) = (|SpecificCall|_|) <@ LanguagePrimitives.IntrinsicFunctions.GetArray3D @>
13838+
let (|GetArray4D|_|) = (|SpecificCall|_|) <@ LanguagePrimitives.IntrinsicFunctions.GetArray4D @>
1380013839

1380113840
let isEmpty s = (s = ExpectedStackState.Empty)
1380213841
let isAddress s = (s = ExpectedStackState.Address)
@@ -13962,7 +14001,7 @@ namespace ProviderImplementation.ProvidedTypes
1396214001

1396314002
popIfEmptyExpected expectedState
1396414003

13965-
| SpecificCall <@ (<) @>(None, [t1], [a1; a2]) ->
14004+
| LessThan(None, [t1], [a1; a2]) ->
1396614005
emitExpr ExpectedStackState.Value a1
1396714006
emitExpr ExpectedStackState.Value a2
1396814007
match t1 with
@@ -13980,7 +14019,7 @@ namespace ProviderImplementation.ProvidedTypes
1398014019
| _ -> failwithf "Operator (<) not supported for type %s" t1.Name
1398114020

1398214021

13983-
| SpecificCall <@ (>) @>(None, [t1], [a1; a2]) ->
14022+
| GreaterThan(None, [t1], [a1; a2]) ->
1398414023
emitExpr ExpectedStackState.Value a1
1398514024
emitExpr ExpectedStackState.Value a2
1398614025
match t1 with
@@ -13998,7 +14037,7 @@ namespace ProviderImplementation.ProvidedTypes
1399814037
| _ -> failwithf "Operator (>) not supported for type %s" t1.Name
1399914038

1400014039

14001-
| SpecificCall <@ (<=) @>(None, [t1], [a1; a2]) ->
14040+
| LessThanOrEqual(None, [t1], [a1; a2]) ->
1400214041
emitExpr ExpectedStackState.Value a1
1400314042
emitExpr ExpectedStackState.Value a2
1400414043
match t1 with
@@ -14024,7 +14063,7 @@ namespace ProviderImplementation.ProvidedTypes
1402414063
| _ -> failwithf "Operator (<=) not supported for type %s" t1.Name
1402514064

1402614065

14027-
| SpecificCall <@ (>=) @>(None, [t1], [a1; a2]) ->
14066+
| GreaterThanOrEqual(None, [t1], [a1; a2]) ->
1402814067
emitExpr ExpectedStackState.Value a1
1402914068
emitExpr ExpectedStackState.Value a2
1403014069
match t1 with
@@ -14049,7 +14088,7 @@ namespace ProviderImplementation.ProvidedTypes
1404914088
ilg.Emit(I_call(Normalcall, transMeth m, None))
1405014089
| _ -> failwithf "Operator (>=) not supported for type %s" t1.Name
1405114090

14052-
| SpecificCall <@ (=) @>(None, [t1], [a1; a2]) ->
14091+
| Equals(None, [t1], [a1; a2]) ->
1405314092
emitExpr ExpectedStackState.Value a1
1405414093
emitExpr ExpectedStackState.Value a2
1405514094
match t1 with
@@ -14064,7 +14103,7 @@ namespace ProviderImplementation.ProvidedTypes
1406414103
ilg.Emit(I_call(Normalcall, transMeth m, None))
1406514104
| _ -> failwithf "Operator (=) not supported for type %s" t1.Name
1406614105

14067-
| SpecificCall <@ (<>) @>(None, [t1], [a1; a2]) ->
14106+
| NotEquals(None, [t1], [a1; a2]) ->
1406814107
emitExpr ExpectedStackState.Value a1
1406914108
emitExpr ExpectedStackState.Value a2
1407014109
match t1 with
@@ -14084,7 +14123,7 @@ namespace ProviderImplementation.ProvidedTypes
1408414123
ilg.Emit(I_call(Normalcall, transMeth m, None))
1408514124
| _ -> failwithf "Operator (<>) not supported for type %s" t1.Name
1408614125

14087-
| SpecificCall <@ (*) @>(None, [t1; t2; _], [a1; a2]) ->
14126+
| Multiply(None, [t1; t2; _], [a1; a2]) ->
1408814127
emitExpr ExpectedStackState.Value a1
1408914128
emitExpr ExpectedStackState.Value a2
1409014129
match t1 with
@@ -14098,7 +14137,7 @@ namespace ProviderImplementation.ProvidedTypes
1409814137
| _ -> failwithf "Operator (*) not supported for type %s" t1.Name
1409914138
emitConvIfNecessary t1
1410014139

14101-
| SpecificCall <@ (+) @>(None, [t1; t2; _], [a1; a2]) ->
14140+
| Addition(None, [t1; t2; _], [a1; a2]) ->
1410214141
emitExpr ExpectedStackState.Value a1
1410314142
emitExpr ExpectedStackState.Value a2
1410414143
match t1 with
@@ -14115,7 +14154,7 @@ namespace ProviderImplementation.ProvidedTypes
1411514154
| _ -> failwithf "Operator (+) not supported for type %s" t1.Name
1411614155
emitConvIfNecessary t1
1411714156

14118-
| SpecificCall <@ (-) @>(None, [t1; t2; _], [a1; a2]) ->
14157+
| Subtraction(None, [t1; t2; _], [a1; a2]) ->
1411914158
emitExpr ExpectedStackState.Value a1
1412014159
emitExpr ExpectedStackState.Value a2
1412114160
match t1 with
@@ -14129,7 +14168,7 @@ namespace ProviderImplementation.ProvidedTypes
1412914168
| _ -> failwithf "Operator (-) not supported for type %s" t1.Name
1413014169
emitConvIfNecessary t1
1413114170

14132-
| SpecificCall <@ (~-) @>(None, [t1], [a1]) ->
14171+
| UnaryNegation(None, [t1], [a1]) ->
1413314172
emitExpr ExpectedStackState.Value a1
1413414173
match t1 with
1413514174
| SByte
@@ -14140,7 +14179,7 @@ namespace ProviderImplementation.ProvidedTypes
1414014179
ilg.Emit(I_call(Normalcall, transMeth m, None))
1414114180
| _ -> failwithf "Operator (~-) not supported for type %s" t1.Name
1414214181

14143-
| SpecificCall <@ (/) @>(None, [t1; t2; _], [a1; a2]) ->
14182+
| Division(None, [t1; t2; _], [a1; a2]) ->
1414414183
emitExpr ExpectedStackState.Value a1
1414514184
emitExpr ExpectedStackState.Value a2
1414614185
match t1 with
@@ -14154,15 +14193,15 @@ namespace ProviderImplementation.ProvidedTypes
1415414193
| _ -> failwithf "Operator (/) not supported for type %s" t1.Name
1415514194
emitConvIfNecessary t1
1415614195

14157-
| SpecificCall <@ (~+) @>(None, [t1], [a1]) ->
14196+
| UnaryPlus(None, [t1], [a1]) ->
1415814197
match t1.GetMethod("op_UnaryPlus", [|t1|]) with
1415914198
| null ->
1416014199
emitExpr expectedState a1
1416114200
| m ->
1416214201
emitExpr ExpectedStackState.Value a1
1416314202
ilg.Emit(I_call(Normalcall, transMeth m, None))
1416414203

14165-
| SpecificCall <@ (%) @>(None, [t1; t2; _], [a1; a2]) ->
14204+
| Modulus(None, [t1; t2; _], [a1; a2]) ->
1416614205
emitExpr ExpectedStackState.Value a1
1416714206
emitExpr ExpectedStackState.Value a2
1416814207
match t1 with
@@ -14176,7 +14215,7 @@ namespace ProviderImplementation.ProvidedTypes
1417614215
| _ -> failwithf "Operator (%%) not supported for type %s" t1.Name
1417714216
emitConvIfNecessary t1
1417814217

14179-
| SpecificCall <@ (<<<) @>(None, [t1], [a1; a2]) ->
14218+
| LeftShift(None, [t1], [a1; a2]) ->
1418014219
emitExpr ExpectedStackState.Value a1
1418114220
let maskShift (x : int) =
1418214221
match a2 with
@@ -14197,7 +14236,7 @@ namespace ProviderImplementation.ProvidedTypes
1419714236
| _ -> failwithf "Operator (<<<) not supported for type %s" t1.Name
1419814237
emitConvIfNecessary t1
1419914238

14200-
| SpecificCall <@ (>>>) @>(None, [t1], [a1; a2]) ->
14239+
| RightShift(None, [t1], [a1; a2]) ->
1420114240
emitExpr ExpectedStackState.Value a1
1420214241
let maskShift (x : int) =
1420314242
match a2 with
@@ -14218,7 +14257,7 @@ namespace ProviderImplementation.ProvidedTypes
1421814257
| _ -> failwithf "Operator (>>>) not supported for type %s" t1.Name
1421914258
emitConvIfNecessary t1
1422014259

14221-
| SpecificCall <@ (&&&) @>(None, [t1], [a1; a2]) ->
14260+
| And(None, [t1], [a1; a2]) ->
1422214261
emitExpr ExpectedStackState.Value a1
1422314262
emitExpr ExpectedStackState.Value a2
1422414263
match t1 with
@@ -14230,7 +14269,7 @@ namespace ProviderImplementation.ProvidedTypes
1423014269
ilg.Emit(I_call(Normalcall, transMeth m, None))
1423114270
| _ -> failwithf "Operator (&&&) not supported for type %s" t1.Name
1423214271

14233-
| SpecificCall <@ (|||) @>(None, [t1], [a1; a2]) ->
14272+
| Or(None, [t1], [a1; a2]) ->
1423414273
emitExpr ExpectedStackState.Value a1
1423514274
emitExpr ExpectedStackState.Value a2
1423614275
match t1 with
@@ -14242,7 +14281,7 @@ namespace ProviderImplementation.ProvidedTypes
1424214281
ilg.Emit(I_call(Normalcall, transMeth m, None))
1424314282
| _ -> failwithf "Operator (|||) not supported for type %s" t1.Name
1424414283

14245-
| SpecificCall <@ (^^^) @>(None, [t1], [a1; a2]) ->
14284+
| Xor(None, [t1], [a1; a2]) ->
1424614285
emitExpr ExpectedStackState.Value a1
1424714286
emitExpr ExpectedStackState.Value a2
1424814287
match t1 with
@@ -14254,7 +14293,7 @@ namespace ProviderImplementation.ProvidedTypes
1425414293
ilg.Emit(I_call(Normalcall, transMeth m, None))
1425514294
| _ -> failwithf "Operator (^^^) not supported for type %s" t1.Name
1425614295

14257-
| SpecificCall <@ (~~~) @>(None, [t1], [a1]) ->
14296+
| Not(None, [t1], [a1]) ->
1425814297
emitExpr ExpectedStackState.Value a1
1425914298
match t1 with
1426014299
| Int32 | UInt32
@@ -14265,7 +14304,7 @@ namespace ProviderImplementation.ProvidedTypes
1426514304
ilg.Emit(I_call(Normalcall, transMeth m, None))
1426614305
| _ -> failwithf "Operator (~~~) not supported for type %s" t1.Name
1426714306

14268-
| SpecificCall <@ byte @>(None, [t1], [a1]) ->
14307+
| CallByte(None, [t1], [a1]) ->
1426914308
emitExpr ExpectedStackState.Value a1
1427014309
match t1 with
1427114310
| Char
@@ -14282,7 +14321,7 @@ namespace ProviderImplementation.ProvidedTypes
1428214321
ilg.Emit(I_call(Normalcall, transMeth m, None))
1428314322
| _ -> failwithf "Operator 'byte' not supported for type %s" t1.Name
1428414323

14285-
| SpecificCall <@ sbyte @>(None, [t1], [a1]) ->
14324+
| CallSByte(None, [t1], [a1]) ->
1428614325
emitExpr ExpectedStackState.Value a1
1428714326
match t1 with
1428814327
| Char
@@ -14299,7 +14338,7 @@ namespace ProviderImplementation.ProvidedTypes
1429914338
ilg.Emit(I_call(Normalcall, transMeth m, None))
1430014339
| _ -> failwithf "Operator 'sbyte' not supported for type %s" t1.Name
1430114340

14302-
| SpecificCall <@ uint16 @>(None, [t1], [a1]) ->
14341+
| CallUInt16(None, [t1], [a1]) ->
1430314342
emitExpr ExpectedStackState.Value a1
1430414343
match t1 with
1430514344
| Char
@@ -14316,7 +14355,7 @@ namespace ProviderImplementation.ProvidedTypes
1431614355
ilg.Emit(I_call(Normalcall, transMeth m, None))
1431714356
| _ -> failwithf "Operator 'uint16' not supported for type %s" t1.Name
1431814357

14319-
| SpecificCall <@ int16 @>(None, [t1], [a1]) ->
14358+
| CallInt16(None, [t1], [a1]) ->
1432014359
emitExpr ExpectedStackState.Value a1
1432114360
match t1 with
1432214361
| Char
@@ -14333,7 +14372,7 @@ namespace ProviderImplementation.ProvidedTypes
1433314372
ilg.Emit(I_call(Normalcall, transMeth m, None))
1433414373
| _ -> failwithf "Operator 'int16' not supported for type %s" t1.Name
1433514374

14336-
| SpecificCall <@ uint32 @>(None, [t1], [a1]) ->
14375+
| CallUInt32(None, [t1], [a1]) ->
1433714376
emitExpr ExpectedStackState.Value a1
1433814377
match t1 with
1433914378
| Char
@@ -14349,8 +14388,8 @@ namespace ProviderImplementation.ProvidedTypes
1434914388
ilg.Emit(I_call(Normalcall, transMeth m, None))
1435014389
| _ -> failwithf "Operator 'uint32' not supported for type %s" t1.Name
1435114390

14352-
| SpecificCall <@ int @>(None, [t1], [a1])
14353-
| SpecificCall <@ int32 @>(None, [t1], [a1]) ->
14391+
| CallInt(None, [t1], [a1])
14392+
| CallInt32(None, [t1], [a1]) ->
1435414393
emitExpr ExpectedStackState.Value a1
1435514394
match t1 with
1435614395
| Char
@@ -14366,7 +14405,7 @@ namespace ProviderImplementation.ProvidedTypes
1436614405
ilg.Emit(I_call(Normalcall, transMeth m, None))
1436714406
| _ -> failwithf "Operator 'int32' not supported for type %s" t1.Name
1436814407

14369-
| SpecificCall <@ uint64 @>(None, [t1], [a1]) ->
14408+
| CallUInt64(None, [t1], [a1]) ->
1437014409
emitExpr ExpectedStackState.Value a1
1437114410
match t1 with
1437214411
| Char
@@ -14382,7 +14421,7 @@ namespace ProviderImplementation.ProvidedTypes
1438214421
ilg.Emit(I_call(Normalcall, transMeth m, None))
1438314422
| _ -> failwithf "Operator 'uint64' not supported for type %s" t1.Name
1438414423

14385-
| SpecificCall <@ int64 @>(None, [t1], [a1]) ->
14424+
| CallInt64(None, [t1], [a1]) ->
1438614425
emitExpr ExpectedStackState.Value a1
1438714426
match t1 with
1438814427
| Double | Single
@@ -14398,8 +14437,8 @@ namespace ProviderImplementation.ProvidedTypes
1439814437
ilg.Emit(I_call(Normalcall, transMeth m, None))
1439914438
| _ -> failwithf "Operator 'int64' not supported for type %s" t1.Name
1440014439

14401-
| SpecificCall <@ single @>(None, [t1], [a1])
14402-
| SpecificCall <@ float32 @>(None, [t1], [a1]) ->
14440+
| CallSingle(None, [t1], [a1])
14441+
| CallFloat32(None, [t1], [a1]) ->
1440314442
emitExpr ExpectedStackState.Value a1
1440414443
match t1 with
1440514444
| Double | Single
@@ -14416,8 +14455,8 @@ namespace ProviderImplementation.ProvidedTypes
1441614455
ilg.Emit(I_call(Normalcall, transMeth m, None))
1441714456
| _ -> failwithf "Operator 'float32' not supported for type %s" t1.Name
1441814457

14419-
| SpecificCall <@ double @>(None, [t1], [a1])
14420-
| SpecificCall <@ float @>(None, [t1], [a1]) ->
14458+
| CallDouble(None, [t1], [a1])
14459+
| CallFloat(None, [t1], [a1]) ->
1442114460
emitExpr ExpectedStackState.Value a1
1442214461
match t1 with
1442314462
| Double | Single
@@ -14434,7 +14473,7 @@ namespace ProviderImplementation.ProvidedTypes
1443414473
ilg.Emit(I_call(Normalcall, transMeth m, None))
1443514474
| _ -> failwithf "Operator 'float' not supported for type %s" t1.Name
1443614475

14437-
| SpecificCall <@ decimal @>(None, [t1], [a1]) ->
14476+
| CallDecimal(None, [t1], [a1]) ->
1443814477
emitExpr ExpectedStackState.Value a1
1443914478
let rtTgt = decimalTypeTgt
1444014479
if t1 = stringTypeTgt then
@@ -14457,7 +14496,7 @@ namespace ProviderImplementation.ProvidedTypes
1445714496
ilg.Emit(I_call(Normalcall, transMeth m, None))
1445814497
| toDecimal -> ilg.Emit(I_call(Normalcall, transMeth toDecimal, None))
1445914498

14460-
| SpecificCall <@ char @>(None, [t1], [a1]) ->
14499+
| CallChar(None, [t1], [a1]) ->
1446114500
emitExpr ExpectedStackState.Value a1
1446214501
match t1 with
1446314502
| Double | Single
@@ -14472,9 +14511,9 @@ namespace ProviderImplementation.ProvidedTypes
1447214511
ilg.Emit(I_call(Normalcall, transMeth m, None))
1447314512
| _ -> failwithf "Operator 'char' not supported for type %s" t1.Name
1447414513

14475-
| SpecificCall <@ ignore @>(None, [t1], [a1]) -> emitExpr expectedState a1
14514+
| Ignore(None, [t1], [a1]) -> emitExpr expectedState a1
1447614515

14477-
| SpecificCall <@ LanguagePrimitives.IntrinsicFunctions.GetArray @> (None, [ty], [arr; index]) ->
14516+
| GetArray(None, [ty], [arr; index]) ->
1447814517
// observable side-effect - IndexOutOfRangeException
1447914518
emitExpr ExpectedStackState.Value arr
1448014519
emitExpr ExpectedStackState.Value index
@@ -14485,9 +14524,9 @@ namespace ProviderImplementation.ProvidedTypes
1448514524

1448614525
popIfEmptyExpected expectedState
1448714526

14488-
| SpecificCall <@ LanguagePrimitives.IntrinsicFunctions.GetArray2D @> (None, _ty, arr::indices)
14489-
| SpecificCall <@ LanguagePrimitives.IntrinsicFunctions.GetArray3D @> (None, _ty, arr::indices)
14490-
| SpecificCall <@ LanguagePrimitives.IntrinsicFunctions.GetArray4D @> (None, _ty, arr::indices) ->
14527+
| GetArray2D(None, _ty, arr::indices)
14528+
| GetArray3D(None, _ty, arr::indices)
14529+
| GetArray4D(None, _ty, arr::indices) ->
1449114530

1449214531
let meth =
1449314532
let name = if isAddress expectedState then "Address" else "Get"

0 commit comments

Comments
 (0)