Updated build script to use MSBuild v4 for compiling the solution

project_name = "FluentValidation"
solution_file = "FluentValidation.sln"
solution_file_silverlight = "FluentValidation.Silverlight.sln"
project_configuration = "release"
build_dir = "build"
test_assemblies = ("src/FluentValidation.Tests/bin/${project_configuration}/FluentValidation.Tests.dll",
  "src/FluentValidation.Tests.Mvc1/bin/${project_configuration}/FluentValidation.Tests.Mvc1.dll")
build_silverlight = false
ncover_path = "C:/Program Files (x86)/ncover"

target default, (init, compile, compile_silverlight, test, deploy, package):
  pass

target ci, (init, silverlight, compile, compile_silverlight, coverage, package):
  pass

target init:
  rm(build_dir)
  rm("teamcity-info.xml")

desc "Enables silverlight build"
target silverlight:
  print "Silverlight build enabled"
  build_silverlight = true

desc "Compiles solution"
target compile:
  msbuild(file: solution_file, configuration: project_configuration, version: "4" )

desc "Compiles silverlight"
target compile_silverlight:
  if build_silverlight:
    msbuild(file: solution_file_silverlight, configuration: project_configuration, version: "4")

desc "Runs tests"
target test:
  nunit(assemblies: test_assemblies)

desc "Creates release package"
target deploy:
  #main binaries
  with FileList("src/FluentValidation/bin/${project_configuration}"):
    .Include("**/*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/FluentValidation")

  #Mvc2 integration
  with FileList("src/FluentValidation.Mvc/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC2")

  #mvc1 integration
  with FileList("src/FluentValidation.Mvc1/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC1")

  #xVal
  with FileList("src/FluentValidation.xValIntegration/bin/${project_configuration}"):
    .Include("FluentValidation.xValIntegration.*")
    .Include("xVal.dll")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/xVal")

  #silverlight
  if build_silverlight:
    with FileList("src/FluentValidation.Silverlight/bin/${project_configuration}"):
      .Include("*.{dll,pdb,xml}")
      .ForEach def(file):
        file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/Silverlight")

  #License/Changelog
  with FileList():
    .Include("License.txt")
    .Include("Changelog.txt")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}")

target package, (deploy):
  zip("${build_dir}/${project_configuration}", "${build_dir}/FluentValidation.zip")

target coverage:
  ncover_path = "c:/program files (x86)/ncover"
  app_assemblies = ("FluentValidation", "FluentValidation.Mvc", "FluentValidation.xValIntegration")
  teamcity_launcher = env("teamcity.dotnet.nunitlauncher")

  with ncover():
    .toolPath = "${ncover_path}/NCover.console.exe"
    .reportDirectory = "${build_dir}/Coverage"
    .workingDirectory = "src/FluentValidation.Tests/bin/${project_configuration}"
    .applicationAssemblies = app_assemblies
    .program = "${teamcity_launcher} v2.0 x86 NUnit-2.4.6"
    .testAssembly = "FluentValidation.Tests.dll"
    .excludeAttributes = "System.Runtime.CompilerServices.CompilerGeneratedAttribute"

  with ncover_explorer():
    .toolPath = "${ncover_path}/NCoverExplorer.console.exe"
    .project = "FluentValidation"
    .reportDirectory = "build/coverage"

project_name = "FluentValidation"
solution_file = "FluentValidation.sln"
solution_file_silverlight = "FluentValidation.Silverlight.sln"
project_configuration = "release"
build_dir = "build"
test_assemblies = ("src/FluentValidation.Tests/bin/${project_configuration}/FluentValidation.Tests.dll",
  "src/FluentValidation.Tests.Mvc1/bin/${project_configuration}/FluentValidation.Tests.Mvc1.dll")
build_silverlight = false
ncover_path = "C:/Program Files (x86)/ncover"

target default, (init, compile, test, deploy, package):
  pass

target ci, (init, silverlight, compile, coverage, package):
  pass

target init:
  rm(build_dir)
  rm("teamcity-info.xml")

desc "Enables silverlight build"
target silverlight:
  print "Silverlight build enabled"
  build_silverlight = true

desc "Compiles solution"
target compile:
  msbuild(file: solution_file, configuration: project_configuration)

  if build_silverlight:
    msbuild(file: solution_file_silverlight, configuration: project_configuration)

desc "Runs tests"
target test:
  nunit(assemblies: test_assemblies)

desc "Creates release package"
target deploy:
  #main binaries
  with FileList("src/FluentValidation/bin/${project_configuration}"):
    .Include("**/*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/FluentValidation")

  #Mvc2 integration
  with FileList("src/FluentValidation.Mvc/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC2")

  #mvc1 integration
  with FileList("src/FluentValidation.Mvc1/bin/${project_configuration}"):
    .Include("FluentValidation.Mvc.*")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/MVC/MVC1")

  #xVal
  with FileList("src/FluentValidation.xValIntegration/bin/${project_configuration}"):
    .Include("FluentValidation.xValIntegration.*")
    .Include("xVal.dll")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/xVal")

  #silverlight
  if build_silverlight:
    with FileList("src/FluentValidation.Silverlight/bin/${project_configuration}"):
      .Include("*.{dll,pdb,xml}")
      .ForEach def(file):
        file.CopyToDirectory("${build_dir}/${project_configuration}/Experimental/Silverlight")

  #License/Changelog
  with FileList():
    .Include("License.txt")
    .Include("Changelog.txt")
    .ForEach def(file):
      file.CopyToDirectory("${build_dir}/${project_configuration}")

target package, (deploy):
  zip("${build_dir}/${project_configuration}", "${build_dir}/FluentValidation.zip")

target coverage:
  ncover_path = "c:/program files (x86)/ncover"
  app_assemblies = ("FluentValidation", "FluentValidation.Mvc", "FluentValidation.xValIntegration")
  teamcity_launcher = env("teamcity.dotnet.nunitlauncher")

  with ncover():
    .toolPath = "${ncover_path}/NCover.console.exe"
    .reportDirectory = "${build_dir}/Coverage"
    .workingDirectory = "src/FluentValidation.Tests/bin/${project_configuration}"
    .applicationAssemblies = app_assemblies
    .program = "${teamcity_launcher} v2.0 x86 NUnit-2.4.6"
    .testAssembly = "FluentValidation.Tests.dll"
    .excludeAttributes = "System.Runtime.CompilerServices.CompilerGeneratedAttribute"

  with ncover_explorer():
    .toolPath = "${ncover_path}/NCoverExplorer.console.exe"
    .project = "FluentValidation"
    .reportDirectory = "build/coverage"


remove warnings

remove warnings

namespace speed

import Boo.OMeta
import Boo.PatternMatching
import Boo.Pegs

ometa WordCollector:
	parse = ++(numbered | word)
	numbered = ((++letter >> letters, ++digit >> digits), wordbreak) ^ (j(letters) + j(digits))
	word = (++letter >> suffix, wordbreak) ^ j(suffix)
	wordbreak = ++whitespace
	number = (++digit >> n, wordbreak) ^ j(n)

def j(items):
	return join(items, '')

def pegWords(text as string):

	words = []
	append = words.Add

	peg:
		parse = ++[numbered, word]
		numbered = ++letter, ++digit, { append($text) }, wordbreak
		word = ++letter, { append($text) }, wordbreak
		letter = a-z
		digit = 0-9
		wordbreak = ++whitespace()

	assert parse.Match(PegContext(text))
	return words

def time(label as string, block as callable()):
	start = date.Now
	block()
	elapsed = date.Now - start
	print "${label}: ${elapsed}"

words = join(("word${i}\n" if 0 == i % 2 else "word\n") for i in range(100000))

time "peg":
	wordList = pegWords(words)
	if false: print wordList

time "ometa":
	input = OMetaInput.For(words)
	match WordCollector().parse(input):
		case SuccessfulMatch(Input, Value):
			assert Input.IsEmpty
			if false: print Value

namespace speed

import Boo.OMeta
import Boo.PatternMatching
import Boo.Pegs

ometa WordCollector:
	parse = ++(numbered | word)
	numbered = ((++letter >> letters, ++digit >> digits), wordbreak) ^ (j(letters) + j(digits))
	word = (++letter >> suffix, wordbreak) ^ j(suffix)
	wordbreak = ++whitespace
	number = (++digit >> n, wordbreak) ^ j(n)

def j(items):
	return join(items, '')

def pegWords(text as string):

	words = []
	append = words.Add

	peg:
		parse = ++[numbered, word]
		numbered = ++letter, ++digit, { append($text) }, wordbreak
		word = ++letter, { append($text) }, wordbreak
		letter = a-z
		digit = 0-9
		wordbreak = ++whitespace()

	assert parse.Match(PegContext(text))
	return words

def time(label as string, block as callable()):
	start = date.Now
	block()
	elapsed = date.Now - start
	print "${label}: ${elapsed}"

words = join(("word${i}\n" if 0 == i % 2 else "word\n") for i in range(100000))

time "peg":
	wordList = pegWords(words)
#	print wordList

time "ometa":
	input = OMetaInput.For(words)
	match WordCollector().parse(input):
		case SuccessfulMatch(Input, Value):
			assert Input.IsEmpty
#		print Value


misleading comments removed

misleading comments removed

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@1908 2c1201b4-01cd-e047-a400-b836ae1fbc61

"""
started
executing
done
"""
import System

def run(message):
	print(message)
	return 42

print("started")

result = run.BeginInvoke("executing", null, null)
assert 42 == run.EndInvoke(result)

print("done")

"""
started
executing
done
"""
import System

def run(message):
	print(message)
	return 42

print("started")

# BeginInvoke is overloaded
# in this example we call the version
# that takes only the original method parameters
result = run.BeginInvoke("executing", null, null)
assert 42 == run.EndInvoke(result)

print("done")


remove unused namespace

remove unused namespace

git-svn-id: fcce7d6ce0ac15bf24f68871b5145d46fc068279@2856 2c1201b4-01cd-e047-a400-b836ae1fbc61

#region license
// Copyright (c) 2003, 2004, 2005 Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Boo.Microsoft.Build.Tasks.Properties
"""
Author:
	Sorin Ionescu (sorin.ionescu@gmail.com)
"""

import System.Reflection
import 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('Boo.Microsoft.Build.Tasks')]
[assembly: AssemblyDescription('Contains Microsoft Build tasks for BOO code.')]
[assembly: AssemblyConfiguration('')]
[assembly: AssemblyCompany('')]
[assembly: AssemblyProduct('Boo.Microsoft.Build.Tasks')]
[assembly: AssemblyCopyright("(C) 2003-2007 Rodrigo Barreto de Oliveira")]
[assembly: AssemblyTrademark('')]
[assembly: AssemblyCulture('')]

# Setting ComVisible to false makes the types in this assembly not visible
# to COM componenets.  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('')]

# 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 Revision and
# Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion('1.0.0.0')]

#region license
// Copyright (c) 2003, 2004, 2005 Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Boo.Microsoft.Build.Tasks.Properties
"""
Author:
	Sorin Ionescu (sorin.ionescu@gmail.com)
"""

import System.Reflection
import System.Runtime.CompilerServices
import 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('Boo.Microsoft.Build.Tasks')]
[assembly: AssemblyDescription('Contains Microsoft Build tasks for BOO code.')]
[assembly: AssemblyConfiguration('')]
[assembly: AssemblyCompany('')]
[assembly: AssemblyProduct('Boo.Microsoft.Build.Tasks')]
[assembly: AssemblyCopyright("(C) 2003-2007 Rodrigo Barreto de Oliveira")]
[assembly: AssemblyTrademark('')]
[assembly: AssemblyCulture('')]

# Setting ComVisible to false makes the types in this assembly not visible
# to COM componenets.  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('')]

# 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 Revision and
# Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion('1.0.0.0')]


Fixing text not scaling correctly and vanishing in lower res screens

import UnityEngine

class TextAutoScale (MonoBehaviour):

	def Awake():
		sizeScaleFactor = Mathf.Min(Screen.width/800.0f, Screen.height/600.0f)
		self.GetComponentInChildren[of Text]().fontSize = (self.GetComponentInChildren[of Text]().fontSize * sizeScaleFactor)

import UnityEngine

class TextAutoScale (MonoBehaviour):

	def Awake():
		sizeScaleFactor = Screen.width/800.0f
		self.GetComponentInChildren[of Text]().fontSize = (self.GetComponentInChildren[of Text]().fontSize * sizeScaleFactor)


removed multi-file support for booi so you can pass parameters to your script.  Will have multi-file ability later with BOO-209.

git-svn-id: c3b8989232654601f1acea7403f771adaaa44a81@1457 2c1201b4-01cd-e047-a400-b836ae1fbc61

#region license
// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

import System
import System.IO
import System.Reflection
import System.Security.Permissions
import System.Threading
import Boo.Lang.Compiler
import Boo.Lang.Compiler.IO
import Boo.Lang.Compiler.Pipelines
import Boo.Lang.Compiler.Steps

class AssemblyResolver:

	_cache = {}

	def AddAssembly([required] asm as Assembly):
		_cache[GetSimpleName(asm.FullName)] = asm

	def AssemblyResolve(sender, args as ResolveEventArgs) as Assembly:
		simpleName = GetSimpleName(args.Name)

		asm as Assembly = _cache[simpleName]
		if asm is null:
			basePath = Path.GetFullPath(simpleName)
			asm = ProbeFile(basePath + ".dll")
			if asm is null:
				asm = ProbeFile(basePath + ".exe")
			_cache[simpleName] = asm

		return asm

	private def GetSimpleName(name as string):
		return /,\s*/.Split(name)[0]

	private def ProbeFile(fname as string):
		return Assembly.LoadFrom(fname) if File.Exists(fname)

def consume(reader as TextReader):
	return join(line for line in reader, "\n")

[STAThread]
def Main(argv as (string)):

	if len(argv) < 1:
		print("booi <script.boo>")
		return -1

	compiler = BooCompiler()

	compiler.Parameters.Pipeline = CompileToMemory()

	for arg in argv:
		if "-" == arg:
			compiler.Parameters.Input.Add(StringInput("<stdin>", consume(Console.In)))
			break
		elif "-ducky" == arg:
			compiler.Parameters.Ducky = true
		else:
			compiler.Parameters.Input.Add(FileInput(arg))
			break

	resolver = AssemblyResolver()
	AppDomain.CurrentDomain.AssemblyResolve += resolver.AssemblyResolve
	result = compiler.Run()
	if len(result.Errors):
		print(result.Errors.ToString(true))
		return -1
	else:
		try:
			resolver.AddAssembly(result.GeneratedAssembly)
			result.GeneratedAssemblyEntryPoint.Invoke(null, (argv[1:],))
		except x as TargetInvocationException:
			print(x.InnerException)
			return -1
	return 0

[assembly: SecurityPermission(
						SecurityAction.RequestMinimum,
						ControlAppDomain: true)]

#region license
// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Rodrigo B. de Oliveira nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

import System
import System.IO
import System.Reflection
import System.Security.Permissions
import System.Threading
import Boo.Lang.Compiler
import Boo.Lang.Compiler.IO
import Boo.Lang.Compiler.Pipelines
import Boo.Lang.Compiler.Steps

class AssemblyResolver:

	_cache = {}

	def AddAssembly([required] asm as Assembly):
		_cache[GetSimpleName(asm.FullName)] = asm

	def AssemblyResolve(sender, args as ResolveEventArgs) as Assembly:
		simpleName = GetSimpleName(args.Name)

		asm as Assembly = _cache[simpleName]
		if asm is null:
			basePath = Path.GetFullPath(simpleName)
			asm = ProbeFile(basePath + ".dll")
			if asm is null:
				asm = ProbeFile(basePath + ".exe")
			_cache[simpleName] = asm

		return asm

	private def GetSimpleName(name as string):
		return /,\s*/.Split(name)[0]

	private def ProbeFile(fname as string):
		return Assembly.LoadFrom(fname) if File.Exists(fname)

def consume(reader as TextReader):
	return join(line for line in reader, "\n")

[STAThread]
def Main(argv as (string)):

	if len(argv) < 1:
		print("booi <script.boo>")
		return -1

	compiler = BooCompiler()

	compiler.Parameters.Pipeline = CompileToMemory()

	for arg in argv:
		if "-" == arg:
			compiler.Parameters.Input.Add(StringInput("<stdin>", consume(Console.In)))
		elif "-ducky" == arg:
			compiler.Parameters.Ducky = true
		else:
			compiler.Parameters.Input.Add(FileInput(arg))

	resolver = AssemblyResolver()
	AppDomain.CurrentDomain.AssemblyResolve += resolver.AssemblyResolve
	result = compiler.Run()
	if len(result.Errors):
		print(result.Errors.ToString(true))
		return -1
	else:
		try:
			resolver.AddAssembly(result.GeneratedAssembly)
			result.GeneratedAssemblyEntryPoint.Invoke(null, (argv[1:],))
		except x as TargetInvocationException:
			print(x.InnerException)
			return -1
	return 0

[assembly: SecurityPermission(
						SecurityAction.RequestMinimum,
						ControlAppDomain: true)]


Changed the version to 0.1

Changed the version to 0.1

import System
import System.IO

# Project Information
title            = "Stitch-AspNet"
company          = ""
version_major    = 0
version_minor    = 1
version_build    = 0
version_revision = 0
repository_url   = ""
repository_type  = "git"

# Build Information
solution_folder  = "Source"
solution_file    = "Stitch-AspNet.sln"
configuration    = "Release"
dotnet_version   = "4.0"
build_directory  = DirectoryInfo("Build/${configuration}")
package_dir      = "Build/${configuration}"

# Targets
desc "Default target"
target default, (clean, binaries, compile, package):
  pass

target clean:
  rmdir("Build")

target binaries:
  exec("Tools\\NuGet\\NuGet.exe install ${solution_folder}\\Stitch-AspNet\\packages.config -o Libraries")

target compile, (assemblyInfo):
  print "Compiling ${solution_file}"
  with msbuild():
    .file = Path.Combine(solution_folder, solution_file)
    .configuration = configuration
    .version = dotnet_version
    .properties = { 'OutDir': build_directory.FullName+"/" }

target package:
  zip(package_dir, String.Format("Build/{4}-{0}.{1}.{2}.{3}.zip", version_major, version_minor, version_build, version_revision, title))

target getRevision:
  int.TryParse(env("build.vcs.number"), version_revision)
  if (version_revision > 0):
    return

  if (repository_type == "git"):
    version_revision = getRevisionMercurial(repository_url)

  if (version_revision > 0):
    return
  else:
    raise "Unable to determine repository revision"

desc "Create the assembly info"
target assemblyInfo, (getRevision):
  print "Generating SolutionVersion.cs"
  with generate_assembly_info():
    .file = "${solution_folder}/SolutionVersion.cs"
    .version = String.Format("{0}.{1}.{2}.{3}", version_major, version_minor, version_build, version_revision)
    .fileVersion = String.Format("{0}.{1}.{2}.{3}", version_major, version_minor, version_build, version_revision)
    .title = title
    .description  = String.Format("{0} is a product of {1}", title, company)
    .copyright = String.Format("Copyright {0} {1}", DateTime.Now.Year, company)
    .comVisible = false
    .companyName = company
    .productName = title

import System
import System.IO

# Project Information
title            = "Stitch-AspNet"
company          = ""
version_major    = 1
version_minor    = 0
version_build    = 0
version_revision = 0
repository_url   = ""
repository_type  = "git"

# Build Information
solution_folder  = "Source"
solution_file    = "Stitch-AspNet.sln"
configuration    = "Release"
dotnet_version   = "4.0"
build_directory  = DirectoryInfo("Build/${configuration}")
package_dir      = "Build/${configuration}"

# Targets
desc "Default target"
target default, (clean, binaries, compile, package):
  pass

target clean:
  rmdir("Build")

target binaries:
  exec("Tools\\NuGet\\NuGet.exe install ${solution_folder}\\Stitch-AspNet\\packages.config -o Libraries")

target compile, (assemblyInfo):
  print "Compiling ${solution_file}"
  with msbuild():
    .file = Path.Combine(solution_folder, solution_file)
    .configuration = configuration
    .version = dotnet_version
    .properties = { 'OutDir': build_directory.FullName+"/" }

target package:
  zip(package_dir, String.Format("Build/{4}-{0}.{1}.{2}.{3}.zip", version_major, version_minor, version_build, version_revision, title))

target getRevision:
  int.TryParse(env("build.vcs.number"), version_revision)
  if (version_revision > 0):
    return

  if (repository_type == "git"):
    version_revision = getRevisionMercurial(repository_url)

  if (version_revision > 0):
    return
  else:
    raise "Unable to determine repository revision"

desc "Create the assembly info"
target assemblyInfo, (getRevision):
  print "Generating SolutionVersion.cs"
  with generate_assembly_info():
    .file = "${solution_folder}/SolutionVersion.cs"
    .version = String.Format("{0}.{1}.{2}.{3}", version_major, version_minor, version_build, version_revision)
    .fileVersion = String.Format("{0}.{1}.{2}.{3}", version_major, version_minor, version_build, version_revision)
    .title = title
    .description  = String.Format("{0} is a product of {1}", title, company)
    .copyright = String.Format("Copyright {0} {1}", DateTime.Now.Year, company)
    .comVisible = false
    .companyName = company
    .productName = title


it must be a type name not a type descriptor

namespace Boojay.Compilation

import System.IO

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Steps
import Boo.Lang.Compiler.TypeSystem

import Boo.PatternMatching

import org.objectweb.asm
import org.objectweb.asm.Type

class BoojayEmitter(AbstractVisitorCompilerStep):

	_classWriter as ClassWriter
	_code as MethodVisitor
	_typeMappings as Hash
	_primitiveMappings as Hash

	override def Initialize(context as CompilerContext):
		super(context)
		initializeTypeMappings()

	def Run():
		Visit(CompileUnit)

	def initializeTypeMappings():
		_typeMappings = {
			typeSystem.ObjectType: "java/lang/Object",
			typeSystem.StringType: "java/lang/String",
		}

		_primitiveMappings = {
			typeSystem.BoolType: BOOLEAN_TYPE.getDescriptor(),
			typeSystem.IntType: INT_TYPE.getDescriptor(),
			typeSystem.VoidType: VOID_TYPE.getDescriptor(),
		}

	override def OnInterfaceDefinition(node as InterfaceDefinition):
		emitTypeDefinition node

	override def OnClassDefinition(node as ClassDefinition):
		emitTypeDefinition node

	def emitTypeDefinition(node as TypeDefinition):
		_classWriter = ClassWriter(ClassWriter.COMPUTE_MAXS)
		_classWriter.visit(
			Opcodes.V1_5,
			typeAttributes(node),
			javaType(node.FullName),
			null,
			javaType(baseType(node)),
			implementedInterfaces(node))

		emit node.Members

		_classWriter.visitEnd()

		writeClassFile node

	def implementedInterfaces(node as TypeDefinition):
		interfaces = array(
				javaType(itf)
				for itf in node.BaseTypes
				if isInterface(itf))
		if len(interfaces) == 0: return null
		return interfaces

	def isInterface(typeRef as TypeReference):
		return (entity(typeRef) as IType).IsInterface

	def typeAttributes(node as TypeDefinition):
		attrs = 0
		match node.NodeType:
			case NodeType.ClassDefinition:
				attrs += Opcodes.ACC_SUPER
			case NodeType.InterfaceDefinition:
				attrs += (Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT)
		if node.IsPublic:
			attrs += Opcodes.ACC_PUBLIC
		return attrs

	def writeClassFile(node as TypeDefinition):
		fname = classFullFileName(node)
		ensurePath(fname)
		File.WriteAllBytes(fname, _classWriter.toByteArray())

	override def OnIfStatement(node as IfStatement):

		elseLabel = Label()
		afterElseLabel = Label()

		emitBranchFalse node.Condition, elseLabel
		emit node.TrueBlock
		if node.FalseBlock is not null:
			GOTO afterElseLabel
		mark elseLabel
		if node.FalseBlock is not null:
			emit node.FalseBlock
			mark afterElseLabel

	def emitBranchFalse(e as Expression, label as Label):
		match e:
			case UnaryExpression(
					Operator: UnaryOperatorType.LogicalNot,
					Operand: condition):
				emitBranchTrue condition, label
			otherwise:
				emit e
				IFEQ label

	def emitBranchTrue(e as Expression, label as Label):
		match e:
			case UnaryExpression(
					Operator: UnaryOperatorType.LogicalNot,
					Operand: condition):
				emitBranchFalse condition, label
			otherwise:
				emit e
				IFNE label

	override def OnWhileStatement(node as WhileStatement):

		testLabel = Label()
		bodyLabel = Label()
		GOTO testLabel
		mark bodyLabel
		emit node.Block
		mark testLabel
		emitBranchTrue node.Condition, bodyLabel

	override def OnField(node as Field):
		field = _classWriter.visitField(
					memberAttributes(node),
					node.Name,
					typeDescriptor(entity(node.Type)),
					null,
					null)
		field.visitEnd()

	override def OnConstructor(node as Constructor):
		emitMethod "<init>", node

	override def OnMethod(node as Method):
		methodName = ("main" if node.Name == "Main" else node.Name)
		emitMethod methodName, node

	def emitMethod(methodName as string, node as Method):
		_code = _classWriter.visitMethod(
					memberAttributes(node),
					methodName,
					javaSignature(node),
					null,
					null)

		if not node.IsAbstract:
			emitMethodBody node
		_code.visitEnd()

	def emitMethodBody(node as Method):
		prepareLocalVariables node

		_code.visitCode()

		emit node.Body
		RETURN

		_code.visitMaxs(0, 0)

	def memberAttributes(node as TypeMember):
		attributes = Opcodes.ACC_PUBLIC
		if node.IsStatic: attributes += Opcodes.ACC_STATIC
		if node.IsAbstract: attributes += Opcodes.ACC_ABSTRACT
		return attributes

	def prepareLocalVariables(node as Method):
		i = firstLocalIndex(node)
		for local in node.Locals:
			index(local, i)
			++i

	def firstLocalIndex(node as Method):
		if 0 == len(node.Parameters):
			if node.IsStatic: return 0
			return 1
		return lastParameterIndex(node) + 1

	def lastParameterIndex(node as Method):
		param as InternalParameter = entity(node.Parameters[-1])
		return param.Index

	def index(node as Local, index as int):
		node["index"] = index

	def index(entity as InternalLocal) as int:
		return entity.Local["index"]

	override def LeaveExpressionStatement(node as ExpressionStatement):
		discardValueOnStack node.Expression

	def discardValueOnStack(node as Expression):
		mie = node as MethodInvocationExpression
		if mie is null: return

		m = entity(mie.Target) as IMethod
		if m is null: return

		if hasReturnValue(m): POP

	def hasReturnValue(m as IMethod):
		return m.ReturnType is not TypeSystemServices.VoidType

	override def OnReturnStatement(node as ReturnStatement):
		if node.Expression is null:
			RETURN
		else:
			emit node.Expression
			ARETURN

	override def OnMethodInvocationExpression(node as MethodInvocationExpression):

		match entity(node.Target):
			case ctor = IConstructor():
				match node.Target:
					case SuperLiteralExpression():
						ALOAD 0
						INVOKESPECIAL ctor
					otherwise:
						emitObjectCreation ctor, node
			case method = IMethod():
				emitMethodInvocation method, node
			case builtin = BuiltinFunction():
				emitBuiltinInvocation builtin, node

	def emitBuiltinInvocation(builtin as BuiltinFunction, node as MethodInvocationExpression):
		match builtin.FunctionType:
			case BuiltinFunctionType.Eval:
				emitEval node

	def emitEval(node as MethodInvocationExpression):
		for e in node.Arguments.ToArray()[:-1]:
			emit e
			discardValueOnStack e
		emit node.Arguments[-1]

	def emitMethodInvocation(method as IMethod, node as MethodInvocationExpression):

		if isSpecialIkvmGetter(method):
			emitSpecialIkvmGetter(method)
			return

		emit node.Target
		emit node.Arguments

		if method.IsStatic:
			INVOKESTATIC method
		elif method.DeclaringType.IsInterface:
			INVOKEINTERFACE method
		else:
			INVOKEVIRTUAL method

	def emitObjectCreation(ctor as IConstructor, node as MethodInvocationExpression):
		NEW ctor.DeclaringType
		DUP
		emit node.Arguments
		INVOKESPECIAL ctor

	def emitSpecialIkvmGetter(method as IMethod):
	"""
	in the ikvm version of GNU.ClassPath the
	console streams are mapped to properties
	where in java they should be treated as static fields
	"""
		emitLoadStaticField(
			method.DeclaringType,
			stripGetterPrefix(method.Name),
			method.ReturnType)

	def isSpecialIkvmGetter(method as IMethod):
		return (method.IsStatic
			and method.DeclaringType.FullName == "java.lang.System"
			and method.Name in ("get_out", "get_in", "get_err"))

	override def OnBinaryExpression(node as BinaryExpression):
		match node.Operator:
			case BinaryOperatorType.Assign:
				emitAssignment node
			case BinaryOperatorType.Subtraction:
				emitSubtraction node
			case BinaryOperatorType.Addition:
				emitAddition node

	def emitAddition(node as BinaryExpression):
		emit node.Left
		emit node.Right
		IADD

	def emitSubtraction(node as BinaryExpression):
		emit node.Left
		emit node.Right
		ISUB

	def emitAssignment(node as BinaryExpression):
		match node.Left:
			case memberRef = MemberReferenceExpression():
				match entity(memberRef):
                    case field = IField(IsStatic: false):
                    	emit memberRef.Target
                    	emit node.Right
                    	PUTFIELD field
			case reference = ReferenceExpression():
				emit node.Right
				match entity(reference):
					case local = ILocalEntity():
						if not local.Type.IsValueType:
							ASTORE index(local)
						elif isIntegerOrBool(local.Type):
							ISTORE index(local)

	override def OnMemberReferenceExpression(node as MemberReferenceExpression):
		match entity(node):
			case field = IField(IsStatic: true):
				GETSTATIC field
			case field = IField(IsStatic: false):
				emit node.Target
				GETFIELD field
			case IMethod(IsStatic: false):
				emit node.Target
			case IMethod(IsStatic: true):
				pass

	override def OnSelfLiteralExpression(node as SelfLiteralExpression):
		ALOAD 0

	override def OnReferenceExpression(node as ReferenceExpression):
		match entity(node):
			case param = InternalParameter():
				emitLoad param.Type, param.Index
			case local = ILocalEntity():
				emitLoad local.Type, index(local)
			case type = IType():
				LDC type

	def emitLoad(type as IType, index as int):
		if not type.IsValueType:
			ALOAD index
		elif isIntegerOrBool(type):
			ILOAD index
		else:
			raise "Unsupported type: ${type}"

	def isIntegerOrBool(type as IType):
		return self.TypeSystemServices.IsIntegerOrBool(type)

	def stripGetterPrefix(name as string):
		return name[len("get_"):]

	override def OnStringLiteralExpression(node as StringLiteralExpression):
		LDC node.Value

	override def OnIntegerLiteralExpression(node as IntegerLiteralExpression):
		ICONST node.Value

	override def OnBoolLiteralExpression(node as BoolLiteralExpression):
		if node.Value:
			ICONST_1
		else:
			ICONST_0

	def baseType(node as TypeDefinition):
		if node isa InterfaceDefinition: return TypeSystemServices.ObjectType
		return self.GetType(node).BaseType

	typeSystem as JavaTypeSystem:
		get: return self.TypeSystemServices

	def javaSignature(method as IMethod):
		return ("("
			+ join(typeDescriptor(p.Type) for p in method.GetParameters(), "")
			+ ")"
			+ typeDescriptor(method.ReturnType))

	def javaSignature(node as Method):
		return javaSignature(entity(node) as IMethod)

	def ensurePath(fname as string):
		path = Path.GetDirectoryName(fname)
		if not string.IsNullOrEmpty(path):
			Directory.CreateDirectory(path)

	def classFullFileName(node as TypeDefinition):
		return javaType(entity(node)) + ".class"

	def emit(node as Node):
		Visit(node)

	def emit(nodes as System.Collections.IEnumerable):
		VisitCollection(nodes)

	def LDC(value):
		emitLdcInsn value

	def LDC(type as IType):
		emitLdcInsn org.objectweb.asm.Type.getType(typeDescriptor(type))

	def IFEQ(label as Label):
		emitJumpInsn Opcodes.IFEQ, label

	def IFNE(label as Label):
        emitJumpInsn Opcodes.IFNE, label

	def GOTO(label as Label):
		emitJumpInsn Opcodes.GOTO, label

	def ILOAD(index as int):
		emitVarInsn Opcodes.ILOAD, index

	def ICONST(value as int):
		if value >= -1 and value <= 5:
			emitInsn iconstOpcodeFor(value)
		elif value >= -127 and value <= 127:
			emitIntInsn Opcodes.BIPUSH, value
		else:
			emitIntInsn Opcodes.SIPUSH, value

	def ICONST_0():
		emitInsn Opcodes.ICONST_0

	def ICONST_1():
		emitInsn Opcodes.ICONST_1

	def iconstOpcodeFor(value as int):
		if value == 0: return Opcodes.ICONST_0
		if value == 1: return Opcodes.ICONST_1
		if value == 2: return Opcodes.ICONST_2
		if value == -1: return Opcodes.ICONST_M1
		raise System.ArgumentException("value")

	def ISTORE(index as int):
		emitVarInsn(Opcodes.ISTORE, index)

	def ALOAD(index as int):
		emitVarInsn(Opcodes.ALOAD, index)

	def ASTORE(index as int):
		emitVarInsn(Opcodes.ASTORE, index)

	def GETSTATIC(field as IField):
		emitLoadStaticField(field.DeclaringType, field.Name, field.Type)

	def GETFIELD(field as IField):
		emitField Opcodes.GETFIELD, field

	def PUTFIELD(field as IField):
		emitField Opcodes.PUTFIELD, field

	def INVOKESTATIC(method as IMethod):
		invoke(Opcodes.INVOKESTATIC, method)

	def INVOKEVIRTUAL(method as IMethod):
		invoke(Opcodes.INVOKEVIRTUAL, method)

	def INVOKESPECIAL(method as IMethod):
		invoke(Opcodes.INVOKESPECIAL, method)

	def INVOKEINTERFACE(method as IMethod):
		invoke(Opcodes.INVOKEINTERFACE, method)

	def RETURN():
	   emitInsn(Opcodes.RETURN)

	def ARETURN():
	   emitInsn(Opcodes.ARETURN)

	def POP():
		emitInsn(Opcodes.POP)

	def NEW(type as IType):
		emitTypeInsn(Opcodes.NEW, javaType(type))

	def DUP():
		emitInsn(Opcodes.DUP)

	def ISUB():
		emitInsn(Opcodes.ISUB)

	def IADD():
		emitInsn(Opcodes.IADD)

	def emitVarInsn(opcode as int, index as int):
		_code.visitVarInsn(opcode, index)

	def emitInsn(i as int):
		_code.visitInsn(i)

	def emitIntInsn(opcode as int, value as int):
		_code.visitIntInsn(opcode, value)

	def emitJumpInsn(i as int, label as Label):
		_code.visitJumpInsn(i, label)

	def emitLdcInsn(value):
		_code.visitLdcInsn(value)

	def emitTypeInsn(opcode as int, name as string):
		_code.visitTypeInsn(opcode, name)

	def mark(label as Label):
		_code.visitLabel(label)

	def invoke(opcode as int, method as IMethod):
		_code.visitMethodInsn(
				opcode,
				javaType(method.DeclaringType),
				("<init>" if method isa IConstructor else method.Name),
				javaSignature(method))

	def emitLoadStaticField(declaringType as IType, fieldName as string, fieldType as IType):
		emitField Opcodes.GETSTATIC, declaringType, fieldName, fieldType

	def emitField(opcode as int, field as IField):
		emitField opcode, field.DeclaringType, field.Name, field.Type

	def emitField(opcode as int, declaringType as IType, fieldName as string, fieldType as IType):
		_code.visitFieldInsn(
				opcode,
				javaType(declaringType),
				fieldName,
				typeDescriptor(fieldType))

	def entity(node as Node):
		return GetEntity(node)

	def javaType(typeRef as TypeReference):
		return javaType(entity(typeRef) as IType)

	def typeDescriptor(type as IType) as string:
		if type in _primitiveMappings: return _primitiveMappings[type]
		if type.IsArray: return "[" + typeDescriptor(type.GetElementType())
		return "L" + javaType(type) + ";"

	def javaType(type as IType) as string:
		if type in _typeMappings: return _typeMappings[type]
		return javaType(type.FullName)

	def javaType(typeName as string):
		return typeName.Replace('.', '/')

namespace Boojay.Compilation

import System.IO

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Steps
import Boo.Lang.Compiler.TypeSystem

import Boo.PatternMatching

import org.objectweb.asm
import org.objectweb.asm.Type

class BoojayEmitter(AbstractVisitorCompilerStep):

	_classWriter as ClassWriter
	_code as MethodVisitor
	_typeMappings as Hash
	_primitiveMappings as Hash

	override def Initialize(context as CompilerContext):
		super(context)
		initializeTypeMappings()

	def Run():
		Visit(CompileUnit)

	def initializeTypeMappings():
		_typeMappings = {
			typeSystem.ObjectType: "java/lang/Object",
			typeSystem.StringType: "java/lang/String",
		}

		_primitiveMappings = {
			typeSystem.BoolType: BOOLEAN_TYPE.getDescriptor(),
			typeSystem.IntType: INT_TYPE.getDescriptor(),
			typeSystem.VoidType: VOID_TYPE.getDescriptor(),
		}

	override def OnInterfaceDefinition(node as InterfaceDefinition):
		emitTypeDefinition node

	override def OnClassDefinition(node as ClassDefinition):
		emitTypeDefinition node

	def emitTypeDefinition(node as TypeDefinition):
		_classWriter = ClassWriter(ClassWriter.COMPUTE_MAXS)
		_classWriter.visit(
			Opcodes.V1_5,
			typeAttributes(node),
			javaType(node.FullName),
			null,
			javaType(baseType(node)),
			implementedInterfaces(node))

		emit node.Members

		_classWriter.visitEnd()

		writeClassFile node

	def implementedInterfaces(node as TypeDefinition):
		interfaces = array(
				javaType(itf)
				for itf in node.BaseTypes
				if isInterface(itf))
		if len(interfaces) == 0: return null
		return interfaces

	def isInterface(typeRef as TypeReference):
		return (entity(typeRef) as IType).IsInterface

	def typeAttributes(node as TypeDefinition):
		attrs = 0
		match node.NodeType:
			case NodeType.ClassDefinition:
				attrs += Opcodes.ACC_SUPER
			case NodeType.InterfaceDefinition:
				attrs += (Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT)
		if node.IsPublic:
			attrs += Opcodes.ACC_PUBLIC
		return attrs

	def writeClassFile(node as TypeDefinition):
		fname = classFullFileName(node)
		ensurePath(fname)
		File.WriteAllBytes(fname, _classWriter.toByteArray())

	override def OnIfStatement(node as IfStatement):

		elseLabel = Label()
		afterElseLabel = Label()

		emitBranchFalse node.Condition, elseLabel
		emit node.TrueBlock
		if node.FalseBlock is not null:
			GOTO afterElseLabel
		mark elseLabel
		if node.FalseBlock is not null:
			emit node.FalseBlock
			mark afterElseLabel

	def emitBranchFalse(e as Expression, label as Label):
		match e:
			case UnaryExpression(
					Operator: UnaryOperatorType.LogicalNot,
					Operand: condition):
				emitBranchTrue condition, label
			otherwise:
				emit e
				IFEQ label

	def emitBranchTrue(e as Expression, label as Label):
		match e:
			case UnaryExpression(
					Operator: UnaryOperatorType.LogicalNot,
					Operand: condition):
				emitBranchFalse condition, label
			otherwise:
				emit e
				IFNE label

	override def OnWhileStatement(node as WhileStatement):

		testLabel = Label()
		bodyLabel = Label()
		GOTO testLabel
		mark bodyLabel
		emit node.Block
		mark testLabel
		emitBranchTrue node.Condition, bodyLabel

	override def OnField(node as Field):
		field = _classWriter.visitField(
					memberAttributes(node),
					node.Name,
					typeDescriptor(entity(node.Type)),
					null,
					null)
		field.visitEnd()

	override def OnConstructor(node as Constructor):
		emitMethod "<init>", node

	override def OnMethod(node as Method):
		methodName = ("main" if node.Name == "Main" else node.Name)
		emitMethod methodName, node

	def emitMethod(methodName as string, node as Method):
		_code = _classWriter.visitMethod(
					memberAttributes(node),
					methodName,
					javaSignature(node),
					null,
					null)

		if not node.IsAbstract:
			emitMethodBody node
		_code.visitEnd()

	def emitMethodBody(node as Method):
		prepareLocalVariables node

		_code.visitCode()

		emit node.Body
		RETURN

		_code.visitMaxs(0, 0)

	def memberAttributes(node as TypeMember):
		attributes = Opcodes.ACC_PUBLIC
		if node.IsStatic: attributes += Opcodes.ACC_STATIC
		if node.IsAbstract: attributes += Opcodes.ACC_ABSTRACT
		return attributes

	def prepareLocalVariables(node as Method):
		i = firstLocalIndex(node)
		for local in node.Locals:
			index(local, i)
			++i

	def firstLocalIndex(node as Method):
		if 0 == len(node.Parameters):
			if node.IsStatic: return 0
			return 1
		return lastParameterIndex(node) + 1

	def lastParameterIndex(node as Method):
		param as InternalParameter = entity(node.Parameters[-1])
		return param.Index

	def index(node as Local, index as int):
		node["index"] = index

	def index(entity as InternalLocal) as int:
		return entity.Local["index"]

	override def LeaveExpressionStatement(node as ExpressionStatement):
		discardValueOnStack node.Expression

	def discardValueOnStack(node as Expression):
		mie = node as MethodInvocationExpression
		if mie is null: return

		m = entity(mie.Target) as IMethod
		if m is null: return

		if hasReturnValue(m): POP

	def hasReturnValue(m as IMethod):
		return m.ReturnType is not TypeSystemServices.VoidType

	override def OnReturnStatement(node as ReturnStatement):
		if node.Expression is null:
			RETURN
		else:
			emit node.Expression
			ARETURN

	override def OnMethodInvocationExpression(node as MethodInvocationExpression):

		match entity(node.Target):
			case ctor = IConstructor():
				match node.Target:
					case SuperLiteralExpression():
						ALOAD 0
						INVOKESPECIAL ctor
					otherwise:
						emitObjectCreation ctor, node
			case method = IMethod():
				emitMethodInvocation method, node
			case builtin = BuiltinFunction():
				emitBuiltinInvocation builtin, node

	def emitBuiltinInvocation(builtin as BuiltinFunction, node as MethodInvocationExpression):
		match builtin.FunctionType:
			case BuiltinFunctionType.Eval:
				emitEval node

	def emitEval(node as MethodInvocationExpression):
		for e in node.Arguments.ToArray()[:-1]:
			emit e
			discardValueOnStack e
		emit node.Arguments[-1]

	def emitMethodInvocation(method as IMethod, node as MethodInvocationExpression):

		if isSpecialIkvmGetter(method):
			emitSpecialIkvmGetter(method)
			return

		emit node.Target
		emit node.Arguments

		if method.IsStatic:
			INVOKESTATIC method
		elif method.DeclaringType.IsInterface:
			INVOKEINTERFACE method
		else:
			INVOKEVIRTUAL method

	def emitObjectCreation(ctor as IConstructor, node as MethodInvocationExpression):
		NEW ctor.DeclaringType
		DUP
		emit node.Arguments
		INVOKESPECIAL ctor

	def emitSpecialIkvmGetter(method as IMethod):
	"""
	in the ikvm version of GNU.ClassPath the
	console streams are mapped to properties
	where in java they should be treated as static fields
	"""
		emitLoadStaticField(
			method.DeclaringType,
			stripGetterPrefix(method.Name),
			method.ReturnType)

	def isSpecialIkvmGetter(method as IMethod):
		return (method.IsStatic
			and method.DeclaringType.FullName == "java.lang.System"
			and method.Name in ("get_out", "get_in", "get_err"))

	override def OnBinaryExpression(node as BinaryExpression):
		match node.Operator:
			case BinaryOperatorType.Assign:
				emitAssignment node
			case BinaryOperatorType.Subtraction:
				emitSubtraction node
			case BinaryOperatorType.Addition:
				emitAddition node

	def emitAddition(node as BinaryExpression):
		emit node.Left
		emit node.Right
		IADD

	def emitSubtraction(node as BinaryExpression):
		emit node.Left
		emit node.Right
		ISUB

	def emitAssignment(node as BinaryExpression):
		match node.Left:
			case memberRef = MemberReferenceExpression():
				match entity(memberRef):
                    case field = IField(IsStatic: false):
                    	emit memberRef.Target
                    	emit node.Right
                    	PUTFIELD field
			case reference = ReferenceExpression():
				emit node.Right
				match entity(reference):
					case local = ILocalEntity():
						if not local.Type.IsValueType:
							ASTORE index(local)
						elif isIntegerOrBool(local.Type):
							ISTORE index(local)

	override def OnMemberReferenceExpression(node as MemberReferenceExpression):
		match entity(node):
			case field = IField(IsStatic: true):
				GETSTATIC field
			case field = IField(IsStatic: false):
				emit node.Target
				GETFIELD field
			case IMethod(IsStatic: false):
				emit node.Target
			case IMethod(IsStatic: true):
				pass

	override def OnSelfLiteralExpression(node as SelfLiteralExpression):
		ALOAD 0

	override def OnReferenceExpression(node as ReferenceExpression):
		match entity(node):
			case param = InternalParameter():
				emitLoad param.Type, param.Index
			case local = ILocalEntity():
				emitLoad local.Type, index(local)
			case type = IType():
				LDC type

	def emitLoad(type as IType, index as int):
		if not type.IsValueType:
			ALOAD index
		elif isIntegerOrBool(type):
			ILOAD index
		else:
			raise "Unsupported type: ${type}"

	def isIntegerOrBool(type as IType):
		return self.TypeSystemServices.IsIntegerOrBool(type)

	def stripGetterPrefix(name as string):
		return name[len("get_"):]

	override def OnStringLiteralExpression(node as StringLiteralExpression):
		LDC node.Value

	override def OnIntegerLiteralExpression(node as IntegerLiteralExpression):
		ICONST node.Value

	override def OnBoolLiteralExpression(node as BoolLiteralExpression):
		if node.Value:
			ICONST_1
		else:
			ICONST_0

	def baseType(node as TypeDefinition):
		if node isa InterfaceDefinition: return TypeSystemServices.ObjectType
		return self.GetType(node).BaseType

	typeSystem as JavaTypeSystem:
		get: return self.TypeSystemServices

	def javaSignature(method as IMethod):
		return ("("
			+ join(typeDescriptor(p.Type) for p in method.GetParameters(), "")
			+ ")"
			+ typeDescriptor(method.ReturnType))

	def javaSignature(node as Method):
		return javaSignature(entity(node) as IMethod)

	def ensurePath(fname as string):
		path = Path.GetDirectoryName(fname)
		if not string.IsNullOrEmpty(path):
			Directory.CreateDirectory(path)

	def classFullFileName(node as TypeDefinition):
		return javaType(entity(node)) + ".class"

	def emit(node as Node):
		Visit(node)

	def emit(nodes as System.Collections.IEnumerable):
		VisitCollection(nodes)

	def LDC(value):
		emitLdcInsn value

	def LDC(type as IType):
		emitLdcInsn org.objectweb.asm.Type.getType(typeDescriptor(type))

	def IFEQ(label as Label):
		emitJumpInsn Opcodes.IFEQ, label

	def IFNE(label as Label):
        emitJumpInsn Opcodes.IFNE, label

	def GOTO(label as Label):
		emitJumpInsn Opcodes.GOTO, label

	def ILOAD(index as int):
		emitVarInsn Opcodes.ILOAD, index

	def ICONST(value as int):
		if value >= -1 and value <= 5:
			emitInsn iconstOpcodeFor(value)
		elif value >= -127 and value <= 127:
			emitIntInsn Opcodes.BIPUSH, value
		else:
			emitIntInsn Opcodes.SIPUSH, value

	def ICONST_0():
		emitInsn Opcodes.ICONST_0

	def ICONST_1():
		emitInsn Opcodes.ICONST_1

	def iconstOpcodeFor(value as int):
		if value == 0: return Opcodes.ICONST_0
		if value == 1: return Opcodes.ICONST_1
		if value == 2: return Opcodes.ICONST_2
		if value == -1: return Opcodes.ICONST_M1
		raise System.ArgumentException("value")

	def ISTORE(index as int):
		emitVarInsn(Opcodes.ISTORE, index)

	def ALOAD(index as int):
		emitVarInsn(Opcodes.ALOAD, index)

	def ASTORE(index as int):
		emitVarInsn(Opcodes.ASTORE, index)

	def GETSTATIC(field as IField):
		emitLoadStaticField(field.DeclaringType, field.Name, field.Type)

	def GETFIELD(field as IField):
		emitField Opcodes.GETFIELD, field

	def PUTFIELD(field as IField):
		emitField Opcodes.PUTFIELD, field

	def INVOKESTATIC(method as IMethod):
		invoke(Opcodes.INVOKESTATIC, method)

	def INVOKEVIRTUAL(method as IMethod):
		invoke(Opcodes.INVOKEVIRTUAL, method)

	def INVOKESPECIAL(method as IMethod):
		invoke(Opcodes.INVOKESPECIAL, method)

	def INVOKEINTERFACE(method as IMethod):
		invoke(Opcodes.INVOKEINTERFACE, method)

	def RETURN():
	   emitInsn(Opcodes.RETURN)

	def ARETURN():
	   emitInsn(Opcodes.ARETURN)

	def POP():
		emitInsn(Opcodes.POP)

	def NEW(type as IType):
		emitTypeInsn(Opcodes.NEW, javaType(type))

	def DUP():
		emitInsn(Opcodes.DUP)

	def ISUB():
		emitInsn(Opcodes.ISUB)

	def IADD():
		emitInsn(Opcodes.IADD)

	def emitVarInsn(opcode as int, index as int):
		_code.visitVarInsn(opcode, index)

	def emitInsn(i as int):
		_code.visitInsn(i)

	def emitIntInsn(opcode as int, value as int):
		_code.visitIntInsn(opcode, value)

	def emitJumpInsn(i as int, label as Label):
		_code.visitJumpInsn(i, label)

	def emitLdcInsn(value):
		_code.visitLdcInsn(value)

	def emitTypeInsn(opcode as int, name as string):
		_code.visitTypeInsn(opcode, name)

	def mark(label as Label):
		_code.visitLabel(label)

	def invoke(opcode as int, method as IMethod):
		_code.visitMethodInsn(
				opcode,
				javaType(method.DeclaringType),
				("<init>" if method isa IConstructor else method.Name),
				javaSignature(method))

	def emitLoadStaticField(declaringType as IType, fieldName as string, fieldType as IType):
		emitField Opcodes.GETSTATIC, declaringType, fieldName, fieldType

	def emitField(opcode as int, field as IField):
		emitField opcode, field.DeclaringType, field.Name, field.Type

	def emitField(opcode as int, declaringType as IType, fieldName as string, fieldType as IType):
		_code.visitFieldInsn(
				opcode,
				javaType(declaringType),
				fieldName,
				typeDescriptor(fieldType))

	def entity(node as Node):
		return GetEntity(node)

	def javaType(typeRef as TypeReference):
		return typeDescriptor(entity(typeRef) as IType)

	def typeDescriptor(type as IType) as string:
		if type in _primitiveMappings: return _primitiveMappings[type]
		if type.IsArray: return "[" + typeDescriptor(type.GetElementType())
		return "L" + javaType(type) + ";"

	def javaType(type as IType) as string:
		if type in _typeMappings: return _typeMappings[type]
		return javaType(type.FullName)

	def javaType(typeName as string):
		return typeName.Replace('.', '/')