diff --git a/.gitattributes b/.gitattributes
index 3a241177..9a816114 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,3 @@
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
+*.exe filter=lfs diff=lfs merge=lfs -text
diff --git a/.github/workflows/build-linux.yaml b/.github/workflows/build-linux.yaml
index ffc9aab0..8d056f90 100644
--- a/.github/workflows/build-linux.yaml
+++ b/.github/workflows/build-linux.yaml
@@ -23,9 +23,14 @@ jobs:
env:
buildConfiguration: ${{ matrix.buildConfiguration }}
steps:
- - uses: actions/checkout@v2
+ - name: Checkout
+ uses: actions/checkout@v2
with:
fetch-depth: 0
+ lfs: true
+ # https://stackoverflow.com/questions/61463578/github-actions-actions-checkoutv2-lfs-true-flag-not-converting-pointers-to-act
+ - name: Checkout LFS objects
+ run: git lfs checkout
- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
@@ -38,8 +43,12 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.402
- - name: Initialize tools
- run: bash ./init-tools.sh
+ - name: Setup .NET 6
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 6.0.100
+ #- name: Initialize tools
+ # run: bash .github/workflows/init-tools-on-ga.sh
- name: Install dependencies
run: |
dotnet restore il2c.sln
diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml
index 7f7616a6..9fb5a011 100644
--- a/.github/workflows/build-windows.yaml
+++ b/.github/workflows/build-windows.yaml
@@ -23,9 +23,14 @@ jobs:
env:
buildConfiguration: ${{ matrix.buildConfiguration }}
steps:
- - uses: actions/checkout@v2
+ - name: Checkout
+ uses: actions/checkout@v2
with:
fetch-depth: 0
+ lfs: true
+ # https://stackoverflow.com/questions/61463578/github-actions-actions-checkoutv2-lfs-true-flag-not-converting-pointers-to-act
+ - name: Checkout LFS objects
+ run: git lfs checkout
- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
@@ -38,6 +43,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.402
+ - name: Setup .NET 6
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 6.0.100
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.3
- name: Initialize tools
diff --git a/.github/workflows/init-tools-on-ga.sh b/.github/workflows/init-tools-on-ga.sh
new file mode 100644
index 00000000..faa06eac
--- /dev/null
+++ b/.github/workflows/init-tools-on-ga.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+sudo -S apt-get update -y < /dev/null
+sudo -S apt-get install build-essential cmake ninja-build mono-devel -y < /dev/null
diff --git a/.gitignore b/.gitignore
index 34729976..8bdeb545 100644
--- a/.gitignore
+++ b/.gitignore
@@ -248,3 +248,4 @@ toolchain/
.idea/
+logs/
diff --git a/.nuget/nuget.exe b/.nuget/nuget.exe
index d56c5788..3bd8edb9 100644
Binary files a/.nuget/nuget.exe and b/.nuget/nuget.exe differ
diff --git a/ArtifactCollector/ArtifactCollector.csproj b/ArtifactCollector/ArtifactCollector.csproj
deleted file mode 100644
index 54f3103d..00000000
--- a/ArtifactCollector/ArtifactCollector.csproj
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
- net45
- Exe
- latest
- true
- AnyCPU
- true
- true
- false
- false
-
- ArtifactCollector
- IL2C.ArtifactCollector
- A translator implementation of .NET intermediate language to C language.
-
- PackageReference
-
- IL2C
- IL2C
- Copyright (c) 2017-2019 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- Apache-2.0
- https://github.com/kekyo/IL2C.git
- https://github.com/kekyo/IL2C.git
- il2c;cil;msil;translate;transpile;aot;ecma335;c;c++;win32;uefi;wdm;multi-platform;systems-programming
-
- .pdb
- true
- true
- true
-
-
-
- full
-
-
-
- embedded
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..a0c38bf6
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,36 @@
+
+
+
+
+ IL2C
+
+ latest
+ disable
+ AnyCPU
+
+ true
+ true
+ false
+ false
+ false
+ true
+ true
+ true
+ $(NoWarn);CS1570;CS1591;NU5105
+
+ true
+ git
+ https://github.com/kekyo/IL2C.git
+
+
+
+ .NETFramework
+ v4.0
+ Client
+
+
+
+
+
+
+
diff --git a/IL2C.Core/IL2C.Core.csproj b/IL2C.Core/IL2C.Core.csproj
deleted file mode 100644
index ab95eb55..00000000
--- a/IL2C.Core/IL2C.Core.csproj
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
- net45;net462;net48;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1;net5.0
- Library
- true
- true
- false
- true
- AnyCPU
- latest
- NU5105
- false
-
- IL2C.Core
- IL2C
- A translator implementation of .NET intermediate language to C language.
-
- PackageReference
-
- IL2C
- IL2C
- Copyright (c) 2017-2019 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- Apache-2.0
- https://github.com/kekyo/IL2C.git
- https://github.com/kekyo/IL2C.git
- il2c;cil;msil;translate;transpile;aot;ecma335;c;c++;win32;uefi;wdm;multi-platform;systems-programming
-
- .pdb
- true
- true
- true
-
-
-
- full
-
-
-
- embedded
- true
-
-
-
-
-
-
-
-
-
-
-
diff --git a/IL2C.Core/Internal/ICombinedComparer.cs b/IL2C.Core/Internal/ICombinedComparer.cs
deleted file mode 100644
index fb164064..00000000
--- a/IL2C.Core/Internal/ICombinedComparer.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System.Collections.Generic;
-
-namespace IL2C.Internal
-{
- internal interface ICombinedComparer
- : IEqualityComparer, IComparer
- {
- }
-}
diff --git a/IL2C.Core/InvalidProgramSequenceException.cs b/IL2C.Core/InvalidProgramSequenceException.cs
deleted file mode 100644
index 37bfca39..00000000
--- a/IL2C.Core/InvalidProgramSequenceException.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-
-namespace IL2C
-{
- public sealed class InvalidProgramSequenceException : Exception
- {
- public InvalidProgramSequenceException(string format, params object[] args)
- : base(string.Format(format, args))
- {
- }
- }
-}
diff --git a/IL2C.Core/Metadata/Attributes/NativeCharSetInformation.cs b/IL2C.Core/Metadata/Attributes/NativeCharSetInformation.cs
deleted file mode 100644
index d1bfe607..00000000
--- a/IL2C.Core/Metadata/Attributes/NativeCharSetInformation.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-namespace IL2C.Metadata.Attributes
-{
- public enum NativeCharSetInformation
- {
- Unicode,
- UTF8
- }
-}
diff --git a/IL2C.Core/Metadata/IOperandPrintable.cs b/IL2C.Core/Metadata/IOperandPrintable.cs
deleted file mode 100644
index 71bec1c1..00000000
--- a/IL2C.Core/Metadata/IOperandPrintable.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-
-namespace IL2C.Metadata
-{
- internal interface IOperandPrintable
- {
- string PrintableString { get; }
- }
-}
diff --git a/IL2C.Core/Properties/AssemblyInfo.cs b/IL2C.Core/Properties/AssemblyInfo.cs
deleted file mode 100644
index b44fc90f..00000000
--- a/IL2C.Core/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-[assembly: InternalsVisibleTo("IL2C.Core.Test.Fixture")]
diff --git a/IL2C.Core/SimpleDriver.cs b/IL2C.Core/SimpleDriver.cs
deleted file mode 100644
index 9792340d..00000000
--- a/IL2C.Core/SimpleDriver.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System.Collections.Generic;
-using System.IO;
-
-namespace IL2C
-{
- public static class SimpleDriver
- {
- public static void Translate(
- TextWriter logw,
- CodeTextStorage storage,
- bool readSymbols,
- bool enableBundler,
- TargetPlatforms targetPlatform,
- DebugInformationOptions debugInformationOptions,
- string assemblyPath)
- {
- logw.Write("IL2C: Preparing assembly: \"{0}\" ...", Path.GetFullPath(assemblyPath));
-
- var translateContext = new TranslateContext(assemblyPath, readSymbols, targetPlatform);
- var preparedFunctions = AssemblyPreparer.Prepare(translateContext);
-
- logw.WriteLine(" done.");
-
- using (var _ = storage.EnterScope("include"))
- {
- AssemblyWriter.WriteHeader(
- storage,
- translateContext,
- preparedFunctions);
- }
-
- using (var _ = storage.EnterScope("src"))
- {
- AssemblyWriter.WriteSourceCode(
- storage,
- translateContext,
- preparedFunctions,
- enableBundler,
- debugInformationOptions);
- }
- }
-
- public static void TranslateAll(
- TextWriter logw,
- CodeTextStorage storage,
- bool readSymbols,
- bool enableBundler,
- TargetPlatforms targetPlatform,
- DebugInformationOptions debugInformationOptions,
- IEnumerable assemblyPaths)
- {
- foreach (var assemblyPath in assemblyPaths)
- {
- Translate(
- logw,
- storage,
- readSymbols,
- enableBundler,
- targetPlatform,
- debugInformationOptions,
- assemblyPath);
- }
- }
-
- public static void TranslateAll(
- TextWriter logw,
- CodeTextStorage storage,
- bool readSymbols,
- bool enableBundler,
- TargetPlatforms targetPlatform,
- DebugInformationOptions debugInformationOptions,
- params string[] assemblyPaths)
- {
- TranslateAll(
- logw,
- storage,
- readSymbols,
- enableBundler,
- targetPlatform,
- debugInformationOptions,
- (IEnumerable)assemblyPaths);
- }
-
- public static void TranslateAll(
- TextWriter logw,
- string outputPath,
- bool readSymbols,
- bool enableCpp,
- bool enableBundler,
- TargetPlatforms targetPlatform,
- DebugInformationOptions debugInformationOptions,
- IEnumerable assemblyPaths)
- {
- var storage = new CodeTextStorage(
- logw,
- outputPath,
- enableCpp,
- " ");
-
- foreach (var assemblyPath in assemblyPaths)
- {
- Translate(
- logw,
- storage,
- readSymbols,
- enableBundler,
- targetPlatform,
- debugInformationOptions,
- assemblyPath);
- }
- }
-
- public static void TranslateAll(
- TextWriter logw,
- string outputPath,
- bool readSymbols,
- bool enableCpp,
- bool enableBundler,
- TargetPlatforms targetPlatform,
- DebugInformationOptions debugInformationOptions,
- params string[] assemblyPaths)
- {
- TranslateAll(
- logw,
- outputPath,
- readSymbols,
- enableCpp,
- enableBundler,
- targetPlatform,
- debugInformationOptions,
- (IEnumerable)assemblyPaths);
- }
- }
-}
diff --git a/IL2C.Core/Translators/Label.cs b/IL2C.Core/Translators/Label.cs
deleted file mode 100644
index 3ed8f768..00000000
--- a/IL2C.Core/Translators/Label.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-namespace IL2C.Translators
-{
- public struct Label
- {
- public readonly int Offset;
-
- public Label(int offset)
- {
- this.Offset = offset;
- }
-
- public override string ToString() =>
- string.Format("IL_{0:x4}", this.Offset);
- }
-}
diff --git a/IL2C.Interop/IL2C.Interop.csproj b/IL2C.Interop/IL2C.Interop.csproj
deleted file mode 100644
index 6917bd9c..00000000
--- a/IL2C.Interop/IL2C.Interop.csproj
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
- net20;net35;net40-client;net45;net462;net48;netstandard1.0;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1;net5.0
- Library
- true
- true
- false
- true
- AnyCPU
- latest
- NU5105
- false
-
- IL2C.Interop
- IL2C
- A translator implementation of .NET intermediate language to C language.
-
- PackageReference
-
- IL2C
- IL2C
- Copyright (c) 2017-2019 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- Apache-2.0
- https://github.com/kekyo/IL2C.git
- https://github.com/kekyo/IL2C.git
- il2c;cil;msil;translate;transpile;aot;ecma335;c;c++;win32;uefi;wdm;multi-platform;systems-programming
-
- .pdb
- true
- true
- true
-
-
-
- full
-
-
-
- embedded
- true
-
-
-
- .NETFramework
- v4.0
- Client
-
-
-
-
-
-
-
-
-
diff --git a/IL2C.Interop/NativeAttribute.cs b/IL2C.Interop/NativeAttribute.cs
deleted file mode 100644
index bb4c303a..00000000
--- a/IL2C.Interop/NativeAttribute.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Collections;
-
-namespace System.Runtime.InteropServices
-{
- public abstract class NativeAttribute : Attribute
- {
- protected NativeAttribute(string includeFileName)
- {
- this.IncludeFileName = includeFileName;
- }
-
- internal NativeAttribute(object arg0, IDictionary props)
- {
- this.IncludeFileName = (string)arg0;
- this.SymbolName = (string)props["SymbolName"];
- }
-
- public string IncludeFileName { get; }
- public string SymbolName { get; set; }
- }
-}
diff --git a/IL2C.Interop/NativeCharSet.cs b/IL2C.Interop/NativeCharSet.cs
deleted file mode 100644
index 0b8d02df..00000000
--- a/IL2C.Interop/NativeCharSet.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace System.Runtime.InteropServices
-{
- public enum NativeCharSet
- {
- Unicode,
- UTF8
- }
-}
diff --git a/IL2C.Interop/NativePointer.cs b/IL2C.Interop/NativePointer.cs
deleted file mode 100644
index 1773a169..00000000
--- a/IL2C.Interop/NativePointer.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-
-namespace System.Runtime.InteropServices
-{
- public struct NativePointer
- {
- private readonly IntPtr pointer;
-
- private NativePointer(IntPtr value) => this.pointer = value;
-
- public static implicit operator NativePointer(IntPtr value) => new NativePointer(value);
- public static implicit operator IntPtr(NativePointer value) => value.pointer;
- }
-}
diff --git a/IL2C.Interop/NativeValueAttribute.cs b/IL2C.Interop/NativeValueAttribute.cs
deleted file mode 100644
index 1a6afbf2..00000000
--- a/IL2C.Interop/NativeValueAttribute.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Collections;
-
-namespace System.Runtime.InteropServices
-{
- [AttributeUsage(AttributeTargets.Field, AllowMultiple=false, Inherited=false)]
- public sealed class NativeValueAttribute : NativeAttribute
- {
- public NativeValueAttribute(string includeFileName)
- : base(includeFileName)
- {
- }
-
- internal NativeValueAttribute(object arg0, IDictionary props)
- : base(arg0, props)
- {
- }
- }
-}
diff --git a/IL2C.Interop/Properties/AssemblyInfo.cs b/IL2C.Interop/Properties/AssemblyInfo.cs
deleted file mode 100644
index 41e92dea..00000000
--- a/IL2C.Interop/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-[assembly: InternalsVisibleTo("IL2C.Core")]
diff --git a/IL2C.Runtime/IL2C.Runtime.msvc.nuspec b/IL2C.Runtime/IL2C.Runtime.msvc.nuspec
deleted file mode 100644
index b3c89387..00000000
--- a/IL2C.Runtime/IL2C.Runtime.msvc.nuspec
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- IL2C.Runtime.msvc
- $version$
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- false
- Apache-2.0
- https://github.com/kekyo/IL2C.git
- A translator implementation of .NET intermediate language to C language.
- Copyright (c) 2017-2019 Kouji Matsui
- il2c native cil msil translate transpile aot ecma335 c c++ win32 uefi wdm multi-platform systems-programming
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/IL2C.Runtime/build/IL2C.Runtime.msvc.props b/IL2C.Runtime/build/IL2C.Runtime.msvc.props
deleted file mode 100644
index 2e7f1074..00000000
--- a/IL2C.Runtime/build/IL2C.Runtime.msvc.props
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- $(MSBuildThisFileDirectory)..\lib\native
-
-
diff --git a/IL2C.Runtime/build/IL2C.Runtime.props b/IL2C.Runtime/build/IL2C.Runtime.props
deleted file mode 100644
index b78e1cb8..00000000
--- a/IL2C.Runtime/build/IL2C.Runtime.props
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- $(MSBuildThisFileDirectory)..\lib\native
-
-
diff --git a/IL2C.Runtime/include/IL2C.Interop.h b/IL2C.Runtime/include/IL2C.Interop.h
deleted file mode 100644
index fc0ba5c2..00000000
--- a/IL2C.Runtime/include/IL2C.Interop.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef IL2C_Interop_dll_H__
-#define IL2C_Interop_dll_H__
-
-#pragma once
-
-// IL2C.Interop.dll contains mostly usable IL2C/Invoke definitions
-// with private knowledge.
-#include
-
-#endif
diff --git a/IL2C.Runtime/include/System.Console.h b/IL2C.Runtime/include/System.Console.h
deleted file mode 100644
index 2a7b0d08..00000000
--- a/IL2C.Runtime/include/System.Console.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef System_Console_dll_H__
-#define System_Console_dll_H__
-
-#pragma once
-
-#include
-
-#endif
diff --git a/IL2C.Runtime/include/System.Private.CoreLib.h b/IL2C.Runtime/include/System.Private.CoreLib.h
deleted file mode 100644
index 34f1ed92..00000000
--- a/IL2C.Runtime/include/System.Private.CoreLib.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef System_Private_CoreLib_dll_H__
-#define System_Private_CoreLib_dll_H__
-
-#pragma once
-
-#include
-
-#endif
diff --git a/IL2C.Runtime/include/System.Runtime.h b/IL2C.Runtime/include/System.Runtime.h
deleted file mode 100644
index 5e3721af..00000000
--- a/IL2C.Runtime/include/System.Runtime.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef System_Runtime_dll_H__
-#define System_Runtime_dll_H__
-
-#pragma once
-
-#include
-
-#endif
diff --git a/IL2C.Runtime/include/mscorlib.h b/IL2C.Runtime/include/mscorlib.h
deleted file mode 100644
index a0dc1138..00000000
--- a/IL2C.Runtime/include/mscorlib.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef mscorlib_dll_H__
-#define mscorlib_dll_H__
-
-#pragma once
-
-#include
-
-#endif
diff --git a/IL2C.Runtime/src/Platform/efi/efichar.h b/IL2C.Runtime/src/Platform/efi/efichar.h
deleted file mode 100644
index 1e29df7b..00000000
--- a/IL2C.Runtime/src/Platform/efi/efichar.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifndef _BOOT_EFI_EFICHAR_H_
-#define _BOOT_EFI_EFICHAR_H_
-
-int ucs2_to_utf8(const efi_char *, char **);
-int utf8_to_ucs2(const char *, efi_char **, size_t *);
-
-#endif /* _BOOT_EFI_EFICHAR_H_ */
diff --git a/IL2C.Runtime/src/Platform/no-threading.c b/IL2C.Runtime/src/Platform/no-threading.c
deleted file mode 100644
index 7e4772a6..00000000
--- a/IL2C.Runtime/src/Platform/no-threading.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include
-
-///////////////////////////////////////////////////
-// Lack for threading support
-
-#if defined(IL2C_NO_THREADING)
-
-intptr_t g_TLS0;
-
-#endif
diff --git a/IL2C.Runtime/src/System/IDisposable.c b/IL2C.Runtime/src/System/IDisposable.c
deleted file mode 100644
index 16b1cf68..00000000
--- a/IL2C.Runtime/src/System/IDisposable.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "il2c_private.h"
-#include
-
-/////////////////////////////////////////////////////////////
-// System.IDisposable
-
-/////////////////////////////////////////////////
-// VTable and runtime type info declarations
-
-IL2C_RUNTIME_TYPE_INTERFACE_BEGIN(System_IDisposable, "System.IDisposable", 0)
-IL2C_RUNTIME_TYPE_END();
diff --git a/IL2C.Runtime/src/System/IFormatProvider.c b/IL2C.Runtime/src/System/IFormatProvider.c
deleted file mode 100644
index e4cccb08..00000000
--- a/IL2C.Runtime/src/System/IFormatProvider.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "il2c_private.h"
-
-/////////////////////////////////////////////////////////////
-// System.IFormatProvider
-
-/////////////////////////////////////////////////
-// VTable and runtime type info declarations
-
-IL2C_RUNTIME_TYPE_INTERFACE_BEGIN(System_IFormatProvider, "System.IFormatProvider", 0)
-IL2C_RUNTIME_TYPE_END();
diff --git a/IL2C.Runtime/src/System/IFormattable.c b/IL2C.Runtime/src/System/IFormattable.c
deleted file mode 100644
index a2e604ca..00000000
--- a/IL2C.Runtime/src/System/IFormattable.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "il2c_private.h"
-
-/////////////////////////////////////////////////////////////
-// System.IFormattable
-
-/////////////////////////////////////////////////
-// VTable and runtime type info declarations
-
-IL2C_RUNTIME_TYPE_INTERFACE_BEGIN(System_IFormattable, "System.IFormattable", 0)
-IL2C_RUNTIME_TYPE_END();
diff --git a/IL2C.Tasks/IL2C.Tasks.csproj b/IL2C.Tasks/IL2C.Tasks.csproj
deleted file mode 100644
index c7ee07a2..00000000
--- a/IL2C.Tasks/IL2C.Tasks.csproj
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
- net46;net48;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1;net5.0
- Library
- true
- true
- false
- latest
- true
- AnyCPU
- NU5105
- false
-
- IL2C.Tasks
- IL2C
- A translator implementation of .NET intermediate language to C language.
-
- PackageReference
-
- IL2C
- IL2C
- Copyright (c) 2017-2019 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- IL2C.Build
- Apache-2.0
- https://github.com/kekyo/IL2C.git
- https://github.com/kekyo/IL2C.git
- il2c;cil;msil;translate;transpile;aot;ecma335;c;c++;win32;uefi;wdm;multi-platform;systems-programming
-
-
- true
-
-
- false
- .pdb
- $(TargetsForTfmSpecificContentInPackage);GetPublishFilesForPack
-
- true
- true
- true
-
-
-
- full
-
-
-
- embedded
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/IL2C.Tasks/LogWriter.cs b/IL2C.Tasks/LogWriter.cs
deleted file mode 100644
index 7cc3dca5..00000000
--- a/IL2C.Tasks/LogWriter.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Globalization;
-using System.Text;
-
-namespace IL2C
-{
- internal sealed class LogWriter : System.IO.TextWriter
- {
- private readonly Action writer;
- private readonly StringBuilder sb = new StringBuilder();
-
- public LogWriter(Action writer)
- : base(CultureInfo.InvariantCulture)
- {
- this.writer = writer;
- }
-
- public override Encoding Encoding
- {
- get
- {
- return Encoding.UTF8;
- }
- }
-
- public override void Flush()
- {
- this.WriteLine();
- }
-
- public override void Write(char ch)
- {
- sb.Append(ch);
- }
-
- public override void Write(char[] buffer, int index, int count)
- {
- var value = new string(buffer, index, count);
- sb.Append(value);
- }
-
- public override void Write(string value)
- {
- sb.Append(value);
- }
-
- public override void WriteLine()
- {
- this.WriteLine(string.Empty);
- }
-
- public override void WriteLine(string value)
- {
- sb.Append(value);
- writer(sb.ToString());
- sb.Clear();
- }
-
- public override void WriteLine(object value)
- {
- this.WriteLine(value?.ToString()??string.Empty);
- }
- }
-}
diff --git a/IL2C.Tasks/Translate.cs b/IL2C.Tasks/Translate.cs
deleted file mode 100644
index 846b3555..00000000
--- a/IL2C.Tasks/Translate.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Linq;
-using Microsoft.Build.Framework;
-
-namespace IL2C
-{
- public sealed class Translate : Microsoft.Build.Utilities.Task
- {
- public Translate()
- {
- this.DebugInformation = "CommentOnly";
- }
-
- [Required]
- public ITaskItem[] AssemblyPaths
- {
- get; set;
- }
-
- [Required]
- public ITaskItem OutputPath
- {
- get; set;
- }
-
- public bool ReadSymbols
- {
- get; set;
- }
-
- public bool EnableCpp
- {
- get; set;
- }
-
- public bool EnableBundler
- {
- get; set;
- }
-
- public string TargetPlatform
- {
- get; set;
- }
-
- public string DebugInformation
- {
- get; set;
- }
-
- public override bool Execute()
- {
- var outputPath = this.OutputPath.ItemSpec.Trim();
- var debugInformation = string.IsNullOrWhiteSpace(this.DebugInformation)
- ? DebugInformationOptions.CommentOnly
- : (DebugInformationOptions)Enum.Parse(typeof(DebugInformationOptions), this.DebugInformation);
- var targetPlatform = !string.IsNullOrWhiteSpace(this.TargetPlatform) ?
- (Enum.TryParse(this.TargetPlatform, true, out var t) ?
- t : TargetPlatforms.Generic) :
- TargetPlatforms.Generic;
-
- var logw = new LogWriter(message =>
- this.Log.LogMessage(
- MessageImportance.High,
- "{0}", message));
-
- SimpleDriver.TranslateAll(
- logw,
- outputPath,
- this.ReadSymbols,
- this.EnableCpp,
- this.EnableBundler,
- targetPlatform,
- debugInformation,
- this.AssemblyPaths.
- Select(path => path.ItemSpec.Trim()).
- ToArray());
-
- return true;
- }
- }
-}
diff --git a/IL2C.Tasks/build/IL2C.Build.props b/IL2C.Tasks/build/IL2C.Build.props
deleted file mode 100644
index 7b646e34..00000000
--- a/IL2C.Tasks/build/IL2C.Build.props
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- netcoreapp2.0
- net46
- $(MSBuildThisFileDirectory)..\tasks\$(TaskFolder)\IL2C.Tasks.dll
-
-
-
diff --git a/IL2C.Tasks/build/IL2C.Build.targets b/IL2C.Tasks/build/IL2C.Build.targets
deleted file mode 100644
index fe56a360..00000000
--- a/IL2C.Tasks/build/IL2C.Build.targets
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- $([System.String]::Concat('$(AssemblyName)','$(TargetExt)'))
- $([System.IO.Path]::Combine('$(ProjectDir)','$(OutputPath)','$(IL2CTargetAssemblyFileName)'))
- $([System.String]::Concat('$(IL2CAssemblyPaths)',';','$(IL2CTargetAssemblyPath)').split(';'))
- $(IL2CTargetAssemblyPath)
- $([System.IO.Path]::Combine('$(ProjectDir)','$(OutputPath)','IL2C'))
- Full
- true
- false
- false
- Generic
-
- $(CoreBuildDependsOn);
- IL2CBuild
-
-
-
-
-
-
-
diff --git a/IL2C.Tasks/buildMultiTargeting/IL2C.Build.props b/IL2C.Tasks/buildMultiTargeting/IL2C.Build.props
deleted file mode 100644
index ddd7fee5..00000000
--- a/IL2C.Tasks/buildMultiTargeting/IL2C.Build.props
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/IL2C.Tasks/buildMultiTargeting/IL2C.Build.targets b/IL2C.Tasks/buildMultiTargeting/IL2C.Build.targets
deleted file mode 100644
index 6dc9d04c..00000000
--- a/IL2C.Tasks/buildMultiTargeting/IL2C.Build.targets
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/IL2C/IL2C.csproj b/IL2C/IL2C.csproj
deleted file mode 100644
index 55d51840..00000000
--- a/IL2C/IL2C.csproj
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
- net48;netcoreapp2.1;netcoreapp3.1;net5.0
- Exe
- true
- true
- false
- latest
- true
- AnyCPU
- NU5105
- false
-
- IL2C
- IL2C
- IL2C.Program
- A translator implementation of .NET intermediate language to C language.
-
- PackageReference
-
- IL2C
- IL2C
- Copyright (c) 2017-2019 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- Apache-2.0
- https://github.com/kekyo/IL2C.git
- https://github.com/kekyo/IL2C.git
- il2c;cil;msil;translate;transpile;aot;ecma335;c;c++;win32;uefi;wdm;multi-platform;systems-programming
-
- .pdb
- true
- true
- true
-
-
-
- full
-
-
-
- embedded
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/IL2C/Program.cs b/IL2C/Program.cs
deleted file mode 100644
index b7144ca7..00000000
--- a/IL2C/Program.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System;
-using System.Linq;
-using System.Runtime.InteropServices;
-
-using Mono.Options;
-
-namespace IL2C
-{
-// warning CS0649: Field is never assigned to, and will always have its default value `null'
-#pragma warning disable 0649
-
- public static class Program
- {
- public static int Main(string[] args)
- {
- try
- {
- var debugInformationOptions = DebugInformationOptions.None;
- var readSymbols = true;
- var enableCpp = false;
- var enableBundler = false;
- var targetPlatform = TargetPlatforms.Generic;
- var help = false;
-
- var options = new OptionSet()
- {
- { "g1|debug", "Emit debug informations (contains only comments)", v => debugInformationOptions = DebugInformationOptions.CommentOnly },
- { "g|g2|debug-full", "Emit debug informations (contains line numbers)", v => debugInformationOptions = DebugInformationOptions.Full },
- { "no-read-symbols", "NO read symbol files", _ => readSymbols = false },
- { "cpp", "Produce C++ extension files (apply extension *.cpp instead *.c, body will not change)", _ => enableCpp = true },
- { "bundler", "Produce bundler source file", _ => enableBundler = true },
- { "target=", "Target platform [generic|ue4]", v => targetPlatform = Enum.TryParse(v, true, out var t) ? t : TargetPlatforms.Generic },
- { "h|help", "Print this help", _ => help = true },
- };
-
- var extra = options.Parse(args);
- if (help || (extra.Count < 2))
- {
- Console.Out.WriteLine("usage: il2c.exe [options] ");
- options.WriteOptionDescriptions(Console.Out);
- }
- else
- {
- var outputPath = extra[0];
- var assemblyPaths = extra.Skip(1);
-
- SimpleDriver.TranslateAll(
- Console.Out,
- outputPath,
- readSymbols,
- enableCpp,
- enableBundler,
- targetPlatform,
- debugInformationOptions,
- assemblyPaths);
- }
-
- return 0;
- }
- catch (OptionException ex)
- {
- Console.Error.WriteLine(ex.Message);
- return Marshal.GetHRForException(ex);
- }
- catch (Exception ex)
- {
- Console.Error.WriteLine(ex);
- return Marshal.GetHRForException(ex);
- }
- }
- }
-}
diff --git a/IL2C/Properties/AssemblyInfo.cs b/IL2C/Properties/AssemblyInfo.cs
deleted file mode 100644
index a2462d49..00000000
--- a/IL2C/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
diff --git a/IL2C/Properties/launchSettings.json b/IL2C/Properties/launchSettings.json
deleted file mode 100644
index 979ea055..00000000
--- a/IL2C/Properties/launchSettings.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "profiles": {
- "IL2C": {
- "commandName": "Project",
- "commandLineArgs": "-g1 $(ProjectDir)../samples/Calculator/Generated $(ProjectDir)../samples/Calculator/Calculator.Core/bin/Debug/netstandard2.0/Calculator.Core.dll"
- }
- }
-}
\ No newline at end of file
diff --git a/images/Calculator.M5Stack.jpg b/Images/Calculator.M5Stack.jpg
similarity index 100%
rename from images/Calculator.M5Stack.jpg
rename to Images/Calculator.M5Stack.jpg
diff --git a/images/Calculator.UEFI.jpg b/Images/Calculator.UEFI.jpg
similarity index 100%
rename from images/Calculator.UEFI.jpg
rename to Images/Calculator.UEFI.jpg
diff --git a/images/Calculator.Win32.png b/Images/Calculator.Win32.png
similarity index 100%
rename from images/Calculator.Win32.png
rename to Images/Calculator.Win32.png
diff --git a/Images/IL2C.100.png b/Images/IL2C.100.png
new file mode 100644
index 00000000..4829bed3
--- /dev/null
+++ b/Images/IL2C.100.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e2eebe1bb4c189a9ce1c4b8031ed78f735186c1ef98e11b7ccf36af6865e9af9
+size 3228
diff --git a/Images/IL2C.2048.png b/Images/IL2C.2048.png
new file mode 100644
index 00000000..52747ab7
--- /dev/null
+++ b/Images/IL2C.2048.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:556b7e2eae4b74f78ad70817a63cce4b7540f3a538407bdda9ce2bc1717d49dd
+size 79634
diff --git a/images/IMG_20170917_194810.jpg b/Images/IMG_20170917_194810.jpg
similarity index 100%
rename from images/IMG_20170917_194810.jpg
rename to Images/IMG_20170917_194810.jpg
diff --git a/images/IMG_20170926_225355.jpg b/Images/IMG_20170926_225355.jpg
similarity index 100%
rename from images/IMG_20170926_225355.jpg
rename to Images/IMG_20170926_225355.jpg
diff --git a/images/IMG_20171130_200549.jpg b/Images/IMG_20171130_200549.jpg
similarity index 100%
rename from images/IMG_20171130_200549.jpg
rename to Images/IMG_20171130_200549.jpg
diff --git a/images/IMG_20181028_165314.jpg b/Images/IMG_20181028_165314.jpg
similarity index 100%
rename from images/IMG_20181028_165314.jpg
rename to Images/IMG_20181028_165314.jpg
diff --git a/images/IMG_20181110_181756.jpg b/Images/IMG_20181110_181756.jpg
similarity index 100%
rename from images/IMG_20181110_181756.jpg
rename to Images/IMG_20181110_181756.jpg
diff --git a/images/IMG_20181112_120412.jpg b/Images/IMG_20181112_120412.jpg
similarity index 100%
rename from images/IMG_20181112_120412.jpg
rename to Images/IMG_20181112_120412.jpg
diff --git a/images/banner.png b/Images/banner.png
similarity index 100%
rename from images/banner.png
rename to Images/banner.png
diff --git a/images/debug-runtime.png b/Images/debug-runtime.png
similarity index 100%
rename from images/debug-runtime.png
rename to Images/debug-runtime.png
diff --git a/Images/icon/IL2C.svg b/Images/icon/IL2C.svg
new file mode 100644
index 00000000..a2d5d1c8
--- /dev/null
+++ b/Images/icon/IL2C.svg
@@ -0,0 +1,116 @@
+
+
+
+
diff --git a/Images/icon/README.md b/Images/icon/README.md
new file mode 100644
index 00000000..c973b0ab
--- /dev/null
+++ b/Images/icon/README.md
@@ -0,0 +1,42 @@
+The icon images imported from [FireFox emoji](https://github.com/mozilla/fxemoji).
+These items exclude this project copyright notice.
+
+----
+
+## License for the Code
+
+Copyright 2015, Mozilla Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+## License for the Visual Design
+
+### Creative Commons Attribution 4.0 International (CC BY 4.0)
+https://creativecommons.org/licenses/by/4.0/legalcode
+or for the human readable summary: https://creativecommons.org/licenses/by/4.0/
+
+
+#### You are free to:
+**Share** — copy and redistribute the material in any medium or format
+**Adapt** — remix, transform, and build upon the material for any purpose, even commercially.
+The licensor cannot revoke these freedoms as long as you follow the license terms.
+
+
+#### Under the following terms:
+**Attribution** — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
+No additional restrictions — You may not apply legal terms or **technological measures** that legally restrict others from doing anything the license permits.
+
+#### Notices:
+You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
diff --git a/Images/icon/u1F5D0-pages.svg b/Images/icon/u1F5D0-pages.svg
new file mode 100644
index 00000000..73726656
--- /dev/null
+++ b/Images/icon/u1F5D0-pages.svg
@@ -0,0 +1,30 @@
+
+
+
+
diff --git a/Images/icon/u2712-blacknib.svg b/Images/icon/u2712-blacknib.svg
new file mode 100644
index 00000000..b34276d9
--- /dev/null
+++ b/Images/icon/u2712-blacknib.svg
@@ -0,0 +1,31 @@
+
+
+
+
diff --git a/images/il2c1.png b/Images/il2c1.png
similarity index 100%
rename from images/il2c1.png
rename to Images/il2c1.png
diff --git a/images/inside-boxing.png b/Images/inside-boxing.png
similarity index 100%
rename from images/inside-boxing.png
rename to Images/inside-boxing.png
diff --git a/images/inside-delegate.png b/Images/inside-delegate.png
similarity index 100%
rename from images/inside-delegate.png
rename to Images/inside-delegate.png
diff --git a/images/inside-string.png b/Images/inside-string.png
similarity index 100%
rename from images/inside-string.png
rename to Images/inside-string.png
diff --git a/images/inside-string2.png b/Images/inside-string2.png
similarity index 100%
rename from images/inside-string2.png
rename to Images/inside-string2.png
diff --git a/images/microbit.jpg b/Images/microbit.jpg
similarity index 100%
rename from images/microbit.jpg
rename to Images/microbit.jpg
diff --git a/images/overview.png b/Images/overview.png
similarity index 100%
rename from images/overview.png
rename to Images/overview.png
diff --git a/images/tutorial111.png b/Images/tutorial111.png
similarity index 100%
rename from images/tutorial111.png
rename to Images/tutorial111.png
diff --git a/images/tutorial112.png b/Images/tutorial112.png
similarity index 100%
rename from images/tutorial112.png
rename to Images/tutorial112.png
diff --git a/images/tutorial12.png b/Images/tutorial12.png
similarity index 100%
rename from images/tutorial12.png
rename to Images/tutorial12.png
diff --git a/images/tutorial13.png b/Images/tutorial13.png
similarity index 100%
rename from images/tutorial13.png
rename to Images/tutorial13.png
diff --git a/images/tutorial141.png b/Images/tutorial141.png
similarity index 100%
rename from images/tutorial141.png
rename to Images/tutorial141.png
diff --git a/images/tutorial142.png b/Images/tutorial142.png
similarity index 100%
rename from images/tutorial142.png
rename to Images/tutorial142.png
diff --git a/images/tutorial151.png b/Images/tutorial151.png
similarity index 100%
rename from images/tutorial151.png
rename to Images/tutorial151.png
diff --git a/images/tutorial152.png b/Images/tutorial152.png
similarity index 100%
rename from images/tutorial152.png
rename to Images/tutorial152.png
diff --git a/images/tutorial16.png b/Images/tutorial16.png
similarity index 100%
rename from images/tutorial16.png
rename to Images/tutorial16.png
diff --git a/images/tutorial17.png b/Images/tutorial17.png
similarity index 100%
rename from images/tutorial17.png
rename to Images/tutorial17.png
diff --git a/images/tutorial21.png b/Images/tutorial21.png
similarity index 100%
rename from images/tutorial21.png
rename to Images/tutorial21.png
diff --git a/images/tutorial22.png b/Images/tutorial22.png
similarity index 100%
rename from images/tutorial22.png
rename to Images/tutorial22.png
diff --git a/images/tutorial23.png b/Images/tutorial23.png
similarity index 100%
rename from images/tutorial23.png
rename to Images/tutorial23.png
diff --git a/images/tutorial24.png b/Images/tutorial24.png
similarity index 100%
rename from images/tutorial24.png
rename to Images/tutorial24.png
diff --git a/images/tutorial31.png b/Images/tutorial31.png
similarity index 100%
rename from images/tutorial31.png
rename to Images/tutorial31.png
diff --git a/images/tutorial32.jpg b/Images/tutorial32.jpg
similarity index 100%
rename from images/tutorial32.jpg
rename to Images/tutorial32.jpg
diff --git a/images/tutorial33.jpg b/Images/tutorial33.jpg
similarity index 100%
rename from images/tutorial33.jpg
rename to Images/tutorial33.jpg
diff --git a/build-runtime.bat b/build-runtime.bat
index 7cb145a1..3615a002 100644
--- a/build-runtime.bat
+++ b/build-runtime.bat
@@ -2,7 +2,7 @@
setlocal enabledelayedexpansion
set TOOLCHAINPATH=%~dp0toolchain\gcc4
-set CMAKE_ROOT=%TOOLCHAINPATH%\share\cmake-3.17
+set CMAKE_ROOT=%TOOLCHAINPATH%\share\cmake-3.23
if not exist %TOOLCHAINPATH% (
echo Native toolchain not found.
@@ -17,7 +17,7 @@ if "%Configuration%" == "" (
set Configuration=Debug
)
-cd IL2C.Runtime
+cd src\IL2C.Runtime
if exist build.cmake (
move build.cmake build.cmake.old
@@ -50,7 +50,7 @@ echo.
mkdir msvc-win-win32-rts-%Configuration%
cd msvc-win-win32-rts-%Configuration%
-cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=Win32 -DRUNTIMELIB=rts -DCONFIGURATION=%Configuration% ../..
+cmake -G "Visual Studio 17 2022" -A Win32 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=Win32 -DRUNTIMELIB=rts -DCONFIGURATION=%Configuration% ../..
if errorlevel 1 (
exit /b %errorlevel%
)
@@ -73,7 +73,7 @@ echo.
mkdir msvc-win-x64-rts-%Configuration%
cd msvc-win-x64-rts-%Configuration%
-cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=x64 -DRUNTIMELIB=rts -DCONFIGURATION=%Configuration% ../..
+cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=x64 -DRUNTIMELIB=rts -DCONFIGURATION=%Configuration% ../..
if errorlevel 1 (
exit /b %errorlevel%
)
@@ -96,7 +96,7 @@ echo.
mkdir msvc-win-win32-rtd-%Configuration%
cd msvc-win-win32-rtd-%Configuration%
-cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=Win32 -DRUNTIMELIB=rtd -DCONFIGURATION=%Configuration% ../..
+cmake -G "Visual Studio 17 2022" -A Win32 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=Win32 -DRUNTIMELIB=rtd -DCONFIGURATION=%Configuration% ../..
if errorlevel 1 (
exit /b %errorlevel%
)
@@ -119,7 +119,7 @@ echo.
mkdir msvc-win-x64-rtd-%Configuration%
cd msvc-win-x64-rtd-%Configuration%
-cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=x64 -DRUNTIMELIB=rtd -DCONFIGURATION=%Configuration% ../..
+cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-win.cmake -DPLATFORM=x64 -DRUNTIMELIB=rtd -DCONFIGURATION=%Configuration% ../..
if errorlevel 1 (
exit /b %errorlevel%
)
@@ -142,7 +142,7 @@ echo.
mkdir msvc-uefi-win32-%Configuration%
cd msvc-uefi-win32-%Configuration%
-cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-uefi.cmake -DPLATFORM=Win32 -DCONFIGURATION=%Configuration% ../..
+cmake -G "Visual Studio 17 2022" -A Win32 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-uefi.cmake -DPLATFORM=Win32 -DCONFIGURATION=%Configuration% ../..
if errorlevel 1 (
exit /b %errorlevel%
)
@@ -165,7 +165,7 @@ echo.
mkdir msvc-uefi-x64-%Configuration%
cd msvc-uefi-x64-%Configuration%
-cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-uefi.cmake -DPLATFORM=x64 -DCONFIGURATION=%Configuration% ../..
+cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=../../cmake/msvc-uefi.cmake -DPLATFORM=x64 -DCONFIGURATION=%Configuration% ../..
if errorlevel 1 (
exit /b %errorlevel%
)
diff --git a/build-runtime.sh b/build-runtime.sh
index 8b9ffd5a..89ebf8d8 100755
--- a/build-runtime.sh
+++ b/build-runtime.sh
@@ -8,7 +8,7 @@ else
Configuration=$1
fi
-cd IL2C.Runtime
+cd src/IL2C.Runtime
rm -rf build.cmake
diff --git a/docs/supported-opcodes.md b/docs/supported-opcodes.md
index a425067a..279b9f8d 100644
--- a/docs/supported-opcodes.md
+++ b/docs/supported-opcodes.md
@@ -1,7 +1,7 @@
# Supported IL opcodes
* Number of opcode implementations: 140 / 219
-* Number of opcode tests: 929 [81 / 219]
+* Number of opcode tests: 931 [81 / 219]
OpCode | Binary | Implement | Test | ILConverter
|:---|:---|:---|:---|:---|
@@ -38,7 +38,7 @@ OpCode | Binary | Implement | Test | ILConverter
| [brfalse.s](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.brfalse_s) | 0x2c | Implemented | [Test [10]](../tests/IL2C.Core.Test.ILConverters/Brfalse_s) | IL2C.ILConverters.Brfalse_sConverter |
| [brtrue](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.brtrue) | 0x3a | Implemented | [Test [10]](../tests/IL2C.Core.Test.ILConverters/Brtrue) | IL2C.ILConverters.BrtrueConverter |
| [brtrue.s](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.brtrue_s) | 0x2d | Implemented | [Test [10]](../tests/IL2C.Core.Test.ILConverters/Brtrue_s) | IL2C.ILConverters.Brtrue_sConverter |
-| [call](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.call) | 0x28 | Implemented | [Test [17]](../tests/IL2C.Core.Test.ILConverters/Call) | IL2C.ILConverters.CallConverter |
+| [call](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.call) | 0x28 | Implemented | [Test [19]](../tests/IL2C.Core.Test.ILConverters/Call) | IL2C.ILConverters.CallConverter |
| [calli](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.calli) | 0x29 | | | |
| [callvirt](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.callvirt) | 0x6f | Implemented | [Test [23]](../tests/IL2C.Core.Test.ILConverters/Callvirt) | IL2C.ILConverters.CallvirtConverter |
| [castclass](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes.castclass) | 0x74 | Implemented | | IL2C.ILConverters.CastclassConverter |
diff --git a/il2c.pack.sln b/il2c.pack.sln
index 1c40fd9d..8cc31959 100644
--- a/il2c.pack.sln
+++ b/il2c.pack.sln
@@ -1,11 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29306.81
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C", "IL2C\IL2C.csproj", "{2CBC90EC-5581-452F-8231-086E4553D20E}"
- ProjectSection(ProjectDependencies) = postProject
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5} = {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}
- EndProjectSection
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Build", "src\IL2C.Build\IL2C.Build.csproj", "{2CBC90EC-5581-452F-8231-086E4553D20E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D105E6CD-626A-4C04-8AF6-0AA34A4E9CF4}"
ProjectSection(SolutionItems) = preProject
@@ -15,27 +12,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
pack.sh = pack.sh
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core", "IL2C.Core\IL2C.Core.csproj", "{678EFB0E-BC0A-4749-AD48-079F98D9468D}"
- ProjectSection(ProjectDependencies) = postProject
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5} = {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}
- EndProjectSection
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core", "src\IL2C.Core\IL2C.Core.csproj", "{678EFB0E-BC0A-4749-AD48-079F98D9468D}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Tasks", "IL2C.Tasks\IL2C.Tasks.csproj", "{A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}"
- ProjectSection(ProjectDependencies) = postProject
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5} = {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}
- EndProjectSection
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IL2C.Runtime", "src\IL2C.Runtime\IL2C.Runtime.vcxproj", "{182A62A4-47AC-4290-8EA5-250AE8131613}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IL2C.Runtime", "IL2C.Runtime\IL2C.Runtime.vcxproj", "{182A62A4-47AC-4290-8EA5-250AE8131613}"
- ProjectSection(ProjectDependencies) = postProject
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5} = {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}
- EndProjectSection
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Interop", "src\IL2C.Interop\IL2C.Interop.csproj", "{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Interop", "IL2C.Interop\IL2C.Interop.csproj", "{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}"
- ProjectSection(ProjectDependencies) = postProject
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5} = {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}
- EndProjectSection
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{726D7AE4-C17F-4530-9D6B-53B517DCA037}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArtifactCollector", "misc\ArtifactCollector\ArtifactCollector.csproj", "{F0FAC02F-7F91-4ABB-8552-F037803523EE}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArtifactCollector", "ArtifactCollector\ArtifactCollector.csproj", "{EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Toolchain.gcc4.mingw32", "misc\IL2C.Toolchain.gcc4.mingw32\IL2C.Toolchain.gcc4.mingw32.csproj", "{9F4783AA-5C0B-446D-952E-3062A380D00B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -51,24 +38,28 @@ Global
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Release|Any CPU.Build.0 = Release|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Release|Any CPU.Build.0 = Release|Any CPU
{182A62A4-47AC-4290-8EA5-250AE8131613}.Debug|Any CPU.ActiveCfg = Debug|x64
{182A62A4-47AC-4290-8EA5-250AE8131613}.Release|Any CPU.ActiveCfg = Release|x64
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}.Release|Any CPU.Build.0 = Release|Any CPU
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EA6C4A63-B6AB-4AAD-98FA-FF102227EAB5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F0FAC02F-7F91-4ABB-8552-F037803523EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F0FAC02F-7F91-4ABB-8552-F037803523EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F0FAC02F-7F91-4ABB-8552-F037803523EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F0FAC02F-7F91-4ABB-8552-F037803523EE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9F4783AA-5C0B-446D-952E-3062A380D00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9F4783AA-5C0B-446D-952E-3062A380D00B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9F4783AA-5C0B-446D-952E-3062A380D00B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9F4783AA-5C0B-446D-952E-3062A380D00B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {F0FAC02F-7F91-4ABB-8552-F037803523EE} = {726D7AE4-C17F-4530-9D6B-53B517DCA037}
+ {9F4783AA-5C0B-446D-952E-3062A380D00B} = {726D7AE4-C17F-4530-9D6B-53B517DCA037}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4628360-6C13-42D4-9011-6E43A3A0777C}
EndGlobalSection
diff --git a/il2c.sln b/il2c.sln
index 0ca9ebe5..5d5bebed 100644
--- a/il2c.sln
+++ b/il2c.sln
@@ -1,14 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29306.81
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C", "IL2C\IL2C.csproj", "{2CBC90EC-5581-452F-8231-086E4553D20E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Build", "src\IL2C.Build\IL2C.Build.csproj", "{2CBC90EC-5581-452F-8231-086E4553D20E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D105E6CD-626A-4C04-8AF6-0AA34A4E9CF4}"
ProjectSection(SolutionItems) = preProject
+ .gitattributes = .gitattributes
.gitignore = .gitignore
build-runtime.bat = build-runtime.bat
build-runtime.sh = build-runtime.sh
+ Directory.Build.props = Directory.Build.props
+ src\Directory.Build.props = src\Directory.Build.props
il2c.sln.licenseheader = il2c.sln.licenseheader
init-tools.bat = init-tools.bat
init-tools.sh = init-tools.sh
@@ -19,20 +22,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core", "IL2C.Core\IL2C.Core.csproj", "{678EFB0E-BC0A-4749-AD48-079F98D9468D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core", "src\IL2C.Core\IL2C.Core.csproj", "{678EFB0E-BC0A-4749-AD48-079F98D9468D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{5710A57F-57F8-4D50-8C78-82E2DFDCB613}"
+ ProjectSection(SolutionItems) = preProject
+ tests\Directory.Build.props = tests\Directory.Build.props
+ EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Tasks", "IL2C.Tasks\IL2C.Tasks.csproj", "{A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IL2C.Runtime", "IL2C.Runtime\IL2C.Runtime.vcxproj", "{182A62A4-47AC-4290-8EA5-250AE8131613}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IL2C.Runtime", "src\IL2C.Runtime\IL2C.Runtime.vcxproj", "{182A62A4-47AC-4290-8EA5-250AE8131613}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.Fixture", "tests\IL2C.Core.Test.Fixture\IL2C.Core.Test.Fixture.csproj", "{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}"
ProjectSection(ProjectDependencies) = postProject
{182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Interop", "IL2C.Interop\IL2C.Interop.csproj", "{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Interop", "src\IL2C.Interop\IL2C.Interop.csproj", "{854E1ABE-0873-4BDC-8ABF-7F9506DD66DB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{3EBFA913-CF51-4A28-9E4D-73CB5AE27D2F}"
ProjectSection(SolutionItems) = preProject
@@ -52,14 +56,60 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.ILConverters
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.RuntimeSystems", "tests\IL2C.Core.Test.RuntimeSystems\IL2C.Core.Test.RuntimeSystems.csproj", "{E397A251-4373-4A8E-AA13-3891282DEDC7}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArtifactCollector", "ArtifactCollector\ArtifactCollector.csproj", "{DF4432C4-A285-4163-9F95-3A56A2226C9A}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{C26C4683-9840-4307-8774-F1F952E3591B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{21592C48-BEE1-4706-8024-CF7EB0CF8BA7}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-linux.yaml = .github\workflows\build-linux.yaml
.github\workflows\build-windows.yaml = .github\workflows\build-windows.yaml
+ .github\workflows\init-tools-on-ga.sh = .github\workflows\init-tools-on-ga.sh
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{4BC9EFBC-600E-48BF-ADDC-3E573D8315F0}"
+ ProjectSection(SolutionItems) = preProject
+ misc\build-tools-pack.bat = misc\build-tools-pack.bat
+ misc\Directory.Build.props = misc\Directory.Build.props
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArtifactCollector", "misc\ArtifactCollector\ArtifactCollector.csproj", "{C5D17DC3-D27B-4812-8916-49912F82DE0F}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PlayGround", "PlayGround", "{EA30816B-8F8B-4584-9D74-103470BB6C76}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Toolchain.gcc4.mingw32", "misc\IL2C.Toolchain.gcc4.mingw32\IL2C.Toolchain.gcc4.mingw32.csproj", "{BB7FA204-433A-416B-B9D0-9A79DF874284}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculator", "src\PlayGround\Calculator\Calculator.csproj", "{9DFD09E3-FEEE-4865-9743-457A676925C1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BB7FA204-433A-416B-B9D0-9A79DF874284} = {BB7FA204-433A-416B-B9D0-9A79DF874284}
+ {182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
+ {2CBC90EC-5581-452F-8231-086E4553D20E} = {2CBC90EC-5581-452F-8231-086E4553D20E}
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculator.Core", "src\PlayGround\Calculator.Core\Calculator.Core.csproj", "{38BA79E6-9BCD-4C1A-821B-F930249ACE6C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BB7FA204-433A-416B-B9D0-9A79DF874284} = {BB7FA204-433A-416B-B9D0-9A79DF874284}
+ {182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
+ {2CBC90EC-5581-452F-8231-086E4553D20E} = {2CBC90EC-5581-452F-8231-086E4553D20E}
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld", "src\PlayGround\HelloWorld\HelloWorld.csproj", "{6574A947-589C-413D-A866-D312F9CB7DE9}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BB7FA204-433A-416B-B9D0-9A79DF874284} = {BB7FA204-433A-416B-B9D0-9A79DF874284}
+ {182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
+ {2CBC90EC-5581-452F-8231-086E4553D20E} = {2CBC90EC-5581-452F-8231-086E4553D20E}
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShowMessageBoxOnWindows", "src\PlayGround\ShowMessageBoxOnWindows\ShowMessageBoxOnWindows.csproj", "{E7653827-67EF-4561-9809-AB52EA3496E0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BB7FA204-433A-416B-B9D0-9A79DF874284} = {BB7FA204-433A-416B-B9D0-9A79DF874284}
+ {182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
+ {2CBC90EC-5581-452F-8231-086E4553D20E} = {2CBC90EC-5581-452F-8231-086E4553D20E}
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TakeAdvantageWithIL2CInvoke", "src\PlayGround\TakeAdvantageWithIL2CInvoke\TakeAdvantageWithIL2CInvoke.csproj", "{1DCAA734-9274-41FF-A660-2D7B281EF680}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BB7FA204-433A-416B-B9D0-9A79DF874284} = {BB7FA204-433A-416B-B9D0-9A79DF874284}
+ {182A62A4-47AC-4290-8EA5-250AE8131613} = {182A62A4-47AC-4290-8EA5-250AE8131613}
+ {2CBC90EC-5581-452F-8231-086E4553D20E} = {2CBC90EC-5581-452F-8231-086E4553D20E}
EndProjectSection
EndProject
Global
@@ -76,10 +126,6 @@ Global
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{678EFB0E-BC0A-4749-AD48-079F98D9468D}.Release|Any CPU.Build.0 = Release|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A1D40B7C-2F51-43E3-9201-EA8DFFE3B214}.Release|Any CPU.Build.0 = Release|Any CPU
{182A62A4-47AC-4290-8EA5-250AE8131613}.Debug|Any CPU.ActiveCfg = Debug|x64
{182A62A4-47AC-4290-8EA5-250AE8131613}.Release|Any CPU.ActiveCfg = Release|x64
{B0F1010D-8B73-46F7-AF8E-E3C58F68525F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -106,10 +152,34 @@ Global
{E397A251-4373-4A8E-AA13-3891282DEDC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E397A251-4373-4A8E-AA13-3891282DEDC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E397A251-4373-4A8E-AA13-3891282DEDC7}.Release|Any CPU.Build.0 = Release|Any CPU
- {DF4432C4-A285-4163-9F95-3A56A2226C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DF4432C4-A285-4163-9F95-3A56A2226C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DF4432C4-A285-4163-9F95-3A56A2226C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DF4432C4-A285-4163-9F95-3A56A2226C9A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C5D17DC3-D27B-4812-8916-49912F82DE0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C5D17DC3-D27B-4812-8916-49912F82DE0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C5D17DC3-D27B-4812-8916-49912F82DE0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C5D17DC3-D27B-4812-8916-49912F82DE0F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BB7FA204-433A-416B-B9D0-9A79DF874284}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BB7FA204-433A-416B-B9D0-9A79DF874284}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BB7FA204-433A-416B-B9D0-9A79DF874284}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BB7FA204-433A-416B-B9D0-9A79DF874284}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9DFD09E3-FEEE-4865-9743-457A676925C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9DFD09E3-FEEE-4865-9743-457A676925C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9DFD09E3-FEEE-4865-9743-457A676925C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9DFD09E3-FEEE-4865-9743-457A676925C1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {38BA79E6-9BCD-4C1A-821B-F930249ACE6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {38BA79E6-9BCD-4C1A-821B-F930249ACE6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {38BA79E6-9BCD-4C1A-821B-F930249ACE6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {38BA79E6-9BCD-4C1A-821B-F930249ACE6C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6574A947-589C-413D-A866-D312F9CB7DE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6574A947-589C-413D-A866-D312F9CB7DE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6574A947-589C-413D-A866-D312F9CB7DE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6574A947-589C-413D-A866-D312F9CB7DE9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E7653827-67EF-4561-9809-AB52EA3496E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E7653827-67EF-4561-9809-AB52EA3496E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E7653827-67EF-4561-9809-AB52EA3496E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E7653827-67EF-4561-9809-AB52EA3496E0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1DCAA734-9274-41FF-A660-2D7B281EF680}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DCAA734-9274-41FF-A660-2D7B281EF680}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1DCAA734-9274-41FF-A660-2D7B281EF680}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1DCAA734-9274-41FF-A660-2D7B281EF680}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -122,6 +192,13 @@ Global
{E397A251-4373-4A8E-AA13-3891282DEDC7} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{C26C4683-9840-4307-8774-F1F952E3591B} = {D105E6CD-626A-4C04-8AF6-0AA34A4E9CF4}
{21592C48-BEE1-4706-8024-CF7EB0CF8BA7} = {C26C4683-9840-4307-8774-F1F952E3591B}
+ {C5D17DC3-D27B-4812-8916-49912F82DE0F} = {4BC9EFBC-600E-48BF-ADDC-3E573D8315F0}
+ {BB7FA204-433A-416B-B9D0-9A79DF874284} = {4BC9EFBC-600E-48BF-ADDC-3E573D8315F0}
+ {9DFD09E3-FEEE-4865-9743-457A676925C1} = {EA30816B-8F8B-4584-9D74-103470BB6C76}
+ {38BA79E6-9BCD-4C1A-821B-F930249ACE6C} = {EA30816B-8F8B-4584-9D74-103470BB6C76}
+ {6574A947-589C-413D-A866-D312F9CB7DE9} = {EA30816B-8F8B-4584-9D74-103470BB6C76}
+ {E7653827-67EF-4561-9809-AB52EA3496E0} = {EA30816B-8F8B-4584-9D74-103470BB6C76}
+ {1DCAA734-9274-41FF-A660-2D7B281EF680} = {EA30816B-8F8B-4584-9D74-103470BB6C76}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4628360-6C13-42D4-9011-6E43A3A0777C}
diff --git a/il2c.sln.licenseheader b/il2c.sln.licenseheader
index c62d624b..b17dd952 100644
--- a/il2c.sln.licenseheader
+++ b/il2c.sln.licenseheader
@@ -1,20 +1,10 @@
extensions: designer.cs generated.cs
-extensions: .cs .il .cpp .h
-/////////////////////////////////////////////////////////////////////////////////////////////////
+extensions: .cs .il .c .cpp .h
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
diff --git a/init-tools.bat b/init-tools.bat
index 3b65a587..89b7801a 100644
--- a/init-tools.bat
+++ b/init-tools.bat
@@ -7,18 +7,18 @@ mkdir toolchain
cd toolchain
-curl -L -O https://github.com/kekyo/IL2C/releases/download/IL2C-toolchain-gcc4-mingw32-3/IL2C-toolchain-gcc4-mingw32-3.exe
+curl -L -O https://github.com/kekyo/IL2C/releases/download/IL2C-toolchain-gcc4-mingw32-4/IL2C-toolchain-gcc4-mingw32-4.exe
if errorlevel 1 (
exit /b %errorlevel%
)
rem It zipped by 7z sfx.
-IL2C-toolchain-gcc4-mingw32-3.exe
+IL2C-toolchain-gcc4-mingw32-4.exe
if errorlevel 1 (
exit /b %errorlevel%
)
-del /q IL2C-toolchain-gcc4-mingw32-3.exe
+del /q IL2C-toolchain-gcc4-mingw32-4.exe
if errorlevel 1 (
exit /b %errorlevel%
)
diff --git a/init-tools.sh b/init-tools.sh
index 56e6318e..59cc3a9e 100755
--- a/init-tools.sh
+++ b/init-tools.sh
@@ -1,13 +1,23 @@
#!/bin/sh
-# Required: .NET 5.0 SDK
-# https://dotnet.microsoft.com/download/dotnet/5.0
+# `mono-devel` is required only running regression test. (net48 platform)
echo "Setup native binary toolchain ..."
-apt update -y
-apt install build-essential cmake ninja-build mono-devel -y
+sudo apt update -y
+sudo apt install build-essential cmake ninja-build mono-devel -y
-# `mono-devel` is required only running regression test. (net48 platform)
+#curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 2.1
+#curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 2.2
+#curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 3.1
+#curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 5.0
+#curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 6.0
+
+#export PATH=$HOME/.dotnet:$PATH
+#export DOTNET_HOME=$HOME/.dotnet
+
+#echo "You have to set environment variables in your sh profile:"
+
+#echo "export PATH=$HOME/.dotnet:$PATH"
+#echo "export DOTNET_HOME=$HOME/.dotnet"
-chmod 755 *.sh
diff --git a/ArtifactCollector/.gitignore b/misc/ArtifactCollector/.gitignore
similarity index 100%
rename from ArtifactCollector/.gitignore
rename to misc/ArtifactCollector/.gitignore
diff --git a/ArtifactCollector/Arduino.properties b/misc/ArtifactCollector/Arduino.properties
similarity index 100%
rename from ArtifactCollector/Arduino.properties
rename to misc/ArtifactCollector/Arduino.properties
diff --git a/misc/ArtifactCollector/ArtifactCollector.csproj b/misc/ArtifactCollector/ArtifactCollector.csproj
new file mode 100644
index 00000000..f3b969b6
--- /dev/null
+++ b/misc/ArtifactCollector/ArtifactCollector.csproj
@@ -0,0 +1,25 @@
+
+
+
+ net45
+ Exe
+
+ ArtifactCollector
+ IL2C.ArtifactCollector
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ArtifactCollector/Collectors.cs b/misc/ArtifactCollector/Collectors.cs
similarity index 92%
rename from ArtifactCollector/Collectors.cs
rename to misc/ArtifactCollector/Collectors.cs
index 5dca0cc8..42a4ca84 100644
--- a/ArtifactCollector/Collectors.cs
+++ b/misc/ArtifactCollector/Collectors.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
@@ -148,6 +138,7 @@ public static async Task BuildNuspecAndCollectArtifactsAsync(
"pack",
"-Version", versionString,
"-NoPackageAnalysis",
+ "-Verbosity", "detailed",
"-Prop", $"Configuration=Release",
"-Prop", $"BuildIdentifier={buildIdentifier}",
"-OutputDirectory", $"\"{outputDirectory}\"",
@@ -232,13 +223,13 @@ await CopyResourceWithReplacementsAsync(
{ "{semver2}", typeof(Program).Assembly.GetCustomAttribute().InformationalVersion }
});
- var fromIncludeDir = Path.Combine(solutionDir, "IL2C.Runtime", "include");
+ var fromIncludeDir = Path.Combine(solutionDir, "src", "IL2C.Runtime", "include");
var toIncludeDir = Path.Combine(arduinoBasePath, "include");
await Task.WhenAll(
Directory.EnumerateFiles(fromIncludeDir, "*.h", SearchOption.AllDirectories).
Select(path => CopyFileAsync(path, Path.Combine(toIncludeDir, path.Substring(fromIncludeDir.Length + 1)))));
- var fromSrcDir = Path.Combine(solutionDir, "IL2C.Runtime", "src");
+ var fromSrcDir = Path.Combine(solutionDir, "src", "IL2C.Runtime", "src");
var toSrcDir = Path.Combine(arduinoBasePath, "src");
await Task.WhenAll(
Directory.EnumerateFiles(fromSrcDir, "*.c", SearchOption.AllDirectories).
diff --git a/ArtifactCollector/Executor.cs b/misc/ArtifactCollector/Executor.cs
similarity index 75%
rename from ArtifactCollector/Executor.cs
rename to misc/ArtifactCollector/Executor.cs
index 4a2cb547..f85d8c7e 100644
--- a/ArtifactCollector/Executor.cs
+++ b/misc/ArtifactCollector/Executor.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/ArtifactCollector/Program.cs b/misc/ArtifactCollector/Program.cs
similarity index 84%
rename from ArtifactCollector/Program.cs
rename to misc/ArtifactCollector/Program.cs
index db81d92e..a8fb966e 100644
--- a/ArtifactCollector/Program.cs
+++ b/misc/ArtifactCollector/Program.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
@@ -66,16 +56,17 @@ private static async Task MainAsync(string[] args)
SelectMany(p => Directory.GetFiles(Path.Combine(solutionDir, p), "*.csproj")).
ToArray();
+ var nuspecPaths = dirNames.
+ SelectMany(p => Directory.GetFiles(Path.Combine(solutionDir, p), "*.nuspec")).
+ Where(p => !csprojPaths.Any(csprojPath => Path.GetDirectoryName(csprojPath) == Path.GetDirectoryName(p))).
+ ToArray();
+
WriteLine("\r\n/////////////////////////////////////////////////////\r\n// Collect for {0}\r\n\r\n",
string.Join(", ", csprojPaths.Select(p => Path.GetFileName(p))));
await Collectors.BuildCsprojAndCollectArtifactsAsync(
solutionDir, artifactsDir, buildIdentifier, csprojPaths);
- var nuspecPaths = dirNames.
- SelectMany(p => Directory.GetFiles(Path.Combine(solutionDir, p), "*.nuspec")).
- ToArray();
-
WriteLine("\r\n/////////////////////////////////////////////////////\r\n// Collect for {0}\r\n\r\n",
string.Join(", ", nuspecPaths.Select(p => Path.GetFileName(p))));
diff --git a/ArtifactCollector/Properties/launchSettings.json b/misc/ArtifactCollector/Properties/launchSettings.json
similarity index 100%
rename from ArtifactCollector/Properties/launchSettings.json
rename to misc/ArtifactCollector/Properties/launchSettings.json
diff --git a/misc/Directory.Build.props b/misc/Directory.Build.props
new file mode 100644
index 00000000..6744f5ad
--- /dev/null
+++ b/misc/Directory.Build.props
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ false
+ portable
+ False
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/.gitignore b/misc/IL2C.Toolchain.gcc4.mingw32/.gitignore
new file mode 100644
index 00000000..bc6998b1
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/.gitignore
@@ -0,0 +1,2 @@
+7z/
+gcc4/
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.csproj b/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.csproj
new file mode 100644
index 00000000..4df2000e
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.csproj
@@ -0,0 +1,19 @@
+
+
+ netstandard2.0
+ IL2C.Toolchain.gcc4.mingw32.nuspec
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.nuspec b/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.nuspec
new file mode 100644
index 00000000..a61264e3
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.nuspec
@@ -0,0 +1,30 @@
+
+
+
+ IL2C.Toolchain.gcc4.mingw32
+ $PackageVersion$
+ Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+ Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+ false
+ Apache-2.0 AND GPL-2.0-only
+ IL2C.100.png
+ https://github.com/kekyo/IL2C.git
+ A translator implementation of .NET intermediate language to C language.
+ Copyright (c) Kouji Matsui
+ il2c native cil msil translate transpile aot ecma335 c c++ win32 uefi wdm multi-platform systems-programming
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.packed.exe b/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.packed.exe
new file mode 100644
index 00000000..25c16132
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/IL2C.Toolchain.gcc4.mingw32.packed.exe
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4a92ed98ba3b1e896f99e8e7ae236ee97d77adfd872075ea19b54ae00ace4366
+size 18929030
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/README.md b/misc/IL2C.Toolchain.gcc4.mingw32/README.md
new file mode 100644
index 00000000..b3826095
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/README.md
@@ -0,0 +1,32 @@
+# What's this?
+
+This is part of [IL2C](https://github.com/kekyo/IL2C) toolchain distribution file.
+It contains GNU compiler collection built on MinGW environment.
+
+## License
+
+IL2C is under Apache-v2, but there are under GPL-v2 inside `IL2C-toolchain-gcc4-mingw32-4-base.exe` (7zip sfx).
+
+These files come from:
+
+```csharp
+mingwBaseUrl = "https://jaist.dl.sourceforge.net/project/mingw/MinGW";
+gccRequirementUrls =
+ mingwBaseUrl + "/Base/binutils/binutils-2.28/binutils-2.28-1-mingw32-bin.tar.xz",
+ mingwBaseUrl + "/Base/mingwrt/mingwrt-3.20/mingwrt-3.20-2-mingw32-dev.tar.lzma",
+ mingwBaseUrl + "/Base/mingwrt/mingwrt-3.20/mingwrt-3.20-2-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/w32api/w32api-3.17/w32api-3.17-2-mingw32-dev.tar.lzma",
+ mingwBaseUrl + "/Base/mpc/mpc-1.0.1-2/mpc-1.0.1-2-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/mpfr/mpfr-3.1.2-2/mpfr-3.1.2-2-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/gmp/gmp-5.1.2/gmp-5.1.2-1-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/libiconv/libiconv-1.14-3/libiconv-1.14-3-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/pthreads-w32/pthreads-w32-2.9.1/pthreads-w32-2.9.1-1-mingw32-dev.tar.lzma",
+ mingwBaseUrl + "/Base/pthreads-w32/pthreads-w32-2.9.1/pthreads-w32-2.9.1-1-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/zlib/zlib-1.2.8/zlib-1.2.8-1-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/gettext/gettext-0.18.3.1-1/gettext-0.18.3.1-1-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-core-4.8.1-4-mingw32-bin.tar.lzma",
+ mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-core-4.8.1-4-mingw32-dev.tar.lzma",
+ mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-core-4.8.1-4-mingw32-dll.tar.lzma",
+ mingwBaseUrl + "/Extension/make/make-3.82-mingw32/make-3.82-5-mingw32-bin.tar.lzma",
+ mingwBaseUrl + "/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma",
+```
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/build/IL2C.Toolchain.gcc4.mingw32.props b/misc/IL2C.Toolchain.gcc4.mingw32/build/IL2C.Toolchain.gcc4.mingw32.props
new file mode 100644
index 00000000..2522a1ef
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/build/IL2C.Toolchain.gcc4.mingw32.props
@@ -0,0 +1,27 @@
+
+
+
+
+ <_IL2C_GCC4_MinGW32_NativeToolchainBasePath>$(MSBuildThisFileDirectory)..
+ <_IL2C_GCC4_MinGW32_NativeToolchainName>gcc4
+ <_IL2C_GCC4_MinGW32_NativeToolchainPath>$([System.IO.Path]::Combine('$(_IL2C_GCC4_MinGW32_NativeToolchainBasePath)','$(_IL2C_GCC4_MinGW32_NativeToolchainName)'))
+
+ <_IL2C_GCC4_MinGW32_PackedNativeToolchainArchivePath>$([System.IO.Path]::Combine('$(_IL2C_GCC4_MinGW32_NativeToolchainBasePath)','IL2C.Toolchain.gcc4.mingw32.packed.exe'))
+ <_IL2C_WinExeMainTemplatePath>$([System.IO.Path]::Combine('$(_IL2C_GCC4_MinGW32_NativeToolchainBasePath)','src','_main_winexe_template.c_'))
+
+ $([System.IO.Path]::Combine('$(_IL2C_GCC4_MinGW32_NativeToolchainPath)','bin','gcc.exe'))
+ -pipe -ggdb -static-libgcc -Wall -Werror -Wstrict-prototypes -Wno-unused
+ -D_WIN32 -Wl,--enable-stdcall-fixup -Wl,--add-stdcall-alias
+ $([System.IO.Path]::Combine('$(_IL2C_GCC4_MinGW32_NativeToolchainPath)','bin','ar.exe'))
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/build/IL2C.Toolchain.gcc4.mingw32.targets b/misc/IL2C.Toolchain.gcc4.mingw32/build/IL2C.Toolchain.gcc4.mingw32.targets
new file mode 100644
index 00000000..717c86f5
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/build/IL2C.Toolchain.gcc4.mingw32.targets
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+ $(_IL2C_GCC_DebugFlags)
+ $(_IL2C_GCC_ReleaseFlags)
+ $(_IL2C_GCC_DisableOptimizingFlags)
+ $(_IL2C_GCC_EnableOptimizingFlags)
+ $(_IL2C_WinExeMainTemplatePath)
+ $(IL2CNativeCompilerRequiredFlags) -mwindows
+
+
+
+
+
+
+
+
+ <_IL2C_TemporaryDirPathForExtractionGCC4PackedToolchainArchive>$([System.IO.Path]::Combine('$(_IL2C_GCC4_MinGW32_NativeToolchainBasePath)','$([System.Guid]::NewGuid().ToString())'))
+
+
+
+
+ <_IL2C_Build_MoveDirectory
+ From="$([System.IO.Path]::Combine('$(_IL2C_TemporaryDirPathForExtractionGCC4PackedToolchainArchive)','$(_IL2C_GCC4_MinGW32_NativeToolchainName)'))"
+ To="$(_IL2C_GCC4_MinGW32_NativeToolchainPath)" />
+
+
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/buildMultiTargeting/IL2C.Toolchain.gcc4.mingw32.props b/misc/IL2C.Toolchain.gcc4.mingw32/buildMultiTargeting/IL2C.Toolchain.gcc4.mingw32.props
new file mode 100644
index 00000000..94a68885
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/buildMultiTargeting/IL2C.Toolchain.gcc4.mingw32.props
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/buildMultiTargeting/IL2C.Toolchain.gcc4.mingw32.targets b/misc/IL2C.Toolchain.gcc4.mingw32/buildMultiTargeting/IL2C.Toolchain.gcc4.mingw32.targets
new file mode 100644
index 00000000..0da6db5b
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/buildMultiTargeting/IL2C.Toolchain.gcc4.mingw32.targets
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/pack7z.bat b/misc/IL2C.Toolchain.gcc4.mingw32/pack7z.bat
new file mode 100644
index 00000000..0b7958ff
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/pack7z.bat
@@ -0,0 +1,49 @@
+@echo off
+
+rem ========================================================
+rem Download preconfigured gcc4 toolchain from GitHub.
+rem It contains:
+rem -----------------
+rem bsdTarUrl = mingwBaseUrl + "/Extension/bsdtar/basic-bsdtar-2.8.3-1/basic-bsdtar-2.8.3-1-mingw32-bin.zip";
+rem mingwBaseUrl = "https://jaist.dl.sourceforge.net/project/mingw/MinGW";
+rem gccRequirementUrls =
+rem mingwBaseUrl + "/Base/binutils/binutils-2.28/binutils-2.28-1-mingw32-bin.tar.xz",
+rem mingwBaseUrl + "/Base/mingwrt/mingwrt-3.20/mingwrt-3.20-2-mingw32-dev.tar.lzma",
+rem mingwBaseUrl + "/Base/mingwrt/mingwrt-3.20/mingwrt-3.20-2-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/w32api/w32api-3.17/w32api-3.17-2-mingw32-dev.tar.lzma",
+rem mingwBaseUrl + "/Base/mpc/mpc-1.0.1-2/mpc-1.0.1-2-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/mpfr/mpfr-3.1.2-2/mpfr-3.1.2-2-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/gmp/gmp-5.1.2/gmp-5.1.2-1-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/libiconv/libiconv-1.14-3/libiconv-1.14-3-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/pthreads-w32/pthreads-w32-2.9.1/pthreads-w32-2.9.1-1-mingw32-dev.tar.lzma",
+rem mingwBaseUrl + "/Base/pthreads-w32/pthreads-w32-2.9.1/pthreads-w32-2.9.1-1-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/zlib/zlib-1.2.8/zlib-1.2.8-1-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/gettext/gettext-0.18.3.1-1/gettext-0.18.3.1-1-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-core-4.8.1-4-mingw32-bin.tar.lzma",
+rem mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-core-4.8.1-4-mingw32-dev.tar.lzma",
+rem mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-core-4.8.1-4-mingw32-dll.tar.lzma",
+rem // Require C++
+rem //mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-c++-4.8.1-4-mingw32-bin.tar.lzma",
+rem //mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-c++-4.8.1-4-mingw32-dev.tar.lzma",
+rem //mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-c++-4.8.1-4-mingw32-dll.tar.lzma",
+rem mingwBaseUrl + "/Extension/make/make-3.82-mingw32/make-3.82-5-mingw32-bin.tar.lzma",
+rem mingwBaseUrl + "/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma",
+
+curl -L -O https://github.com/kekyo/IL2C/releases/download/IL2C-toolchain-gcc4-mingw32-3/7z-19.00.exe
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
+
+7z-19.00.exe
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
+
+del /q 7z-19.00.exe
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
+
+7z\7za.exe a -mx9 -sfx IL2C.Toolchain.gcc4.mingw32.packed.exe gcc4
+
+rmdir /s/q 7z
diff --git a/misc/IL2C.Toolchain.gcc4.mingw32/src/_main_winexe_template.c_ b/misc/IL2C.Toolchain.gcc4.mingw32/src/_main_winexe_template.c_
new file mode 100644
index 00000000..f24c0567
--- /dev/null
+++ b/misc/IL2C.Toolchain.gcc4.mingw32/src/_main_winexe_template.c_
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include
+#include
+#include <{headerName}>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ ((void)hInstance);
+ ((void)hPrevInstance);
+ ((void)lpCmdLine);
+ ((void)nCmdShow);
+
+#if defined(_MSC_VER) && defined(_WIN32) && defined(_DEBUG)
+ _crtBreakAlloc = -1;
+#endif
+
+ il2c_initialize();
+
+#if {mainIsVoid}
+ {mainSymbol}();
+
+ il2c_shutdown();
+ return 0;
+#else
+ const int r = {mainSymbol}();
+
+ il2c_shutdown();
+ return r;
+#endif
+}
diff --git a/build-tools-pack.bat b/misc/build-tools-pack.bat
similarity index 95%
rename from build-tools-pack.bat
rename to misc/build-tools-pack.bat
index 4b8f10f5..e6d67f3b 100644
--- a/build-tools-pack.bat
+++ b/misc/build-tools-pack.bat
@@ -4,8 +4,8 @@ rem ========================================================
rem Download preconfigured gcc4 toolchain from GitHub.
rem It contains:
rem -----------------
-rem mingwBaseUrl = "https://jaist.dl.sourceforge.net/project/mingw/MinGW";
rem bsdTarUrl = mingwBaseUrl + "/Extension/bsdtar/basic-bsdtar-2.8.3-1/basic-bsdtar-2.8.3-1-mingw32-bin.zip";
+rem mingwBaseUrl = "https://jaist.dl.sourceforge.net/project/mingw/MinGW";
rem gccRequirementUrls =
rem mingwBaseUrl + "/Base/binutils/binutils-2.28/binutils-2.28-1-mingw32-bin.tar.xz",
rem mingwBaseUrl + "/Base/mingwrt/mingwrt-3.20/mingwrt-3.20-2-mingw32-dev.tar.lzma",
@@ -28,10 +28,11 @@ rem //mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-c++-4.8.1-4-mingw32
rem //mingwBaseUrl + "/Base/gcc/Version4/gcc-4.8.1-4/gcc-c++-4.8.1-4-mingw32-dll.tar.lzma",
rem mingwBaseUrl + "/Extension/make/make-3.82-mingw32/make-3.82-5-mingw32-bin.tar.lzma",
rem mingwBaseUrl + "/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma",
-rem "https://cmake.org/files/v3.17/cmake-3.17.3-win32-x86.zip",
+rem builderRequirementUrls =
+rem "https://cmake.org/files/v3.23/cmake-3.23.1-windows-i386.zip",
rem "https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip"
-cd toolchain
+cd ..\toolchain
curl -L -O https://github.com/kekyo/IL2C/releases/download/IL2C-toolchain-gcc4-mingw32-3/7z-19.00.exe
if errorlevel 1 (
@@ -48,8 +49,8 @@ if errorlevel 1 (
exit /b %errorlevel%
)
-7z\7za.exe a -mx9 -sfx ..\artifacts\IL2C-toolchain-gcc4-mingw32-3.exe gcc4
+7z\7za.exe a -mx9 -sfx ..\artifacts\IL2C-toolchain-gcc4-mingw32-4.exe gcc4
rem ========================================================
-cd ..
+cd ..\misc
diff --git a/pack.bat b/pack.bat
index 2ffbd42a..558db656 100644
--- a/pack.bat
+++ b/pack.bat
@@ -2,7 +2,7 @@
setlocal enabledelayedexpansion
set TOOLCHAINPATH=%~dp0toolchain\gcc4
-set CMAKE_ROOT=%TOOLCHAINPATH%\share\cmake-3.17
+set CMAKE_ROOT=%TOOLCHAINPATH%\share\cmake-3.23
if not exist %TOOLCHAINPATH% (
echo Native toolchain not found.
@@ -15,12 +15,6 @@ if "%BuildIdentifier%" == "" (
set BuildIdentifier=manually
)
-rem if not exist ArtifactCollector\ArtifactCollector.exe (
-rem echo ArtifactCollector not found.
-rem echo Build il2c.sln first.
-rem exit /b 1
-rem )
-
rem =========================================
call build-runtime.bat Debug
@@ -42,7 +36,7 @@ echo ///////////////////////////////////////////////
echo // Collects artifacts.
echo.
-ArtifactCollector\ArtifactCollector.exe . .\artifacts "%BuildIdentifier%" IL2C.Interop IL2C.Core IL2C.Tasks IL2C.Runtime
+misc\ArtifactCollector\ArtifactCollector.exe . .\artifacts "%BuildIdentifier%" src\IL2C.Interop src\IL2C.Core src\IL2C.Build src\IL2C.Runtime misc\IL2C.Toolchain.gcc4.mingw32
rem =========================================
diff --git a/pack.sh b/pack.sh
index c55b874f..291ce310 100755
--- a/pack.sh
+++ b/pack.sh
@@ -10,31 +10,31 @@ echo "///////////////////////////////////////////////"
echo "// Build IL2C.Interop"
echo ""
-dotnet pack --configuration Release --include-symbols -p:VersionPrefix=${VERSION} IL2C.Interop/IL2C.Interop.csproj
-cp IL2C.Interop/bin/Release/IL2C.Interop.${VERSION}.symbols.nupkg artifacts/IL2C.Interop.${VERSION}.nupkg
+dotnet pack --configuration Release src/IL2C.Interop/IL2C.Interop.csproj
+cp src/IL2C.Interop/bin/Release/IL2C.Interop.*.nupkg artifacts/
echo ""
echo "///////////////////////////////////////////////"
echo "// Build IL2C.Core"
echo ""
-dotnet pack --configuration Release --include-symbols -p:VersionPrefix=${VERSION} IL2C.Core/IL2C.Core.csproj
-cp IL2C.Core/bin/Release/IL2C.Core.${VERSION}.symbols.nupkg artifacts/IL2C.Core.${VERSION}.nupkg
+dotnet pack --configuration Release src/IL2C.Core/IL2C.Core.csproj
+cp src/IL2C.Core/bin/Release/IL2C.Core.*.nupkg artifacts/
echo ""
echo "///////////////////////////////////////////////"
echo "// Build IL2C.Runtime"
echo ""
-.nuget/nuget pack -Prop version=${VERSION} -OutputDirectory artifacts IL2C.Runtime/IL2C.Runtime.nuspec
+.nuget/nuget pack -Prop version=${VERSION} -OutputDirectory artifacts src/IL2C.Runtime/IL2C.Runtime.nuspec
echo ""
echo "///////////////////////////////////////////////"
echo "// Build IL2C.Build"
echo ""
-dotnet pack --configuration Release --include-symbols -p:VersionPrefix=${VERSION} IL2C.Tasks/IL2C.Tasks.csproj
-cp IL2C.Tasks/bin/Release/IL2C.Build.${VERSION}.symbols.nupkg artifacts/IL2C.Build.${VERSION}.nupkg
+dotnet pack --configuration Release src/IL2C.Build/IL2C.Build.csproj
+cp src/IL2C.Build/bin/Release/IL2C.Build.*.symbols.nupkg artifacts/
echo ""
echo "///////////////////////////////////////////////"
@@ -42,9 +42,9 @@ echo "// Build Arduino library"
echo ""
mkdir artifacts/Arduino
-cp /R IL2C.Runtime/include/*.h artifacts/Arduino/src/
-cp /R IL2C.Runtime/src/*.h artifacts/Arduino/src/
-cp /R IL2C.Runtime/src/*.c artifacts/Arduino/src/
+cp -R src/IL2C.Runtime/include/*.h artifacts/Arduino/src/
+cp -R src/IL2C.Runtime/src/*.h artifacts/Arduino/src/
+cp -R src/IL2C.Runtime/src/*.c artifacts/Arduino/src/
sed 's/{version}/${VERSION}/g' Arduino.properties > artifacts/Arduino/library.properties
diff --git a/samples/Calculator/Calculator.CMake/CMakeLists.txt b/samples/Calculator/Calculator.CMake/CMakeLists.txt
index a3464959..e680d3c1 100644
--- a/samples/Calculator/Calculator.CMake/CMakeLists.txt
+++ b/samples/Calculator/Calculator.CMake/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7)
project(Calculator.CMake C)
-include(${CMAKE_CURRENT_LIST_DIR}/../../../IL2C.Runtime/cmake/${BUILDER}.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/../../../src/IL2C.Runtime/cmake/${BUILDER}.cmake)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../Generated/include)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../Generated/src)
diff --git a/samples/Calculator/Calculator.Core.Tests/Calculator.Core.Tests.csproj b/samples/Calculator/Calculator.Core.Tests/Calculator.Core.Tests.csproj
index 1b49239d..09592032 100644
--- a/samples/Calculator/Calculator.Core.Tests/Calculator.Core.Tests.csproj
+++ b/samples/Calculator/Calculator.Core.Tests/Calculator.Core.Tests.csproj
@@ -1,28 +1,16 @@
- netcoreapp3.1
+ net6.0
Library
- true
- PackageReference
- false
Calculator.Core.Tests
Calculator
- A translator implementation of .NET intermediate language to C language.
- IL2C
- IL2C
- Copyright (c) 2017 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- https://github.com/kekyo/IL2C.git
-
-
-
+
+
+
diff --git a/samples/Calculator/Calculator.Core/Calculator.Core.csproj b/samples/Calculator/Calculator.Core/Calculator.Core.csproj
index b24a93d8..c72bfd15 100644
--- a/samples/Calculator/Calculator.Core/Calculator.Core.csproj
+++ b/samples/Calculator/Calculator.Core/Calculator.Core.csproj
@@ -1,30 +1,42 @@
+
+
+
+
+
+
+
netstandard2.0
- false
- PackageReference
- true
- false
Calculator.Core
Calculator
- A translator implementation of .NET intermediate language to C language.
- IL2C
- IL2C
- Copyright (c) 2017-2019 Kouji Matsui
- A translator implementation of .NET intermediate language to C language.
- Kouji Matsui (@kozy_kekyo)
- Kouji Matsui (@kozy_kekyo)
- git
- https://github.com/kekyo/IL2C.git
-
- $(ProjectDir)../Generated
+
+ ..\..\..\..\Generated
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\..\src\IL2C.Build\bin\$(Configuration)\$(_IL2C_PlatformName)'))
+
diff --git a/samples/Calculator/Calculator.UEFI/Calculator.UEFI.vcxproj b/samples/Calculator/Calculator.UEFI/Calculator.UEFI.vcxproj
index b44921f7..a5bf3bac 100644
--- a/samples/Calculator/Calculator.UEFI/Calculator.UEFI.vcxproj
+++ b/samples/Calculator/Calculator.UEFI/Calculator.UEFI.vcxproj
@@ -23,15 +23,15 @@
-
+
- 15.0
+ 17.0
{B4BC66C2-9D98-40BC-BB24-94CA3D0E3DD5}
Win32Proj
Calculator
DynamicLibrary
- v142
+ v143
false
false
$(ProjectDir)bin\$(Platform)\$(Configuration)\
@@ -74,7 +74,7 @@
ProgramDatabase
true
true
- .;../Generated/include;../Generated/src;../../../IL2C.Runtime/include
+ .;../Generated/include;../Generated/src;../../../src/IL2C.Runtime/include
Disabled
@@ -91,7 +91,7 @@
EFI Application
true
- ../../../IL2C.Runtime/lib/$(Configuration)
+ ../../../src/IL2C.Runtime/lib/$(Configuration)
libil2c-msvc-uefi-$(Platform).lib
true
true
diff --git a/samples/Calculator/Calculator.Win32/Calculator.Win32.vcxproj b/samples/Calculator/Calculator.Win32/Calculator.Win32.vcxproj
index f9b45ad3..aed5a121 100644
--- a/samples/Calculator/Calculator.Win32/Calculator.Win32.vcxproj
+++ b/samples/Calculator/Calculator.Win32/Calculator.Win32.vcxproj
@@ -19,7 +19,7 @@
- 15.0
+ 17.0
{4DB1CA14-5035-4848-BCDE-10F0A7DC0F50}
Win32Proj
Win32Target
@@ -29,7 +29,7 @@
Application
true
- v142
+ v143
Unicode
@@ -51,7 +51,7 @@
Level3
4100;4146;4197;4206
true
- .;../Generated/include;../Generated/src;../../../IL2C.Runtime/include
+ .;../Generated/include;../Generated/src;../../../src/IL2C.Runtime/include
false
true
true
@@ -80,7 +80,7 @@
Console
true
true
- ../../../IL2C.Runtime/lib/$(Configuration)
+ ../../../src/IL2C.Runtime/lib/$(Configuration)
libil2c-msvc-win-$(Platform)-rts.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
/ignore:4217 %(AdditionalOptions)
true
@@ -96,7 +96,7 @@
-
+
diff --git a/samples/Calculator/Calculator/Calculator.csproj b/samples/Calculator/Calculator/Calculator.csproj
new file mode 100644
index 00000000..d1959a21
--- /dev/null
+++ b/samples/Calculator/Calculator/Calculator.csproj
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+ net48;net6.0
+ Exe
+
+ Calculator
+ Calculator
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\..\src\IL2C.Build\bin\$(Configuration)\$(_IL2C_PlatformName)'))
+
+
+
diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props
new file mode 100644
index 00000000..00df7dc6
--- /dev/null
+++ b/samples/Directory.Build.props
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ false
+ portable
+ False
+
+
+
diff --git a/samples/GettingStartedIL2C/GettingStartedIL2C.sln b/samples/GettingStartedIL2C/GettingStartedIL2C.sln
index 7dc73a69..cd656526 100644
--- a/samples/GettingStartedIL2C/GettingStartedIL2C.sln
+++ b/samples/GettingStartedIL2C/GettingStartedIL2C.sln
@@ -1,14 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29411.108
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStartedIL2C", "GettingStartedIL2C\GettingStartedIL2C.csproj", "{DA321962-5C65-4DD4-9224-B1A664431A75}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShowMessageBoxOnWindows", "ShowMessageBoxOnWindows\ShowMessageBoxOnWindows.csproj", "{9C9C2926-081A-4193-94A9-2FE8BD19772C}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GettingStartedIL2CMain", "GettingStartedIL2CMain\GettingStartedIL2CMain.vcxproj", "{C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}"
- ProjectSection(ProjectDependencies) = postProject
- {DA321962-5C65-4DD4-9224-B1A664431A75} = {DA321962-5C65-4DD4-9224-B1A664431A75}
- EndProjectSection
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld", "HelloWorld\HelloWorld.csproj", "{849B0A98-1053-412A-96DC-08D299E9F56A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TakeAdvantageWithIL2CInvoke", "TakeAdvantageWithIL2CInvoke\TakeAdvantageWithIL2CInvoke.csproj", "{504A5EF3-5DA7-489D-BECD-CCACCF22244B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -20,30 +19,42 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Debug|x64.ActiveCfg = Debug|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Debug|x64.Build.0 = Debug|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Debug|x86.ActiveCfg = Debug|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Debug|x86.Build.0 = Debug|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Release|Any CPU.Build.0 = Release|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Release|x64.ActiveCfg = Release|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Release|x64.Build.0 = Release|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Release|x86.ActiveCfg = Release|Any CPU
- {DA321962-5C65-4DD4-9224-B1A664431A75}.Release|x86.Build.0 = Release|Any CPU
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Debug|Any CPU.ActiveCfg = Debug|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Debug|Any CPU.Build.0 = Debug|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Debug|x64.ActiveCfg = Debug|x64
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Debug|x64.Build.0 = Debug|x64
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Debug|x86.ActiveCfg = Debug|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Debug|x86.Build.0 = Debug|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Release|Any CPU.ActiveCfg = Release|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Release|Any CPU.Build.0 = Release|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Release|x64.ActiveCfg = Release|x64
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Release|x64.Build.0 = Release|x64
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Release|x86.ActiveCfg = Release|Win32
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}.Release|x86.Build.0 = Release|Win32
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Debug|x64.Build.0 = Debug|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Debug|x86.Build.0 = Debug|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Release|x64.ActiveCfg = Release|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Release|x64.Build.0 = Release|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Release|x86.ActiveCfg = Release|Any CPU
+ {9C9C2926-081A-4193-94A9-2FE8BD19772C}.Release|x86.Build.0 = Release|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Debug|x64.Build.0 = Debug|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Debug|x86.Build.0 = Debug|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Release|x64.ActiveCfg = Release|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Release|x64.Build.0 = Release|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Release|x86.ActiveCfg = Release|Any CPU
+ {849B0A98-1053-412A-96DC-08D299E9F56A}.Release|x86.Build.0 = Release|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Debug|x64.Build.0 = Debug|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Debug|x86.Build.0 = Debug|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Release|x64.ActiveCfg = Release|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Release|x64.Build.0 = Release|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Release|x86.ActiveCfg = Release|Any CPU
+ {504A5EF3-5DA7-489D-BECD-CCACCF22244B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/samples/GettingStartedIL2C/GettingStartedIL2C/GettingStartedIL2C.csproj b/samples/GettingStartedIL2C/GettingStartedIL2C/GettingStartedIL2C.csproj
deleted file mode 100644
index 13c92217..00000000
--- a/samples/GettingStartedIL2C/GettingStartedIL2C/GettingStartedIL2C.csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- Exe
- netcoreapp3.1
-
-
-
-
-
-
-
diff --git a/samples/GettingStartedIL2C/GettingStartedIL2C/Program.cs b/samples/GettingStartedIL2C/GettingStartedIL2C/Program.cs
deleted file mode 100644
index 91595c6f..00000000
--- a/samples/GettingStartedIL2C/GettingStartedIL2C/Program.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-namespace GettingStartedIL2C
-{
- public static class Program
- {
- [DllImport("user32.dll")]
- public static extern int MessageBoxW(
- IntPtr hWnd, string text, string caption, int options);
-
- public static void Main()
- {
- Console.WriteLine("Hello world with IL2C!");
- //MessageBoxW(IntPtr.Zero, "Hello world with IL2C!", "Getting started IL2C", 1);
- }
- }
-}
diff --git a/samples/GettingStartedIL2C/GettingStartedIL2CMain/GettingStartedIL2CMain.c b/samples/GettingStartedIL2C/GettingStartedIL2CMain/GettingStartedIL2CMain.c
deleted file mode 100644
index b3457faa..00000000
--- a/samples/GettingStartedIL2C/GettingStartedIL2CMain/GettingStartedIL2CMain.c
+++ /dev/null
@@ -1,16 +0,0 @@
-// Referrer translated code.
-#include
-
-int main()
-{
- // Initialize the IL2C runtime.
- il2c_initialize();
-
- // Invoke (translated) the C# code.
- GettingStartedIL2C_Program_Main();
-
- // Shutdown the IL2C runtime.
- il2c_shutdown();
-
- return 0;
-}
diff --git a/samples/GettingStartedIL2C/GettingStartedIL2CMain/GettingStartedIL2CMain.vcxproj b/samples/GettingStartedIL2C/GettingStartedIL2CMain/GettingStartedIL2CMain.vcxproj
deleted file mode 100644
index 07c00b5a..00000000
--- a/samples/GettingStartedIL2C/GettingStartedIL2CMain/GettingStartedIL2CMain.vcxproj
+++ /dev/null
@@ -1,183 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- {C1B0FEDE-8761-4CD9-B5EE-E60D3ACBEAEB}
- Win32Proj
- GettingStartedIL2CMain
- $(LatestTargetPlatformVersion)
-
-
-
- Application
- true
- v142
- Unicode
-
-
- Application
- false
- v142
- true
- Unicode
-
-
- Application
- true
- v142
- Unicode
-
-
- Application
- false
- v142
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
-
-
- Level3
- Disabled
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
- $(ProjectDir)../../../IL2C.Runtime/include;$(ProjectDir)../../../IL2C.Runtime/src;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/include;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/src;%(AdditionalIncludeDirectories)
- NotUsing
-
-
- Console
- true
-
-
-
-
-
-
- Level3
- Disabled
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
- $(ProjectDir)../../../IL2C.Runtime/include;$(ProjectDir)../../../IL2C.Runtime/src;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/include;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/src;%(AdditionalIncludeDirectories)
- NotUsing
-
-
- Console
- true
-
-
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
- $(ProjectDir)../../../IL2C.Runtime/include;$(ProjectDir)../../../IL2C.Runtime/src;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/include;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/src;%(AdditionalIncludeDirectories)
- NotUsing
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
- $(ProjectDir)../../../IL2C.Runtime/include;$(ProjectDir)../../../IL2C.Runtime/src;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/include;$(ProjectDir)../GettingStartedIL2C/bin/$(Configuration)/netcoreapp3.1/IL2C/src;%(AdditionalIncludeDirectories)
- NotUsing
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/GettingStartedIL2C/HelloWorld/HelloWorld.csproj b/samples/GettingStartedIL2C/HelloWorld/HelloWorld.csproj
new file mode 100644
index 00000000..f39bbcef
--- /dev/null
+++ b/samples/GettingStartedIL2C/HelloWorld/HelloWorld.csproj
@@ -0,0 +1,19 @@
+
+
+
+ Exe
+ net6.0
+
+
+ -s
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/GettingStartedIL2C/HelloWorld/Program.cs b/samples/GettingStartedIL2C/HelloWorld/Program.cs
new file mode 100644
index 00000000..b6190ec6
--- /dev/null
+++ b/samples/GettingStartedIL2C/HelloWorld/Program.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace HelloWorld
+{
+ public static class Program
+ {
+ public static void Main() =>
+ Console.WriteLine("Hello world with IL2C!");
+ }
+}
diff --git a/samples/GettingStartedIL2C/ShowMessageBoxOnWindows/Program.cs b/samples/GettingStartedIL2C/ShowMessageBoxOnWindows/Program.cs
new file mode 100644
index 00000000..74ce553b
--- /dev/null
+++ b/samples/GettingStartedIL2C/ShowMessageBoxOnWindows/Program.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace GettingStartedIL2C
+{
+ public static class Program
+ {
+ public enum MessageBoxOptions : uint
+ {
+ MB_OK = 0,
+ MB_OKCANCEL,
+ MB_ABORTRETRYIGNORE,
+ MB_YESNOCANCEL,
+ MB_YESNO,
+ MB_RETRYCANCEL,
+ MB_CANCELTRYCONTINUE,
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Unicode)]
+ public static extern int MessageBoxW(
+ IntPtr hWnd, string text, string caption, MessageBoxOptions options);
+
+ public static int Main() =>
+ MessageBoxW(
+ IntPtr.Zero,
+ "Hello world with IL2C!", "Getting started IL2C",
+ MessageBoxOptions.MB_YESNOCANCEL);
+ }
+}
diff --git a/samples/GettingStartedIL2C/ShowMessageBoxOnWindows/ShowMessageBoxOnWindows.csproj b/samples/GettingStartedIL2C/ShowMessageBoxOnWindows/ShowMessageBoxOnWindows.csproj
new file mode 100644
index 00000000..06263acd
--- /dev/null
+++ b/samples/GettingStartedIL2C/ShowMessageBoxOnWindows/ShowMessageBoxOnWindows.csproj
@@ -0,0 +1,21 @@
+
+
+
+
+ WinExe
+
+ net6.0
+
+
+ -s
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/GettingStartedIL2C/TakeAdvantageWithIL2CInvoke/Program.cs b/samples/GettingStartedIL2C/TakeAdvantageWithIL2CInvoke/Program.cs
new file mode 100644
index 00000000..e0c888fe
--- /dev/null
+++ b/samples/GettingStartedIL2C/TakeAdvantageWithIL2CInvoke/Program.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// It is intruduced what/how to do 'IL2C/Invoke'.
+namespace TakeAdvantageWithIL2CInvoke
+{
+ // Refer tm struct type from pure C header file.
+ // IL2C/Invoke doesn't need to adjust any field offset/packing.
+ // Managed side declarations are pure stub.
+ [NativeType("time.h", SymbolName = "struct tm")]
+ internal struct tm
+ {
+ public int tm_sec;
+ public int tm_min;
+ public int tm_hour;
+ public int tm_mday;
+ public int tm_mon;
+ public int tm_year;
+ public int tm_wday;
+ public int tm_yday;
+ public int tm_isdst;
+ }
+
+ public static class Program
+ {
+ // Refer mktime() API from pure C header file.
+ // extern "C" time_t mktime(struct tm*);
+ [NativeMethod("time.h")]
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private static extern long mktime(in tm tmValue);
+
+ public static void Main()
+ {
+ // 2022/10/23 12:34:56
+ var tmValue = new tm
+ {
+ tm_year = 2022 - 1900,
+ tm_mon = 10 - 1,
+ tm_mday = 23,
+ tm_hour = 12,
+ tm_min = 34,
+ tm_sec = 56,
+ tm_wday = 0,
+ tm_yday = 0,
+ tm_isdst = 0,
+ };
+
+ var result = mktime(tmValue);
+
+ // 1666496096
+ Console.WriteLine(result);
+ }
+ }
+}
diff --git a/samples/GettingStartedIL2C/TakeAdvantageWithIL2CInvoke/TakeAdvantageWithIL2CInvoke.csproj b/samples/GettingStartedIL2C/TakeAdvantageWithIL2CInvoke/TakeAdvantageWithIL2CInvoke.csproj
new file mode 100644
index 00000000..f7c702ce
--- /dev/null
+++ b/samples/GettingStartedIL2C/TakeAdvantageWithIL2CInvoke/TakeAdvantageWithIL2CInvoke.csproj
@@ -0,0 +1,22 @@
+
+
+
+ Exe
+ net6.0
+
+
+ -s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 00000000..575e46b6
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+ true
+ true
+ true
+
+ IL2C
+ IL2C
+ Copyright (c) Kouji Matsui
+ A translator implementation of .NET intermediate language to C language.
+
+ Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+ Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+ Apache-2.0
+ https://github.com/kekyo/IL2C.git
+ IL2C.100.png
+ il2c;cil;msil;translate;transpile;aot;ecma335;c;c++;win32;uefi;wdm;multi-platform;systems-programming
+ .pdb
+ $(NoWarn);NU1605;NU1701;NU5105
+
+
+
+ portable
+ false
+ false
+
+
+
+ embedded
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/IL2C.Build/IL2C.Build.csproj b/src/IL2C.Build/IL2C.Build.csproj
new file mode 100644
index 00000000..28981309
--- /dev/null
+++ b/src/IL2C.Build/IL2C.Build.csproj
@@ -0,0 +1,29 @@
+
+
+
+ net462;netcoreapp2.1;netcoreapp2.2;netcoreapp3.1;net5.0;net6.0
+ Exe
+ enable
+
+ il2c
+ IL2C.Program
+ IL2C.Build.nuspec
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/IL2C.Build/IL2C.Build.nuspec b/src/IL2C.Build/IL2C.Build.nuspec
new file mode 100644
index 00000000..da5ec109
--- /dev/null
+++ b/src/IL2C.Build/IL2C.Build.nuspec
@@ -0,0 +1,43 @@
+
+
+
+
+ IL2C.Build
+ $PackageVersion$
+ Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+ false
+ Apache-2.0
+ https://licenses.nuget.org/Apache-2.0
+ IL2C.100.png
+ https://github.com/kekyo/IL2C.git
+ A translator implementation of .NET intermediate language to C language.
+ $PackageReleaseNotes$
+ Copyright (c) Kouji Matsui
+ il2c cil msil translate transpile aot ecma335 c c++ win32 uefi wdm multi-platform systems-programming
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/IL2C.Build/Program.cs b/src/IL2C.Build/Program.cs
new file mode 100644
index 00000000..eea28463
--- /dev/null
+++ b/src/IL2C.Build/Program.cs
@@ -0,0 +1,186 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+using Mono.Options;
+
+using IL2C.Drivers;
+using IL2C.Metadata;
+
+#pragma warning disable CS0219
+
+namespace IL2C
+{
+ // warning CS0649: Field is never assigned to, and will always have its default value `null'
+#pragma warning disable 0649
+
+ public static class Program
+ {
+ private enum DrivingModes
+ {
+ Translation = 1,
+ Compilation = 2,
+ Both = 3,
+ }
+
+ public static async Task Main(string[] args)
+ {
+ try
+ {
+ var drivingMode = DrivingModes.Both;
+ var debugInformationOptions = DebugInformationOptions.None;
+ var produceCpp = false;
+ var enableBundler = false;
+ var targetPlatform = TargetPlatforms.Generic;
+ var refDirs = new string[0];
+ var outputNativeDirPath = default(string);
+ var nativeCompiler = default(string);
+ var nativeCompilerFlags = "";
+ var nativeLinkingFlags = "";
+ var nativeArchiver = default(string);
+ var outputNativeExecutableFileName = default(string);
+ var outputNativeArchiveFileName = default(string);
+ var additionalIncludeDirs = new string[0];
+ var libraryPaths = new string[0];
+ var mainTemplatePath = default(string);
+ var logLevel = LogLevels.Information;
+ var logtfm = default(string);
+ var launchDebugger = false;
+ var help = false;
+
+ var options = new OptionSet()
+ {
+ { "mode=", "Driving mode [both|translation|compilation]", v => drivingMode = Enum.TryParse(v, true, out var dm) ? dm : DrivingModes.Both },
+ { "debug=", "Emit debug informations [none|commentonly|full]", v => debugInformationOptions = Enum.TryParse(v, true, out var t) ? t : DebugInformationOptions.None },
+ { "produceCpp=", "Produce C++ extension files (apply extension *.cpp instead *.c, body will not change)", v => produceCpp = bool.TryParse(v, out var pc) ? pc : false },
+ { "bundler=", "Produce bundler source file", v => enableBundler = bool.TryParse(v, out var eb) ? eb : false },
+ { "target=", "Target platform [generic|ue4]", v => targetPlatform = Enum.TryParse(v, true, out var tp) ? tp : TargetPlatforms.Generic },
+ { "refDirs=", "Reference assembly paths (semi-colon separated)", v => refDirs = v.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) },
+ { "compiler=", "Native compiler driver file", v => nativeCompiler = v },
+ { "compilerFlags=", "Native compiler flags", v => nativeCompilerFlags = v },
+ { "linkingFlags=", "Native compiler linking flags", v => nativeLinkingFlags = v },
+ { "archiver=", "Native archiver file", v => nativeArchiver = v },
+ { "includeDirs=", "Compilation additional include directory path", v => additionalIncludeDirs = v.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) },
+ { "libs=", "Compilation library path", v => libraryPaths = v.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) },
+ { "outputNativeArchive=", "Output native archive file name", v => outputNativeArchiveFileName = v },
+ { "outputNativeExecutable=", "Output native executable file name", v => outputNativeExecutableFileName = v },
+ { "outputNativeDir=", "Output native binary directory path", v => outputNativeDirPath = v },
+ { "mainTemplate=", "Native main template path", v => mainTemplatePath = v },
+ { "logLevel=", "Log level [debug|trace|information|warning|error|silent]", v => logLevel = Enum.TryParse(v, true, out var ll) ? ll : LogLevels.Information },
+ { "logtfm=", "Log header tfm", v => logtfm = v },
+ { "launchDebugger", "Launch debugger", _ => launchDebugger = true },
+ { "h|help", "Print this help", _ => help = true },
+ };
+
+ var extra = options.Parse(args);
+ if (help || (extra.Count < 2))
+ {
+ Console.Out.WriteLine($"IL2C.Build [{ThisAssembly.AssemblyVersion}]");
+ Console.Out.WriteLine(" A translator for ECMA-335 CIL/MSIL to C language.");
+ Console.Out.WriteLine(" Copyright (c) Kouji Matsui.");
+ Console.Out.WriteLine("usage: il2c.exe [options] ");
+ options.WriteOptionDescriptions(Console.Out);
+ }
+ else
+ {
+ var outputBaseDirPath = extra[0];
+ var inputPaths = extra.Skip(1);
+
+ using var logger = new TextWriterLogger(
+ logLevel, Console.Out, logtfm);
+
+ logger.Information($"Started.");
+
+ if (launchDebugger)
+ {
+ Debugger.Launch();
+ }
+
+ // TODO: refs, trace
+
+ IMethodInformation? mainEntryPoint = null;
+ string inputCompilationDirPath;
+ if ((drivingMode & DrivingModes.Translation) == DrivingModes.Translation)
+ {
+ var translationOptions = new TranslationOptions(
+ true, enableBundler, targetPlatform, debugInformationOptions);
+#if DEBUG
+ var results = new List();
+ foreach (var assemblyPath in inputPaths)
+ {
+ var r = await SimpleTranslator.TranslateAsync(
+ logger,
+ outputBaseDirPath,
+ produceCpp,
+ translationOptions,
+ assemblyPath);
+ results.Add(r);
+ }
+#else
+ var results = await Task.WhenAll(
+ inputPaths.Select(assemblyPath =>
+ SimpleTranslator.TranslateAsync(
+ logger,
+ outputBaseDirPath,
+ produceCpp,
+ translationOptions,
+ assemblyPath).AsTask())).
+ ConfigureAwait(false);
+#endif
+ mainEntryPoint = results.FirstOrDefault();
+ inputCompilationDirPath = outputBaseDirPath;
+ }
+ else
+ {
+ inputCompilationDirPath = inputPaths.First();
+ }
+
+ if ((drivingMode & DrivingModes.Compilation) == DrivingModes.Compilation &&
+ !string.IsNullOrWhiteSpace(nativeCompiler) &&
+ !string.IsNullOrWhiteSpace(nativeArchiver) &&
+ !string.IsNullOrWhiteSpace(outputNativeArchiveFileName))
+ {
+ var toolchainOptions = new ToolchainOptions(
+ nativeCompiler!, nativeCompilerFlags, nativeLinkingFlags, nativeArchiver!,
+ additionalIncludeDirs, libraryPaths, mainTemplatePath);
+ var artifactPathOptions = new ArtifactPathOptions(
+ outputNativeArchiveFileName!, outputNativeExecutableFileName);
+
+ await NativeBinaryBuilder.CompileToNativeAsync(
+ logger,
+ toolchainOptions,
+ artifactPathOptions,
+ mainEntryPoint,
+ inputCompilationDirPath,
+ string.IsNullOrWhiteSpace(outputNativeDirPath) ?
+ inputCompilationDirPath : outputNativeDirPath!);
+ }
+ }
+
+ return 0;
+ }
+ catch (OptionException ex)
+ {
+ Console.Error.WriteLine(ex.Message);
+ return Marshal.GetHRForException(ex);
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex);
+ return Marshal.GetHRForException(ex);
+ }
+ }
+ }
+}
diff --git a/src/IL2C.Build/Properties/AssemblyInfo.cs b/src/IL2C.Build/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..77e346b8
--- /dev/null
+++ b/src/IL2C.Build/Properties/AssemblyInfo.cs
@@ -0,0 +1,12 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
diff --git a/src/IL2C.Build/Properties/launchSettings.json b/src/IL2C.Build/Properties/launchSettings.json
new file mode 100644
index 00000000..9d9b118c
--- /dev/null
+++ b/src/IL2C.Build/Properties/launchSettings.json
@@ -0,0 +1,8 @@
+{
+ "profiles": {
+ "IL2C": {
+ "commandName": "Project",
+ "commandLineArgs": "--debug=commentonly $(ProjectDir)../samples/Calculator/Generated $(ProjectDir)../samples/Calculator/Calculator.Core/bin/Debug/netstandard2.0/Calculator.Core.dll"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/IL2C.Build/build/IL2C.Build.props b/src/IL2C.Build/build/IL2C.Build.props
new file mode 100644
index 00000000..9bd9dc1c
--- /dev/null
+++ b/src/IL2C.Build/build/IL2C.Build.props
@@ -0,0 +1,155 @@
+
+
+
+
+ <_IL2C_RuntimeName>dotnet
+ <_IL2C_ExecutableName>il2c.dll
+
+
+ <_IL2C_RuntimeName>
+ <_IL2C_ExecutableName>il2c.exe
+
+
+ <_IL2C_RuntimeName>mono
+ <_IL2C_ExecutableName>il2c.exe
+
+
+
+ <_IL2C_GCC_Compiler Condition="'$(OS)' == 'Windows_NT'">gcc.exe
+ <_IL2C_GCC_Compiler Condition="'$(OS)' != 'Windows_NT'">gcc
+ <_IL2C_GCC_DefaultFlags>-pipe -g -Wall -Werror -Wstrict-prototypes -Wno-unused
+ <_IL2C_GCC_DebugFlags>-D_DEBUG
+ <_IL2C_GCC_ReleaseFlags>-fdata-sections -ffunction-sections -Wl,--gc-sections -DNDEBUG
+ <_IL2C_GCC_DisableOptimizingFlags>-O0
+ <_IL2C_GCC_EnableOptimizingFlags>-Ofast -fomit-frame-pointer -march=native -mtune=native
+ <_IL2C_GCC_Archiver Condition="'$(OS)' == 'Windows_NT'">ar.exe
+ <_IL2C_GCC_Archiver Condition="'$(OS)' != 'Windows_NT'">ar
+ <_IL2C_GCC_PosixRequiredFlags>-pthread
+
+
+
+ $(MSBuildThisFileDirectory)..
+ $(Configuration)
+ $(IL2CConfiguration)
+ il2c
+
+
+
+
+
+
+
+
+ RoslynCodeTaskFactory
+
+
+
+
+ CodeTaskFactory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/IL2C.Build/build/IL2C.Build.targets b/src/IL2C.Build/build/IL2C.Build.targets
new file mode 100644
index 00000000..6970eabc
--- /dev/null
+++ b/src/IL2C.Build/build/IL2C.Build.targets
@@ -0,0 +1,178 @@
+
+
+
+
+
+
+
+ true
+ true
+ Full
+ false
+ false
+ Generic
+ Information
+ false
+
+
+
+
+
+
+ <_IL2C_PlatformName>$(MicrosoftNETBuildTasksTFM)
+
+
+ <_IL2C_PlatformName Condition="$(BundledNETCoreAppTargetFrameworkVersion) >= 5.0">net$(BundledNETCoreAppTargetFrameworkVersion)
+ <_IL2C_PlatformName Condition="$(BundledNETCoreAppTargetFrameworkVersion) < 5.0">netcoreapp$(BundledNETCoreAppTargetFrameworkVersion)
+
+
+ <_IL2C_PlatformName>netcoreapp2.0
+
+
+ <_IL2C_PlatformName>net462
+
+
+
+ <_IL2C_ToolingDir>$([System.IO.Path]::Combine('$(IL2CBuildBaseDir)','tools','$(_IL2C_PlatformName)'))
+
+
+
+
+
+
+
+
+
+ $(TargetFileName)
+ $([System.IO.Path]::Combine('$(ProjectDir)','$(OutputPath)','$(IL2CTargetAssemblyFileName)'))
+ $([System.String]::Concat('$(IL2CAssemblyPaths)',';','$(IL2CTargetAssemblyPath)').split(';'))
+ $(IL2CTargetAssemblyPath)
+ $([System.IO.Path]::Combine('$(ProjectDir)','$(OutputPath)','$(IL2COutputPath)'))
+ $(TargetName)
+
+
+
+
+ $(_IL2C_RuntimeName)
+ $([System.IO.Path]::GetFullPath('$(_IL2C_ToolingDir)'))
+ $([System.IO.Path]::Combine('$(IL2CBuildToolingDir)','$(_IL2C_ExecutableName)'))
+
+
+
+
+
+
+
+ $(_IL2C_GCC_Compiler)
+ $(_IL2C_GCC_DefaultFlags)
+ $(_IL2C_GCC_DebugFlags)
+ $(_IL2C_GCC_ReleaseFlags)
+ $(_IL2C_GCC_DisableOptimizingFlags)
+ $(_IL2C_GCC_EnableOptimizingFlags)
+ $(_IL2C_GCC_PosixRequiredFlags)
+
+
+ $(_IL2C_GCC_Archiver)
+
+
+
+
+ <_IL2C_BuildLogOption>--logLevel=$(IL2CBuildLogLevel) --logtfm="$(TargetFramework)"
+
+
+
+
+ <_IL2C_NativeCompilerAllFlags>$(IL2CNativeCompilerDefaultFlags) $(IL2CNativeCompilerRequiredFlags) $(IL2CNativeCompilerConditionalFlags) $(IL2CNativeCompilerOptimizingFlags) $(IL2CNativeCompilerOptionalFlags)
+
+ <_IL2C_CalculateContentHash Content="$(IL2CNativeCompiler) $(_IL2C_NativeCompilerAllFlags) $(_IL2C_NativeArchiverOption)">
+
+
+
+ <_IL2C_CandidateRuntimeLibraryBasePath>$([System.IO.Path]::Combine('$(_IL2C_RuntimeLibraryCacheBaseDirPath)','$(_IL2C_RuntimeLibraryBaseDirName)'))
+ <_IL2C_CandidateRuntimeLibraryPath>$([System.IO.Path]::Combine('$(_IL2C_CandidateRuntimeLibraryBasePath)','$(_IL2C_RuntimeLibraryCacheFileName)'))
+ $(_IL2C_CandidateRuntimeLibraryPath);$(IL2CNativeLibPath)
+ $(_IL2C_CandidateRuntimeLibraryPath)
+
+
+
+
+ <_IL2C_OutputNativeArchiveFileName>$(IL2COutputNativeName).a
+ <_IL2C_OutputNativeExecutableFileName Condition="('$(OutputType)' != 'Library') AND ('$(OS)' == 'Windows_NT')">$(IL2COutputNativeName).exe
+ <_IL2C_OutputNativeExecutableFileName Condition="('$(OutputType)' != 'Library') AND ('$(OS)' != 'Windows_NT')">$(IL2COutputNativeName)
+
+
+
+
+ <_IL2C_DrivingMode>both
+ <_IL2C_NativeCompilerOption>--compiler="$(IL2CNativeCompiler)"
+ <_IL2C_NativeCompilerFlagsOption>--compilerFlags="$(_IL2C_NativeCompilerAllFlags)"
+ <_IL2C_NativeLinkingFlagsOption Condition="'$(IL2CNativeLinkingFlags)' != ''">--linkingFlags="$(IL2CNativeLinkingFlags)"
+ <_IL2C_NativeArchiverOption>--archiver="$(IL2CNativeArchiver)"
+ <_IL2C_NativeIncludeDirOption>--includeDirs="$(IL2CNativeIncludeDir)"
+ <_IL2C_NativeLibPathOption>--libs="$(IL2CNativeLibPath)"
+ <_IL2C_OutputNativeArchiveFileNameOption>--outputNativeArchive="$(_IL2C_OutputNativeArchiveFileName)"
+ <_IL2C_OutputNativeExecutableFileNameOption Condition="'$(_IL2C_OutputNativeExecutableFileName)' != ''">--outputNativeExecutable="$(_IL2C_OutputNativeExecutableFileName)"
+ <_IL2C_NativeMainTemplatePathOption Condition="'$(OutputType)' != 'Library'">--mainTemplate="$(IL2CNativeMainTemplatePath)"
+ <_IL2C_LaunchDebuggerOption Condition="$(IL2CBuildLaunchDebugger)">--launchDebugger
+ <_IL2C_NativeOptions>$(_IL2C_NativeCompilerOption) $(_IL2C_NativeCompilerFlagsOption) $(_IL2C_NativeLinkingFlagsOption) $(_IL2C_NativeArchiverOption) $(_IL2C_NativeIncludeDirOption) $(_IL2C_NativeLibPathOption) $(_IL2C_OutputNativeArchiveFileNameOption) $(_IL2C_OutputNativeExecutableFileNameOption) $(_IL2C_NativeMainTemplatePathOption) $(_IL2C_LaunchDebuggerOption)
+
+
+ <_IL2C_DrivingMode>translation
+
+
+
+ <_IL2C_GetCombinedReferencesBasePath References="@(ReferencePath)">
+
+
+
+
+
+
+
+
+
+
+
+ <_IL2C_TemporaryDirPathForRuntimeLibrary>$([System.IO.Path]::Combine('$(_IL2C_RuntimeLibraryCacheBaseDirPath)','$([System.Guid]::NewGuid().ToString())'))
+ <_IL2C_BuildRuntimeLibraryOptions>$(_IL2C_NativeCompilerOption) $(_IL2C_NativeCompilerFlagsOption) $(_IL2C_NativeArchiverOption) $(_IL2C_NativeIncludeDirOption) $(_IL2C_RaiseDebugBreakOption) --outputNativeArchive="$(_IL2C_RuntimeLibraryCacheFileName)" --outputNativeDir="$(_IL2C_TemporaryDirPathForRuntimeLibrary)"
+
+
+
+
+ <_IL2C_Build_MoveDirectory
+ From="$(_IL2C_TemporaryDirPathForRuntimeLibrary)"
+ To="$(_IL2C_CandidateRuntimeLibraryBasePath)" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/IL2C.Build/buildMultiTargeting/IL2C.Build.props b/src/IL2C.Build/buildMultiTargeting/IL2C.Build.props
new file mode 100644
index 00000000..1cedb221
--- /dev/null
+++ b/src/IL2C.Build/buildMultiTargeting/IL2C.Build.props
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/src/IL2C.Build/buildMultiTargeting/IL2C.Build.targets b/src/IL2C.Build/buildMultiTargeting/IL2C.Build.targets
new file mode 100644
index 00000000..d70eff5a
--- /dev/null
+++ b/src/IL2C.Build/buildMultiTargeting/IL2C.Build.targets
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/IL2C.Core/AssemblyPreparer.cs b/src/IL2C.Core/AssemblyPreparer.cs
similarity index 93%
rename from IL2C.Core/AssemblyPreparer.cs
rename to src/IL2C.Core/AssemblyPreparer.cs
index 12389a6e..236ba0e4 100644
--- a/IL2C.Core/AssemblyPreparer.cs
+++ b/src/IL2C.Core/AssemblyPreparer.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
@@ -59,7 +49,7 @@ private static IEnumerable DecodeAndEnumerateILBodies(
}
var code = decodeContext.CurrentCode;
- if (Utilities.TryGetILConverter(code.OpCode, out var ilc) == false)
+ if (TypeUtilities.TryGetILConverter(code.OpCode, out var ilc) == false)
{
throw new InvalidProgramSequenceException(
"Invalid opcode: Method={0}, OpCode={1}, Offset={2}",
diff --git a/IL2C.Core/AssemblyWriter.cs b/src/IL2C.Core/AssemblyWriter.cs
similarity index 79%
rename from IL2C.Core/AssemblyWriter.cs
rename to src/IL2C.Core/AssemblyWriter.cs
index a92bcf51..0ef28919 100644
--- a/IL2C.Core/AssemblyWriter.cs
+++ b/src/IL2C.Core/AssemblyWriter.cs
@@ -1,26 +1,16 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
-using System;
using System.Collections.Generic;
-using IL2C.Metadata;
using IL2C.Translators;
using IL2C.Writers;
diff --git a/IL2C.Core/CodeTextStorage.cs b/src/IL2C.Core/CodeTextStorage.cs
similarity index 52%
rename from IL2C.Core/CodeTextStorage.cs
rename to src/IL2C.Core/CodeTextStorage.cs
index f7b0bb2e..43b214e3 100644
--- a/IL2C.Core/CodeTextStorage.cs
+++ b/src/IL2C.Core/CodeTextStorage.cs
@@ -1,61 +1,53 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
-using IL2C.Internal;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
+using IL2C.Internal;
+
namespace IL2C
{
public class CodeTextStorage
{
- private readonly TextWriter logw;
- private readonly string basePath;
- private readonly bool enableCpp;
+ public readonly string BasePath;
+
+ private readonly ILogger logger;
+ private readonly bool produceCpp;
private readonly string indent;
private readonly Stack scopeNames = new Stack();
- public CodeTextStorage(TextWriter logw, string basePath, bool enableCpp, string indent)
+ public CodeTextStorage(ILogger logger, string basePath, bool produceCpp, string indent)
{
- this.logw = logw;
- this.basePath = basePath;
- this.enableCpp = enableCpp;
+ this.logger = logger;
+ this.BasePath = Path.GetFullPath(basePath);
+ this.produceCpp = produceCpp;
this.indent = indent;
}
public CodeTextWriter CreateTextWriter(string fileName, string ext)
{
var scopedPath = Path.Combine(scopeNames.Reverse().ToArray());
- var path = Path.Combine(basePath, scopedPath, fileName + ext);
- var tw = this.OnCreateTextWriter(Path.GetFullPath(path));
-
- logw.Write("IL2C: Writing: \"{0}\" ...", path);
+ var path = Path.Combine(this.BasePath, scopedPath, fileName + ext);
+ var tw = this.OnCreateTextWriter(path);
- return new InternalCodeTextWriter(logw, tw, path, indent);
+ return new InternalCodeTextWriter(this.logger, tw, path, indent);
}
public CodeTextWriter CreateSourceCodeWriter(string fileName)
{
- return this.CreateTextWriter(fileName, enableCpp ? ".cpp" : ".c");
+ return this.CreateTextWriter(fileName, produceCpp ? ".cpp" : ".c");
}
public CodeTextWriter CreateHeaderWriter(string fileName)
@@ -65,7 +57,7 @@ public CodeTextWriter CreateHeaderWriter(string fileName)
protected virtual TextWriter OnCreateTextWriter(string path)
{
- var directoryPath = Path.GetDirectoryName(path);
+ var directoryPath = IOAccessor.SafeGetDirectoryName(path);
try
{
if (!Directory.Exists(directoryPath))
@@ -83,34 +75,34 @@ protected virtual TextWriter OnCreateTextWriter(string path)
public IDisposable EnterScope(string scopeName, bool splitScope = true)
{
- scopeNames.Push(splitScope ? Utilities.GetCLanguageScopedPath(scopeName) : scopeName);
+ scopeNames.Push(splitScope ? SymbolManipulator.GetCLanguageScopedPath(scopeName) : scopeName);
return new ScopeDisposer(this);
}
private sealed class InternalCodeTextWriter : CodeTextWriter
{
- private TextWriter logw;
+ private ILogger? logger;
- public InternalCodeTextWriter(TextWriter logw, TextWriter tw, string relatedPath, string indent)
+ public InternalCodeTextWriter(ILogger logger, TextWriter tw, string relatedPath, string indent)
: base(tw, relatedPath, indent)
{
- this.logw = logw;
+ this.logger = logger;
}
public override void Dispose()
{
- if (logw != null)
+ if (this.logger != null)
{
base.Dispose();
- logw.WriteLine(" Done.");
- logw = null;
+ this.logger.Trace($"Translated: \"{base.RelatedPath}\"");
+ this.logger = null;
}
}
}
private sealed class ScopeDisposer : IDisposable
{
- private CodeTextStorage parent;
+ private CodeTextStorage? parent;
public ScopeDisposer(CodeTextStorage parent)
{
@@ -119,10 +111,10 @@ public ScopeDisposer(CodeTextStorage parent)
public void Dispose()
{
- if (parent != null)
+ if (this.parent != null)
{
- parent.scopeNames.Pop();
- parent = null;
+ this.parent.scopeNames.Pop();
+ this.parent = null;
}
}
}
diff --git a/IL2C.Core/CodeTextWriter.cs b/src/IL2C.Core/CodeTextWriter.cs
similarity index 80%
rename from IL2C.Core/CodeTextWriter.cs
rename to src/IL2C.Core/CodeTextWriter.cs
index e29dc12b..c3c64406 100644
--- a/IL2C.Core/CodeTextWriter.cs
+++ b/src/IL2C.Core/CodeTextWriter.cs
@@ -1,21 +1,13 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
using System;
using System.Diagnostics;
@@ -129,7 +121,7 @@ public static CodeTextWriter Create(Stream stream, string relatedPath, string in
private sealed class Unshifter : IDisposable
{
- private CodeTextWriter parent;
+ private CodeTextWriter? parent;
private int shiftCount;
public Unshifter(CodeTextWriter parent, int shiftCount)
@@ -140,11 +132,11 @@ public Unshifter(CodeTextWriter parent, int shiftCount)
public void Dispose()
{
- if (parent != null)
+ if (this.parent != null)
{
- parent.UpdateIndent(shiftCount);
- parent = null;
- shiftCount = 0;
+ this.parent.UpdateIndent(shiftCount);
+ this.parent = null;
+ this.shiftCount = 0;
}
}
}
diff --git a/src/IL2C.Core/Drivers/NativeBinaryBuilder.cs b/src/IL2C.Core/Drivers/NativeBinaryBuilder.cs
new file mode 100644
index 00000000..1eeea88e
--- /dev/null
+++ b/src/IL2C.Core/Drivers/NativeBinaryBuilder.cs
@@ -0,0 +1,331 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using IL2C.Internal;
+using IL2C.Metadata;
+
+namespace IL2C.Drivers
+{
+ public sealed class ToolchainOptions
+ {
+ public readonly string NativeCompiler;
+ public readonly string NativeCompilerFlags;
+ public readonly string NativeLinkingFlags;
+ public readonly string NativeArchiver;
+ public readonly string[] AdditionalIncludeDirs;
+ public readonly string[] LibraryPaths;
+ public readonly string? MainTemplatePath;
+
+ public ToolchainOptions(
+ string nativeCompiler,
+ string nativeCompilerFlags,
+ string nativeLinkingFlags,
+ string nativeArchiver,
+ string[] additionalIncludeDirs,
+ string[] libraryPaths,
+ string? mainTemplatePath)
+ {
+ this.NativeCompiler = nativeCompiler;
+ this.NativeCompilerFlags = nativeCompilerFlags;
+ this.NativeLinkingFlags = nativeLinkingFlags;
+ this.NativeArchiver = nativeArchiver;
+ this.AdditionalIncludeDirs = additionalIncludeDirs;
+ this.LibraryPaths = libraryPaths;
+ this.MainTemplatePath = mainTemplatePath;
+ }
+ }
+
+ public sealed class ArtifactPathOptions
+ {
+ public readonly string OutputNativeArchiveFileName;
+ public readonly string? OutputNativeExecutableFileName;
+
+ public ArtifactPathOptions(
+ string outputNativeArchiveFileName,
+ string? outputNativeExecutableFileName)
+ {
+ this.OutputNativeExecutableFileName = outputNativeExecutableFileName;
+ this.OutputNativeArchiveFileName = outputNativeArchiveFileName;
+ }
+ }
+
+ public static class NativeBinaryBuilder
+ {
+ private readonly struct CompilationResult
+ {
+ public readonly int ExitCode;
+ public readonly string Logs;
+ public readonly string OutputPath;
+
+ public CompilationResult(int exitCode, string logs, string outputPath)
+ {
+ this.ExitCode = exitCode;
+ this.Logs = logs;
+ this.OutputPath = outputPath;
+ }
+
+ public override string ToString() =>
+ $"{this.ExitCode}: {this.Logs}";
+ }
+
+ private static async Task ExecuteCompilerAsync(
+ string sourceCodePath,
+ string outputStagingDirPath,
+ string outputFileName,
+ string[] nativeToolchainBasePaths,
+ string nativeCompiler,
+ string nativeCompilerFlags,
+ string includeDir,
+ string sourceDir,
+ bool isCompileOnly,
+ string? libraryPath,
+ string[] additionalIncludeDirs,
+ string[] additionalLibraryPaths)
+ {
+ var sourceCodeFileName = Path.GetFileNameWithoutExtension(sourceCodePath);
+ var outputBasePath = Path.Combine(
+ outputStagingDirPath,
+ IOAccessor.SafeGetDirectoryName(sourceCodePath.Substring(sourceDir.Length + 1)));
+ var outputPath = Path.Combine(
+ outputBasePath,
+ outputFileName);
+ var buildScriptPath = Path.Combine(
+ outputBasePath,
+ $"build_{sourceCodeFileName}");
+
+ await IOAccessor.SafeCreateDirectoryAsync(
+ outputBasePath, false).
+ ConfigureAwait(false);
+
+ var result = await IOAccessor.ExecuteAsync(
+ outputBasePath,
+ buildScriptPath,
+ nativeToolchainBasePaths,
+ nativeCompiler,
+ new[]
+ {
+ nativeCompilerFlags,
+ isCompileOnly ? "-c" : "",
+ $"-I{IOAccessor.ToRelativePath(outputBasePath, includeDir)}",
+ $"-I{IOAccessor.ToRelativePath(outputBasePath, sourceDir)}",
+ }.
+ Concat(additionalIncludeDirs.Select(p => $"-I{IOAccessor.ToRelativePath(outputBasePath, p)}")).
+ Concat(new[]
+ {
+ "-o", IOAccessor.ToRelativePath(outputBasePath, outputPath),
+ IOAccessor.ToRelativePath(outputBasePath, sourceCodePath),
+ }).
+ Concat(libraryPath is { } lp ? new[] { IOAccessor.ToRelativePath(outputBasePath, lp) } : new string[0]).
+ Concat(additionalLibraryPaths.Select(p => IOAccessor.ToRelativePath(outputBasePath, p))).
+ ToArray()).
+ ConfigureAwait(false);
+
+ return new CompilationResult(result.ExitCode, result.Logs, outputPath);
+ }
+
+ private static ValueTask ExecuteArchiverAsync(
+ string[] objectPaths,
+ string outputPath,
+ string[] nativeCompilerBasePaths,
+ string nativeArchiver)
+ {
+ var outputBasePath = IOAccessor.SafeGetDirectoryName(outputPath);
+ var buildScriptPath = Path.Combine(
+ outputBasePath,
+ $"build_{Path.GetFileNameWithoutExtension(outputPath)}");
+
+ return IOAccessor.ExecuteAsync(
+ outputBasePath,
+ buildScriptPath,
+ nativeCompilerBasePaths,
+ nativeArchiver,
+ new[]
+ {
+ "rcs",
+ IOAccessor.ToRelativePath(outputBasePath, outputPath),
+ }.
+ Concat(objectPaths.Select(p => IOAccessor.ToRelativePath(outputBasePath, p))).
+ ToArray());
+ }
+
+ public static async ValueTask CompileToNativeAsync(
+ ILogger logger,
+ ToolchainOptions toolchainOptions,
+ ArtifactPathOptions artifactPathOptions,
+ IMethodInformation? mainEntryPoint,
+ string sourceCodeDirPath,
+ string outputDirPath)
+ {
+ var sourceCodeDirFullPath = Path.GetFullPath(sourceCodeDirPath);
+ var outputDirFullPath = Path.GetFullPath(outputDirPath);
+ var outputNativeArchiveFullPath = Path.GetFullPath(
+ Path.Combine(
+ outputDirFullPath,
+ artifactPathOptions.OutputNativeArchiveFileName));
+ var nativeToolchainBasePath = IOAccessor.SafeGetDirectoryName(
+ toolchainOptions.NativeCompiler);
+ var nativeToolchainBasePaths =
+ string.IsNullOrWhiteSpace(nativeToolchainBasePath) ?
+ new string[0] :
+ new[] { Path.GetFullPath(nativeToolchainBasePath) };
+
+ logger.Information($"Preparing for compilation native binary: \"{sourceCodeDirFullPath}\" ...");
+
+ await IOAccessor.SafeCreateDirectoryAsync(
+ outputDirFullPath, outputDirFullPath != sourceCodeDirFullPath).
+ ConfigureAwait(false);
+
+ var outputStagingBaseDirPath = Path.Combine(outputDirFullPath, "obj");
+ await IOAccessor.SafeCreateDirectoryAsync(
+ outputStagingBaseDirPath, true).
+ ConfigureAwait(false);
+
+ var includeDir = Path.Combine(sourceCodeDirFullPath, "include");
+ var sourceDir = Path.Combine(sourceCodeDirFullPath, "src");
+ var sourceCodePaths =
+ Directory.EnumerateFiles(
+ sourceDir, "*.*", SearchOption.AllDirectories).
+ Where(p =>
+ Path.GetExtension(p) switch { ".c" => true, ".cpp" => true, _ => false, } &&
+ !Path.GetFileNameWithoutExtension(p).EndsWith("_bundle")). // Except bundler
+ Select(p => Path.Combine(sourceCodeDirFullPath, p)).
+ ToArray();
+
+ /////////////////////////////////////////////////////////////
+ // Compiling step:
+
+ logger.Information($"Compiling native binary into \"{outputNativeArchiveFullPath}\" ...");
+
+ // Compile in small pieces:
+ // Because LTO (LTCG) is not always enable, it is better to subdivide object files
+ // to reduce the amount of code when linking.
+#if DEBUG
+ var crs = new List();
+ foreach (var sourceCodePath in sourceCodePaths)
+ {
+ logger.Trace($"Compiling source code: \"{sourceCodePath}\" ...");
+ var r = await ExecuteCompilerAsync(
+ sourceCodePath,
+ outputStagingBaseDirPath,
+ Path.GetFileNameWithoutExtension(sourceCodePath) + ".o",
+ nativeToolchainBasePaths,
+ toolchainOptions.NativeCompiler,
+ toolchainOptions.NativeCompilerFlags,
+ includeDir,
+ sourceDir,
+ true,
+ null,
+ toolchainOptions.AdditionalIncludeDirs,
+ new string[0]).
+ ConfigureAwait(false);
+ crs.Add(r);
+ }
+#else
+ var crs = await Task.WhenAll(
+ sourceCodePaths.
+ Select(sourceCodePath =>
+ {
+ logger.Trace($"Compiling source code: \"{sourceCodePath}\" ...");
+ return ExecuteCompilerAsync(
+ sourceCodePath,
+ outputStagingBaseDirPath,
+ Path.GetFileNameWithoutExtension(sourceCodePath) + ".o",
+ nativeToolchainBasePaths,
+ toolchainOptions.NativeCompiler,
+ toolchainOptions.NativeCompilerFlags,
+ includeDir,
+ sourceDir,
+ true,
+ null,
+ toolchainOptions.AdditionalIncludeDirs,
+ new string[0]);
+ })).
+ ConfigureAwait(false);
+#endif
+ var cr = crs.FirstOrDefault(r => r.ExitCode != 0);
+ if (cr.ExitCode != 0)
+ {
+ throw new Exception($"{Path.GetFileName(toolchainOptions.NativeCompiler)}: {cr}");
+ }
+
+ var ar = await ExecuteArchiverAsync(
+ crs.Select(cr => cr.OutputPath).ToArray(),
+ outputNativeArchiveFullPath,
+ nativeToolchainBasePaths,
+ toolchainOptions.NativeArchiver).
+ ConfigureAwait(false);
+
+ if (ar.ExitCode != 0)
+ {
+ throw new Exception($"{Path.GetFileName(toolchainOptions.NativeArchiver)}: {ar}");
+ }
+
+ /////////////////////////////////////////////////////////////
+ // Linking step:
+
+ if (artifactPathOptions.OutputNativeExecutableFileName is { } &&
+ mainEntryPoint is { } &&
+ toolchainOptions.MainTemplatePath is { })
+ {
+ var outputNativeExecutableFullPath = Path.GetFullPath(
+ Path.Combine(
+ outputDirFullPath,
+ artifactPathOptions.OutputNativeExecutableFileName));
+
+ logger.Information($"Linking native binary \"{outputNativeExecutableFullPath}\"");
+
+ var mainSourceCodePath = Path.Combine(
+ outputDirFullPath,
+ Path.GetFileNameWithoutExtension(outputNativeExecutableFullPath) + ".c");
+
+ var mainBody = new StringBuilder(
+ await IOAccessor.ReadAllTextAsync(toolchainOptions.MainTemplatePath, new UTF8Encoding(false, true)).
+ ConfigureAwait(false));
+
+ mainBody.Replace("{headerName}", mainEntryPoint.DeclaringModule.DeclaringAssembly.Name + ".h");
+ mainBody.Replace("{mainIsVoid}", mainEntryPoint.ReturnType.IsVoidType ? "1" : "0");
+ mainBody.Replace("{mainSymbol}", mainEntryPoint.CLanguageFunctionFullName);
+
+ await IOAccessor.WriteAllTextAsync(mainSourceCodePath, mainBody.ToString(), new UTF8Encoding(false, true)).
+ ConfigureAwait(false);
+
+ var crf = await ExecuteCompilerAsync(
+ mainSourceCodePath,
+ outputDirFullPath,
+ outputNativeExecutableFullPath,
+ nativeToolchainBasePaths,
+ toolchainOptions.NativeCompiler,
+ toolchainOptions.NativeCompilerFlags + " " + toolchainOptions.NativeLinkingFlags,
+ includeDir,
+ sourceDir,
+ false,
+ outputNativeArchiveFullPath,
+ toolchainOptions.AdditionalIncludeDirs,
+ toolchainOptions.LibraryPaths).
+ ConfigureAwait(false);
+
+ if (crf.ExitCode != 0)
+ {
+ throw new Exception($"{Path.GetFileName(toolchainOptions.NativeCompiler)}: {crf}");
+ }
+
+ logger.Information($"Built native binary: \"{outputNativeExecutableFullPath}\" ...");
+ }
+ }
+ }
+}
diff --git a/src/IL2C.Core/Drivers/SimpleTranslator.cs b/src/IL2C.Core/Drivers/SimpleTranslator.cs
new file mode 100644
index 00000000..321f8ce0
--- /dev/null
+++ b/src/IL2C.Core/Drivers/SimpleTranslator.cs
@@ -0,0 +1,106 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
+
+using System.IO;
+using System.Threading.Tasks;
+
+using IL2C.Internal;
+using IL2C.Metadata;
+
+namespace IL2C.Drivers
+{
+ public sealed class TranslationOptions
+ {
+ public readonly bool ReadSymbols;
+ public readonly bool EnableBundler;
+ public readonly TargetPlatforms TargetPlatform;
+ public readonly DebugInformationOptions DebugInformationOption;
+
+ public TranslationOptions(
+ bool readSymbols,
+ bool enableBundler,
+ TargetPlatforms targetPlatform,
+ DebugInformationOptions debugInformationOption)
+ {
+ this.ReadSymbols = readSymbols;
+ this.EnableBundler = enableBundler;
+ this.TargetPlatform = targetPlatform;
+ this.DebugInformationOption = debugInformationOption;
+ }
+ }
+
+ public static class SimpleTranslator
+ {
+ public static async ValueTask TranslateAsync(
+ ILogger logger,
+ CodeTextStorage storage,
+ TranslationOptions options,
+ string assemblyPath)
+ {
+ logger.Information($"Preparing assembly: \"{Path.GetFullPath(assemblyPath)}\" ...");
+
+ await IOAccessor.SafeCreateDirectoryAsync(
+ storage.BasePath, true).
+ ConfigureAwait(false);
+
+ var translateContext = new TranslateContext(
+ assemblyPath, options.ReadSymbols, options.TargetPlatform);
+ var preparedFunctions = AssemblyPreparer.Prepare(
+ translateContext);
+
+ logger.Information($"Translating assembly: \"{Path.GetFullPath(assemblyPath)}\" ...");
+
+ // TODO: Makes asynchronously operation.
+
+ using (var _ = storage.EnterScope("include"))
+ {
+ AssemblyWriter.WriteHeader(
+ storage,
+ translateContext,
+ preparedFunctions);
+ }
+
+ using (var _ = storage.EnterScope("src"))
+ {
+ AssemblyWriter.WriteSourceCode(
+ storage,
+ translateContext,
+ preparedFunctions,
+ options.EnableBundler,
+ options.DebugInformationOption);
+ }
+
+ logger.Information($"Translated assembly: Stored into \"{Path.GetFullPath(storage.BasePath)}\"");
+
+ return translateContext.MetadataContext.EntryPoint;
+ }
+
+ public static ValueTask TranslateAsync(
+ ILogger logger,
+ string outputBaseDirPath,
+ bool produceCpp,
+ TranslationOptions options,
+ string assemblyPath)
+ {
+ var storage = new CodeTextStorage(
+ logger,
+ outputBaseDirPath,
+ produceCpp,
+ " ");
+
+ return TranslateAsync(
+ logger,
+ storage,
+ options,
+ assemblyPath);
+ }
+ }
+}
diff --git a/src/IL2C.Core/IL2C.Core.csproj b/src/IL2C.Core/IL2C.Core.csproj
new file mode 100644
index 00000000..539be241
--- /dev/null
+++ b/src/IL2C.Core/IL2C.Core.csproj
@@ -0,0 +1,20 @@
+
+
+
+ net462;net48;netstandard2.0;netstandard2.1;netcoreapp2.2;netcoreapp3.1;net5.0;net6.0
+ Library
+
+ IL2C.Core
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IL2C.Core/ILConveters/ArithmeticalConverters.cs b/src/IL2C.Core/ILConveters/ArithmeticalConverters.cs
similarity index 93%
rename from IL2C.Core/ILConveters/ArithmeticalConverters.cs
rename to src/IL2C.Core/ILConveters/ArithmeticalConverters.cs
index 6010bd4e..8e40e9dd 100644
--- a/IL2C.Core/ILConveters/ArithmeticalConverters.cs
+++ b/src/IL2C.Core/ILConveters/ArithmeticalConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/BoxConverters.cs b/src/IL2C.Core/ILConveters/BoxConverters.cs
similarity index 87%
rename from IL2C.Core/ILConveters/BoxConverters.cs
rename to src/IL2C.Core/ILConveters/BoxConverters.cs
index d40a9b01..e3cef4cc 100644
--- a/IL2C.Core/ILConveters/BoxConverters.cs
+++ b/src/IL2C.Core/ILConveters/BoxConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/BranchConverters.cs b/src/IL2C.Core/ILConveters/BranchConverters.cs
similarity index 92%
rename from IL2C.Core/ILConveters/BranchConverters.cs
rename to src/IL2C.Core/ILConveters/BranchConverters.cs
index cb36384b..572780ec 100644
--- a/IL2C.Core/ILConveters/BranchConverters.cs
+++ b/src/IL2C.Core/ILConveters/BranchConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/CallConverters.cs b/src/IL2C.Core/ILConveters/CallConverters.cs
similarity index 94%
rename from IL2C.Core/ILConveters/CallConverters.cs
rename to src/IL2C.Core/ILConveters/CallConverters.cs
index 6b780479..1d25cc0e 100644
--- a/IL2C.Core/ILConveters/CallConverters.cs
+++ b/src/IL2C.Core/ILConveters/CallConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
@@ -213,13 +203,13 @@ public static ExpressionEmitter Prepare(
return (extractContext, _) =>
{
var parameters = pairParameters.Select(parameter =>
- new Utilities.RightExpressionGivenParameter(
+ new SymbolManipulator.RightExpressionGivenParameter(
parameter.variable.TargetType,
parameter.variable,
string.Format(parameter.format, extractContext.GetSymbolName(parameter.variable)))).
ToArray();
- var parameterString = Utilities.GetGivenParameterDeclaration(
+ var parameterString = SymbolManipulator.GetGivenParameterDeclaration(
parameters,
extractContext,
codeInformation);
@@ -267,13 +257,13 @@ public static ExpressionEmitter Prepare(
string.Empty;
var parameters = pairParameters.Select(parameter =>
- new Utilities.RightExpressionGivenParameter(
+ new SymbolManipulator.RightExpressionGivenParameter(
parameter.type,
parameter.variable,
string.Format(parameter.format, extractContext.GetSymbolName(parameter.variable)))).
ToArray();
- var parameterString = Utilities.GetGivenParameterDeclaration(
+ var parameterString = SymbolManipulator.GetGivenParameterDeclaration(
parameters,
extractContext,
codeInformation);
diff --git a/IL2C.Core/ILConveters/ConditionalConverters.cs b/src/IL2C.Core/ILConveters/ConditionalConverters.cs
similarity index 89%
rename from IL2C.Core/ILConveters/ConditionalConverters.cs
rename to src/IL2C.Core/ILConveters/ConditionalConverters.cs
index bdbe2abe..43f50673 100644
--- a/IL2C.Core/ILConveters/ConditionalConverters.cs
+++ b/src/IL2C.Core/ILConveters/ConditionalConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/ConvConverters.cs b/src/IL2C.Core/ILConveters/ConvConverters.cs
similarity index 95%
rename from IL2C.Core/ILConveters/ConvConverters.cs
rename to src/IL2C.Core/ILConveters/ConvConverters.cs
index b8d6435d..a9535ade 100644
--- a/IL2C.Core/ILConveters/ConvConverters.cs
+++ b/src/IL2C.Core/ILConveters/ConvConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/ILConverter.cs b/src/IL2C.Core/ILConveters/ILConverter.cs
similarity index 68%
rename from IL2C.Core/ILConveters/ILConverter.cs
rename to src/IL2C.Core/ILConveters/ILConverter.cs
index 90997909..498e27c9 100644
--- a/IL2C.Core/ILConveters/ILConverter.cs
+++ b/src/IL2C.Core/ILConveters/ILConverter.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/IL2C.Core/ILConveters/ILConverters.cs b/src/IL2C.Core/ILConveters/ILConverters.cs
similarity index 95%
rename from IL2C.Core/ILConveters/ILConverters.cs
rename to src/IL2C.Core/ILConveters/ILConverters.cs
index 83ae8ab7..5cf362f7 100644
--- a/IL2C.Core/ILConveters/ILConverters.cs
+++ b/src/IL2C.Core/ILConveters/ILConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/IL2C.Core/ILConveters/LdargConverters.cs b/src/IL2C.Core/ILConveters/LdargConverters.cs
similarity index 83%
rename from IL2C.Core/ILConveters/LdargConverters.cs
rename to src/IL2C.Core/ILConveters/LdargConverters.cs
index 9c062584..6a53845d 100644
--- a/IL2C.Core/ILConveters/LdargConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdargConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/LdcConverters.cs b/src/IL2C.Core/ILConveters/LdcConverters.cs
similarity index 88%
rename from IL2C.Core/ILConveters/LdcConverters.cs
rename to src/IL2C.Core/ILConveters/LdcConverters.cs
index db5f480c..0c95eaa6 100644
--- a/IL2C.Core/ILConveters/LdcConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdcConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
@@ -37,7 +27,7 @@ public static ExpressionEmitter Prepare(
return (extractContext, _) => new[] { string.Format(
"{0} = {1}",
extractContext.GetSymbolName(symbol),
- Utilities.GetCLanguageExpression(value)) };
+ SymbolManipulator.GetCLanguageExpression(value)) };
}
public static ExpressionEmitter Prepare(
diff --git a/IL2C.Core/ILConveters/LdelemConverters.cs b/src/IL2C.Core/ILConveters/LdelemConverters.cs
similarity index 92%
rename from IL2C.Core/ILConveters/LdelemConverters.cs
rename to src/IL2C.Core/ILConveters/LdelemConverters.cs
index 1a9195a8..c427c109 100644
--- a/IL2C.Core/ILConveters/LdelemConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdelemConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/LdfldConverters.cs b/src/IL2C.Core/ILConveters/LdfldConverters.cs
similarity index 91%
rename from IL2C.Core/ILConveters/LdfldConverters.cs
rename to src/IL2C.Core/ILConveters/LdfldConverters.cs
index 5939acb5..cd4bc848 100644
--- a/IL2C.Core/ILConveters/LdfldConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdfldConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/IL2C.Core/ILConveters/LdftnConverters.cs b/src/IL2C.Core/ILConveters/LdftnConverters.cs
similarity index 85%
rename from IL2C.Core/ILConveters/LdftnConverters.cs
rename to src/IL2C.Core/ILConveters/LdftnConverters.cs
index 505bd18f..51a366ec 100644
--- a/IL2C.Core/ILConveters/LdftnConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdftnConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Linq;
diff --git a/IL2C.Core/ILConveters/LdindConverters.cs b/src/IL2C.Core/ILConveters/LdindConverters.cs
similarity index 86%
rename from IL2C.Core/ILConveters/LdindConverters.cs
rename to src/IL2C.Core/ILConveters/LdindConverters.cs
index 3a9a5d59..7046d1e7 100644
--- a/IL2C.Core/ILConveters/LdindConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdindConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/LdlenConverters.cs b/src/IL2C.Core/ILConveters/LdlenConverters.cs
similarity index 66%
rename from IL2C.Core/ILConveters/LdlenConverters.cs
rename to src/IL2C.Core/ILConveters/LdlenConverters.cs
index 695e51c3..009eda8d 100644
--- a/IL2C.Core/ILConveters/LdlenConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdlenConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/LdlocConverters.cs b/src/IL2C.Core/ILConveters/LdlocConverters.cs
similarity index 84%
rename from IL2C.Core/ILConveters/LdlocConverters.cs
rename to src/IL2C.Core/ILConveters/LdlocConverters.cs
index 3a4c56c4..f4cbd5b5 100644
--- a/IL2C.Core/ILConveters/LdlocConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdlocConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/LdtokenConverters.cs b/src/IL2C.Core/ILConveters/LdtokenConverters.cs
similarity index 78%
rename from IL2C.Core/ILConveters/LdtokenConverters.cs
rename to src/IL2C.Core/ILConveters/LdtokenConverters.cs
index 03e2fbe4..7df43723 100644
--- a/IL2C.Core/ILConveters/LdtokenConverters.cs
+++ b/src/IL2C.Core/ILConveters/LdtokenConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/LogicalConverters.cs b/src/IL2C.Core/ILConveters/LogicalConverters.cs
similarity index 86%
rename from IL2C.Core/ILConveters/LogicalConverters.cs
rename to src/IL2C.Core/ILConveters/LogicalConverters.cs
index 76231fc2..a0d19f5b 100644
--- a/IL2C.Core/ILConveters/LogicalConverters.cs
+++ b/src/IL2C.Core/ILConveters/LogicalConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/NewConverters.cs b/src/IL2C.Core/ILConveters/NewConverters.cs
similarity index 89%
rename from IL2C.Core/ILConveters/NewConverters.cs
rename to src/IL2C.Core/ILConveters/NewConverters.cs
index efe5a1e4..dbfd4b68 100644
--- a/IL2C.Core/ILConveters/NewConverters.cs
+++ b/src/IL2C.Core/ILConveters/NewConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
@@ -86,13 +76,13 @@ public override ExpressionEmitter Prepare(
var type = ctor.DeclaringType;
ILocalVariableInformation thisSymbol = null;
- var pairParameters = new LinkedList();
+ var pairParameters = new LinkedList();
foreach (var parameter in ctor.Parameters.Reverse())
{
// Except this parameter
if (pairParameters.Count < (ctor.Parameters.Length) - 1)
{
- pairParameters.AddFirst(new Utilities.RightExpressionGivenParameter(
+ pairParameters.AddFirst(new SymbolManipulator.RightExpressionGivenParameter(
parameter.TargetType,
decodeContext.PopStack()));
}
@@ -104,7 +94,7 @@ public override ExpressionEmitter Prepare(
// Instance from get_uninitialized_object
thisSymbol = decodeContext.PushStack(type, ctor);
- pairParameters.AddFirst(new Utilities.RightExpressionGivenParameter(
+ pairParameters.AddFirst(new SymbolManipulator.RightExpressionGivenParameter(
type,
thisSymbol));
}
@@ -141,7 +131,7 @@ public override ExpressionEmitter Prepare(
return (extractContext, _) =>
{
- var parameterString = Utilities.GetGivenParameterDeclaration(
+ var parameterString = SymbolManipulator.GetGivenParameterDeclaration(
pairParameters.Skip(1).ToArray(), extractContext, codeInformation);
return new[]
@@ -178,7 +168,7 @@ public override ExpressionEmitter Prepare(
return (extractContext, _) =>
{
- var parameterString = Utilities.GetGivenParameterDeclaration(
+ var parameterString = SymbolManipulator.GetGivenParameterDeclaration(
pairParameters.Skip(1).ToArray(), extractContext, codeInformation);
return new[]
@@ -196,7 +186,7 @@ public override ExpressionEmitter Prepare(
return (extractContext, _) =>
{
- var parameterString = Utilities.GetGivenParameterDeclaration(
+ var parameterString = SymbolManipulator.GetGivenParameterDeclaration(
pairParameters.ToArray(), extractContext, codeInformation);
// newobj opcode can handle value type with parameter applied constructor.
diff --git a/IL2C.Core/ILConveters/OperandTypeConverters.cs b/src/IL2C.Core/ILConveters/OperandTypeConverters.cs
similarity index 74%
rename from IL2C.Core/ILConveters/OperandTypeConverters.cs
rename to src/IL2C.Core/ILConveters/OperandTypeConverters.cs
index 171d44e9..105932c9 100644
--- a/IL2C.Core/ILConveters/OperandTypeConverters.cs
+++ b/src/IL2C.Core/ILConveters/OperandTypeConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/IL2C.Core/ILConveters/PrefixConverters.cs b/src/IL2C.Core/ILConveters/PrefixConverters.cs
similarity index 50%
rename from IL2C.Core/ILConveters/PrefixConverters.cs
rename to src/IL2C.Core/ILConveters/PrefixConverters.cs
index 50242c76..c7bf8517 100644
--- a/IL2C.Core/ILConveters/PrefixConverters.cs
+++ b/src/IL2C.Core/ILConveters/PrefixConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/IL2C.Core/ILConveters/StelemConverters.cs b/src/IL2C.Core/ILConveters/StelemConverters.cs
similarity index 91%
rename from IL2C.Core/ILConveters/StelemConverters.cs
rename to src/IL2C.Core/ILConveters/StelemConverters.cs
index de9142cb..8d6721e8 100644
--- a/IL2C.Core/ILConveters/StelemConverters.cs
+++ b/src/IL2C.Core/ILConveters/StelemConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/StfldConverters.cs b/src/IL2C.Core/ILConveters/StfldConverters.cs
similarity index 89%
rename from IL2C.Core/ILConveters/StfldConverters.cs
rename to src/IL2C.Core/ILConveters/StfldConverters.cs
index dfe39b5c..88a00bf3 100644
--- a/IL2C.Core/ILConveters/StfldConverters.cs
+++ b/src/IL2C.Core/ILConveters/StfldConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
using System.Diagnostics;
diff --git a/IL2C.Core/ILConveters/StindConverters.cs b/src/IL2C.Core/ILConveters/StindConverters.cs
similarity index 82%
rename from IL2C.Core/ILConveters/StindConverters.cs
rename to src/IL2C.Core/ILConveters/StindConverters.cs
index 6ebba82e..f3863073 100644
--- a/IL2C.Core/ILConveters/StindConverters.cs
+++ b/src/IL2C.Core/ILConveters/StindConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/IL2C.Core/ILConveters/StlocConverters.cs b/src/IL2C.Core/ILConveters/StlocConverters.cs
similarity index 84%
rename from IL2C.Core/ILConveters/StlocConverters.cs
rename to src/IL2C.Core/ILConveters/StlocConverters.cs
index 41fa7f3d..5618422e 100644
--- a/IL2C.Core/ILConveters/StlocConverters.cs
+++ b/src/IL2C.Core/ILConveters/StlocConverters.cs
@@ -1,21 +1,11 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
using System;
diff --git a/src/IL2C.Core/ILogger.cs b/src/IL2C.Core/ILogger.cs
new file mode 100644
index 00000000..f5b497f1
--- /dev/null
+++ b/src/IL2C.Core/ILogger.cs
@@ -0,0 +1,154 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
+
+using System;
+using System.ComponentModel;
+using System.IO;
+using System.Threading.Tasks;
+
+namespace IL2C
+{
+ public enum LogLevels
+ {
+ Debug = 1,
+ Trace,
+ Information,
+ Warning,
+ Error,
+ Silent = 100,
+ }
+
+ public interface ILogger
+ {
+ ValueTask OutputLogAsync(
+ LogLevels logLevel, FormattableString? message, Exception? ex);
+ }
+
+ public static class LoggerExtension
+ {
+ public static void Debug(this ILogger logger, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Debug, message, null);
+
+ public static void Trace(this ILogger logger, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Trace, message, null);
+
+ public static void Information(this ILogger logger, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Information, message, null);
+
+ public static void Warning(this ILogger logger, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Warning, message, null);
+ public static void Warning(this ILogger logger, Exception ex) =>
+ _ = logger.OutputLogAsync(LogLevels.Warning, null, ex);
+ public static void Warning(this ILogger logger, Exception ex, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Warning, message, ex);
+
+ public static void Error(this ILogger logger, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Error, message, null);
+ public static void Error(this ILogger logger, Exception ex) =>
+ _ = logger.OutputLogAsync(LogLevels.Error, null, ex);
+ public static void Error(this ILogger logger, Exception ex, FormattableString message) =>
+ _ = logger.OutputLogAsync(LogLevels.Error, message, ex);
+
+ ////////////////////////////////////////////////
+
+ public static ValueTask DebugAsync(this ILogger logger, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Debug, message, null);
+
+ public static ValueTask TraceAsync(this ILogger logger, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Trace, message, null);
+
+ public static ValueTask InformationAsync(this ILogger logger, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Information, message, null);
+
+ public static ValueTask WarningAsync(this ILogger logger, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Warning, message, null);
+ public static ValueTask WarningAsync(this ILogger logger, Exception ex) =>
+ logger.OutputLogAsync(LogLevels.Warning, null, ex);
+ public static ValueTask WarningAsync(this ILogger logger, Exception ex, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Warning, message, ex);
+
+ public static ValueTask ErrorAsync(this ILogger logger, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Error, message, null);
+ public static ValueTask ErrorAsync(this ILogger logger, Exception ex) =>
+ logger.OutputLogAsync(LogLevels.Error, null, ex);
+ public static ValueTask ErrorAsync(this ILogger logger, Exception ex, FormattableString message) =>
+ logger.OutputLogAsync(LogLevels.Error, message, ex);
+ }
+
+ public abstract class LoggerBase : ILogger
+ {
+ public readonly LogLevels BaseLevel;
+
+ protected LoggerBase(LogLevels baseLevel) =>
+ this.BaseLevel = baseLevel;
+
+ public async ValueTask OutputLogAsync(
+ LogLevels logLevel, FormattableString? message, Exception? ex)
+ {
+ if (logLevel >= this.BaseLevel)
+ {
+ await this.OnOutputLogAsync(logLevel, message, ex).
+ ConfigureAwait(false);
+ }
+ }
+
+ protected virtual string? ToString(
+ string? header, LogLevels logLevel, FormattableString? message, Exception? ex)
+ {
+ static string GetHeaderString(string? header) =>
+ header is { } ? $",{header}" : "";
+ static string GetLogLevelString(LogLevels logLevel) =>
+ logLevel != LogLevels.Information ? $" {logLevel}:" : "";
+
+ switch (message, ex)
+ {
+ case ({ }, { }):
+ return $"IL2C [{ThisAssembly.AssemblyVersion}]{GetHeaderString(header)}:{GetLogLevelString(logLevel)} {message}, {ex}";
+ case ({ }, null):
+ return $"IL2C [{ThisAssembly.AssemblyVersion}]{GetHeaderString(header)}:{GetLogLevelString(logLevel)} {message}";
+ case (null, { }):
+ return $"IL2C [{ThisAssembly.AssemblyVersion}]{GetHeaderString(header)}:{GetLogLevelString(logLevel)} {ex}";
+ default:
+ return null;
+ }
+ }
+
+ protected abstract ValueTask OnOutputLogAsync(
+ LogLevels logLevel, FormattableString? message, Exception? ex);
+ }
+
+ public sealed class TextWriterLogger : LoggerBase, IDisposable
+ {
+ public readonly TextWriter Writer;
+
+ private readonly string? header;
+
+ public TextWriterLogger(LogLevels baseLevel, TextWriter tw, string? header = null) :
+ base(baseLevel)
+ {
+ this.Writer = tw;
+ this.header = header;
+ }
+
+ public void Dispose() =>
+ this.Writer.Flush();
+
+ protected override async ValueTask OnOutputLogAsync(
+ LogLevels logLevel, FormattableString? message, Exception? ex)
+ {
+ if (base.ToString(this.header, logLevel, message, ex) is { } formatted)
+ {
+ await this.Writer.WriteLineAsync(formatted).
+ ConfigureAwait(false);
+ }
+ }
+ }
+}
diff --git a/IL2C.Core/Internal/EndiannessBinaryReader.cs b/src/IL2C.Core/Internal/EndiannessBinaryReader.cs
similarity index 86%
rename from IL2C.Core/Internal/EndiannessBinaryReader.cs
rename to src/IL2C.Core/Internal/EndiannessBinaryReader.cs
index b540169c..b9aa910f 100644
--- a/IL2C.Core/Internal/EndiannessBinaryReader.cs
+++ b/src/IL2C.Core/Internal/EndiannessBinaryReader.cs
@@ -1,21 +1,13 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
using System;
using System.IO;
diff --git a/src/IL2C.Core/Internal/ICombinedComparer.cs b/src/IL2C.Core/Internal/ICombinedComparer.cs
new file mode 100644
index 00000000..5fe5ca97
--- /dev/null
+++ b/src/IL2C.Core/Internal/ICombinedComparer.cs
@@ -0,0 +1,20 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
+
+using System.Collections.Generic;
+
+namespace IL2C.Internal
+{
+ internal interface ICombinedComparer
+ : IEqualityComparer, IComparer
+ {
+ }
+}
diff --git a/src/IL2C.Core/Internal/IOAccessor.cs b/src/IL2C.Core/Internal/IOAccessor.cs
new file mode 100644
index 00000000..d1f3fd77
--- /dev/null
+++ b/src/IL2C.Core/Internal/IOAccessor.cs
@@ -0,0 +1,175 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
+//
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
+//
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace IL2C.Internal
+{
+ internal readonly struct ExecuteResult
+ {
+ public readonly int ExitCode;
+ public readonly string Logs;
+
+ public ExecuteResult(int exitCode, string logs)
+ {
+ this.ExitCode = exitCode;
+ this.Logs = logs;
+ }
+
+ public override string ToString() =>
+ $"{this.ExitCode}: {this.Logs}";
+ }
+
+ internal static class IOAccessor
+ {
+ public static string ToRelativePath(string baseDirPath, string path)
+ {
+ var length = baseDirPath.EndsWith(Path.DirectorySeparatorChar.ToString()) ?
+ baseDirPath.Length : baseDirPath.Length + 1;
+ var candidate = path.StartsWith(baseDirPath) ?
+ path.Substring(length) : path;
+ return candidate.Length >= 1 ? candidate : ".";
+ }
+
+ public static string SafeGetDirectoryName(string path) =>
+ Path.GetDirectoryName(path) ?? ".";
+
+ public static ValueTask SafeCreateDirectoryAsync(string path, bool clean) =>
+ new ValueTask(Task.Run(() =>
+ {
+ if (clean)
+ {
+ try
+ {
+ Directory.Delete(path, true);
+ }
+ catch
+ {
+ }
+ }
+ if (!Directory.Exists(path))
+ {
+ try
+ {
+ Directory.CreateDirectory(path);
+ }
+ catch
+ {
+ }
+ }
+ }));
+
+#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER
+ public static ValueTask ReadAllTextAsync(string path, Encoding encoding) =>
+ new ValueTask(File.ReadAllTextAsync(path, encoding));
+ public static ValueTask WriteAllTextAsync(string path, string contents, Encoding encoding) =>
+ new ValueTask(File.WriteAllTextAsync(path, contents, encoding));
+#else
+ public static ValueTask ReadAllTextAsync(string path, Encoding encoding) =>
+ new ValueTask(Task.Run(() => File.ReadAllText(path, encoding)));
+ public static ValueTask WriteAllTextAsync(string path, string contents, Encoding encoding) =>
+ new ValueTask(Task.Run(() => File.WriteAllText(path, contents, encoding)));
+#endif
+
+ public static async ValueTask ExecuteAsync(
+ string workingPath, string scriptName, string[] searchPaths,
+ string executablePath, string[] args)
+ {
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+ {
+ await WriteAllTextAsync(
+ Path.Combine(workingPath, scriptName + ".bat"),
+ string.Join(Environment.NewLine, new[]
+ {
+ "@echo off",
+ string.Empty,
+ "rem IL2C: It is a pseudo script.",
+ string.Empty,
+ searchPaths.Length >= 1 ?
+ $"set PATH={string.Join(";",searchPaths)};%PATH%" :
+ "rem set PATH=;%PATH%",
+ string.Empty,
+ $"\"{executablePath}\" {string.Join(" ", args)}",
+ string.Empty,
+ }),
+ new UTF8Encoding(false, true)).
+ ConfigureAwait(false);
+ }
+ else
+ {
+ await WriteAllTextAsync(
+ Path.Combine(workingPath, scriptName + ".sh"),
+ string.Join(Environment.NewLine, new[]
+ {
+ "#!/bin/sh",
+ string.Empty,
+ "# IL2C: It is a pseudo script.",
+ string.Empty,
+ searchPaths.Length >= 1 ?
+ $"export PATH=\"{string.Join(":",searchPaths)}:$PATH\"" :
+ "#export PATH=\":$PATH\"",
+ string.Empty,
+ $"\"{executablePath}\" {string.Join(" ", args)}",
+ string.Empty,
+ }),
+ new UTF8Encoding(false, true)).
+ ConfigureAwait(false);
+ }
+
+ using (var p = new Process())
+ {
+ p.StartInfo.FileName = executablePath;
+ p.StartInfo.Arguments = string.Join(" ", args);
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.CreateNoWindow = true;
+ p.StartInfo.ErrorDialog = false;
+ p.StartInfo.WorkingDirectory = workingPath;
+
+#if NET46_OR_GREATER || NETSTANDARD || NETCOREAPP
+ var pathEnv = p.StartInfo.Environment["PATH"];
+ p.StartInfo.Environment["PATH"] = string.Join(";", searchPaths) + ";" + pathEnv;
+#else
+ var pathEnv = p.StartInfo.EnvironmentVariables["PATH"];
+ p.StartInfo.EnvironmentVariables["PATH"] = string.Join(";", searchPaths) + ";" + pathEnv;
+#endif
+ p.StartInfo.RedirectStandardOutput = true;
+ p.StartInfo.RedirectStandardError = true;
+
+ var sb = new StringBuilder();
+ p.OutputDataReceived += (sender, e) => { if (e.Data != null) lock (sb) sb.AppendLine(e.Data); };
+ p.ErrorDataReceived += (sender, e) => { if (e.Data != null) lock (sb) sb.AppendLine(e.Data); };
+
+ var tcs = new TaskCompletionSource();
+ p.Exited += (sender, e) => tcs.SetResult(p.ExitCode);
+ p.EnableRaisingEvents = true;
+
+ p.Start();
+
+ p.BeginOutputReadLine();
+ p.BeginErrorReadLine();
+
+ var exitCode = await tcs.Task.
+ ConfigureAwait(false);
+
+ p.WaitForExit();
+
+ p.CancelOutputRead();
+ p.CancelErrorRead();
+
+ return new ExecuteResult(exitCode, sb.ToString());
+ }
+ }
+ }
+}
diff --git a/IL2C.Core/Internal/Utilities.cs b/src/IL2C.Core/Internal/SymbolManipulator.cs
similarity index 64%
rename from IL2C.Core/Internal/Utilities.cs
rename to src/IL2C.Core/Internal/SymbolManipulator.cs
index 99c0f71d..d48a0238 100644
--- a/IL2C.Core/Internal/Utilities.cs
+++ b/src/IL2C.Core/Internal/SymbolManipulator.cs
@@ -1,41 +1,29 @@
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
-// Copyright (c) 2016-2019 Kouji Matsui (@kozy_kekyo, @kekyo2)
+// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
+// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+
+#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
-using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
-using Mono.Cecil.Cil;
-
-using IL2C.ILConverters;
-using IL2C.Translators;
using IL2C.Metadata;
+using IL2C.Translators;
namespace IL2C.Internal
{
- internal static class Utilities
+ internal static class SymbolManipulator
{
private static readonly string intMinValueExpression = string.Format("{0} - 1", int.MinValue + 1);
private static readonly string longMinValueExpression = string.Format("{0}LL - 1LL", long.MinValue + 1);
@@ -44,22 +32,6 @@ internal static class Utilities
'.', ',', '@', '+', '-', '*', '/', '^', '\\', '#', '%', '&', '$', '?', '!', '=', '~', '|',
'(', ')', '<', '>', '[', ']', '{', '}', '\'', '"', '`', ';', ':', ' ' };
- private static readonly Dictionary ilConverters;
-
- static Utilities()
- {
- ilConverters = typeof(ILConverter).
- GetTypeInfo().
- Assembly.
- DefinedTypes.
- Where(type => type.IsSealed && typeof(ILConverter).GetTypeInfo().IsAssignableFrom(type)).
- Select(type => (ILConverter)Activator.CreateInstance(type.AsType())).
- ToDictionary(ilc => ilc.OpCode);
- }
-
- public static bool TryGetILConverter(OpCode opCode, out ILConverter ilc) =>
- ilConverters.TryGetValue(opCode, out ilc);
-
public static string GetMangledName(string name)
{
var sb = new StringBuilder(name);
@@ -77,7 +49,7 @@ public static string GetCLanguageScopedPath(params string[] scopeNames) =>
GetCLanguageScopedPath((IEnumerable)scopeNames);
public static string GetCLanguageTypeName(
- Type type, string symbolName = null, bool cArrayExpression = false)
+ Type type, string? symbolName = null, bool cArrayExpression = false)
{
var sn = (symbolName != null) ? (" " + symbolName) : string.Empty;
@@ -85,7 +57,7 @@ public static string GetCLanguageTypeName(
{
return string.Format(
"{0}*{1}",
- GetCLanguageTypeName(type.GetElementType()),
+ GetCLanguageTypeName(type.GetElementType()!),
sn);
}
@@ -95,19 +67,19 @@ public static string GetCLanguageTypeName(
{
return string.Format(
"{0}{1}[]",
- GetCLanguageTypeName(type.GetElementType(), null, true),
+ GetCLanguageTypeName(type.GetElementType()!, null, true),
sn);
}
else
{
return string.Format(
"{0}*{1}",
- GetCLanguageTypeName(type.GetElementType(), null, true),
+ GetCLanguageTypeName(type.GetElementType()!, null, true),
sn);
}
}
- string typeName = null;
+ string typeName;
if (type == typeof(bool))
{
typeName = "bool";
@@ -174,20 +146,18 @@ public static string GetCLanguageTypeName(
}
else
{
- typeName = GetMangledName(type.FullName);
+ typeName = GetMangledName(type.FullName!);
if (!type.IsValueType)
{
typeName += "*";
}
}
- Debug.Assert(typeName != null);
-
return typeName + sn;
}
#region GetCLanguageSizeOf
- private static string InternalGetCLanguageSizeOfExpression(Type type)
+ private static string? InternalGetCLanguageSizeOfExpression(Type type)
{
if (type.IsEnum)
{
@@ -412,15 +382,15 @@ public static string GetCLanguageExpression(UIntPtr value) =>
public static string GetCLanguageExpression(Enum value) =>
Enum.IsDefined(value.GetType(), value) ?
string.Format("{0}_{1}",
- GetMangledName(value.GetType().FullName),
+ GetMangledName(value.GetType().FullName!),
value) :
string.Format("({0}){1}",
- GetMangledName(value.GetType().FullName),
+ GetMangledName(value.GetType().FullName!),
GetCLanguageExpression(
value.GetType().
GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly).
First().
- GetValue(value)));
+ GetValue(value)!));
public static string GetCLanguageExpression(Array arr)
{
@@ -447,7 +417,7 @@ public static string GetCLanguageExpression(object value)
if (value is string) return GetCLanguageExpression((string)value);
if (value is Enum) return GetCLanguageExpression((Enum)value);
if (value is Array) return GetCLanguageExpression((Array)value);
- return value.ToString();
+ return value.ToString() ?? "NULL";
}
#endregion
@@ -459,107 +429,11 @@ public static string GetCSharpLanguageExpression(object value)
if (value is char) return string.Format("'{0}'", value);
if (value is Array) return string.Format(
"{0}[{1}]",
- value.GetType().GetElementType().Name,
+ value.GetType().GetElementType()!.Name,
string.Join(
", ",
((IEnumerable)value).RuntimeCast