Skip to content

Commit 4928cfb

Browse files
committed
Merge remote-tracking branch 'hagane/master'
2 parents db16681 + 726fe52 commit 4928cfb

6 files changed

Lines changed: 165 additions & 1 deletion

File tree

Naggum.Runtime/Reader.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,23 @@ private static Object ReadSymbol(StreamReader reader)
7676
private static Object ReadList(StreamReader reader)
7777
{
7878
bool in_list = true;
79+
Stack<Object> list_stack = new Stack<object>();
7980
Cons list = null;
8081
while (in_list)
8182
{
8283
var ch = reader.Peek();
8384
if (ch < 0) throw new IOException("Unexpected end of stream.");
8485
if ((char)ch != ')')
8586
{
86-
list = new Cons(ReadObject(reader), list);
87+
list_stack.Push(ReadObject(reader));
8788
}
8889
else
8990
{
9091
reader.Read(); //consume closing paren
9192
in_list = false;
9293
}
9394
}
95+
while (list_stack.Count > 0) list = new Cons(list_stack.Pop(), list);
9496
return list;
9597
}
9698

Naggum.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,52 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test programs", "Test progr
1313
EndProject
1414
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Naggum.Runtime", "Naggum.Runtime\Naggum.Runtime.csproj", "{402B5E79-E063-4833-AE4B-2986AEEC1D75}"
1515
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ngi", "ngi\ngi.csproj", "{34E781DF-EAD9-4034-ADE4-8DA41A16644A}"
17+
ProjectSection(ProjectDependencies) = postProject
18+
{402B5E79-E063-4833-AE4B-2986AEEC1D75} = {402B5E79-E063-4833-AE4B-2986AEEC1D75}
19+
EndProjectSection
1620
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Naggum.Test", "Naggum.Test\Naggum.Test.fsproj", "{38230CBD-DE3E-4470-925F-DE966E8691AA}"
1721
EndProject
1822
Global
1923
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2024
Debug|Any CPU = Debug|Any CPU
25+
Debug|Mixed Platforms = Debug|Mixed Platforms
26+
Debug|x86 = Debug|x86
2127
Release|Any CPU = Release|Any CPU
28+
Release|Mixed Platforms = Release|Mixed Platforms
29+
Release|x86 = Release|x86
2230
EndGlobalSection
2331
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2432
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2533
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
35+
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
36+
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Debug|x86.ActiveCfg = Debug|Any CPU
2637
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
2738
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
40+
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
41+
{A4269C5E-E4AC-44BF-A06E-1B45248910AD}.Release|x86.ActiveCfg = Release|Any CPU
2842
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2943
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Debug|Any CPU.Build.0 = Debug|Any CPU
44+
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
45+
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
46+
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Debug|x86.ActiveCfg = Debug|Any CPU
3047
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|Any CPU.ActiveCfg = Release|Any CPU
3148
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
50+
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|Mixed Platforms.Build.0 = Release|Any CPU
51+
{402B5E79-E063-4833-AE4B-2986AEEC1D75}.Release|x86.ActiveCfg = Release|Any CPU
52+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Debug|Any CPU.ActiveCfg = Debug|x86
53+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
54+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Debug|Mixed Platforms.Build.0 = Debug|x86
55+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Debug|x86.ActiveCfg = Debug|x86
56+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Debug|x86.Build.0 = Debug|x86
57+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Release|Any CPU.ActiveCfg = Release|x86
58+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Release|Mixed Platforms.ActiveCfg = Release|x86
59+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Release|Mixed Platforms.Build.0 = Release|x86
60+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Release|x86.ActiveCfg = Release|x86
61+
{34E781DF-EAD9-4034-ADE4-8DA41A16644A}.Release|x86.Build.0 = Release|x86
3262
{38230CBD-DE3E-4470-925F-DE966E8691AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3363
{38230CBD-DE3E-4470-925F-DE966E8691AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
3464
{38230CBD-DE3E-4470-925F-DE966E8691AA}.Release|Any CPU.ActiveCfg = Release|Any CPU

ngc/Context.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ type Context =
5454
let types = List.ofArray (asm.GetTypes())
5555
List.iter (fun (t:Type) -> this.types.Add(new Symbol(t.FullName),t)) types
5656

57+
member public this.captureLocal(localName: Symbol, typeBuilder: TypeBuilder) =
58+
let local = this.locals.[localName]
59+
match local with
60+
| Local (_,t) ->
61+
let field = typeBuilder.DefineField(localName.Name,t,FieldAttributes.Static ||| FieldAttributes.Private)
62+
this.locals.[localName] <- Field (field, t)
63+
| Field (fb,_) -> ()
64+
| Arg (_,_) -> failwithf "Unable to capture parameter %A" localName.Name
65+
5766
let create () =
5867
let context = new Context()
5968
context

ngi/Program.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.IO;
5+
using System.Text;
6+
using Naggum.Runtime;
7+
8+
namespace ngi
9+
{
10+
class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
Stream input = System.Console.OpenStandardInput();
15+
for (; ; )
16+
{
17+
System.Console.Out.Write(">");
18+
Object obj = Reader.Read(input);
19+
System.Console.Out.WriteLine(obj.ToString());
20+
}
21+
input.Close();
22+
}
23+
}
24+
}

ngi/Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("ngi")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ngi")]
13+
[assembly: AssemblyCopyright("Copyright © Hagane 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("fe6d0e11-90e5-4715-9a40-878ecf803b52")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

ngi/ngi.csproj

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{34E781DF-EAD9-4034-ADE4-8DA41A16644A}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>ngi</RootNamespace>
12+
<AssemblyName>ngi</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
<FileAlignment>512</FileAlignment>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18+
<PlatformTarget>x86</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>..\bin\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28+
<PlatformTarget>x86</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>..\bin\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<ProjectReference Include="..\Naggum.Runtime\Naggum.Runtime.csproj">
51+
<Project>{402B5E79-E063-4833-AE4B-2986AEEC1D75}</Project>
52+
<Name>Naggum.Runtime</Name>
53+
</ProjectReference>
54+
</ItemGroup>
55+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
57+
Other similar extension points exist, see Microsoft.Common.targets.
58+
<Target Name="BeforeBuild">
59+
</Target>
60+
<Target Name="AfterBuild">
61+
</Target>
62+
-->
63+
</Project>

0 commit comments

Comments
 (0)