Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bin/
obj/
*.suo
*.suo
/_ReSharper.Naggum/
/*.user
/packages/
45 changes: 43 additions & 2 deletions Naggum.Runtime/Symbol.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -16,15 +36,36 @@ public Symbol(String aName)

bool IEquatable<Symbol>.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();
}

/// <summary>
/// </summary>
/// <returns>Returns symbol's name as string.</returns>
public override string ToString()
{
return Name;
}

private static bool AreEqual(Symbol one, Symbol other)
{
return one.Name.Equals(other.Name);
}
}
}
37 changes: 37 additions & 0 deletions Naggum.Test/CompilerTest.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(* 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
open System.IO

[<TestFixture>]
type CompilerTest() =
let sourceFilename = @"..\..\..\tests\test.naggum"

[<Test>]
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
65 changes: 65 additions & 0 deletions Naggum.Test/Naggum.Test.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{38230cbd-de3e-4470-925f-de966e8691aa}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Naggum.Test</RootNamespace>
<AssemblyName>Naggum.Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<Name>Naggum.Test</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\Naggum.Test.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\Naggum.Test.XML</DocumentationFile>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
<ItemGroup>
<Compile Include="CompilerTest.fs" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.1\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ngc\ngc.fsproj">
<Name>ngc</Name>
<Project>{a4269c5e-e4ac-44bf-a06e-1b45248910ad}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
4 changes: 4 additions & 0 deletions Naggum.Test/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.1" targetFramework="net40" />
</packages>
6 changes: 6 additions & 0 deletions Naggum.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ngc/Generator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test.naggum
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down