Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit 2ce1fa1

Browse files
committed
[WIP] Fable support - typed
1 parent 4aeb3c0 commit 2ce1fa1

36 files changed

+2981
-163
lines changed

Export.FCS.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio 14
3+
VisualStudioVersion = 14.0.25420.1
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service", "src\fsharp\FSharp.Compiler.Service\FSharp.Compiler.Service.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}"
6+
EndProject
7+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Export.FCS", "src\fsharp\Export.FCS\Export.FCS.fsproj", "{C89727FE-5D40-4DE2-B751-753D75C86E4C}"
8+
EndProject
9+
Global
10+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
11+
Debug|Any CPU = Debug|Any CPU
12+
Release|Any CPU = Release|Any CPU
13+
EndGlobalSection
14+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{C89727FE-5D40-4DE2-B751-753D75C86E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{C89727FE-5D40-4DE2-B751-753D75C86E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{C89727FE-5D40-4DE2-B751-753D75C86E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{C89727FE-5D40-4DE2-B751-753D75C86E4C}.Release|Any CPU.Build.0 = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(SolutionProperties) = preSolution
25+
HideSolutionNode = FALSE
26+
EndGlobalSection
27+
EndGlobal

src/absil/illib.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ type UniqueStampGenerator<'T when 'T : equality>() =
627627

628628
type MemoizationTable<'T,'U>(compute: 'T -> 'U, keyComparer: IEqualityComparer<'T>, ?canMemoize) =
629629

630-
let table = new System.Collections.Generic.Dictionary<'T,'U>(keyComparer)
630+
let table = new System.Collections.Generic.Dictionary<'T,'U>(3, keyComparer)
631631
member t.Apply(x) =
632632
if (match canMemoize with None -> true | Some f -> f x) then
633633
#if FABLE_COMPILER

src/fsharp/CompileOps.fs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ type IRawFSharpAssemblyData =
18891889
type TimeStampCache() =
18901890
let cacheCreation = DateTime.Now
18911891
let files = Dictionary<string,DateTime>()
1892-
let projects = Dictionary<IProjectReference,DateTime>(HashIdentity.Reference)
1892+
let projects = Dictionary<IProjectReference,DateTime>(3, HashIdentity.Reference)
18931893
member x.CacheCreation = cacheCreation
18941894
member x.Files = files
18951895
member x.Projects = projects
@@ -4662,6 +4662,21 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
46624662
Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants.parseILGlobals := tcGlobals.ilg
46634663
#endif
46644664
frameworkTcImports.SetTcGlobals(tcGlobals)
4665+
4666+
#if EXPORT_SIGDATA
4667+
let writeSigData (ccu:CcuThunk) =
4668+
let path = "../../../../../temp/"
4669+
let exportRemapping = MakeExportRemapping ccu ccu.Contents
4670+
let resource = WriteSignatureData (tcConfig,tcGlobals,exportRemapping,ccu,ccu.name)
4671+
match resource.Location with
4672+
| ILResourceLocation.Local bytes ->
4673+
File.WriteAllBytes(path + ccu.name + ".sigdata", bytes())
4674+
| _ -> ()
4675+
4676+
fslibCcu |> writeSigData
4677+
sysCcus |> Array.iter writeSigData
4678+
#endif
4679+
46654680
tcGlobals,frameworkTcImports
46664681

46674682
member tcImports.ReportUnresolvedAssemblyReferences(knownUnresolved) =
@@ -5190,6 +5205,9 @@ let CheckSimulateException(tcConfig:TcConfig) =
51905205
type TcConfig() =
51915206
member x.implicitIncludeDir = ""
51925207
member x.compilingFslib = false
5208+
member x.isInteractive = false
5209+
member x.mlCompatibility = false
5210+
member x.emitDebugInfoInQuotations = false
51935211
member x.conditionalCompilationDefines = []
51945212
member x.globalWarnAsError = false
51955213
member x.globalWarnLevel = 0

src/fsharp/Export.FCS/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
5+
</startup>
6+
</configuration>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace Export.FCS.AssemblyInfo
2+
3+
open System.Reflection
4+
open System.Runtime.CompilerServices
5+
open System.Runtime.InteropServices
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[<assembly: AssemblyTitle("Export.FCS")>]
11+
[<assembly: AssemblyDescription("")>]
12+
[<assembly: AssemblyConfiguration("")>]
13+
[<assembly: AssemblyCompany("")>]
14+
[<assembly: AssemblyProduct("Export.FCS")>]
15+
[<assembly: AssemblyCopyright("Copyright © 2016")>]
16+
[<assembly: AssemblyTrademark("")>]
17+
[<assembly: AssemblyCulture("")>]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[<assembly: ComVisible(false)>]
23+
24+
// The following GUID is for the ID of the typelib if this project is exposed to COM
25+
[<assembly: Guid("c89727fe-5d40-4de2-b751-753d75c86e4c")>]
26+
27+
// Version information for an assembly consists of the following four values:
28+
//
29+
// Major Version
30+
// Minor Version
31+
// Build Number
32+
// Revision
33+
//
34+
// You can specify all the values or you can default the Build and Revision Numbers
35+
// by using the '*' as shown below:
36+
// [<assembly: AssemblyVersion("1.0.*")>]
37+
[<assembly: AssemblyVersion("1.0.0.0")>]
38+
[<assembly: AssemblyFileVersion("1.0.0.0")>]
39+
40+
do
41+
()
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>c89727fe-5d40-4de2-b751-753d75c86e4c</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<RootNamespace>Export.FCS</RootNamespace>
11+
<AssemblyName>Export.FCS</AssemblyName>
12+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
15+
<Name>Export.FCS</Name>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<Tailcalls>false</Tailcalls>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<WarningLevel>3</WarningLevel>
25+
<PlatformTarget>AnyCPU</PlatformTarget>
26+
<DocumentationFile>bin\Debug\Export.FCS.XML</DocumentationFile>
27+
<Prefer32Bit>true</Prefer32Bit>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<Tailcalls>true</Tailcalls>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<WarningLevel>3</WarningLevel>
36+
<PlatformTarget>AnyCPU</PlatformTarget>
37+
<DocumentationFile>bin\Release\Export.FCS.XML</DocumentationFile>
38+
<Prefer32Bit>true</Prefer32Bit>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="mscorlib" />
42+
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
43+
<Private>True</Private>
44+
</Reference>
45+
<Reference Include="System" />
46+
<Reference Include="System.Core" />
47+
<Reference Include="System.Numerics" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="AssemblyInfo.fs" />
51+
<Compile Include="Program.fs" />
52+
<None Include="App.config" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<ProjectReference Include="..\FSharp.Compiler.Service\FSharp.Compiler.Service.fsproj">
56+
<Name>FSharp.Compiler.Service</Name>
57+
<Project>{2e4d67b4-522d-4cf7-97e4-ba940f0b18f3}</Project>
58+
<Private>True</Private>
59+
</ProjectReference>
60+
</ItemGroup>
61+
<PropertyGroup>
62+
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
63+
</PropertyGroup>
64+
<Choose>
65+
<When Condition="'$(VisualStudioVersion)' == '11.0'">
66+
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
67+
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
68+
</PropertyGroup>
69+
</When>
70+
<Otherwise>
71+
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
72+
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
73+
</PropertyGroup>
74+
</Otherwise>
75+
</Choose>
76+
<Import Project="$(FSharpTargetsPath)" />
77+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
78+
Other similar extension points exist, see Microsoft.Common.targets.
79+
<Target Name="BeforeBuild">
80+
</Target>
81+
<Target Name="AfterBuild">
82+
</Target>
83+
-->
84+
</Project>

src/fsharp/Export.FCS/Program.fs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
open System.IO
2+
open System.Collections.Generic
3+
open Microsoft.FSharp.Compiler
4+
open Microsoft.FSharp.Compiler.SourceCodeServices
5+
6+
let input =
7+
"""
8+
open System
9+
10+
let foo() =
11+
let msg = String.Concat("Hello"," ","world")
12+
if true then
13+
printfn "%s" msg
14+
"""
15+
16+
// Create one global interactive checker instance
17+
let checker = FSharpChecker.Create()
18+
19+
let parseAndCheckScript (file, input) =
20+
let projectOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously
21+
let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, input, projectOptions) |> Async.RunSynchronously
22+
23+
// if parseResult.Errors.Length > 0 then
24+
// printfn "---> Parse Input = %A" input
25+
// printfn "---> Parse Error = %A" parseResult.Errors
26+
27+
match typedRes with
28+
| FSharpCheckFileAnswer.Succeeded(res) -> parseResult, res
29+
| res -> failwithf "Parsing did not finish... (%A)" res
30+
31+
let test() =
32+
let file = "/Test.fsx"
33+
let parseResult, typeCheckResults = parseAndCheckScript(file, input)
34+
35+
// We only expect one reported error. However,
36+
// on Unix, using filenames like /home/user/Test.fsx gives a second copy of all parse errors due to the
37+
// way the load closure for scripts is generated. So this returns two identical errors
38+
39+
// So we check that the messages are the same
40+
for msg in typeCheckResults.Errors do
41+
printfn "Error: %A" msg
42+
43+
[<EntryPoint>]
44+
let main argv =
45+
printfn "Parsing..."
46+
test()
47+
0 // return an integer exit code

src/fsharp/ExtensionTyping.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ module internal ExtensionTyping =
274274
member ctxt.GetDictionaries() =
275275
match ctxt with
276276
| NoEntries ->
277-
Dictionary<System.Type,ILTypeRef>(providedSystemTypeComparer), Dictionary<System.Type,obj>(providedSystemTypeComparer)
277+
Dictionary<System.Type,ILTypeRef>(3, providedSystemTypeComparer), Dictionary<System.Type,obj>(3, providedSystemTypeComparer)
278278
| Entries (lookupILTR, lookupILTCR) ->
279279
lookupILTR, lookupILTCR.Force()
280280

@@ -297,7 +297,7 @@ module internal ExtensionTyping =
297297
match ctxt with
298298
| NoEntries -> NoEntries
299299
| Entries(d1,d2) ->
300-
Entries(d1, lazy (let dict = new Dictionary<System.Type,obj>(providedSystemTypeComparer)
300+
Entries(d1, lazy (let dict = new Dictionary<System.Type,obj>(3, providedSystemTypeComparer)
301301
for KeyValue (st, tcref) in d2.Force() do dict.Add(st, f tcref)
302302
dict))
303303

src/fsharp/Fable.FCS/Fable.FCS.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "project", "project.fsproj", "{503AD75D-B915-4DAB-8819-16F9E8711881}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{503AD75D-B915-4DAB-8819-16F9E8711881}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{503AD75D-B915-4DAB-8819-16F9E8711881}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{503AD75D-B915-4DAB-8819-16F9E8711881}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{503AD75D-B915-4DAB-8819-16F9E8711881}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

src/fsharp/Fable.FCS/Program.fs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)