diff options
author | mihaylov <mihaylov@epfl.ch> | 2005-09-27 07:29:32 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2005-09-27 07:29:32 +0000 |
commit | 7bcb0076ade6d22d45738718035ccc688f7cc0b6 (patch) | |
tree | 5a39b404dfa5143dd44e7f7e2d9e6e1848c56a70 | |
parent | 6b71c24b1de7e9e2052b509280ed0cdc9c2ee037 (diff) | |
download | scala-7bcb0076ade6d22d45738718035ccc688f7cc0b6.tar.gz scala-7bcb0076ade6d22d45738718035ccc688f7cc0b6.tar.bz2 scala-7bcb0076ade6d22d45738718035ccc688f7cc0b6.zip |
Implemented the Java part of the library in C#
-rw-r--r-- | sources/msil/AssemblyInfo.cs.tmpl | 58 | ||||
-rw-r--r-- | sources/msil/scala_part2.il.diff.tmpl | 21 | ||||
-rw-r--r-- | sources/scala/AnyVal.cs | 18 | ||||
-rw-r--r-- | sources/scala/Array.cs | 35 | ||||
-rw-r--r-- | sources/scala/Boolean.cs | 61 | ||||
-rw-r--r-- | sources/scala/Byte.cs | 132 | ||||
-rw-r--r-- | sources/scala/Char.cs | 128 | ||||
-rw-r--r-- | sources/scala/Double.cs | 66 | ||||
-rw-r--r-- | sources/scala/Float.cs | 81 | ||||
-rw-r--r-- | sources/scala/Int.cs | 127 | ||||
-rw-r--r-- | sources/scala/Long.cs | 108 | ||||
-rw-r--r-- | sources/scala/MatchError.cs | 62 | ||||
-rw-r--r-- | sources/scala/Ref.cs | 31 | ||||
-rw-r--r-- | sources/scala/ScalaObject.cs | 24 | ||||
-rw-r--r-- | sources/scala/Short.cs | 129 | ||||
-rw-r--r-- | sources/scala/Unit.cs | 45 | ||||
-rw-r--r-- | sources/scala/runtime/RunTime.cs | 513 |
17 files changed, 1639 insertions, 0 deletions
diff --git a/sources/msil/AssemblyInfo.cs.tmpl b/sources/msil/AssemblyInfo.cs.tmpl new file mode 100644 index 0000000000..c32f40ff11 --- /dev/null +++ b/sources/msil/AssemblyInfo.cs.tmpl @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// 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("scala")] +[assembly: AssemblyDescription("Scala Runtime Library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("EPFL-LAMP")] +[assembly: AssemblyProduct("Scala Language Distribution")] +[assembly: AssemblyCopyright("2002-2005 EPFL-LAMP")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// 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("SCALA_VERSION")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(true)] +[assembly: AssemblyKeyFile("lamp.key")] +[assembly: AssemblyKeyName("")] diff --git a/sources/msil/scala_part2.il.diff.tmpl b/sources/msil/scala_part2.il.diff.tmpl new file mode 100644 index 0000000000..8f63867b2b --- /dev/null +++ b/sources/msil/scala_part2.il.diff.tmpl @@ -0,0 +1,21 @@ +--- scala_part2.il 2005-09-21 16:19:30.676754000 +0200 ++++ scala_part2.il.new 2005-09-21 16:21:58.522947000 +0200 +@@ -1,18 +1,3 @@ +-.assembly extern 'mscorlib' +-{ +- .ver 1:0:3300:0 +- .publickeytoken = (b7 7a 5c 56 19 34 e0 89) +-} +-.assembly extern 'scala_part1' +-{ +- .ver SCALA_VERSION +- .publickeytoken = (80 07 fc 78 8a 2e 53 08) +-} +-.assembly 'scala_part2' +-{ +-} +-.module 'scala_part2.dll' +- + .namespace 'scala' + { + .class public auto ansi interface 'Tuple1' diff --git a/sources/scala/AnyVal.cs b/sources/scala/AnyVal.cs new file mode 100644 index 0000000000..2178416e4e --- /dev/null +++ b/sources/scala/AnyVal.cs @@ -0,0 +1,18 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.Any;")] + public abstract class AnyVal {} +} diff --git a/sources/scala/Array.cs b/sources/scala/Array.cs new file mode 100644 index 0000000000..f48f18d5e4 --- /dev/null +++ b/sources/scala/Array.cs @@ -0,0 +1,35 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class [?T] extends scala.AnyRef;")] + [Serializable] + public abstract class Array /*: Cloneable*/ + { + + [Meta("constr (scala.Int);")] + public Array() {} + + [Meta("method []scala.Array[?T];")] + public abstract object value(); + + [Meta("method []scala.Int;")] + public abstract int length(); + [Meta("method (scala.Int)?T;")] + public abstract object apply(int i); + [Meta("method (scala.Int,?T)scala.Unit;")] + public abstract void update(int i, object x); + } +} diff --git a/sources/scala/Boolean.cs b/sources/scala/Boolean.cs new file mode 100644 index 0000000000..add1f882f1 --- /dev/null +++ b/sources/scala/Boolean.cs @@ -0,0 +1,61 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Boolean : AnyVal + { + + public readonly bool value; + + public Boolean(bool value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return other is Boolean && value == ((Boolean)other).value; + } + public override int GetHashCode() + { + return value ? 1231 : 1237; + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Boolean;")] + public bool __bang ( ) { return !value ; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (bool that) { return value == that; } + public bool __bang__eq (bool that) { return value != that; } + public bool __bar__bar (bool that) { return value || that; } + public bool __amp__amp (bool that) { return value && that; } + public bool __bar (bool that) { return value | that; } + public bool __amp (bool that) { return value & that; } + public bool __up (bool that) { return value ^ that; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Byte.cs b/sources/scala/Byte.cs new file mode 100644 index 0000000000..4fd6493458 --- /dev/null +++ b/sources/scala/Byte.cs @@ -0,0 +1,132 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Byte : AnyVal { + + public readonly sbyte value; + + public Byte(sbyte value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return (other is Byte) && (value == ((Byte)other).value); + } + public override int GetHashCode() + { + return value; + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Int;")] + public int __plus ( ) { return +value ; } + [Meta("method []scala.Int;")] + public int __minus ( ) { return -value ; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + [Meta("method []scala.Double;")] + public double coerce ( ) { return value ; } + + public bool __eq__eq (float that) { return value == that; } + public bool __bang__eq (float that) { return value != that; } + public bool __less (float that) { return value < that; } + public bool __greater (float that) { return value > that; } + public bool __less__eq (float that) { return value <= that; } + public bool __greater__eq(float that) { return value >= that; } + public float __plus (float that) { return value + that; } + public float __minus (float that) { return value - that; } + public float __times (float that) { return value * that; } + public float __div (float that) { return value / that; } + public float __percent (float that) { return value % that; } + + [Meta("method []scala.Float;")] + public float coerce (float dummy) { return value ; } + [Meta("method []scala.Int;")] + public int __tilde ( ) { return ~value ; } + + public int __less__less (int that) { return value << that; } + public int __less__less (long that) { return value << (int)that; } + public int __greater__greater(int that) { return value >> that; } + public int __greater__greater(long that) { return value >> (int)that; } + public int __greater__greater__greater(int that) { return (int)((uint)value >>that); } + public int __greater__greater__greater(long that) { return (int)((uint)value >>(int)that); } + + public bool __eq__eq (long that) { return value == that; } + public bool __bang__eq (long that) { return value != that; } + public bool __less (long that) { return value < that; } + public bool __greater (long that) { return value > that; } + public bool __less__eq (long that) { return value <= that; } + public bool __greater__eq(long that) { return value >= that; } + public long __plus (long that) { return value + that; } + public long __minus (long that) { return value - that; } + public long __times (long that) { return value * that; } + public long __div (long that) { return value / that; } + public long __percent (long that) { return value % that; } + public long __bar (long that) { return value | that; } + public long __amp (long that) { return value & that; } + public long __up (long that) { return value ^ that; } + + [Meta("method []scala.Long;")] + public long coerce (long dummy) { return value ; } + + public bool __eq__eq (int that) { return value == that; } + public bool __bang__eq (int that) { return value != that; } + public bool __less (int that) { return value < that; } + public bool __greater (int that) { return value > that; } + public bool __less__eq (int that) { return value <= that; } + public bool __greater__eq(int that) { return value >= that; } + public int __plus (int that) { return value + that; } + public int __minus (int that) { return value - that; } + public int __times (int that) { return value * that; } + public int __div (int that) { return value / that; } + public int __percent (int that) { return value % that; } + public int __bar (int that) { return value | that; } + public int __amp (int that) { return value & that; } + public int __up (int that) { return value ^ that; } + + [Meta("method []scala.Int;")] + public int coerce (int dummy) { return value ; } + + [Meta("method []scala.Short;")] + public short coerce (short dummy) { return value ; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Char.cs b/sources/scala/Char.cs new file mode 100644 index 0000000000..b3e28a454b --- /dev/null +++ b/sources/scala/Char.cs @@ -0,0 +1,128 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + public abstract class Char : AnyVal { + + public readonly char value; + + public Char(char value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return other is Char && value == ((Char)other).value; + } + public override int GetHashCode() + { + return value; + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Int;")] + public int __plus ( ) { return +value ; } + [Meta("method []scala.Int;")] + public int __minus ( ) { return -value ; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + [Meta("method []scala.Double;")] + public double coerce ( ) { return value ; } + + public bool __eq__eq (float that) { return value == that; } + public bool __bang__eq (float that) { return value != that; } + public bool __less (float that) { return value < that; } + public bool __greater (float that) { return value > that; } + public bool __less__eq (float that) { return value <= that; } + public bool __greater__eq(float that) { return value >= that; } + public float __plus (float that) { return value + that; } + public float __minus (float that) { return value - that; } + public float __times (float that) { return value * that; } + public float __div (float that) { return value / that; } + public float __percent (float that) { return value % that; } + + [Meta("method []scala.Float;")] + public float coerce (float dummy) { return value; } + [Meta("method []scala.Int;")] + public int __tilde ( ) { return ~value; } + + public int __less__less (int that) { return value << that; } + public int __less__less (long that) { return value << (int)that; } + public int __greater__greater(int that) { return value >> that; } + public int __greater__greater(long that) { return value >> (int)that; } + public int __greater__greater__greater(int that) { return (int)((uint)value >>that); } + public int __greater__greater__greater(long that) { return (int)((uint)value >>(int)that); } + + public bool __eq__eq (long that) { return value == that; } + public bool __bang__eq (long that) { return value != that; } + public bool __less (long that) { return value < that; } + public bool __greater (long that) { return value > that; } + public bool __less__eq (long that) { return value <= that; } + public bool __greater__eq(long that) { return value >= that; } + public long __plus (long that) { return value + that; } + public long __minus (long that) { return value - that; } + public long __times (long that) { return value * that; } + public long __div (long that) { return value / that; } + public long __percent (long that) { return value % that; } + public long __bar (long that) { return value | that; } + public long __amp (long that) { return value & that; } + public long __up (long that) { return value ^ that; } + + [Meta("method []scala.Long;")] + public long coerce (long dummy) { return value ; } + + public bool __eq__eq (int that) { return value == that; } + public bool __bang__eq (int that) { return value != that; } + public bool __less (int that) { return value < that; } + public bool __greater (int that) { return value > that; } + public bool __less__eq (int that) { return value <= that; } + public bool __greater__eq(int that) { return value >= that; } + public int __plus (int that) { return value + that; } + public int __minus (int that) { return value - that; } + public int __times (int that) { return value * that; } + public int __div (int that) { return value / that; } + public int __percent (int that) { return value % that; } + public int __bar (int that) { return value | that; } + public int __amp (int that) { return value & that; } + public int __up (int that) { return value ^ that; } + + [Meta("method []scala.Int;")] + public int coerce (int dummy) { return value ; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Double.cs b/sources/scala/Double.cs new file mode 100644 index 0000000000..59da220403 --- /dev/null +++ b/sources/scala/Double.cs @@ -0,0 +1,66 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Double : AnyVal { + + public readonly double value; + + public Double (double value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return other is Double && value == ((Double )other).value; + } + public override int GetHashCode() + { + return value.GetHashCode(); + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Double;")] + public double __plus (object dummy) { return +value; } + [Meta("method []scala.Double;")] + public double __minus ( ) { return -value; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Float.cs b/sources/scala/Float.cs new file mode 100644 index 0000000000..13832f3f1b --- /dev/null +++ b/sources/scala/Float.cs @@ -0,0 +1,81 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Float : AnyVal { + + public readonly float value; + + public Float(float value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return (other is Float) && (value == ((Float)other).value); + } + public override int GetHashCode() + { + return value.GetHashCode(); + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq(object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Float;")] + public float __plus ( ) { return +value ; } + [Meta("method []scala.Float;")] + public float __minus ( ) { return -value ; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + [Meta("method []scala.Double;")] + public double coerce ( ) { return value; } + + public bool __eq__eq (float that) { return value == that; } + public bool __bang__eq (float that) { return value != that; } + public bool __less (float that) { return value < that; } + public bool __greater (float that) { return value > that; } + public bool __less__eq (float that) { return value <= that; } + public bool __greater__eq(float that) { return value >= that; } + public float __plus (float that) { return value + that; } + public float __minus (float that) { return value - that; } + public float __times (float that) { return value * that; } + public float __div (float that) { return value / that; } + public float __percent (float that) { return value % that; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Int.cs b/sources/scala/Int.cs new file mode 100644 index 0000000000..001ee900d5 --- /dev/null +++ b/sources/scala/Int.cs @@ -0,0 +1,127 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Int : AnyVal { + + public readonly int value; + + public Int(int value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return (other is Int) && (value == ((Int)other).value); + } + public override int GetHashCode() + { + return value; + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Int;")] + public int __plus ( ) { return +value ; } + + [Meta("method []scala.Int;")] + public int __minus ( ) { return -value ; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + [Meta("method []scala.Double;")] + public double coerce (double dummy) { return value; } + + public bool __eq__eq (float that) { return value == that; } + public bool __bang__eq (float that) { return value != that; } + public bool __less (float that) { return value < that; } + public bool __greater (float that) { return value > that; } + public bool __less__eq (float that) { return value <= that; } + public bool __greater__eq(float that) { return value >= that; } + public float __plus (float that) { return value + that; } + public float __minus (float that) { return value - that; } + public float __times (float that) { return value * that; } + public float __div (float that) { return value / that; } + public float __percent (float that) { return value % that; } + + [Meta("method []scala.Float;")] + public float coerce (float dummy) { return value; } + [Meta("method []scala.Int;")] + public int __tilde ( ) { return ~value; } + + public int __less__less (int that) { return value << that; } + public int __less__less (long that) { return value << (int)that; } + public int __greater__greater(int that) { return value >> that; } + public int __greater__greater(long that) { return value >> (int)that; } + public int __greater__greater__greater(int that) { return (int)((uint)value >>that); } + public int __greater__greater__greater(long that) { return (int)((uint)value >>(int)that); } + + public bool __eq__eq (long that) { return value == that; } + public bool __bang__eq (long that) { return value != that; } + public bool __less (long that) { return value < that; } + public bool __greater (long that) { return value > that; } + public bool __less__eq (long that) { return value <= that; } + public bool __greater__eq(long that) { return value >= that; } + public long __plus (long that) { return value + that; } + public long __minus (long that) { return value - that; } + public long __times (long that) { return value * that; } + public long __div (long that) { return value / that; } + public long __percent (long that) { return value % that; } + public long __bar (long that) { return value | that; } + public long __amp (long that) { return value & that; } + public long __up (long that) { return value ^ that; } + + [Meta("method []scala.Long;")] + public long coerce (object dummy) { return value ; } + + public bool __eq__eq (int that) { return value == that; } + public bool __bang__eq (int that) { return value != that; } + public bool __less (int that) { return value < that; } + public bool __greater (int that) { return value > that; } + public bool __less__eq (int that) { return value <= that; } + public bool __greater__eq(int that) { return value >= that; } + public int __plus (int that) { return value + that; } + public int __minus (int that) { return value - that; } + public int __times (int that) { return value * that; } + public int __div (int that) { return value / that; } + public int __percent (int that) { return value % that; } + public int __bar (int that) { return value | that; } + public int __amp (int that) { return value & that; } + public int __up (int that) { return value ^ that; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Long.cs b/sources/scala/Long.cs new file mode 100644 index 0000000000..01995f7d04 --- /dev/null +++ b/sources/scala/Long.cs @@ -0,0 +1,108 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Long : AnyVal { + + public readonly long value; + + public Long (long value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return (other is Long) && value == ((Long)other).value; + } + public override int GetHashCode() + { + return value.GetHashCode(); + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Long;")] + public long __plus ( ) { return +value ; } + [Meta("method []scala.Long;")] + public long __minus ( ) { return -value ; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + [Meta("method []scala.Double;")] + public double coerce ( ) { return value ; } + + public bool __eq__eq (float that) { return value == that; } + public bool __bang__eq (float that) { return value != that; } + public bool __less (float that) { return value < that; } + public bool __greater (float that) { return value > that; } + public bool __less__eq (float that) { return value <= that; } + public bool __greater__eq(float that) { return value >= that; } + public float __plus (float that) { return value + that; } + public float __minus (float that) { return value - that; } + public float __times (float that) { return value * that; } + public float __div (float that) { return value / that; } + public float __percent (float that) { return value % that; } + + [Meta("method []scala.Float;")] + public float coerce (object dummy) { return value ; } + [Meta("method []scala.Long;")] + public long __tilde ( ) { return ~value ; } + + public long __less__less (int that) { return value << that; } + public long __less__less (long that) { return value << (int)that; } + public long __greater__greater(int that) { return value >> that; } + public long __greater__greater(long that) { return value >> (int)that; } + public long __greater__greater__greater(int that) { return (int)((ulong)value >>that); } + public long __greater__greater__greater(long that) { return (int)((ulong)value >>(int)that); } + + public bool __eq__eq (long that) { return value == that; } + public bool __bang__eq (long that) { return value != that; } + public bool __less (long that) { return value < that; } + public bool __greater (long that) { return value > that; } + public bool __less__eq (long that) { return value <= that; } + public bool __greater__eq(long that) { return value >= that; } + public long __plus (long that) { return value + that; } + public long __minus (long that) { return value - that; } + public long __times (long that) { return value * that; } + public long __div (long that) { return value / that; } + public long __percent (long that) { return value % that; } + public long __bar (long that) { return value | that; } + public long __amp (long that) { return value & that; } + public long __up (long that) { return value ^ that; } + + } +}
\ No newline at end of file diff --git a/sources/scala/MatchError.cs b/sources/scala/MatchError.cs new file mode 100644 index 0000000000..1ce0b37b09 --- /dev/null +++ b/sources/scala/MatchError.cs @@ -0,0 +1,62 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** ** +** $Id$ +\* */ +using System; +using scala.runtime; + +namespace scala +{ + + + /** This class implements errors which are thrown whenever an + * object doesn't match any pattern of a pattern matching + * expression. + * + * @author Matthias Zenger + * @version 1.1, 05/03/2004 + */ + public sealed class MatchError : ApplicationException + { + + [Meta("constr (System.String, scala.Int);")] + private MatchError(string source, int line) : + base(" in '" + source + "' at line " + line) + { + } + + [Meta("constr (System.String, scala.Int, System.String);")] + private MatchError(string source, int line, string obj) : + base("for object " + obj + " in '" + source + "' at line " + line) + { + } + + [Meta("method [?T](System.String, scala.Int) ?T;")] + public static object fail(string source, int line) + { + throw new MatchError(source, line); + } + + [Meta("method [?T](System.String, scala.Int, scala.Any) ?T;")] + public static object report(string source, int line, object obj) + { + try + { + throw new MatchError(source, line, obj.ToString()); + } + catch (MatchError e) + { + throw e; + } + catch (Exception e) + { + throw new MatchError(source, line); + } + } + } +}
\ No newline at end of file diff --git a/sources/scala/Ref.cs b/sources/scala/Ref.cs new file mode 100644 index 0000000000..3a10a7c648 --- /dev/null +++ b/sources/scala/Ref.cs @@ -0,0 +1,31 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $OldId: Ref.java,v 1.2 2002/03/12 13:16:04 zenger Exp $ +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class [?T] extends scala.AnyRef;")] + [Serializable] + public class Ref : object { + + [Meta("field ?T;")] + public object elem = null; + + [Meta("constr (?T);")] + public Ref(object x) + { + elem = x; + } + } +}
\ No newline at end of file diff --git a/sources/scala/ScalaObject.cs b/sources/scala/ScalaObject.cs new file mode 100644 index 0000000000..7f2b7f693b --- /dev/null +++ b/sources/scala/ScalaObject.cs @@ -0,0 +1,24 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + [Meta("class extends scala.AnyRef;")] + public interface ScalaObject + { + /** This method is needed for optimizing pattern matching expressions + * which match on constructors of case classes. + */ + int __tag(); + } +}
\ No newline at end of file diff --git a/sources/scala/Short.cs b/sources/scala/Short.cs new file mode 100644 index 0000000000..0e03090d59 --- /dev/null +++ b/sources/scala/Short.cs @@ -0,0 +1,129 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + [Meta("class extends scala.AnyVal;")] + [Serializable] + public abstract class Short : AnyVal { + + public readonly short value; + + public Short(short value) + { + this.value = value; + } + + public override bool Equals(object other) + { + return (other is Short) && value == ((Short)other).value; + } + public override int GetHashCode() + { + return value; + } + public override string ToString() + { + return value.ToString(); + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + [Meta("method []scala.Int;")] + public int __plus () { return +value; } + [Meta("method []scala.Int;")] + public int __minus () { return -value; } + + public string __plus (string that) { return value + that; } + + public bool __eq__eq (double that) { return value == that; } + public bool __bang__eq (double that) { return value != that; } + public bool __less (double that) { return value < that; } + public bool __greater (double that) { return value > that; } + public bool __less__eq (double that) { return value <= that; } + public bool __greater__eq(double that) { return value >= that; } + public double __plus (double that) { return value + that; } + public double __minus (double that) { return value - that; } + public double __times (double that) { return value * that; } + public double __div (double that) { return value / that; } + public double __percent (double that) { return value % that; } + + [Meta("method []scala.Double;")] + public double coerce ( ) { return value; } + + public bool __eq__eq (float that) { return value == that; } + public bool __bang__eq (float that) { return value != that; } + public bool __less (float that) { return value < that; } + public bool __greater (float that) { return value > that; } + public bool __less__eq (float that) { return value <= that; } + public bool __greater__eq(float that) { return value >= that; } + public float __plus (float that) { return value + that; } + public float __minus (float that) { return value - that; } + public float __times (float that) { return value * that; } + public float __div (float that) { return value / that; } + public float __percent (float that) { return value % that; } + + [Meta("method []scala.Float;")] + public float coerce (float dummy) { return value ; } + [Meta("method []scala.Int;")] + public int __tilde ( ) { return ~value ; } + + public int __less__less (int that) { return value << that; } + public int __less__less (long that) { return value << (int)that; } + public int __greater__greater(int that) { return value >> that; } + public int __greater__greater(long that) { return value >> (int)that; } + public int __greater__greater__greater(int that) { return (int)((uint)value >>that); } + public int __greater__greater__greater(long that) { return (int)((uint)value >>(int)that); } + + public bool __eq__eq (long that) { return value == that; } + public bool __bang__eq (long that) { return value != that; } + public bool __less (long that) { return value < that; } + public bool __greater (long that) { return value > that; } + public bool __less__eq (long that) { return value <= that; } + public bool __greater__eq(long that) { return value >= that; } + public long __plus (long that) { return value + that; } + public long __minus (long that) { return value - that; } + public long __times (long that) { return value * that; } + public long __div (long that) { return value / that; } + public long __percent (long that) { return value % that; } + public long __bar (long that) { return value | that; } + public long __amp (long that) { return value & that; } + public long __up (long that) { return value ^ that; } + + [Meta("method []scala.Long;")] + public long coerce (long dummy) { return value ; } + + public bool __eq__eq (int that) { return value == that; } + public bool __bang__eq (int that) { return value != that; } + public bool __less (int that) { return value < that; } + public bool __greater (int that) { return value > that; } + public bool __less__eq (int that) { return value <= that; } + public bool __greater__eq(int that) { return value >= that; } + public int __plus (int that) { return value + that; } + public int __minus (int that) { return value - that; } + public int __times (int that) { return value * that; } + public int __div (int that) { return value / that; } + public int __percent (int that) { return value % that; } + public int __bar (int that) { return value | that; } + public int __amp (int that) { return value & that; } + public int __up (int that) { return value ^ that; } + + [Meta("method []scala.Int;")] + public int coerce (int dummy) { return value ; } + + } +}
\ No newline at end of file diff --git a/sources/scala/Unit.cs b/sources/scala/Unit.cs new file mode 100644 index 0000000000..0acb8db74b --- /dev/null +++ b/sources/scala/Unit.cs @@ -0,0 +1,45 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +using System; +using scala.runtime; + +namespace scala +{ + + public abstract class Unit : AnyVal { + + public void value() {} + + public Unit() {} + + public override bool Equals(object other) + { + return other is Unit; + } + public override int GetHashCode() + { + int bits = 4041; + return bits; + } + public override string ToString() + { + return "()"; + } + + [Meta("method (scala.Any)scala.Boolean;")] + public bool __eq__eq (object other) { return Equals(other); } + [Meta("method (scala.Any)scala.Boolean;")] + public bool __bang__eq(object other) { return !Equals(other); } + + public string __plus (string that) { return this + that; } + + } +}
\ No newline at end of file diff --git a/sources/scala/runtime/RunTime.cs b/sources/scala/runtime/RunTime.cs new file mode 100644 index 0000000000..eadb95bacf --- /dev/null +++ b/sources/scala/runtime/RunTime.cs @@ -0,0 +1,513 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $OldId: RunTime.java,v 1.13 2002/11/19 12:01:40 paltherr Exp $ +// $Id$ + +using System; +using scala; + +namespace scala.runtime +{ + + public abstract class RunTime + { + + //######################################################################## + // Private Constants + + private static readonly int BITS = 8; + private static readonly int ARRAY_SIZE = 2 << BITS; + private static readonly int INDEX_MASK = ARRAY_SIZE - 1; + private static readonly int CHECK_MASK = ~(ARRAY_SIZE / 2 - 1); + + private static readonly UValue uvalue = new UValue(); + private static readonly ZValue zvalue_f = new ZValue(false); + private static readonly ZValue zvalue_t = new ZValue(true); + private static readonly BValue[] bvalue = new BValue[256]; + private static readonly SValue[] svalue = new SValue[ARRAY_SIZE]; + private static readonly CValue[] cvalue = new CValue[ARRAY_SIZE / 2]; + private static readonly IValue[] ivalue = new IValue[ARRAY_SIZE]; + private static readonly LValue[] lvalue = new LValue[ARRAY_SIZE]; + + static RunTime() + { + for (int i = 0; i < bvalue.Length; i++) + bvalue[i] = new BValue((sbyte)i); + for (int i = 0; i < ARRAY_SIZE / 2; i++) + { + svalue[i] = new SValue((short)i); + cvalue[i] = new CValue((char )i); + ivalue[i] = new IValue((int )i); + lvalue[i] = new LValue((long )i); + svalue[i + ARRAY_SIZE / 2] = new SValue((short)(CHECK_MASK | i)); + ivalue[i + ARRAY_SIZE / 2] = new IValue((int )(CHECK_MASK | i)); + lvalue[i + ARRAY_SIZE / 2] = new LValue((long )(CHECK_MASK | i)); + } + } + + //######################################################################## + // Private Variables + + //private static ClassLoader loader = ClassLoader.getSystemClassLoader(); + + //######################################################################## + // Public Functions - Getting & setting class loader + +// public static ClassLoader getClassLoader() +// { +// return loader; +// } +// +// public static void setClassLoader(ClassLoader loader) +// { +// RunTime.loader = loader; +// } + + //######################################################################## + // Public Functions - Catching exceptions + public interface Runnable { + void run(); + } + + public static Exception tryCatch(Runnable runnable) + { + try + { + runnable.run(); + return null; + } + catch (Exception exception) + { + return exception; + } + } + + //######################################################################## + // Public Functions - Boxing primitives + + public static Unit box_uvalue( ) + { + return uvalue; + } + + public static Boolean box_zvalue(bool x) + { + return x ? zvalue_t : zvalue_f; + } + + public static Byte box_bvalue(sbyte x) + { + return bvalue[x & 0x000000FF]; + } + + public static Short box_svalue(short x) + { + int c = x & CHECK_MASK; + if (c == 0 || c == CHECK_MASK) return svalue[x & INDEX_MASK]; + return new SValue(x); + } + + public static Char box_cvalue(char x) + { + int c = (int)x & CHECK_MASK; + if (c == 0) return cvalue[(int)x & INDEX_MASK]; + return new CValue(x); + } + + public static Int box_ivalue(int x) + { + int c = x & CHECK_MASK; + if (c == 0 || c == CHECK_MASK) return ivalue[x & INDEX_MASK]; + return new IValue(x); + } + + public static Long box_lvalue(long x) + { + long c = x & CHECK_MASK; + if (c == 0 || c == CHECK_MASK) return lvalue[(int)x & INDEX_MASK]; + return new LValue(x); + } + + public static Float box_fvalue(float x) + { + return new FValue(x); + } + + public static Double box_dvalue(double x) + { + return new DValue(x); + } + + /** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/ + public static Array box_zarray(bool[] xs) + { + return new ZArray(xs); + } + + /** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */ + public static Array box_barray(sbyte [] xs) + { + return new BArray(xs); + } + + /** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */ + public static Array box_sarray(short [] xs) + { + return new SArray(xs); + } + + /** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */ + public static Array box_carray(char [] xs) + { + return new CArray(xs); + } + + /** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */ + public static Array box_iarray(int [] xs) + { + return new IArray(xs); + } + + /** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */ + public static Array box_larray(long [] xs) + { + return new LArray(xs); + } + + /** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */ + public static Array box_farray(float [] xs) + { + return new FArray(xs); + } + + /** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */ + public static Array box_darray(double [] xs) + { + return new DArray(xs); + } + + /** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[?T]; */ + public static Array box_oarray(object [] xs) + { + return new OArray(xs); + } + + /** @meta method [?T](scala.Array[?T]) scala.Array[?T]; */ + public static Array box__array(object xs) + { + if (xs == null ) return box_oarray((object [])xs); + if (xs is bool[]) return box_zarray((bool[])xs); + if (xs is sbyte []) return box_barray((sbyte [])xs); + if (xs is short []) return box_sarray((short [])xs); + if (xs is char []) return box_carray((char [])xs); + if (xs is int []) return box_iarray((int [])xs); + if (xs is long []) return box_larray((long [])xs); + if (xs is float []) return box_farray((float [])xs); + if (xs is double []) return box_darray((double [])xs); + if (xs is object []) return box_oarray((object [])xs); + throw new InvalidCastException(xs.GetType() + " is not an array class"); + } + + //######################################################################## + // Public Functions - Unboxing primitives + + public static void unbox_uvalue(Unit x) { x.value(); } + public static bool unbox_zvalue(Boolean x) { return x.value ; } + public static sbyte unbox_bvalue(Byte x) { return x.value ; } + public static short unbox_svalue(Short x) { return x.value ; } + public static char unbox_cvalue(Char x) { return x.value ; } + public static int unbox_ivalue(Int x) { return x.value ; } + public static long unbox_lvalue(Long x) { return x.value ; } + public static float unbox_fvalue(Float x) { return x.value ; } + public static double unbox_dvalue(Double x) { return x.value ; } + + /** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/ + public static bool[] unbox_zarray(Array xs) + { + return xs == null ? null : ((ZArray)xs)._value; + } + /** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */ + public static sbyte [] unbox_barray(Array xs) + { + return xs == null ? null : ((BArray)xs)._value; + } + /** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */ + public static short [] unbox_sarray(Array xs) + { + return xs == null ? null : ((SArray)xs)._value; + } + /** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */ + public static char [] unbox_carray(Array xs) + { + return xs == null ? null : ((CArray)xs)._value; + } + /** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */ + public static int [] unbox_iarray(Array xs) + { + return xs == null ? null : ((IArray)xs)._value; + } + /** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */ + public static long [] unbox_larray(Array xs) + { + return xs == null ? null : ((LArray)xs)._value; + } + /** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */ + public static float [] unbox_farray(Array xs) + { + return xs == null ? null : ((FArray)xs)._value; + } + /** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */ + public static double [] unbox_darray(Array xs) + { + return xs == null ? null : ((DArray)xs)._value; + } + /** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[scala.AnyRef]; */ + public static object [] unbox_oarray(Array xs) + { + return xs == null ? null : ((OArray)xs)._value; + } + /** @meta method [?T](scala.Array[?T]) scala.AnyRef; */ + public static object unbox__array(Array xs) + { + return xs == null ? null : xs.value(); + } + + //######################################################################## + // Public Functions - Conversion primitives + + public static sbyte b2b(sbyte x) { return (sbyte )x; } + public static short b2s(sbyte x) { return (short )x; } + public static char b2c(sbyte x) { return (char )x; } + public static int b2i(sbyte x) { return (int )x; } + public static long b2l(sbyte x) { return (long )x; } + public static float b2f(sbyte x) { return (float )x; } + public static double b2d(sbyte x) { return (double)x; } + public static sbyte s2b(short x) { return (sbyte )x; } + public static short s2s(short x) { return (short )x; } + public static char s2c(short x) { return (char )x; } + public static int s2i(short x) { return (int )x; } + public static long s2l(short x) { return (long )x; } + public static float s2f(short x) { return (float )x; } + public static double s2d(short x) { return (double)x; } + public static sbyte c2b(char x) { return (sbyte )x; } + public static short c2s(char x) { return (short )x; } + public static char c2c(char x) { return (char )x; } + public static int c2i(char x) { return (int )x; } + public static long c2l(char x) { return (long )x; } + public static float c2f(char x) { return (float )x; } + public static double c2d(char x) { return (double)x; } + public static sbyte i2b(int x) { return (sbyte )x; } + public static short i2s(int x) { return (short )x; } + public static char i2c(int x) { return (char )x; } + public static int i2i(int x) { return (int )x; } + public static long i2l(int x) { return (long )x; } + public static float i2f(int x) { return (float )x; } + public static double i2d(int x) { return (double)x; } + public static sbyte l2b(long x) { return (sbyte )x; } + public static short l2s(long x) { return (short )x; } + public static char l2c(long x) { return (char )x; } + public static int l2i(long x) { return (int )x; } + public static long l2l(long x) { return (long )x; } + public static float l2f(long x) { return (float )x; } + public static double l2d(long x) { return (double)x; } + public static sbyte f2b(float x) { return (sbyte )x; } + public static short f2s(float x) { return (short )x; } + public static char f2c(float x) { return (char )x; } + public static int f2i(float x) { return (int )x; } + public static long f2l(float x) { return (long )x; } + public static float f2f(float x) { return (float )x; } + public static double f2d(float x) { return (double)x; } + public static sbyte d2b(double x) { return (sbyte )x; } + public static short d2s(double x) { return (short )x; } + public static char d2c(double x) { return (char )x; } + public static int d2i(double x) { return (int )x; } + public static long d2l(double x) { return (long )x; } + public static float d2f(double x) { return (float )x; } + public static double d2d(double x) { return (double)x; } + + //######################################################################## + // Public Functions - Array primitives + + public static bool[] zarray(int length) { return new bool[length]; } + public static sbyte [] barray(int length) { return new sbyte [length]; } + public static short [] sarray(int length) { return new short [length]; } + public static char [] carray(int length) { return new char [length]; } + public static int [] iarray(int length) { return new int [length]; } + public static long [] larray(int length) { return new long [length]; } + public static float [] farray(int length) { return new float [length]; } + public static double [] darray(int length) { return new double [length]; } + public static object oarray(int length, string classname) + { + try + { + Type clasz = Type.GetType(classname); + return System.Array.CreateInstance(clasz, length); + } + catch (Exception exception) + { + //throw new Error(exception.ToString()); + throw new ApplicationException(exception.ToString()); + } + } + + public static int zarray_length(bool[] xs) { return xs.Length; } + public static int barray_length(sbyte [] xs) { return xs.Length; } + public static int sarray_length(short [] xs) { return xs.Length; } + public static int carray_length(char [] xs) { return xs.Length; } + public static int iarray_length(int [] xs) { return xs.Length; } + public static int larray_length(long [] xs) { return xs.Length; } + public static int farray_length(float [] xs) { return xs.Length; } + public static int darray_length(double [] xs) { return xs.Length; } + public static int oarray_length(object [] xs) { return xs.Length; } + + public static bool zarray_get(bool[] xs, int i) { return xs[i]; } + public static sbyte barray_get(sbyte [] xs, int i) { return xs[i]; } + public static short sarray_get(short [] xs, int i) { return xs[i]; } + public static char carray_get(char [] xs, int i) { return xs[i]; } + public static int iarray_get(int [] xs, int i) { return xs[i]; } + public static long larray_get(long [] xs, int i) { return xs[i]; } + public static float farray_get(float [] xs, int i) { return xs[i]; } + public static double darray_get(double [] xs, int i) { return xs[i]; } + public static object oarray_get(object [] xs, int i) { return xs[i]; } + + public static void zarray_set(bool[] xs, int i, bool x) { xs[i] = x;} + public static void barray_set(sbyte [] xs, int i, sbyte x) { xs[i] = x;} + public static void sarray_set(short [] xs, int i, short x) { xs[i] = x;} + public static void carray_set(char [] xs, int i, char x) { xs[i] = x;} + public static void iarray_set(int [] xs, int i, int x) { xs[i] = x;} + public static void larray_set(long [] xs, int i, long x) { xs[i] = x;} + public static void farray_set(float [] xs, int i, float x) { xs[i] = x;} + public static void darray_set(double [] xs, int i, double x) { xs[i] = x;} + public static void oarray_set(object [] xs, int i, object x) { xs[i] = x;} + + //######################################################################## + } + + // These classes may not be defined in class RunTime because inner + // classes confuse pico which then attributes the metadata to the + // wrong members. + + sealed class UValue : Unit { public UValue( ) : base( ) { } } + sealed class ZValue : Boolean { public ZValue(bool x ) : base(x) { } } + sealed class BValue : Byte { public BValue(sbyte x) : base(x) { } } + sealed class SValue : Short { public SValue(short x) : base(x) { } } + sealed class CValue : Char { public CValue(char x) : base(x) { } } + sealed class IValue : Int { public IValue(int x) : base(x) { } } + sealed class LValue : Long { public LValue(long x) : base(x) { } } + sealed class FValue : Float { public FValue(float x) : base(x) { } } + sealed class DValue : Double { public DValue(double x) : base(x) { } } + + /** @meta class extends scala.Array[scala.Boolean]; */ + sealed class ZArray : Array + { + internal readonly bool[] _value; + public ZArray(bool[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_zvalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Boolean)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class extends scala.Array[scala.Byte];")] + sealed class BArray : Array + { + internal readonly sbyte[] _value; + public BArray(sbyte[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_bvalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Byte)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class extends scala.Array[scala.Short];")] + sealed class SArray : Array + { + internal readonly short[] _value; + public SArray(short[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_svalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Short)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class extends scala.Array[scala.Char];")] + sealed class CArray : Array + { + internal readonly char[] _value; + public CArray(char[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_cvalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Char)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return ((object)_value).ToString(); } + } + + [Meta("class extends scala.Array[scala.Int];")] + sealed class IArray : Array + { + internal readonly int[] _value; + public IArray(int[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_ivalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Int)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class extends scala.Array[scala.Long];")] + sealed class LArray : Array + { + internal readonly long[] _value; + public LArray(long[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_lvalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Long)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class extends scala.Array[scala.Float];")] + sealed class FArray : Array + { + internal readonly float[] _value; + public FArray(float[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_fvalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Float)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class extends scala.Array[scala.Double];")] + sealed class DArray : Array + { + internal readonly double[] _value; + public DArray(double[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return RunTime.box_dvalue(_value[i]); } + public override void update(int i, object x) { _value[i] = ((Double)x).value; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } + + [Meta("class [?T < scala.AnyRef] extends scala.Array[?T];")] + sealed class OArray : Array + { + internal readonly object[] _value; + public OArray(object[] _value) { this._value = _value; } + public override object value() { return _value; } + public override object apply(int i) { return _value[i]; } + public override void update(int i, object x) { _value[i] = x; } + public override int length() { return _value.Length; } + public override string ToString() { return _value.ToString(); } + } +}
\ No newline at end of file |