From 2b621d66eea568f51c5daf0c4fce432718923617 Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Tue, 23 Oct 2012 21:18:13 +0700 Subject: [PATCH 1/8] Global: ignored Resharper stuff. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7b9cf3..21c9f83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/ obj/ -*.suo \ No newline at end of file +*.suo +/_ReSharper.Naggum/ From 783eff3d2feefc0138840fe5a616eb44a28af094 Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Tue, 23 Oct 2012 21:19:07 +0700 Subject: [PATCH 2/8] Tests: tab converted to space. --- tests/test.naggum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.naggum b/tests/test.naggum index af07ca9..31b01e7 100644 --- a/tests/test.naggum +++ b/tests/test.naggum @@ -52,7 +52,7 @@ (System.Console.WriteLine "Instance calls:") (let ((test-obj (new System.Random))) (System.Console.Write "Random number:") - (System.Console.WriteLine (call Next test-obj)))) + (System.Console.WriteLine (call Next test-obj)))) (System.Console.WriteLine "Naggum test suite") From 05a29345888cefba8ea2dab652977e923e86cff2 Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Tue, 23 Oct 2012 21:41:40 +0700 Subject: [PATCH 3/8] Global: some NuGet stuff ignored. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 21c9f83..0bfcbd8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ bin/ obj/ *.suo /_ReSharper.Naggum/ +/*.user +/packages/ From 2859c905a70c5d8e7a524100725f96dfa631816c Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Tue, 23 Oct 2012 21:42:02 +0700 Subject: [PATCH 4/8] Naggum.Test: our first test method. --- Naggum.Test/CompilerTest.fs | 17 +++++++++ Naggum.Test/Naggum.Test.fsproj | 65 ++++++++++++++++++++++++++++++++++ Naggum.Test/packages.config | 4 +++ Naggum.sln | 6 ++++ 4 files changed, 92 insertions(+) create mode 100644 Naggum.Test/CompilerTest.fs create mode 100644 Naggum.Test/Naggum.Test.fsproj create mode 100644 Naggum.Test/packages.config diff --git a/Naggum.Test/CompilerTest.fs b/Naggum.Test/CompilerTest.fs new file mode 100644 index 0000000..90a4542 --- /dev/null +++ b/Naggum.Test/CompilerTest.fs @@ -0,0 +1,17 @@ +namespace Naggum.Test +open Naggum.Compiler +open NUnit.Framework +open System.Diagnostics +open System.IO + +[] +type CompilerTest() = + let sourceFilename = @"..\..\..\tests\test.naggum" + + [] + member this.RunTest() = + let filename = "test.exe" + + use stream = File.Open(sourceFilename, FileMode.Open) + Generator.compile stream "test" filename [] + ignore <| (Process.Start filename).WaitForExit(30000) // 30 sec should be enough diff --git a/Naggum.Test/Naggum.Test.fsproj b/Naggum.Test/Naggum.Test.fsproj new file mode 100644 index 0000000..5c8264b --- /dev/null +++ b/Naggum.Test/Naggum.Test.fsproj @@ -0,0 +1,65 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {38230cbd-de3e-4470-925f-de966e8691aa} + Library + Naggum.Test + Naggum.Test + v4.0 + Naggum.Test + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\Naggum.Test.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\Naggum.Test.XML + + + + + + + + + + + + ..\packages\NUnit.2.6.1\lib\nunit.framework.dll + True + + + + + + + + ngc + {a4269c5e-e4ac-44bf-a06e-1b45248910ad} + True + + + + \ No newline at end of file diff --git a/Naggum.Test/packages.config b/Naggum.Test/packages.config new file mode 100644 index 0000000..bd9ee8b --- /dev/null +++ b/Naggum.Test/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Naggum.sln b/Naggum.sln index 0fbe977..634c621 100644 --- a/Naggum.sln +++ b/Naggum.sln @@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test programs", "Test progr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Naggum.Runtime", "Naggum.Runtime\Naggum.Runtime.csproj", "{402B5E79-E063-4833-AE4B-2986AEEC1D75}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Naggum.Test", "Naggum.Test\Naggum.Test.fsproj", "{38230CBD-DE3E-4470-925F-DE966E8691AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,6 +26,10 @@ Global {402B5E79-E063-4833-AE4B-2986AEEC1D75}.Debug|Any CPU.Build.0 = Debug|Any CPU {402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|Any CPU.ActiveCfg = Release|Any CPU {402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|Any CPU.Build.0 = Release|Any CPU + {38230CBD-DE3E-4470-925F-DE966E8691AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38230CBD-DE3E-4470-925F-DE966E8691AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38230CBD-DE3E-4470-925F-DE966E8691AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38230CBD-DE3E-4470-925F-DE966E8691AA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From bff60bc5975aee9b6b3f8c4b32630ee6b3494e2c Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Tue, 23 Oct 2012 21:45:44 +0700 Subject: [PATCH 5/8] Naggum.Test: copy-pasted the copyright notice. --- Naggum.Test/CompilerTest.fs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Naggum.Test/CompilerTest.fs b/Naggum.Test/CompilerTest.fs index 90a4542..77bb835 100644 --- a/Naggum.Test/CompilerTest.fs +++ b/Naggum.Test/CompilerTest.fs @@ -1,4 +1,24 @@ -namespace Naggum.Test +(* Copyright (C) 2012 by ForNeVeR + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. *) + +namespace Naggum.Test open Naggum.Compiler open NUnit.Framework open System.Diagnostics From 1161c83f3adc0451c3ca78fa21366b5720c949a8 Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Wed, 24 Oct 2012 21:29:52 +0700 Subject: [PATCH 6/8] Generator: loading mscorlib library. --- ngc/Generator.fs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ngc/Generator.fs b/ngc/Generator.fs index ec11a43..c9e208a 100644 --- a/ngc/Generator.fs +++ b/ngc/Generator.fs @@ -59,6 +59,8 @@ let compile (source : Stream) (assemblyName : string) (fileName : string) (asmRe let rta = Assembly.LoadFrom("Naggum.Runtime.dll") context.loadAssembly rta + // Load .NET runtime and all referenced assemblies: + context.loadAssembly <| Assembly.Load "mscorlib" List.iter context.loadAssembly (List.map Assembly.LoadFrom asmRefs) prologue ilGenerator From fd41fe7abcb8cd297fd9279ee197bdd087c86913 Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Wed, 24 Oct 2012 21:31:56 +0700 Subject: [PATCH 7/8] Symbol: fixed equality test. --- Naggum.Runtime/Symbol.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Naggum.Runtime/Symbol.cs b/Naggum.Runtime/Symbol.cs index 92fd003..7d78ecf 100644 --- a/Naggum.Runtime/Symbol.cs +++ b/Naggum.Runtime/Symbol.cs @@ -16,9 +16,25 @@ public Symbol(String aName) bool IEquatable.Equals(Symbol other) { - return Name.Equals(other.Name); + return AreEqual(this, other); } + public override bool Equals(object obj) + { + var symbol = obj as Symbol; + if (symbol != null) + { + return AreEqual(this, symbol); + } + + return false; + } + + public override int GetHashCode() + { + return Name.GetHashCode(); + } + /// /// /// Returns symbol's name as string. @@ -26,5 +42,10 @@ public override string ToString() { return Name; } + + private static bool AreEqual(Symbol one, Symbol other) + { + return one.Name.Equals(other.Name); + } } } From 6b1b846c70f369cc43112f5abc05d18dc5188744 Mon Sep 17 00:00:00 2001 From: ForNeVeR Date: Wed, 24 Oct 2012 21:36:42 +0700 Subject: [PATCH 8/8] Symbol: copyright notice. --- Naggum.Runtime/Symbol.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Naggum.Runtime/Symbol.cs b/Naggum.Runtime/Symbol.cs index 7d78ecf..eded498 100644 --- a/Naggum.Runtime/Symbol.cs +++ b/Naggum.Runtime/Symbol.cs @@ -1,4 +1,24 @@ -using System; +/* Copyright (C) 2012 by ForNeVeR, Hagane + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ + +using System; namespace Naggum.Runtime {