Added VBScript Console
This commit is contained in:
parent
fa14c7c2cd
commit
d6ec554b20
33 changed files with 3472 additions and 3207 deletions
|
@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NerdDinnerAsp", "NerdDinner
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBScriptTest", "VBScriptTest\VBScriptTest.csproj", "{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBScriptTest", "VBScriptTest\VBScriptTest.csproj", "{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBSC", "VBSC\VBSC.csproj", "{556BAE6E-AA67-48C7-ACD6-1AB0AA930197}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -47,6 +49,10 @@ Global
|
||||||
{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3153B5A6-B372-46D0-A10B-0CC4C4FBAE9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{556BAE6E-AA67-48C7-ACD6-1AB0AA930197}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{556BAE6E-AA67-48C7-ACD6-1AB0AA930197}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{556BAE6E-AA67-48C7-ACD6-1AB0AA930197}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{556BAE6E-AA67-48C7-ACD6-1AB0AA930197}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
46
aspclassiccompiler/VBSC/Program.cs
Normal file
46
aspclassiccompiler/VBSC/Program.cs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Dynamic;
|
||||||
|
#if USE35
|
||||||
|
using Microsoft.Scripting.Hosting;
|
||||||
|
using Microsoft.Scripting.Ast;
|
||||||
|
#else
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using Dlrsoft.VBScript.Hosting;
|
||||||
|
namespace Dlrsoft.VBScript
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Setup DLR ScriptRuntime with our languages. We hardcode them here
|
||||||
|
// but a .NET app looking for general language scripting would use
|
||||||
|
// an app.config file and ScriptRuntime.CreateFromConfiguration.
|
||||||
|
var setup = new ScriptRuntimeSetup();
|
||||||
|
string qualifiedname = typeof(VBScriptContext).AssemblyQualifiedName;
|
||||||
|
setup.LanguageSetups.Add(new LanguageSetup(
|
||||||
|
qualifiedname, "vbscript", new[] { "vbscript" }, new[] { ".vbs" }));
|
||||||
|
var dlrRuntime = new ScriptRuntime(setup);
|
||||||
|
// Don't need to tell the DLR about the assemblies we want to be
|
||||||
|
// available, which the SymplLangContext constructor passes to the
|
||||||
|
// Sympl constructor, because the DLR loads mscorlib and System by
|
||||||
|
// default.
|
||||||
|
//dlrRuntime.LoadAssembly(typeof(object).Assembly);
|
||||||
|
dlrRuntime.LoadAssembly(typeof(global::Dlrsoft.VBScript.Runtime.BuiltInFunctions).Assembly);
|
||||||
|
|
||||||
|
// Get a Sympl engine and run stuff ...
|
||||||
|
var engine = dlrRuntime.GetEngine("vbscript");
|
||||||
|
//string filename = @"..\..\test\test.vbs";
|
||||||
|
string filename = args[0];
|
||||||
|
var scriptSource = engine.CreateScriptSourceFromFile(filename);
|
||||||
|
var compiledCode = scriptSource.Compile();
|
||||||
|
var feo = engine.CreateScope(); //File Level Expando Object
|
||||||
|
//feo = engine.ExecuteFile(filename, feo);
|
||||||
|
feo.SetVariable("response", System.Console.Out);
|
||||||
|
compiledCode.Execute(feo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
aspclassiccompiler/VBSC/Properties/AssemblyInfo.cs
Normal file
36
aspclassiccompiler/VBSC/Properties/AssemblyInfo.cs
Normal file
|
@ -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("VBSC")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("DLRSoft")]
|
||||||
|
[assembly: AssemblyProduct("VBScript.NET")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © DLRSoft 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("568c9d7b-8dfc-4462-b0f4-768c2d6cfa39")]
|
||||||
|
|
||||||
|
// 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("0.5.7.34834")]
|
88
aspclassiccompiler/VBSC/VBSC.csproj
Normal file
88
aspclassiccompiler/VBSC/VBSC.csproj
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
<?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>{556BAE6E-AA67-48C7-ACD6-1AB0AA930197}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Dlrsoft.VBScript</RootNamespace>
|
||||||
|
<AssemblyName>VBSC</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>TRACE;DEBUG;USE35</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;USE35</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Dynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\library\35\Microsoft.Dynamic.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\library\35\Microsoft.Scripting.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Scripting.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\library\35\Microsoft.Scripting.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\library\35\Microsoft.Scripting.ExtensionAttribute.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="test\array.vbs" />
|
||||||
|
<Content Include="test\builtin.vbs" />
|
||||||
|
<Content Include="test\foreach.vbs" />
|
||||||
|
<Content Include="test\dotnet.vbs" />
|
||||||
|
<Content Include="test\dountil.vbs" />
|
||||||
|
<Content Include="test\dowhile.vbs" />
|
||||||
|
<Content Include="test\for.vbs" />
|
||||||
|
<Content Include="test\function.vbs" />
|
||||||
|
<Content Include="test\hello.vbs" />
|
||||||
|
<Content Include="test\if.vbs" />
|
||||||
|
<Content Include="test\new.vbs" />
|
||||||
|
<Content Include="test\sub.vbs" />
|
||||||
|
<Content Include="test\variables.vbs" />
|
||||||
|
<Content Include="test\while.vbs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\VBScript\VBScript.csproj">
|
||||||
|
<Project>{0846368D-EA96-4AC4-81AF-E4F9B78CE60B}</Project>
|
||||||
|
<Name>VBScript</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>
|
3
aspclassiccompiler/VBSC/test/array.vbs
Normal file
3
aspclassiccompiler/VBSC/test/array.vbs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
dim a(1)
|
||||||
|
a(0) = 3
|
||||||
|
Response.WriteLine(a(0))
|
3
aspclassiccompiler/VBSC/test/builtin.vbs
Normal file
3
aspclassiccompiler/VBSC/test/builtin.vbs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
dim i
|
||||||
|
i = -1
|
||||||
|
response.write Abs(i)
|
6
aspclassiccompiler/VBSC/test/dotnet.vbs
Normal file
6
aspclassiccompiler/VBSC/test/dotnet.vbs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
imports system
|
||||||
|
imports BuiltIn = VBScript.Runtime.BuiltInFunctions
|
||||||
|
System.Console.WriteLine "Hello from vbs"
|
||||||
|
'System.Console.WriteLine System.Math.Abs(-1)
|
||||||
|
'System.Console.WriteLine VBScript.BuiltInFunctions.Abs(-1)
|
||||||
|
System.Console.WriteLine BuiltIn.Abs(-1)
|
8
aspclassiccompiler/VBSC/test/dountil.vbs
Normal file
8
aspclassiccompiler/VBSC/test/dountil.vbs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
dim i
|
||||||
|
i = 5
|
||||||
|
f = 1
|
||||||
|
do
|
||||||
|
f = f * i
|
||||||
|
i = i - 1
|
||||||
|
loop until i = 0
|
||||||
|
response.write f
|
8
aspclassiccompiler/VBSC/test/dowhile.vbs
Normal file
8
aspclassiccompiler/VBSC/test/dowhile.vbs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
dim i
|
||||||
|
i = 5
|
||||||
|
f = 1
|
||||||
|
do while i > 0
|
||||||
|
f = f * i
|
||||||
|
i = i - 1
|
||||||
|
loop
|
||||||
|
response.write f
|
6
aspclassiccompiler/VBSC/test/for.vbs
Normal file
6
aspclassiccompiler/VBSC/test/for.vbs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
dim i
|
||||||
|
for i = 1 to 8
|
||||||
|
response.write i
|
||||||
|
next
|
||||||
|
|
||||||
|
response.write i
|
9
aspclassiccompiler/VBSC/test/foreach.vbs
Normal file
9
aspclassiccompiler/VBSC/test/foreach.vbs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
dim a(2)
|
||||||
|
dim i
|
||||||
|
|
||||||
|
a(0) = 2
|
||||||
|
a(1) = 5
|
||||||
|
|
||||||
|
for each i in a
|
||||||
|
Response.WriteLine(i)
|
||||||
|
next
|
5
aspclassiccompiler/VBSC/test/function.vbs
Normal file
5
aspclassiccompiler/VBSC/test/function.vbs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
response.write c2f(37)
|
||||||
|
|
||||||
|
function c2f(c)
|
||||||
|
c2f = c * 9 / 5 + 32
|
||||||
|
end function
|
1
aspclassiccompiler/VBSC/test/hello.vbs
Normal file
1
aspclassiccompiler/VBSC/test/hello.vbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Response.WriteLine("hello world")
|
13
aspclassiccompiler/VBSC/test/if.vbs
Normal file
13
aspclassiccompiler/VBSC/test/if.vbs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
dim i, color
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
if i = 1 then
|
||||||
|
color = "red"
|
||||||
|
elseif i = 2 then
|
||||||
|
color = "green"
|
||||||
|
elseif i = 3 then
|
||||||
|
color = "blue"
|
||||||
|
else
|
||||||
|
color = "black"
|
||||||
|
end if
|
||||||
|
response.write color
|
9
aspclassiccompiler/VBSC/test/new.vbs
Normal file
9
aspclassiccompiler/VBSC/test/new.vbs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
imports system
|
||||||
|
|
||||||
|
dim sb
|
||||||
|
|
||||||
|
sb = new System.Text.StringBuilder()
|
||||||
|
sb.append("this")
|
||||||
|
sb.append(" is ")
|
||||||
|
sb.append(" stringbuilder!")
|
||||||
|
response.write sb.toString()
|
8
aspclassiccompiler/VBSC/test/sub.vbs
Normal file
8
aspclassiccompiler/VBSC/test/sub.vbs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
printnum 5
|
||||||
|
|
||||||
|
sub printnum(n)
|
||||||
|
for i = 1 to n
|
||||||
|
response.write i
|
||||||
|
next
|
||||||
|
end sub
|
||||||
|
|
3
aspclassiccompiler/VBSC/test/variables.vbs
Normal file
3
aspclassiccompiler/VBSC/test/variables.vbs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
dim a
|
||||||
|
a = 3
|
||||||
|
Response.Writeline(a)
|
7
aspclassiccompiler/VBSC/test/while.vbs
Normal file
7
aspclassiccompiler/VBSC/test/while.vbs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
i = 5
|
||||||
|
f = 1
|
||||||
|
while i > 0
|
||||||
|
f = f * i
|
||||||
|
i = i - 1
|
||||||
|
wend
|
||||||
|
response.write f
|
|
@ -25,7 +25,7 @@
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE;USE35</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>..\bin\Release\</OutputPath>
|
<OutputPath>..\bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE;USE35</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue