Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When casting to an int, use Math.floor() in order to simulate the imp…

…licit conversion that would happen in .NET
  • Loading branch information...
commit 4797344316e6aca1df9202b5e90539213bf81d97 1 parent ab1e4c5
@flaub authored
Showing with 1,689 additions and 476 deletions.
  1. +0 −5 src/DotWeb.Decompiler/CodeModel/Member/CodeMethodMember.cs
  2. +52 −0 src/DotWeb.Decompiler/CodeModel/Member/CodeTypeInitializer.cs
  3. +39 −6 src/DotWeb.Decompiler/CodeTypeEvaluator.cs
  4. +4 −0 src/DotWeb.Decompiler/Core/Interpreter.cs
  5. +1 −0  src/DotWeb.Decompiler/DotWeb.Decompiler.csproj
  6. +34 −15 src/DotWeb.Decompiler/MethodDecompiler.cs
  7. +39 −19 src/DotWeb.System/Array.cs
  8. +223 −2 src/DotWeb.System/Collections/Generic/Dictionary.cs
  9. +0 −257 src/DotWeb.System/Collections/Hashtable.cs
  10. +3 −0  src/DotWeb.System/Console.cs
  11. +0 −1  src/DotWeb.System/DotWeb.System.csproj
  12. +40 −17 src/DotWeb.System/Exception.cs
  13. +0 −1  src/DotWeb.System/Hosted-DotWeb.System.csproj
  14. +42 −0 src/DotWeb.Translator/Generator/JavaScript/JsCodeGenerator.cs
  15. +17 −11 src/DotWeb.Translator/Generator/JavaScript/JsPrinter.cs
  16. +7 −0 src/DotWeb.Translator/TranslationContext.cs
  17. +3 −2 src/DotWeb.Utility/Cecil/TypeDefinitionCache.cs
  18. +1 −1  test/DotWeb.Functional.Test/Client/ArrayTest.cs
  19. +8 −8 test/DotWeb.Functional.Test/Client/{HashtableTest.cs → DictionaryTest.cs}
  20. +2 −2 test/DotWeb.Functional.Test/Client/DotWeb.Functional.Test.Client.csproj
  21. +21 −21 test/DotWeb.Functional.Test/Client/{List.cs → ListTest.cs}
  22. +6 −6 test/DotWeb.Functional.Test/Client/StringBuilderTest.cs
  23. +26 −26 test/DotWeb.Functional.Test/Client/StringTest.cs
  24. +4 −2 test/DotWeb.Functional.Test/Client/TestResultView.cs
  25. +2 −2 test/DotWeb.Functional.Test/Server/App_Data/TestDirectory.txt
  26. +1 −0  test/DotWeb.Translator.Test/DotWeb.Translator.Test.csproj
  27. +2 −2 test/DotWeb.Translator.Test/Expected/DecorationTest/TestJsIntrinsic.js
  28. +451 −2 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ArgumentException.js
  29. +4 −0 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/CallDerived.js
  30. +5 −5 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/Callback.js
  31. +12 −12 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ExpectExceptionTest.js
  32. +451 −2 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/ArgumentException.js
  33. +4 −0 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/CallDerived.js
  34. +5 −5 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/Callback.js
  35. +12 −12 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/ExpectExceptionTest.js
  36. +45 −8 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/StringFormat.js
  37. +29 −0 test/DotWeb.Translator.Test/Expected/SystemTest/TestCastPrimitive.js
  38. +12 −12 test/DotWeb.Translator.Test/Expected/SystemTest/TestListEnumerator.js
  39. +16 −12 test/DotWeb.Translator.Test/Expected/SystemTest/TestString.js
  40. +26 −0 test/DotWeb.Translator.Test/Resources/SystemTestData.Designer.cs
  41. +3 −0  test/DotWeb.Translator.Test/Resources/SystemTestData.resx
  42. +34 −0 test/DotWeb.Translator.Test/Script/SystemTest.cs
  43. +3 −0  test/DotWeb.Translator.Test/SystemTest.cs
View
5 src/DotWeb.Decompiler/CodeModel/Member/CodeMethodMember.cs
@@ -59,10 +59,5 @@ public CodeMethodMember(MethodDefinition method)
public List<CodeParameterDeclarationExpression> Parameters { get; set; }
public HashSet<MethodReference> ExternalMethods { get; set; }
public string NativeCode { get; set; }
-
- /// <summary>
- /// Used for debugging purposes
- /// </summary>
- //public IEnumerable<Instruction> Instructions { get; set; }
}
}
View
52 src/DotWeb.Decompiler/CodeModel/Member/CodeTypeInitializer.cs
@@ -0,0 +1,52 @@
+// Copyright 2010, Frank Laub
+//
+// This file is part of DotWeb.
+//
+// DotWeb is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// DotWeb is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with DotWeb. If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+using DotWeb.Decompiler.Core;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+
+namespace DotWeb.Decompiler.CodeModel
+{
+ public class CodeTypeInitializer : CodeMethodMember
+ {
+ public CodeTypeInitializer(CodeMethodMember method) {
+ this.Definition = method.Definition;
+ this.Statements = method.Statements;
+ this.Parameters = method.Parameters;
+ this.ExternalMethods = method.ExternalMethods;
+ this.NativeCode = method.NativeCode;
+ this.DefaultStaticFields = new List<FieldDefinition>();
+ }
+
+ #region Visitor Pattern
+ public override void Accept<V>(V visitor) {
+ ((ICodeVisitor<CodeTypeInitializer>)visitor).Visit(this);
+ }
+
+ public override R Accept<V, R>(V visitor) {
+ return ((ICodeVisitor<CodeTypeInitializer, R>)visitor).VisitReturn(this);
+ }
+ #endregion
+
+ public List<FieldDefinition> DefaultStaticFields { get; set; }
+ }
+}
View
45 src/DotWeb.Decompiler/CodeTypeEvaluator.cs
@@ -59,24 +59,57 @@ public class CodeTypeEvaluator : ICodeExpressionVisitor<TypeReference>
case CodeBinaryOperator.LessThanOrEqual:
case CodeBinaryOperator.ValueEquality:
return this.typeSystem.TypeDefinitionCache.Boolean;
- case CodeBinaryOperator.Add:
case CodeBinaryOperator.BitwiseAnd:
case CodeBinaryOperator.BitwiseOr:
- case CodeBinaryOperator.Divide:
case CodeBinaryOperator.ExclusiveOr:
case CodeBinaryOperator.LeftShift:
case CodeBinaryOperator.Modulus:
- case CodeBinaryOperator.Multiply:
case CodeBinaryOperator.RightShift:
- case CodeBinaryOperator.Subtract:
case CodeBinaryOperator.UnsignedRightShift:
- // FIXME: find 'highest' type of each side
return Evaluate(obj.Left);
+ case CodeBinaryOperator.Add:
+ case CodeBinaryOperator.Subtract:
+ case CodeBinaryOperator.Multiply:
+ case CodeBinaryOperator.Divide:
+ return SelectType(obj.Left, obj.Right);
default:
throw new NotSupportedException();
}
}
+ private int GetTypeScore(TypeReference type) {
+ switch (type.FullName) {
+ case Constants.Byte:
+ case Constants.SByte:
+ case Constants.Char:
+ return 1;
+ case Constants.Int16:
+ case Constants.UInt16:
+ return 2;
+ case Constants.Int32:
+ case Constants.UInt32:
+ return 3;
+ case Constants.Int64:
+ case Constants.UInt64:
+ return 4;
+ case Constants.Single:
+ return 5;
+ case Constants.Double:
+ return 6;
+ }
+ return 0;
+ }
+
+ private TypeReference SelectType(CodeExpression lhs, CodeExpression rhs) {
+ var lhsType = Evaluate(lhs);
+ var rhsType = Evaluate(rhs);
+
+ int lhsScore = GetTypeScore(lhsType);
+ int rhsScore = GetTypeScore(rhsType);
+
+ return lhsScore > rhsScore ? lhsType : rhsType;
+ }
+
public TypeReference VisitReturn(CodeCastExpression obj) {
return obj.TargetType;
}
@@ -124,7 +157,7 @@ public class CodeTypeEvaluator : ICodeExpressionVisitor<TypeReference>
}
public TypeReference VisitReturn(CodeLengthReference obj) {
- throw new NotSupportedException();
+ return this.typeSystem.TypeDefinitionCache.Int32;
}
public TypeReference VisitReturn(CodeMethodReference obj) {
View
4 src/DotWeb.Decompiler/Core/Interpreter.cs
@@ -38,9 +38,11 @@ public class Interpreter
private CodeTypeEvaluator typeEvaluator;
public HashSet<MethodReference> ExternalMethods { get; private set; }
+ public HashSet<FieldDefinition> StaticFieldsSet { get; private set; }
public Interpreter(TypeSystem typeSystem, MethodDefinition method) {
this.ExternalMethods = new HashSet<MethodReference>();
+ this.StaticFieldsSet = new HashSet<FieldDefinition>();
this.typeSystem = typeSystem;
this.method = method;
this.typeEvaluator = new CodeTypeEvaluator(this.typeSystem, this.method);
@@ -773,6 +775,8 @@ public class Interpreter
var typeRef = new CodeTypeReference(field.DeclaringType);
var lhs = new CodeFieldReference(typeRef, field);
AddAssignment(lhs, rhs);
+
+ this.StaticFieldsSet.Add(field.Resolve());
}
private void BinaryExpression(Instruction il, CodeBinaryOperator op) {
View
1  src/DotWeb.Decompiler/DotWeb.Decompiler.csproj
@@ -85,6 +85,7 @@
<Compile Include="CodeModel\Member\CodePropertySetterMember.cs" />
<Compile Include="CodeModel\Member\CodeTypeDeclaration.cs" />
<Compile Include="CodeModel\Member\CodeTypeMember.cs" />
+ <Compile Include="CodeModel\Member\CodeTypeInitializer.cs" />
<Compile Include="CodeModel\Member\ICodeMemberVisitor.cs" />
<Compile Include="CodeModel\Statement\CodeAssignStatement.cs" />
<Compile Include="CodeModel\Statement\CodeCommentStatement.cs" />
View
49 src/DotWeb.Decompiler/MethodDecompiler.cs
@@ -28,6 +28,40 @@ namespace DotWeb.Decompiler
public static class MethodDecompiler
{
public static CodeMethodMember Parse(TypeSystem typeSystem, MethodDefinition method) {
+ var interpreter = new Interpreter(typeSystem, method);
+ var ret = ParseMethod(method, typeSystem, interpreter);
+ var ap = method.GetMonoAssociatedProperty();
+ if (ap != null) {
+ if (ap.IsGetter) {
+ return new CodePropertyGetterMember(ret) {
+ Property = ap.Definition
+ };
+ }
+
+ return new CodePropertySetterMember(ret) {
+ Property = ap.Definition
+ };
+ }
+ return ret;
+ }
+
+ public static CodeTypeInitializer ParseStaticConstructor(TypeSystem typeSystem, MethodDefinition method) {
+ var interpreter = new Interpreter(typeSystem, method);
+ var methodMember = ParseMethod(method, typeSystem, interpreter);
+ var typeInitializer = new CodeTypeInitializer(methodMember);
+
+ var type = method.DeclaringType;
+ foreach (FieldDefinition field in type.Fields) {
+ if (field.IsStatic && !interpreter.StaticFieldsSet.Contains(field)) {
+ // create default initializer
+ typeInitializer.DefaultStaticFields.Add(field);
+ }
+ }
+
+ return typeInitializer;
+ }
+
+ private static CodeMethodMember ParseMethod(MethodDefinition method, TypeSystem typeSystem, Interpreter interpreter) {
#if DEBUG
Console.WriteLine(method);
#endif
@@ -41,7 +75,6 @@ public static class MethodDecompiler
graph.SortByDepthFirstPostOrder();
- var interpreter = new Interpreter(typeSystem, method);
foreach (BasicBlock block in graph.Nodes) {
interpreter.ProcessBlock(block);
}
@@ -55,20 +88,6 @@ public static class MethodDecompiler
var generator = new StatementsGenerator(method, graph);
var ret = generator.WriteMethodBody();
ret.ExternalMethods = interpreter.ExternalMethods;
-
- var ap = method.GetMonoAssociatedProperty();
- if (ap != null) {
- if (ap.IsGetter) {
- return new CodePropertyGetterMember(ret) {
- Property = ap.Definition
- };
- }
-
- return new CodePropertySetterMember(ret) {
- Property = ap.Definition
- };
- }
-
return ret;
}
}
View
58 src/DotWeb.System/Array.cs
@@ -36,25 +36,45 @@ public class Array : JsObject
public extern object this[int index] { get; set; }
#if !HOSTED_MODE
- ///// <summary>
- ///// Copies a range of elements from an Array starting at the specified source index and
- ///// pastes them to another Array starting at the specified destination index.
- ///// The length and the indexes are specified as 32-bit integers.
- ///// </summary>
- ///// <param name="sourceArray">The Array that contains the data to copy.</param>
- ///// <param name="sourceIndex">A 32-bit integer that represents the index in the sourceArray at which copying begins.</param>
- ///// <param name="destinationArray">The Array that receives the data.</param>
- ///// <param name="destinationIndex">A 32-bit integer that represents the index in the destinationArray at which storing begins.</param>
- ///// <param name="length">A 32-bit integer that represents the number of elements to copy.</param>
- //public static void Copy(
- // global::System.Array sourceArray,
- // int sourceIndex,
- // global::System.Array destinationArray,
- // int destinationIndex,
- // int length) {
- // var jsSource = new JsArray(sourceArray);
- // var jsDest = new JsArray(destinationArray);
- //}
+ /// <summary>
+ /// Copies a range of elements from an Array starting at the specified source index and
+ /// pastes them to another Array starting at the specified destination index.
+ /// The length and the indexes are specified as 32-bit integers.
+ /// </summary>
+ /// <param name="sourceArray">The Array that contains the data to copy.</param>
+ /// <param name="sourceIndex">A 32-bit integer that represents the index in the sourceArray at which copying begins.</param>
+ /// <param name="destinationArray">The Array that receives the data.</param>
+ /// <param name="destinationIndex">A 32-bit integer that represents the index in the destinationArray at which storing begins.</param>
+ /// <param name="length">A 32-bit integer that represents the number of elements to copy.</param>
+ public static void Copy(
+ global::System.Array sourceArray,
+ int sourceIndex,
+ global::System.Array destinationArray,
+ int destinationIndex,
+ int length) {
+
+ if (sourceArray == null)
+ throw new ArgumentNullException("sourceArray");
+
+ if (destinationArray == null)
+ throw new ArgumentNullException("destinationArray");
+
+ if (length < 0)
+ throw new ArgumentOutOfRangeException("length", "Value has to be >= 0.");
+
+ if (sourceIndex < 0)
+ throw new ArgumentOutOfRangeException("sourceIndex", "Value has to be >= 0.");
+
+ if (destinationIndex < 0)
+ throw new ArgumentOutOfRangeException("destinationIndex", "Value has to be >= 0.");
+
+ var jsSource = new JsArray(sourceArray);
+ var jsTarget = new JsArray(destinationArray);
+
+ for (int i = 0; i < length; i++) {
+ jsTarget[destinationIndex + i] = jsSource[sourceIndex + i];
+ }
+ }
#endif
}
}
View
225 src/DotWeb.System/Collections/Generic/Dictionary.cs
@@ -17,42 +17,142 @@
//
using SysArray = System.Array;
+using StringBuilder = System.Text.StringBuilder;
#if HOSTED_MODE
+using DotWeb.System.DotWeb;
namespace DotWeb.System.Collections.Generic
#else
+using System.DotWeb;
namespace System.Collections.Generic
#endif
{
+ [JsAnonymous]
+ internal struct Link
+ {
+ public int HashCode;
+ public int Next;
+ }
+
public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary
{
#region Fields
- IEqualityComparer<TKey> hcp;
+ const int INITIAL_SIZE = 10;
+ const float DEFAULT_LOAD_FACTOR = (90f / 100);
+ const int NO_SLOT = -1;
+ const int HASH_FLAG = -2147483648;
+
+ private int[] table;
+ private Link[] linkSlots;
+ private TKey[] keySlots;
+ private TValue[] valueSlots;
+ private int touchedSlots;
+ private int emptySlot;
+ private int count;
+ private int threshold;
+ private IEqualityComparer<TKey> hcp;
+ private int generation;
+
+ private static readonly int[] primeTable = {
+ 11,
+ 19,
+ 37,
+ 73,
+ 109,
+ 163,
+ 251,
+ 367,
+ 557,
+ 823,
+ 1237,
+ 1861,
+ 2777,
+ 4177,
+ 6247,
+ 9371,
+ 14057,
+ 21089,
+ 31627,
+ 47431,
+ 71143,
+ 106721,
+ 160073,
+ 240101,
+ 360163,
+ 540217,
+ 810343,
+ 1215497,
+ 1823231,
+ 2734867,
+ 4102283,
+ 6153409,
+ 9230113,
+ 13845163
+ };
#endregion
#region Construction
public Dictionary() {
+ Init(INITIAL_SIZE, null);
}
public Dictionary(IEqualityComparer<TKey> comparer) {
+ Init(INITIAL_SIZE, comparer);
}
- public Dictionary(IDictionary<TKey, TValue> dictionary) {
+ public Dictionary(IDictionary<TKey, TValue> dictionary)
+ : this(dictionary, null) {
}
public Dictionary(int capacity) {
+ Init(capacity, null);
}
public Dictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer) {
+ if (dictionary == null)
+ throw new ArgumentNullException("dictionary");
+
+ int capacity = dictionary.Count;
+ Init(capacity, comparer);
+ foreach (KeyValuePair<TKey, TValue> entry in dictionary) {
+ this.Add(entry.Key, entry.Value);
+ }
}
public Dictionary(int capacity, IEqualityComparer<TKey> comparer) {
+ Init(capacity, comparer);
}
private void Init(int capacity, IEqualityComparer<TKey> hcp) {
if (capacity < 0)
throw new ArgumentOutOfRangeException("capacity");
+
this.hcp = (hcp != null) ? hcp : EqualityComparer<TKey>.Default;
+ if (capacity == 0)
+ capacity = INITIAL_SIZE;
+
+ // Modify capacity so 'capacity' elements can be added without resizing
+ capacity = (int)(capacity / DEFAULT_LOAD_FACTOR) + 1;
+
+ InitArrays(capacity);
+ generation = 0;
+ }
+
+ private void InitArrays(int size) {
+ JsDebug.Log("InitArrays: " + size);
+ table = new int[size];
+
+ linkSlots = new Link[size];
+ emptySlot = NO_SLOT;
+
+ keySlots = new TKey[size];
+ valueSlots = new TValue[size];
+ touchedSlots = 0;
+
+ threshold = (int)(table.Length * DEFAULT_LOAD_FACTOR);
+ if (threshold == 0 && table.Length > 0)
+ threshold = 1;
+ JsDebug.Log("threshold: " + threshold);
}
#endregion
@@ -197,5 +297,126 @@ public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary
}
#endregion
+
+ #region Overrides
+ public override string ToString() {
+ var result = new StringBuilder();
+ result.Append("{");
+ result.Append("}");
+ return result.ToString();
+ }
+ #endregion
+
+ #region Impl
+ internal static bool TestPrime(int x) {
+ if ((x & 1) != 0) {
+ int top = (int)Math.Sqrt(x);
+
+ for (int n = 3; n < top; n += 2) {
+ if ((x % n) == 0)
+ return false;
+ }
+ return true;
+ }
+ // There is only one even prime - 2.
+ return (x == 2);
+ }
+
+ internal static int CalcPrime(int x) {
+ for (int i = (x & (~1)) - 1; i < Int32.MaxValue; i += 2) {
+ if (TestPrime(i)) return i;
+ }
+ return x;
+ }
+
+ internal static int ToPrime(int x) {
+ for (int i = 0; i < primeTable.Length; i++) {
+ if (x <= primeTable[i]) {
+ return primeTable[i];
+ }
+ }
+ return CalcPrime(x);
+ }
+
+ private void PutImpl(TKey key, TValue value) {
+ if (key == null)
+ throw new ArgumentNullException("key");
+
+ // get first item of linked list corresponding to given key
+ int hashCode = hcp.GetHashCode(key) | HASH_FLAG;
+ int index = (hashCode & int.MaxValue) % table.Length;
+ int cur = table[index] - 1;
+
+ // walk linked list until end is reached (throw an exception if a
+ // existing slot is found having an equivalent key)
+ while (cur != NO_SLOT) {
+ // The ordering is important for compatibility with MS and strange
+ // Object.Equals () implementations
+ if (linkSlots[cur].HashCode == hashCode && hcp.Equals(keySlots[cur], key))
+ throw new ArgumentException("An element with the same key already exists in the dictionary.");
+ cur = linkSlots[cur].Next;
+ }
+
+ if (++count > threshold) {
+ Resize();
+ index = (hashCode & int.MaxValue) % table.Length;
+ }
+
+ // find an empty slot
+ cur = emptySlot;
+ if (cur == NO_SLOT)
+ cur = touchedSlots++;
+ else
+ emptySlot = linkSlots[cur].Next;
+
+ // store the hash code of the added item,
+ // prepend the added item to its linked list,
+ // update the hash table
+ linkSlots[cur].HashCode = hashCode;
+ linkSlots[cur].Next = table[index] - 1;
+ table[index] = cur + 1;
+
+ // store item's data
+ keySlots[cur] = key;
+ valueSlots[cur] = value;
+
+ generation++;
+ }
+
+ private void Resize() {
+ // From the SDK docs:
+ // Hashtable is automatically increased
+ // to the smallest prime number that is larger
+ // than twice the current number of Hashtable buckets
+ int newSize = ToPrime((table.Length << 1) | 1);
+
+ // allocate new hash table and link slots array
+ int[] newTable = new int[newSize];
+ Link[] newLinkSlots = new Link[newSize];
+
+ for (int i = 0; i < table.Length; i++) {
+ int cur = table[i] - 1;
+ while (cur != NO_SLOT) {
+ int hashCode = newLinkSlots[cur].HashCode = hcp.GetHashCode(keySlots[cur]) | HASH_FLAG;
+ int index = (hashCode & int.MaxValue) % newSize;
+ newLinkSlots[cur].Next = newTable[index] - 1;
+ newTable[index] = cur + 1;
+ cur = linkSlots[cur].Next;
+ }
+ }
+ table = newTable;
+ linkSlots = newLinkSlots;
+
+ // allocate new data slots, copy data
+ TKey[] newKeySlots = new TKey[newSize];
+ TValue[] newValueSlots = new TValue[newSize];
+ SysArray.Copy(keySlots, 0, newKeySlots, 0, touchedSlots);
+ SysArray.Copy(valueSlots, 0, newValueSlots, 0, touchedSlots);
+ keySlots = newKeySlots;
+ valueSlots = newValueSlots;
+
+ threshold = (int)(newSize * DEFAULT_LOAD_FACTOR);
+ }
+ #endregion
}
}
View
257 src/DotWeb.System/Collections/Hashtable.cs
@@ -1,257 +0,0 @@
-// Copyright 2010, Frank Laub
-//
-// This file is part of DotWeb.
-//
-// DotWeb is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// DotWeb is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with DotWeb. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#if HOSTED_MODE
-using DotWeb.System.DotWeb;
-namespace DotWeb.System.Collections
-#else
-using System.DotWeb;
-namespace System.Collections
-#endif
-{
- public class Hashtable : IDictionary, ICloneable
- {
- #region Slot
- [JsAnonymous]
- internal struct Slot
- {
- internal object key;
- internal object value;
- }
- #endregion
-
- #region Fields
- private float loadFactor;
- private Slot[] table;
- private int threshold;
- private IEqualityComparer hcp;
-
- private static readonly int[] primeTable = {
- 11,
- 19,
- 37,
- 73,
- 109,
- 163,
- 251,
- 367,
- 557,
- 823,
- 1237,
- 1861,
- 2777,
- 4177,
- 6247,
- 9371,
- 14057,
- 21089,
- 31627,
- 47431,
- 71143,
- 106721,
- 160073,
- 240101,
- 360163,
- 540217,
- 810343,
- 1215497,
- 1823231,
- 2734867,
- 4102283,
- 6153409,
- 9230113,
- 13845163
- };
- #endregion
-
- #region Construction
- public Hashtable()
- : this(0, 1.0f, null) {
- }
-
- public Hashtable(int capacity, float loadFactor)
- : this(capacity, loadFactor, null) {
- }
-
- public Hashtable(int capacity)
- : this(capacity, 1.0f, null) {
- }
-
- public Hashtable(IEqualityComparer equalityComparer)
- : this(1, 1.0f, equalityComparer) {
- }
-
- public Hashtable(int capacity, float loadFactor, IEqualityComparer equalityComparer) {
- if (capacity < 0)
- throw new ArgumentOutOfRangeException("capacity", "negative capacity");
-
- if (loadFactor < 0.1f || loadFactor > 1.0f)// || Single.IsNaN(loadFactor))
- throw new ArgumentOutOfRangeException("loadFactor", "load factor");
-
- this.hcp = equalityComparer;
- if (capacity == 0) ++capacity;
- this.loadFactor = 0.75f * loadFactor;
- double tableSize = capacity / this.loadFactor;
- //if (tableSize > Int32.MaxValue)
- // throw new ArgumentException("Size is too big");
- int size = (int)tableSize;
- size = ToPrime(size);
- this.hcp = equalityComparer;
- }
-
- public Hashtable(IDictionary dict)
- : this(dict, 1.0f, null) {
- }
-
- public Hashtable(IDictionary dict, IEqualityComparer equalityComparer)
- : this(dict, 1.0f, equalityComparer) {
- }
-
- public Hashtable(IDictionary dict, float loadFactor)
- : this(dict, loadFactor, null) {
- }
-
- public Hashtable(IDictionary dict, float loadFactor, IEqualityComparer equalityComparer)
- : this(dict != null ? dict.Count : 0, loadFactor, equalityComparer) {
- if (dict == null)
- throw new ArgumentNullException("dictionary");
-
- var it = dict.GetEnumerator();
- while (it.MoveNext()) {
- Add(it.Key, it.Value);
- }
- }
- #endregion
-
- #region IDictionary Members
-
- public bool IsFixedSize {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsReadOnly {
- get { throw new NotImplementedException(); }
- }
-
- public object this[object key] {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
- }
-
- public ICollection Keys {
- get { throw new NotImplementedException(); }
- }
-
- public ICollection Values {
- get { throw new NotImplementedException(); }
- }
-
- public void Add(object key, object value) {
- throw new NotImplementedException();
- }
-
- public void Clear() {
- throw new NotImplementedException();
- }
-
- public bool Contains(object key) {
- throw new NotImplementedException();
- }
-
- public IDictionaryEnumerator GetEnumerator() {
- throw new NotImplementedException();
- }
-
- public void Remove(object key) {
- throw new NotImplementedException();
- }
-
- #endregion
-
- #region ICollection Members
-
- public void CopyTo(global::System.Array array, int index) {
- throw new NotImplementedException();
- }
-
- public int Count {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsSynchronized {
- get { throw new NotImplementedException(); }
- }
-
- public object SyncRoot {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
-
- #region IEnumerable Members
-
- IEnumerator IEnumerable.GetEnumerator() {
- throw new NotImplementedException();
- }
-
- #endregion
-
- #region ICloneable Members
-
- public object Clone() {
- throw new NotImplementedException();
- }
-
- #endregion
-
- #region Impl
- internal static bool TestPrime(int x) {
- if ((x & 1) != 0) {
- int top = (int)Math.Sqrt(x);
-
- for (int n = 3; n < top; n += 2) {
- if ((x % n) == 0)
- return false;
- }
- return true;
- }
- // There is only one even prime - 2.
- return (x == 2);
- }
-
- internal static int CalcPrime(int x) {
- for (int i = (x & (~1)) - 1; i < Int32.MaxValue; i += 2) {
- if (TestPrime(i)) return i;
- }
- return x;
- }
-
- internal static int ToPrime(int x) {
- for (int i = 0; i < primeTable.Length; i++) {
- if (x <= primeTable[i])
- return primeTable[i];
- }
- return CalcPrime(x);
- }
- #endregion
- }
-}
View
3  src/DotWeb.System/Console.cs
@@ -30,6 +30,9 @@ public static class Console
public static extern void Write(int value);
[JsCode("console.log(value);")]
+ public static extern void Write(object value);
+
+ [JsCode("console.log(value);")]
public static extern void WriteLine(object value);
[JsCode("console.log(value);")]
View
1  src/DotWeb.System/DotWeb.System.csproj
@@ -44,7 +44,6 @@
<Compile Include="Array.cs" />
<Compile Include="Attribute.cs" />
<Compile Include="Collections\Generic\HashSet.cs" />
- <Compile Include="Collections\Hashtable.cs" />
<Compile Include="Collections\IDictionary.cs" />
<Compile Include="Collections\Generic\IDictionary.cs" />
<Compile Include="Collections\Generic\Dictionary.cs" />
View
57 src/DotWeb.System/Exception.cs
@@ -20,47 +20,72 @@
#if HOSTED_MODE
using DotWeb.System.DotWeb;
+using DotWeb.System.Text;
namespace DotWeb.System
#else
using System.DotWeb;
+using System.Text;
namespace System
#endif
{
[UseSystem]
public class Exception
{
+ private string message;
+
public Exception() {
}
public Exception(string message) {
Message = message;
}
- // protected Exception(SerializationInfo info, StreamingContext context);
+
public Exception(string message, Exception innerException) {
Message = message;
InnerException = innerException;
}
- // public virtual IDictionary Data { get; }
- // public virtual string HelpLink { get; set; }
- // protected int HResult { get; set; }
public Exception InnerException { get; protected set; }
-
- public virtual string Message { get; protected set; }
public virtual string Source { get; set; }
public virtual string StackTrace { get; protected set; }
- // public MethodBase TargetSite { get; }
- // public virtual Exception GetBaseException();
- // public virtual void GetObjectData(SerializationInfo info, StreamingContext context);
- // public Type GetType();
- // public override string ToString();
+ public virtual string Message {
+ get {
+ if (message == null) {
+ message = string.Format("Exception of type '{0}' was thrown.", this.GetTypeName());
+ }
+ return message;
+ }
+ protected set { this.message = value; }
+ }
+
+#if !HOSTED_MODE
+ public override string ToString() {
+ var result = new StringBuilder();
+ result.Append(this.GetTypeName());
+ result.Append(": ").Append(Message);
+
+ //if (null != _remoteStackTraceString)
+ // result.Append(_remoteStackTraceString);
+
+ if (InnerException != null) {
+ result.Append(" ---> ").Append(InnerException.ToString());
+ //result.Append(Environment.NewLine);
+ result.AppendLine();
+ result.Append(" --- End of inner exception stack trace ---");
+ }
+
+ //if (StackTrace != null)
+ // result.Append(Environment.NewLine).Append(StackTrace);
+ return result.ToString();
+ }
+#endif
}
[UseSystem]
public class SystemException : SysException
{
- public SystemException() : base("System error.") { }
+ public SystemException() : base("A system exception has occurred.") { }
public SystemException(string message) : base(message) { }
public SystemException(string message, SysException innerException) : base(message, innerException) { }
}
@@ -68,7 +93,7 @@ public class SystemException : SysException
[UseSystem]
public class NotImplementedException : SystemException
{
- public NotImplementedException() { }
+ public NotImplementedException() : base("The requested feature is not implemented.") { }
public NotImplementedException(string message) : base(message) { }
public NotImplementedException(string message, SysException inner) : base(message, inner) { }
}
@@ -76,7 +101,7 @@ public class NotImplementedException : SystemException
[UseSystem]
public class NotSupportedException : SystemException
{
- public NotSupportedException() { }
+ public NotSupportedException() : base("Operation is not supported.") { }
public NotSupportedException(string message) : base(message) { }
public NotSupportedException(string message, SysException inner) : base(message, inner) { }
}
@@ -151,9 +176,7 @@ public ArgumentOutOfRangeException(string paramName, object actualValue, string
}
}
- private static string RangeMessage {
- get { return "Specified argument was out of the range of valid values."; }
- }
+ private static string RangeMessage = "Specified argument was out of the range of valid values.";
}
[UseSystem]
View
1  src/DotWeb.System/Hosted-DotWeb.System.csproj
@@ -56,7 +56,6 @@
<Compile Include="Collections\Generic\IEnumerator.cs" />
<Compile Include="Collections\Generic\IList.cs" />
<Compile Include="Collections\Generic\List.cs" />
- <Compile Include="Collections\Hashtable.cs" />
<Compile Include="Collections\ICollection.cs" />
<Compile Include="Collections\IDictionary.cs" />
<Compile Include="Collections\IEnumerable.cs" />
View
42 src/DotWeb.Translator/Generator/JavaScript/JsCodeGenerator.cs
@@ -312,6 +312,48 @@ public class JsCodeGenerator: ICodeStatementVisitor, ICodeMemberVisitor
WriteLine();
}
+ public void WriteStaticConstructor(CodeTypeInitializer method) {
+ this.printer.CurrentMethod = method.Definition;
+ this.currentMethod = method;
+ this.locals.Clear();
+
+ WriteLine("(function() {{");
+ this.writer.Indent++;
+
+ foreach (var field in method.DefaultStaticFields) {
+ var typeRef = new CodeTypeReference(field.DeclaringType);
+ var lhs = new CodeFieldReference(typeRef, field);
+
+ object initialValue = 0;
+ if (field.Constant != null) {
+ initialValue = field.Constant;
+ }
+
+ var targetType = TypeSystem.GetReflectionType(field.FieldType);
+ if (targetType.IsPrimitive) {
+ initialValue = Convert.ChangeType(initialValue, targetType);
+ }
+ else {
+ initialValue = null;
+ }
+ var rhs = new CodePrimitiveExpression(initialValue);
+
+ WriteLine("{0} = {1};", Print(lhs), Print(rhs));
+ }
+
+ if (string.IsNullOrEmpty(method.NativeCode)) {
+ Write(method.Statements);
+ }
+ else {
+ this.writer.WriteLine(method.NativeCode);
+ }
+
+ this.writer.Indent--;
+ WriteLine("}})();");
+
+ WriteLine();
+ }
+
#region Members
public void Visit(CodeTypeDeclaration type) {
try {
View
28 src/DotWeb.Translator/Generator/JavaScript/JsPrinter.cs
@@ -25,6 +25,7 @@
using DotWeb.Decompiler.CodeModel;
using Mono.Cecil;
using DotWeb.Utility.Cecil;
+using DotWeb.Decompiler;
namespace DotWeb.Translator.Generator.JavaScript
{
@@ -263,17 +264,17 @@ class JsPrinter : ICodeExpressionVisitor<string>
}
}
- private int GetFixedArgs(MethodDefinition method) {
- for (int i = 0; i < method.Parameters.Count; i++) {
- var def = method.Parameters[i];
- foreach (CustomAttribute attr in def.CustomAttributes) {
- if (attr.Constructor.DeclaringType.FullName == "System.ParamArrayAttribute") {
- return i;
- }
- }
- }
- return method.Parameters.Count;
- }
+ //private int GetFixedArgs(MethodDefinition method) {
+ // for (int i = 0; i < method.Parameters.Count; i++) {
+ // var def = method.Parameters[i];
+ // foreach (CustomAttribute attr in def.CustomAttributes) {
+ // if (attr.Constructor.DeclaringType.FullName == "System.ParamArrayAttribute") {
+ // return i;
+ // }
+ // }
+ // }
+ // return method.Parameters.Count;
+ //}
private string PrintMacro(string macro, MethodDefinition method, string target, List<CodeExpression> parameters) {
var args = new List<string>();
@@ -422,6 +423,11 @@ class JsPrinter : ICodeExpressionVisitor<string>
public string VisitReturn(CodeCastExpression exp) {
//return string.Format("/*({0})*/{1}", Print(exp.TargetType), Print(exp.Expression));
+ var evaluator = new CodeTypeEvaluator(this.typeSystem, this.CurrentMethod);
+ var type = evaluator.Evaluate(exp.Expression);
+ if (exp.TargetType.FullName == Constants.Int32 && type.FullName != Constants.Int32) {
+ return string.Format("Math.floor({0})", Print(exp.Expression));
+ }
return Print(exp.Expression);
}
View
7 src/DotWeb.Translator/TranslationContext.cs
@@ -102,6 +102,13 @@ public class TranslationContext
}
this.generator.WriteTypeConstructor(type);
+ var staticCtor = type.Constructors.Cast<MethodDefinition>().SingleOrDefault(x => x.IsStatic);
+ if (staticCtor != null) {
+ var staticCtorMethod = MethodDecompiler.ParseStaticConstructor(this.typeSystem, staticCtor);
+ if (staticCtorMethod.Statements.Any() || !string.IsNullOrEmpty(staticCtorMethod.NativeCode)) {
+ this.generator.WriteStaticConstructor(staticCtorMethod);
+ }
+ }
typesCache.Add(type);
}
}
View
5 src/DotWeb.Utility/Cecil/TypeDefinitionCache.cs
@@ -25,7 +25,6 @@ public static class ConstantTypeNames
public const string Delegate = "System.Delegate";
public const string Exception = "System.Exception";
public const string JsObject = "System.DotWeb.JsObject";
- public const string Boolean = "System.Boolean";
}
public class TypeDefinitionCache
@@ -35,7 +34,8 @@ public class TypeDefinitionCache
this.JsObject = typeSystem.GetTypeDefinition(ConstantTypeNames.JsObject);
this.Delegate = typeSystem.GetTypeDefinition(ConstantTypeNames.Delegate);
this.Exception = typeSystem.GetTypeDefinition(ConstantTypeNames.Exception);
- this.Boolean = typeSystem.GetTypeDefinition(ConstantTypeNames.Boolean);
+ this.Boolean = typeSystem.GetTypeDefinition(Constants.Boolean);
+ this.Int32 = typeSystem.GetTypeDefinition(Constants.Int32);
}
public TypeDefinition Object { get; private set; }
@@ -43,6 +43,7 @@ public class TypeDefinitionCache
public TypeDefinition Delegate { get; private set; }
public TypeDefinition Exception { get; private set; }
public TypeDefinition Boolean { get; private set; }
+ public TypeDefinition Int32 { get; private set; }
}
}
View
2  test/DotWeb.Functional.Test/Client/ArrayTest.cs
@@ -25,7 +25,7 @@ class ArrayTest : JsScript
private void RunTest() {
var array = new int[] { 1, 2, 3 };
- this.view.AreEqual("identity", array, array);
+ this.view.AreEqual("identity", array, () => array);
}
}
}
View
16 test/DotWeb.Functional.Test/Client/HashtableTest.cs → test/DotWeb.Functional.Test/Client/DictionaryTest.cs
@@ -1,14 +1,14 @@
using System;
using DotWeb.Client;
-using System.Collections;
+using System.Collections.Generic;
namespace DotWeb.Functional.Test.Client
{
- class HashtableTest : JsScript
+ class DictionaryTest : JsScript
{
private TestResultView view;
- public HashtableTest() {
+ public DictionaryTest() {
var sandbox = Document.getElementById("sandbox");
this.view = new TestResultView(sandbox);
@@ -23,13 +23,13 @@ class HashtableTest : JsScript
}
private void RunTest() {
- var hashtable = new Hashtable();
+ var dict = new Dictionary<string, string>();
- this.view.AreStringsEqual("empty", "", hashtable);
- this.view.AreEqual("hashtable.Count == 0", 0, hashtable.Count);
+ this.view.AreStringsEqual("empty", "{}", () => dict);
+ this.view.AreEqual("hashtable.Count == 0", 0, () => dict.Count);
- hashtable.Add("key", "value");
- this.view.AreStringsEqual("hashtable.Add(\"key\", \"value\")", "", hashtable);
+ dict.Add("key", "value");
+ this.view.AreStringsEqual("hashtable.Add(\"key\", \"value\")", "", () => dict);
}
}
}
View
4 test/DotWeb.Functional.Test/Client/DotWeb.Functional.Test.Client.csproj
@@ -34,12 +34,12 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="ArrayTest.cs" />
- <Compile Include="HashtableTest.cs" />
+ <Compile Include="DictionaryTest.cs" />
<Compile Include="StringBuilderTest.cs" />
<Compile Include="StringTest.cs" />
<Compile Include="Lambda.cs" />
<Compile Include="TestResultView.cs" />
- <Compile Include="List.cs" />
+ <Compile Include="ListTest.cs" />
<Compile Include="Log.cs" />
<Compile Include="Sanity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
View
42 test/DotWeb.Functional.Test/Client/List.cs → test/DotWeb.Functional.Test/Client/ListTest.cs
@@ -4,11 +4,11 @@
namespace DotWeb.Functional.Test.Client
{
- class List : JsScript
+ class ListTest : JsScript
{
private TestResultView view;
- public List() {
+ public ListTest() {
var sandbox = Document.getElementById("sandbox");
this.view = new TestResultView(sandbox);
@@ -28,50 +28,50 @@ class List : JsScript
list.Add("two");
list.Add("three");
- view.AreStringsEqual("list.ToString()", "[ one,two,three ]", list);
+ view.AreStringsEqual("list.ToString()", "[ one,two,three ]", () => list);
- view.AreEqual("list.IndexOf('one')", 0, list.IndexOf("one"));
- view.AreEqual("list.IndexOf('two')", 1, list.IndexOf("two"));
- view.AreEqual("list.IndexOf('three')", 2, list.IndexOf("three"));
- view.AreEqual("list.IndexOf('none')", -1, list.IndexOf("none"));
+ view.AreEqual("list.IndexOf('one')", 0, () => list.IndexOf("one"));
+ view.AreEqual("list.IndexOf('two')", 1, () => list.IndexOf("two"));
+ view.AreEqual("list.IndexOf('three')", 2, () => list.IndexOf("three"));
+ view.AreEqual("list.IndexOf('none')", -1, () => list.IndexOf("none"));
list.Add("two");
- view.AreStringsEqual("list.Add('two')", "[ one,two,three,two ]", list);
+ view.AreStringsEqual("list.Add('two')", "[ one,two,three,two ]", () => list);
list.Remove("two");
- view.AreStringsEqual("list.Remove('two')", "[ one,three,two ]", list);
+ view.AreStringsEqual("list.Remove('two')", "[ one,three,two ]", () => list);
list.Clear();
- view.AreStringsEqual("list.Clear()", "[ ]", list);
+ view.AreStringsEqual("list.Clear()", "[ ]", () => list);
list.Add("x");
list.Add("y");
list.Add("z");
- view.AreStringsEqual("list.Add(x, y, z)", "[ x,y,z ]", list);
- view.AreEqual("list.Contains('x')", true, list.Contains("x"));
- view.AreEqual("list.Contains('nothere')", false, list.Contains("nothere"));
+ view.AreStringsEqual("list.Add(x, y, z)", "[ x,y,z ]", () => list);
+ view.AreEqual("list.Contains('x')", true, () => list.Contains("x"));
+ view.AreEqual("list.Contains('nothere')", false, () => list.Contains("nothere"));
list.Insert(0, "a");
- view.AreStringsEqual("list.Insert(0, 'a')", "[ a,x,y,z ]", list);
+ view.AreStringsEqual("list.Insert(0, 'a')", "[ a,x,y,z ]", () => list);
list.Insert(4, "zz");
- view.AreStringsEqual("list.Insert(4, 'zz')", "[ a,x,y,z,zz ]", list);
+ view.AreStringsEqual("list.Insert(4, 'zz')", "[ a,x,y,z,zz ]", () => list);
list.Insert(1, "b");
- view.AreStringsEqual("list.Insert(1, 'b')", "[ a,b,x,y,z,zz ]", list);
+ view.AreStringsEqual("list.Insert(1, 'b')", "[ a,b,x,y,z,zz ]", () => list);
list.Insert(2, "c");
- view.AreStringsEqual("list.Insert(2, 'c')", "[ a,b,c,x,y,z,zz ]", list);
+ view.AreStringsEqual("list.Insert(2, 'c')", "[ a,b,c,x,y,z,zz ]", () => list);
list.RemoveAt(2);
- view.AreStringsEqual("list.RemoveAt(2)", "[ a,b,x,y,z,zz ]", list);
+ view.AreStringsEqual("list.RemoveAt(2)", "[ a,b,x,y,z,zz ]", () => list);
list.RemoveAt(0);
- view.AreStringsEqual("list.RemoveAt(0)", "[ b,x,y,z,zz ]", list);
+ view.AreStringsEqual("list.RemoveAt(0)", "[ b,x,y,z,zz ]", () => list);
list.RemoveAt(4);
- view.AreStringsEqual("list.RemoveAt(5)", "[ b,x,y,z ]", list);
+ view.AreStringsEqual("list.RemoveAt(5)", "[ b,x,y,z ]", () => list);
var strArgOutOfRange = "System.ArgumentOutOfRangeException";
view.ExpectException("list.Insert(5, 'zz')", strArgOutOfRange, () => list.Insert(5, "zz"));
@@ -88,7 +88,7 @@ class List : JsScript
int i = 0;
foreach (var x in list2) {
Log.Write("enumerator" + i);
- view.AreEqual("enumerator" + i, i, x);
+ view.AreEqual("enumerator" + i, i, () => x);
i++;
}
}
View
12 test/DotWeb.Functional.Test/Client/StringBuilderTest.cs
@@ -26,22 +26,22 @@ class StringBuilderTest : JsScript
private void RunTest() {
var sb = new StringBuilder();
- this.view.AreStringsEqual("empty", sb.ToString(), sb);
+ this.view.AreStringsEqual("empty", sb.ToString(), () => sb);
sb.Append(true);
- this.view.AreStringsEqual("sb.Append(true)", "true", sb);
+ this.view.AreStringsEqual("sb.Append(true)", "true", () => sb);
sb.Append(':');
- this.view.AreStringsEqual("sb.Append(':')", "true:", sb);
+ this.view.AreStringsEqual("sb.Append(':')", "true:", () => sb);
sb.Append('x', 2);
- this.view.AreStringsEqual("sb.Append(':')", "true:xx", sb);
+ this.view.AreStringsEqual("sb.Append(':')", "true:xx", () => sb);
sb.Append("/test/", 1, 4);
- this.view.AreStringsEqual("sb.Append(\"/test/\", 1, 4)", "true:xxtest", sb);
+ this.view.AreStringsEqual("sb.Append(\"/test/\", 1, 4)", "true:xxtest", () => sb);
sb.AppendFormat("Test: {0}", 55);
- this.view.AreStringsEqual("sb.Append(\"Test: {0}\", 55)", "true:xxtestTest: 55", sb);
+ this.view.AreStringsEqual("sb.Append(\"Test: {0}\", 55)", "true:xxtestTest: 55", () => sb);
}
}
}
View
52 test/DotWeb.Functional.Test/Client/StringTest.cs
@@ -25,40 +25,40 @@ class StringTest : JsScript
private void RunTest() {
var str = "This is a string";
- this.view.AreStringsEqual("str == str", str, str);
+ this.view.AreStringsEqual("str == str", str, () => str);
var str2 = "This is a string";
- this.view.AreStringsEqual("str == str2", str, str2);
+ this.view.AreStringsEqual("str == str2", str, () => str2);
- this.view.AreEqual("str.Length", 16, str.Length);
- this.view.AreEqual("str[0] == 'T'", 'T', str[0]);
- this.view.AreStringsEqual("str.Substring(10)", "string", str.Substring(10));
- this.view.AreStringsEqual("str.Substring(0, 4)", "This", str.Substring(0, 4));
- this.view.AreStringsEqual("str.Substring(5, 4)", "is a", str.Substring(5, 4));
- this.view.AreStringsEqual("str.Substring(0)", str, str.Substring(0));
- this.view.AreStringsEqual("string.Format(\"Test: {0}\")", "Test: arg0", string.Format("Test: {0}", "arg0"));
- this.view.AreStringsEqual("string.Format(\"/{0, 10}/\")", "/ 1/", string.Format("/{0, 10}/", 1));
+ this.view.AreEqual("str.Length", 16, () => str.Length);
+ this.view.AreEqual("str[0] == 'T'", 'T', () => str[0]);
+ this.view.AreStringsEqual("str.Substring(10)", "string", () => str.Substring(10));
+ this.view.AreStringsEqual("str.Substring(0, 4)", "This", () => str.Substring(0, 4));
+ this.view.AreStringsEqual("str.Substring(5, 4)", "is a", () => str.Substring(5, 4));
+ this.view.AreStringsEqual("str.Substring(0)", str, () => str.Substring(0));
+ this.view.AreStringsEqual("string.Format(\"Test: {0}\")", "Test: arg0", () => string.Format("Test: {0}", "arg0"));
+ this.view.AreStringsEqual("string.Format(\"/{0, 10}/\")", "/ 1/", () => string.Format("/{0, 10}/", 1));
// This only works in web-mode because we are using Mono's hashcode implementation
- this.view.AreEqual("str.GetHashCode()", 5894048900, str.GetHashCode());
- this.view.AreEqual("str.Contains(\"is\")", true, str.Contains("is"));
- this.view.AreEqual("str.Contains(\"not\")", false, str.Contains("not"));
- this.view.AreEqual("str.IndexOf(\"is\")", 2, str.IndexOf("is"));
- this.view.AreEqual("str.IndexOf(\"is\", 4)", 5, str.IndexOf("is", 4));
- this.view.AreEqual("str.IndexOf(\"not\")", -1, str.IndexOf("not"));
- this.view.AreEqual("str.LastIndexOf(\"is\")", 5, str.LastIndexOf("is"));
- this.view.AreEqual("str.LastIndexOf(\"not\")", -1, str.LastIndexOf("not"));
- this.view.AreStringsEqual("str.ToUpper()", "THIS IS A STRING", str.ToUpper());
- this.view.AreStringsEqual("str.ToLower()", "this is a string", str.ToLower());
+ this.view.AreEqual("str.GetHashCode()", 5894048900, () => str.GetHashCode());
+ this.view.AreEqual("str.Contains(\"is\")", true, () => str.Contains("is"));
+ this.view.AreEqual("str.Contains(\"not\")", false, () => str.Contains("not"));
+ this.view.AreEqual("str.IndexOf(\"is\")", 2, () => str.IndexOf("is"));
+ this.view.AreEqual("str.IndexOf(\"is\", 4)", 5, () => str.IndexOf("is", 4));
+ this.view.AreEqual("str.IndexOf(\"not\")", -1, () => str.IndexOf("not"));
+ this.view.AreEqual("str.LastIndexOf(\"is\")", 5, () => str.LastIndexOf("is"));
+ this.view.AreEqual("str.LastIndexOf(\"not\")", -1, () => str.LastIndexOf("not"));
+ this.view.AreStringsEqual("str.ToUpper()", "THIS IS A STRING", () => str.ToUpper());
+ this.view.AreStringsEqual("str.ToLower()", "this is a string", () => str.ToLower());
var str3 = " trim ";
- this.view.AreStringsEqual("str3", " trim ", str3);
- this.view.AreStringsEqual("str3.Trim()", "trim", str3.Trim());
+ this.view.AreStringsEqual("str3", " trim ", () => str3);
+ this.view.AreStringsEqual("str3.Trim()", "trim", () => str3.Trim());
var parts = str.Split(' ');
- this.view.AreStringsEqual("str.Split(' ')[0]", "This", parts[0]);
- this.view.AreStringsEqual("str.Split(' ')[1]", "is", parts[1]);
- this.view.AreStringsEqual("str.Split(' ')[2]", "a", parts[2]);
- this.view.AreStringsEqual("str.Split(' ')[3]", "string", parts[3]);
+ this.view.AreStringsEqual("str.Split(' ')[0]", "This", () => parts[0]);
+ this.view.AreStringsEqual("str.Split(' ')[1]", "is", () => parts[1]);
+ this.view.AreStringsEqual("str.Split(' ')[2]", "a", () => parts[2]);
+ this.view.AreStringsEqual("str.Split(' ')[3]", "string", () => parts[3]);
}
}
}
View
6 test/DotWeb.Functional.Test/Client/TestResultView.cs
@@ -41,8 +41,9 @@ class TestResultView : JsScript
this.table.tBodies[0].appendChild(row);
}
- public void AreStringsEqual(string name, string expected, object actual) {
+ public void AreStringsEqual(string name, string expected, Func<object> func) {
try {
+ var actual = func();
var str = actual.ToString();
AddRow(name, expected, str, expected == str);
}
@@ -51,9 +52,10 @@ class TestResultView : JsScript
}
}
- public void AreEqual(string name, object expected, object actual) {
+ public void AreEqual(string name, object expected, Func<object> func) {
var expectedString = expected.ToString();
try {
+ var actual = func();
AddRow(name, expectedString, actual.ToString(), expected.Equals(actual));
}
catch (Exception ex) {
View
4 test/DotWeb.Functional.Test/Server/App_Data/TestDirectory.txt
@@ -2,5 +2,5 @@
StringTest
StringBuilderTest
ArrayTest
-List
-HashtableTest
+ListTest
+DictionaryTest
View
1  test/DotWeb.Translator.Test/DotWeb.Translator.Test.csproj
@@ -214,6 +214,7 @@
<Content Include="Expected\GeneralTests\Release\StringFormat.js" />
<Content Include="Expected\GeneralTests\Release\ParseDecimal.js" />
<Content Include="Expected\Loops\WhileIfLessOrLessBreak.js" />
+ <Content Include="Expected\SystemTest\TestCastPrimitive.js" />
<Content Include="Expected\SystemTest\TestCtorChain.js" />
<Content Include="Expected\SystemTest\TestString.js" />
<Content Include="Expected\SystemTest\TestJsArray.js" />
View
4 test/DotWeb.Translator.Test/Expected/DecorationTest/TestJsIntrinsic.js
@@ -6,7 +6,7 @@ H8.IntrinsicClass.prototype.$ctor = function() {
$Class(null, 'System', 'Console');
-System.Console.Write = function(value) {
+System.Console.Write$0 = function(value) {
console.log(value);
};
@@ -16,5 +16,5 @@ H8.DecorationTests.prototype.TestJsIntrinsic = function() {
var __g__initLocal3 = new H8.IntrinsicClass().$ctor();
__g__initLocal3.Value = 1;
var item = __g__initLocal3;
- System.Console.Write(item.Value);
+ System.Console.Write$0(item.Value);
};
View
453 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ArgumentException.js
@@ -1,7 +1,7 @@
$Class(null, 'System', 'Exception');
System.Exception.prototype.set_Message = function(value) {
- this._Message_k__BackingField = value;
+ this.message = value;
};
System.Exception.prototype.$ctor$1 = function(message) {
@@ -23,8 +23,434 @@ System.ArgumentException.prototype.$ctor$0 = function() {
return this;
};
+$Class(null, 'System.Text', 'StringBuilder');
+
+System.Text.StringBuilder.prototype.$ctor = function() {
+ this.value = "";
+ return this;
+};
+
+$Class(System.SystemException, 'System', 'FormatException');
+
+System.FormatException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
+ return this;
+};
+
+System.Text.StringBuilder.prototype.toString = function() {
+ return this.value;
+};
+
+System.Text.StringBuilder.prototype.Append$0 = function(value) {
+ var V_1 = value != null;
+ if (!V_1) {
+ var V_0 = this;
+ }
+ else {
+ V_1 = value.length != 0;
+ if (!V_1) {
+ this.value = value;
+ V_0 = this;
+ }
+ else {
+ this.value = this.value + value;
+ V_0 = this;
+ }
+ }
+ return V_0;
+};
+
+System.Exception.prototype.get_InnerException = function() {
+ return this._InnerException_k__BackingField;
+};
+
+System.Text.StringBuilder.prototype.AppendLine$0 = function() {
+ return this;
+};
+
+System.Exception.prototype.toString = function() {
+ var V_0 = new System.Text.StringBuilder().$ctor();
+ V_0.Append$0(this.$typename);
+ V_0.Append$0(": ").Append$0(this.get_Message());
+ var V_2 = this.get_InnerException() == null;
+ if (!V_2) {
+ V_0.Append$0(" ---> ").Append$0(this.get_InnerException().toString());
+ V_0.AppendLine$0();
+ V_0.Append$0(" --- End of inner exception stack trace ---");
+ }
+ return V_0.toString();
+};
+
+System.Text.StringBuilder.prototype.Append$1 = function(value) {
+ return this.Append$0(value.toString());
+};
+
+System.ArgumentException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
+ return this;
+};
+
+$Class(System.ArgumentException, 'System', 'ArgumentOutOfRangeException');
+
+(function() {
+ System.ArgumentOutOfRangeException.RangeMessage = "Specified argument was out of the range of valid values.";
+})();
+
+System.ArgumentOutOfRangeException.prototype.$ctor$0 = function() {
+ this.$super.$ctor$1(System.ArgumentOutOfRangeException.RangeMessage);
+ return this;
+};
+
+System.ArgumentException.prototype.set_ParamName = function(value) {
+ this._ParamName_k__BackingField = value;
+};
+
+System.ArgumentException.prototype.$ctor$3 = function(message, paramName) {
+ this.$super.$ctor$1(message);
+ this.set_ParamName(paramName);
+ return this;
+};
+
+$Class(System.ArgumentException, 'System', 'ArgumentNullException');
+
+(function() {
+ System.ArgumentNullException.DefaultMessage = "Value cannot be null.";
+})();
+
+System.ArgumentNullException.prototype.$ctor$1 = function(paramName) {
+ this.$super.$ctor$3(System.ArgumentNullException.DefaultMessage, paramName);
+ return this;
+};
+
+System.Text.StringBuilder.prototype.Append$5 = function(value, startIndex, count) {
+ var V_2 = value != null;
+ if (!V_2) {
+ if (startIndex) {
+ var R_1 = count == 0;
+ }
+ else {
+ R_1 = 1;
+ }
+ V_2 = R_1;
+ if (!V_2) {
+ throw new System.ArgumentNullException().$ctor$1("value");
+ }
+ var V_1 = this;
+ }
+ else {
+ if ((count >= 0) && (startIndex >= 0)) {
+ R_1 = startIndex <= (value.length - count);
+ }
+ else {
+ R_1 = 0;
+ }
+ V_2 = R_1;
+ if (!V_2) {
+ throw new System.ArgumentOutOfRangeException().$ctor$0();
+ }
+ var V_0 = startIndex;
+ while (true) {
+ V_2 = V_0 < (startIndex + count);
+ if (!V_2) {
+ break;
+ }
+ this.Append$1(value.charAt(V_0));
+ V_0 = V_0 + 1;
+ }
+ V_1 = this;
+ }
+ return V_1;
+};
+
+$Class(null, 'System', 'String_FormatSpecifier');
+
+System.String_FormatSpecifier.prototype.ParseDecimal = function() {
+ var V_0 = this.ptr;
+ var V_1 = 0;
+ while (true) {
+ var V_4 = true;
+ var V_2 = this.str.charCodeAt(V_0);
+ if (V_2 >= 48) {
+ var R_1 = 57 >= V_2;
+ }
+ else {
+ R_1 = 0;
+ }
+ V_4 = R_1;
+ if (!V_4) {
+ break;
+ }
+ V_1 = ((V_1 * 10) + V_2) - 48;
+ V_0 = V_0 + 1;
+ }
+ V_4 = V_0 != this.ptr;
+ if (!V_4) {
+ var V_3 = -1;
+ }
+ else {
+ this.ptr = V_0;
+ V_3 = V_1;
+ }
+ return V_3;
+};
+
+System.String_FormatSpecifier.prototype.IsWhiteSpace = function() {
+ var V_0 = this.str.charCodeAt(this.ptr);
+ if ((((V_0 < 9) || (V_0 > 13)) && (V_0 != 32)) && (V_0 != 133)) {
+ var R_1 = V_0 == 8287;
+ }
+ else {
+ R_1 = 1;
+ }
+ return R_1;
+};
+
+System.ArgumentOutOfRangeException.prototype.$ctor$3 = function(paramName, message) {
+ this.$super.$ctor$3(message, paramName);
+ return this;
+};
+
+(function() {
+ String.empty = "";
+})();
+
+String.prototype._Substring$1 = function(startIndex, length) {
+ var V_1 = length >= 0;
+ if (!V_1) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("length", "Cannot be negative.");
+ }
+ V_1 = startIndex >= 0;
+ if (!V_1) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("startIndex", "Cannot be negative.");
+ }
+ V_1 = startIndex <= this.length;
+ if (!V_1) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("startIndex", "Cannot exceed length of string.");
+ }
+ V_1 = startIndex <= (this.length - length);
+ if (!V_1) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("length", "startIndex + length > this.length");
+ }
+ if (!startIndex) {
+ var R_1 = length != this.length;
+ }
+ else {
+ R_1 = 1;
+ }
+ V_1 = R_1;
+ if (!V_1) {
+ var V_0 = this;
+ }
+ else {
+ V_0 = this.substring(startIndex, startIndex + length);
+ }
+ return V_0;
+};
+
+$Class(System.SystemException, 'System', 'IndexOutOfRangeException');
+
+System.IndexOutOfRangeException.prototype.$ctor$0 = function() {
+ this.$super.$ctor$1("Array index is out of range.");
+ return this;
+};
+
+System.String_FormatSpecifier.prototype.ParseFormatSpecifier = function() {
+ try {
+ this.n = this.ParseDecimal();
+ var V_2 = this.n >= 0;
+ if (!V_2) {
+ throw new System.FormatException().$ctor$1("Invalid argument specifier.");
+ }
+ V_2 = this.str.charAt(this.ptr) != ',';
+ if (!V_2) {
+ this.ptr = this.ptr + 1;
+ while (true) {
+ V_2 = this.IsWhiteSpace();
+ if (!V_2) {
+ break;
+ }
+ this.ptr = this.ptr + 1;
+ }
+ var V_0 = this.ptr;
+ var V_1 = this.ptr - V_0;
+ this.format = this.str._Substring$1(V_0, V_1);
+ this.left_align = this.str.charAt(this.ptr) == '-';
+ V_2 = !this.left_align;
+ if (!V_2) {
+ this.ptr = this.ptr + 1;
+ }
+ this.width = this.ParseDecimal();
+ V_2 = this.width >= 0;
+ if (!V_2) {
+ throw new System.FormatException().$ctor$1("Invalid width specifier.");
+ }
+ }
+ else {
+ this.width = 0;
+ this.left_align = false;
+ this.format = "";
+ }
+ V_2 = this.str.charAt(this.ptr) != ':';
+ if (!V_2) {
+ var D_0 = this.ptr + 1;
+ var V_3 = D_0;
+ this.ptr = D_0;
+ V_0 = V_3;
+ while (true) {
+ V_2 = this.str.charAt(this.ptr) != '}';
+ if (!V_2) {
+ break;
+ }
+ this.ptr = this.ptr + 1;
+ }
+ this.format = this.format + this.str._Substring$1(V_0, this.ptr - V_0);
+ }
+ else {
+ this.format = null;
+ }
+ var D_1 = this.ptr;
+ V_3 = D_1;
+ this.ptr = D_1 + 1;
+ V_2 = this.str.charAt(V_3) == '}';
+ if (!V_2) {
+ throw new System.FormatException().$ctor$1("Missing end characeter.");
+ }
+ }
+ catch (__ex__) {
+ if (__ex__ instanceof System.IndexOutOfRangeException) {
+ throw new System.FormatException().$ctor$1("Input string was not in a correct format.");
+ }
+ else {
+ throw __ex__;
+ }
+ }
+};
+
+System.String_FormatSpecifier.prototype.$ctor = function(str, ptr) {
+ this.str = str;
+ this.ptr = ptr;
+ this.ParseFormatSpecifier();
+ return this;
+};
+
+System.Text.StringBuilder.prototype.Append$3 = function(value, repeatCount) {
+ var V_0 = 0;
+ while (true) {
+ var V_2 = V_0 < repeatCount;
+ if (!V_2) {
+ break;
+ }
+ this.Append$1(value);
+ V_0 = V_0 + 1;
+ }
+ return this;
+};
+
+String.formatHelper = function(result, format, args) {
+ var V_8 = format != null;
+ if (!V_8) {
+ throw new System.ArgumentNullException().$ctor$1("format");
+ }
+ V_8 = args != null;
+ if (!V_8) {
+ throw new System.ArgumentNullException().$ctor$1("args");
+ }
+ V_8 = result != null;
+ if (!V_8) {
+ result = new System.Text.StringBuilder().$ctor();
+ }
+ var V_0 = 0;
+ var V_1 = V_0;
+ while (true) {
+ V_8 = V_0 < format.length;
+ if (!V_8) {
+ break;
+ }
+ var D_0 = V_0;
+ V_0 = D_0 + 1;
+ var V_2 = format.charAt(D_0);
+ V_8 = V_2 != '{';
+ if (!V_8) {
+ result.Append$5(format, V_1, (V_0 - V_1) - 1);
+ V_8 = format.charAt(V_0) != '{';
+ if (!V_8) {
+ var D_2 = V_0;
+ V_0 = D_2 + 1;
+ V_1 = D_2;
+ continue;
+ }
+ var V_3 = new System.String_FormatSpecifier().$ctor(format, V_0);
+ V_0 = V_3.ptr;
+ V_8 = V_3.n < args.length;
+ if (!V_8) {
+ throw new System.FormatException().$ctor$1("Index (zero based) must be greater than or equal to zero and less than the size of the argument list.");
+ }
+ var V_4 = args[V_3.n];
+ V_8 = V_4 != null;
+ if (!V_8) {
+ var V_5 = "";
+ }
+ V_5 = V_4.toString();
+ V_8 = V_3.width <= V_5.length;
+ if (!V_8) {
+ var V_6 = V_3.width - V_5.length;
+ V_8 = !V_3.left_align;
+ if (!V_8) {
+ result.Append$0(V_5);
+ result.Append$3(' ', V_6);
+ }
+ else {
+ result.Append$3(' ', V_6);
+ result.Append$0(V_5);
+ }
+ }
+ else {
+ result.Append$0(V_5);
+ }
+ V_1 = V_0;
+ V_8 = R_1;
+ if (!V_8) {
+ result.Append$5(format, V_1, (V_0 - V_1) - 1);
+ var D_1 = V_0;
+ V_0 = D_1 + 1;
+ V_1 = D_1;
+ }
+ else {
+ V_8 = V_2 != '}';
+ if (!V_8) {
+ throw new System.FormatException().$ctor$1("Input string was not in a correct format.");
+ }
+ }
+ }
+ else {
+ if ((V_2 == '}') && (V_0 < format.length)) {
+ var R_1 = format.charAt(V_0) != '}';
+ }
+ else {
+ R_1 = 1;
+ }
+ }
+ }
+ V_8 = V_1 >= format.length;
+ if (!V_8) {
+ result.Append$5(format, V_1, format.length - V_1);
+ }
+ return result;
+};
+
+String.format$0 = function(format, arg0) {
+ var V_2 = new Array(1);
+ V_2[0] = arg0;
+ var V_0 = String.formatHelper(null, format, V_2);
+ return V_0.toString();
+};
+
System.Exception.prototype.get_Message = function() {
- return this._Message_k__BackingField;
+ var V_1 = this.message != null;
+ if (!V_1) {
+ this.message = String.format$0("Exception of type '{0}' was thrown.", this.$typename);
+ }
+ return this.message;
};
System.ArgumentException.prototype.get_ParamName = function() {
@@ -49,6 +475,29 @@ System.ArgumentException.prototype.get_Message = function() {
return V_1;
};
+System.ArgumentOutOfRangeException.prototype.get_ActualValue = function() {
+ return this._ActualValue_k__BackingField;
+};
+
+System.ArgumentOutOfRangeException.prototype.get_Message = function() {
+ var V_0 = this.$super.get_Message();
+ var V_3 = this.get_ActualValue() != null;
+ if (!V_3) {
+ var V_2 = V_0;
+ }
+ else {
+ var V_1 = "Actual value was " + this.get_ActualValue().toString();
+ V_3 = V_0 != null;
+ if (!V_3) {
+ V_2 = V_1;
+ }
+ else {
+ V_2 = V_0 + "\n" + V_1;
+ }
+ }
+ return V_2;
+};
+
$Class(null, 'System', 'Console');
System.Console.WriteLine$1 = function(value) {
View
4 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/CallDerived.js
@@ -2,6 +2,10 @@
$Class(H8.Base, 'H8', 'Derived');
+(function() {
+ H8.Derived.counter = 0;
+})();
+
H8.Derived.NextId = function() {
var D_0 = H8.Derived.counter;
H8.Derived.counter = D_0 + 1;
View
10 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/Callback.js
@@ -1,7 +1,7 @@
$Class(null, 'System', 'Exception');
System.Exception.prototype.set_Message = function(value) {
- this._Message_k__BackingField = value;
+ this.message = value;
};
System.Exception.prototype.$ctor$1 = function(message) {
@@ -11,15 +11,15 @@ System.Exception.prototype.$ctor$1 = function(message) {
$Class(System.Exception, 'System', 'SystemException');
-System.SystemException.prototype.$ctor$0 = function() {
- this.$super.$ctor$1("System error.");
+System.SystemException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
return this;
};
$Class(System.SystemException, 'System', 'NotImplementedException');
System.NotImplementedException.prototype.$ctor$0 = function() {
- this.$super.$ctor$0();
+ this.$super.$ctor$1("The requested feature is not implemented.");
return this;
};
@@ -32,7 +32,7 @@ H8.GeneralTests.prototype.SourceTests_SimpleEvent = function() {
$Class(System.SystemException, 'System', 'NotSupportedException');
System.NotSupportedException.prototype.$ctor$0 = function() {
- this.$super.$ctor$0();
+ this.$super.$ctor$1("Operation is not supported.");
return this;
};
View
24 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ExpectExceptionTest.js
@@ -1,17 +1,7 @@
$Class(null, 'System', 'Exception');
-$Class(System.Exception, 'System', 'SystemException');
-
-$Class(System.SystemException, 'System', 'ArgumentException');
-
-$Class(System.ArgumentException, 'System', 'ArgumentOutOfRangeException');
-
-System.ArgumentOutOfRangeException.get_RangeMessage = function() {
- return "Specified argument was out of the range of valid values.";
-};
-
System.Exception.prototype.set_Message = function(value) {
- this._Message_k__BackingField = value;
+ this.message = value;
};
System.Exception.prototype.$ctor$1 = function(message) {
@@ -19,18 +9,28 @@ System.Exception.prototype.$ctor$1 = function(message) {
return this;
};
+$Class(System.Exception, 'System', 'SystemException');
+
System.SystemException.prototype.$ctor$1 = function(message) {
this.$super.$ctor$1(message);
return this;
};
+$Class(System.SystemException, 'System', 'ArgumentException');
+
System.ArgumentException.prototype.$ctor$1 = function(message) {
this.$super.$ctor$1(message);
return this;
};
+$Class(System.ArgumentException, 'System', 'ArgumentOutOfRangeException');
+
+(function() {
+ System.ArgumentOutOfRangeException.RangeMessage = "Specified argument was out of the range of valid values.";
+})();
+
System.ArgumentOutOfRangeException.prototype.$ctor$0 = function() {
- this.$super.$ctor$1(System.ArgumentOutOfRangeException.get_RangeMessage());
+ this.$super.$ctor$1(System.ArgumentOutOfRangeException.RangeMessage);
return this;
};
View
453 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/ArgumentException.js
@@ -1,7 +1,7 @@
$Class(null, 'System', 'Exception');
System.Exception.prototype.set_Message = function(value) {
- this._Message_k__BackingField = value;
+ this.message = value;
};
System.Exception.prototype.$ctor$1 = function(message) {
@@ -23,8 +23,434 @@ System.ArgumentException.prototype.$ctor$0 = function() {
return this;
};
+$Class(null, 'System.Text', 'StringBuilder');
+
+System.Text.StringBuilder.prototype.$ctor = function() {
+ this.value = "";
+ return this;
+};
+
+$Class(System.SystemException, 'System', 'FormatException');
+
+System.FormatException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
+ return this;
+};
+
+System.Text.StringBuilder.prototype.toString = function() {
+ return this.value;
+};
+
+System.Text.StringBuilder.prototype.Append$0 = function(value) {
+ var V_1 = value != null;
+ if (!V_1) {
+ var V_0 = this;
+ }
+ else {
+ V_1 = value.length != 0;
+ if (!V_1) {
+ this.value = value;
+ V_0 = this;
+ }
+ else {
+ this.value = this.value + value;
+ V_0 = this;
+ }
+ }
+ return V_0;
+};
+
+System.Exception.prototype.get_InnerException = function() {
+ return this._InnerException_k__BackingField;
+};
+
+System.Text.StringBuilder.prototype.AppendLine$0 = function() {
+ return this;
+};
+
+System.Exception.prototype.toString = function() {
+ var V_0 = new System.Text.StringBuilder().$ctor();
+ V_0.Append$0(this.$typename);
+ V_0.Append$0(": ").Append$0(this.get_Message());
+ var V_2 = this.get_InnerException() == null;
+ if (!V_2) {
+ V_0.Append$0(" ---> ").Append$0(this.get_InnerException().toString());
+ V_0.AppendLine$0();
+ V_0.Append$0(" --- End of inner exception stack trace ---");
+ }
+ return V_0.toString();
+};
+
+System.Text.StringBuilder.prototype.Append$1 = function(value) {
+ return this.Append$0(value.toString());
+};
+
+System.ArgumentException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
+ return this;
+};
+
+$Class(System.ArgumentException, 'System', 'ArgumentOutOfRangeException');
+
+(function() {
+ System.ArgumentOutOfRangeException.RangeMessage = "Specified argument was out of the range of valid values.";
+})();
+
+System.ArgumentOutOfRangeException.prototype.$ctor$0 = function() {
+ this.$super.$ctor$1(System.ArgumentOutOfRangeException.RangeMessage);
+ return this;
+};
+
+System.ArgumentException.prototype.set_ParamName = function(value) {
+ this._ParamName_k__BackingField = value;
+};
+
+System.ArgumentException.prototype.$ctor$3 = function(message, paramName) {
+ this.$super.$ctor$1(message);
+ this.set_ParamName(paramName);
+ return this;
+};
+
+$Class(System.ArgumentException, 'System', 'ArgumentNullException');
+
+(function() {
+ System.ArgumentNullException.DefaultMessage = "Value cannot be null.";
+})();
+
+System.ArgumentNullException.prototype.$ctor$1 = function(paramName) {
+ this.$super.$ctor$3(System.ArgumentNullException.DefaultMessage, paramName);
+ return this;
+};
+
+System.Text.StringBuilder.prototype.Append$5 = function(value, startIndex, count) {