Skip to content

Commit 7e5dbbe

Browse files
committed
Added decimal support
1 parent 1a0c731 commit 7e5dbbe

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

fcs/fcs-fable/test/bench.fs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let printErrors showWarnings (errors: FSharpErrorInfo[]) =
2222
errors |> Array.iter printError
2323
failwith "Too many errors."
2424

25-
let parseFiles projectPath outDir optimized =
25+
let parseFiles projectPath outDir optimize =
2626
// parse project
2727
let projSet = makeHashSetIgnoreCase ()
2828
let (projectFileName, dllRefs, fileNames, sources, otherOptions) = parseProject projSet projectPath
@@ -33,6 +33,8 @@ let parseFiles projectPath outDir optimized =
3333

3434
// create checker
3535
let readAllBytes dllName = readAllBytes (metadataPath + dllName)
36+
let optimizeFlag = "--optimize" + (if optimize then "+" else "-")
37+
let otherOptions = otherOptions |> Array.append [| optimizeFlag |]
3638
let createChecker () = InteractiveChecker.Create(references, readAllBytes, otherOptions)
3739
let ms0, checker = measureTime createChecker ()
3840
printfn "--------------------------------------------"
@@ -77,7 +79,7 @@ let parseFiles projectPath outDir optimized =
7779
let fileNames = fileNames |> Array.filter (fun x -> not (x.EndsWith(".fsi")))
7880

7981
// this is memory intensive, only do it once
80-
let implFiles = if optimized
82+
let implFiles = if optimize
8183
then projectResults.GetOptimizedAssemblyContents().ImplementationFiles
8284
else projectResults.AssemblyContents.ImplementationFiles
8385

@@ -95,8 +97,8 @@ let parseArguments (argv: string[]) =
9597
match args with
9698
| [| projectPath |] ->
9799
let outDir = "./out-test"
98-
let optimized = opts |> Array.contains "--optimize-fcs"
99-
parseFiles projectPath outDir optimized
100+
let optimize = opts |> Array.contains "--optimize-fcs"
101+
parseFiles projectPath outDir optimize
100102
| _ -> printfn "%s" usage
101103

102104
[<EntryPoint>]

src/fsharp/TastOps.fs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6495,10 +6495,6 @@ let mkCallNewDecimal (g:TcGlobals) m (e1, e2, e3, e4, e5) = mkApps g (t
64956495

64966496
let mkCallNewFormat (g:TcGlobals) m aty bty cty dty ety e1 = mkApps g (typedExprForIntrinsic g m g.new_format_info, [[aty;bty;cty;dty;ety]], [ e1 ], m)
64976497

6498-
#if FABLE_COMPILER
6499-
let TryEliminateDesugaredConstants (_g:TcGlobals) (_m:range) (_c:Const) : Expr option =
6500-
None
6501-
#else
65026498
let TryEliminateDesugaredConstants g m c =
65036499
match c with
65046500
| Const.Decimal d ->
@@ -6510,7 +6506,6 @@ let TryEliminateDesugaredConstants g m c =
65106506
| _ -> failwith "unreachable"
65116507
| _ ->
65126508
None
6513-
#endif
65146509

65156510
let mkSeqTy (g:TcGlobals) ty = mkAppTy g.seq_tcr [ty]
65166511
let mkIEnumeratorTy (g:TcGlobals) ty = mkAppTy g.tcref_System_Collections_Generic_IEnumerator [ty]

src/fsharp/lex.fsl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,7 @@ rule token args skip = parse
360360
{ try
361361
let s = removeUnderscores (lexemeTrimRight lexbuf 1)
362362
// This implements a range check for decimal literals
363-
#if FABLE_COMPILER
364-
let d = Convert.ToDecimal(s)
365-
#else
366363
let d = System.Decimal.Parse(s,System.Globalization.NumberStyles.AllowExponent ||| System.Globalization.NumberStyles.Number,System.Globalization.CultureInfo.InvariantCulture)
367-
#endif
368364
DECIMAL d
369365
with
370366
e -> fail args lexbuf (FSComp.SR.lexOusideDecimal()) (DECIMAL (decimal 0))

0 commit comments

Comments
 (0)