Skip to content

Commit

Permalink
Added decimal support
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Mar 13, 2019
1 parent 1a0c731 commit 7e5dbbe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
10 changes: 6 additions & 4 deletions fcs/fcs-fable/test/bench.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let printErrors showWarnings (errors: FSharpErrorInfo[]) =
errors |> Array.iter printError
failwith "Too many errors."

let parseFiles projectPath outDir optimized =
let parseFiles projectPath outDir optimize =
// parse project
let projSet = makeHashSetIgnoreCase ()
let (projectFileName, dllRefs, fileNames, sources, otherOptions) = parseProject projSet projectPath
Expand All @@ -33,6 +33,8 @@ let parseFiles projectPath outDir optimized =

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

// this is memory intensive, only do it once
let implFiles = if optimized
let implFiles = if optimize
then projectResults.GetOptimizedAssemblyContents().ImplementationFiles
else projectResults.AssemblyContents.ImplementationFiles

Expand All @@ -95,8 +97,8 @@ let parseArguments (argv: string[]) =
match args with
| [| projectPath |] ->
let outDir = "./out-test"
let optimized = opts |> Array.contains "--optimize-fcs"
parseFiles projectPath outDir optimized
let optimize = opts |> Array.contains "--optimize-fcs"
parseFiles projectPath outDir optimize
| _ -> printfn "%s" usage

[<EntryPoint>]
Expand Down
5 changes: 0 additions & 5 deletions src/fsharp/TastOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6495,10 +6495,6 @@ let mkCallNewDecimal (g:TcGlobals) m (e1, e2, e3, e4, e5) = mkApps g (t

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)

#if FABLE_COMPILER
let TryEliminateDesugaredConstants (_g:TcGlobals) (_m:range) (_c:Const) : Expr option =
None
#else
let TryEliminateDesugaredConstants g m c =
match c with
| Const.Decimal d ->
Expand All @@ -6510,7 +6506,6 @@ let TryEliminateDesugaredConstants g m c =
| _ -> failwith "unreachable"
| _ ->
None
#endif

let mkSeqTy (g:TcGlobals) ty = mkAppTy g.seq_tcr [ty]
let mkIEnumeratorTy (g:TcGlobals) ty = mkAppTy g.tcref_System_Collections_Generic_IEnumerator [ty]
Expand Down
4 changes: 0 additions & 4 deletions src/fsharp/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,7 @@ rule token args skip = parse
{ try
let s = removeUnderscores (lexemeTrimRight lexbuf 1)
// This implements a range check for decimal literals
#if FABLE_COMPILER
let d = Convert.ToDecimal(s)
#else
let d = System.Decimal.Parse(s,System.Globalization.NumberStyles.AllowExponent ||| System.Globalization.NumberStyles.Number,System.Globalization.CultureInfo.InvariantCulture)
#endif
DECIMAL d
with
e -> fail args lexbuf (FSComp.SR.lexOusideDecimal()) (DECIMAL (decimal 0))
Expand Down

0 comments on commit 7e5dbbe

Please sign in to comment.