diff options
Diffstat (limited to 'ClojureCLR/Clojure/Simple.Console')
3 files changed, 217 insertions, 0 deletions
diff --git a/ClojureCLR/Clojure/Simple.Console/Properties/AssemblyInfo.cs b/ClojureCLR/Clojure/Simple.Console/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..513c88d4 --- /dev/null +++ b/ClojureCLR/Clojure/Simple.Console/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Simple.Console")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Simple.Console")]
+[assembly: AssemblyCopyright("Copyright © 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("2ebfb04e-e46e-4146-9fba-0ed41df0111e")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ClojureCLR/Clojure/Simple.Console/Simple.Console.csproj b/ClojureCLR/Clojure/Simple.Console/Simple.Console.csproj new file mode 100644 index 00000000..f5058bf9 --- /dev/null +++ b/ClojureCLR/Clojure/Simple.Console/Simple.Console.csproj @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{B57B71C6-A952-41A1-ABF1-9B9BACDD12ED}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Simple.Console</RootNamespace>
+ <AssemblyName>Simple.Console</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="SimpleConsole.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\DLR_Main\Src\Runtime\Microsoft.Scripting.Core\Microsoft.Scripting.Core.csproj">
+ <Project>{2AE75F5A-CD1F-4925-9647-AF4D1C282FB4}</Project>
+ <Name>Microsoft.Scripting.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\DLR_Main\Src\Runtime\Microsoft.Scripting\Microsoft.Scripting.csproj">
+ <Project>{EB66B766-6354-4208-A3D4-AACBDCB5C3B3}</Project>
+ <Name>Microsoft.Scripting</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Clojure\Clojure.csproj">
+ <Project>{B8089F66-DFBD-4906-BEE0-B317689C2524}</Project>
+ <Name>Clojure</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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>
\ No newline at end of file diff --git a/ClojureCLR/Clojure/Simple.Console/SimpleConsole.cs b/ClojureCLR/Clojure/Simple.Console/SimpleConsole.cs new file mode 100644 index 00000000..357cd02d --- /dev/null +++ b/ClojureCLR/Clojure/Simple.Console/SimpleConsole.cs @@ -0,0 +1,108 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using clojure.lang;
+using System.Diagnostics;
+using System.IO;
+using Microsoft.Linq.Expressions;
+using Microsoft.Scripting.Generation;
+
+namespace clojure.console
+{
+ class SimpleConsole
+ {
+ static void Main(string[] args)
+ {
+ new SimpleConsole().Run();
+ }
+
+
+
+ private void Run()
+ {
+ Initialize();
+ RunInteractiveLoop();
+ }
+
+
+ private void Initialize()
+ {
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+
+ Var.pushThreadBindings(
+ RT.map(RT.CURRENT_NS, RT.CURRENT_NS.deref()));
+ try
+ {
+
+
+ //LoadFromStream(new StringReader(clojure.lang.Properties.Resources.core),false);
+ //RT.load("/core");
+ //LoadFromStream(new StringReader(clojure.lang.Properties.Resources.core_print), false);
+ //LoadFromStream(new StringReader(clojure.lang.Properties.Resources.test), false);
+
+ }
+ finally
+ {
+ Var.popThreadBindings();
+ }
+
+ sw.Stop();
+ Console.WriteLine("Loading took {0} milliseconds.", sw.ElapsedMilliseconds);
+
+ }
+
+ public object LoadFromStream(PushbackTextReader rdr, bool addPrint)
+ {
+ object ret = null;
+ object eofVal = new object();
+ object form;
+ while ((form = LispReader.read(rdr, false, eofVal, false)) != eofVal)
+ {
+ try
+ {
+ LambdaExpression ast = Compiler.GenerateLambda(form, addPrint);
+ ret = ast.Compile().DynamicInvoke();
+ }
+ catch (Exception ex)
+ {
+ if (addPrint)
+ {
+ Exception root = ex;
+ while (root.InnerException != null)
+ root = root.InnerException;
+
+ Console.WriteLine("Error evaluating {0}: {1}", form, root.Message);
+ Console.WriteLine(root.StackTrace);
+ }
+ }
+ }
+ return ret;
+ }
+
+
+ private void RunInteractiveLoop()
+ {
+ Var.pushThreadBindings(RT.map(
+ RT.CURRENT_NS, RT.CURRENT_NS.deref(),
+ RT.WARN_ON_REFLECTION, RT.WARN_ON_REFLECTION.deref(),
+ RT.PRINT_META, RT.PRINT_META.deref(),
+ RT.PRINT_LENGTH, RT.PRINT_LENGTH.deref(),
+ RT.PRINT_LEVEL, RT.PRINT_LEVEL.deref(),
+ Compiler.COMPILE_PATH, Environment.GetEnvironmentVariable("clojure.compile.path" ?? "classes")
+ ));
+
+ try
+ {
+ LoadFromStream(new LineNumberingTextReader(Console.In), true);
+ }
+ finally
+ {
+ Var.popThreadBindings();
+ }
+ }
+
+
+ }
+}
|