Permalink
Browse files

Updating to Mono.Cecil 0.9.3. Getting almost all of the translation t…

…ests to pass. Still need to re-do the weaver
  • Loading branch information...
1 parent 717f34e commit 64628ce7b4983f273d42bab4ab068c1dd55935f6 Frank Laub committed Jun 23, 2010
Showing with 2,146 additions and 2,367 deletions.
  1. BIN Depends/Mono.Cecil.Pdb.dll
  2. BIN Depends/Mono.Cecil.Pdb.pdb
  3. BIN Depends/Mono.Cecil.dll
  4. BIN Depends/Mono.Cecil.pdb
  5. +1 −0 src/DotWeb.Client/DotWeb.Client.csproj
  6. +12 −12 src/DotWeb.Decompiler/CodeTypeEvaluator.cs
  7. +1 −1 src/DotWeb.Decompiler/Core/BasicBlock.cs
  8. +1 −1 src/DotWeb.Decompiler/Core/ControlFlowGraphBuilder.cs
  9. +2 −2 src/DotWeb.Decompiler/Core/InstructionExtensions.cs
  10. +8 −7 src/DotWeb.Decompiler/Core/Interpreter.cs
  11. +1 −1 src/DotWeb.Decompiler/Core/TryStructure.cs
  12. +1 −1 src/DotWeb.Hosting.Bridge/HostingServer.cs
  13. +3 −14 src/DotWeb.Hosting.Weaver/DotWeb.Hosting.Weaver.csproj
  14. +19 −1 src/DotWeb.Hosting.Weaver/ExternalType.cs
  15. +18 −0 src/DotWeb.Hosting.Weaver/SimpleWeaver.cs
  16. +12 −9 src/DotWeb.Translator/AttributeHelper.cs
  17. +3 −3 src/DotWeb.Translator/Generator/JavaScript/JsCodeGenerator.cs
  18. +8 −7 src/DotWeb.Translator/Generator/JavaScript/JsPrinter.cs
  19. +1 −1 src/DotWeb.Translator/TranslationContext.cs
  20. +11 −10 src/DotWeb.Translator/TranslationEngine.cs
  21. +7 −4 src/DotWeb.Utility/AssociatedProperty.cs
  22. +71 −0 src/DotWeb.Utility/Cecil/Extensions.cs
  23. +256 −1 src/DotWeb.Utility/Cecil/GlobalAssemblyResolver.cs
  24. +2 −4 src/DotWeb.Utility/Cecil/MethodReferenceExtenstions.cs
  25. +3 −3 src/DotWeb.Utility/Cecil/TypeDefinitionCache.cs
  26. +29 −31 src/DotWeb.Utility/Cecil/TypeSystem.cs
  27. +2 −5 src/DotWeb.Utility/DotWeb.Utility.csproj
  28. +1 −1 src/DotWebWeaver/Program.cs
  29. +1 −1 test/DotWeb.Hosting.Test/HostingWeaverTest.cs
  30. +33 −0 test/DotWeb.Translator.Test/DotWeb.Translator.Test.csproj
  31. +29 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/String._Substring_1.js
  32. +91 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/String.formatHelper.js
  33. +6 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/String.format_0.js
  34. +14 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.ArgumentException.get_Message.js
  35. +13 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.ArgumentOutOfRangeException.get_Message.js
  36. +21 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Collections.Generic.Dictionary_2.Init.js
  37. +19 −0 ...tWeb.Translator.Test/Expected/CommonMethods/System.Collections.Generic.Dictionary_2.InitArrays.js
  38. +10 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Collections.Generic.Dictionary_2.js
  39. +3 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Console.WriteLine_0.js
  40. +3 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Console.WriteLine_1.js
  41. +7 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Exception.get_Message.js
  42. +10 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Exception.js
  43. +12 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Exception.toString.js
  44. +6 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.FormatException.js
  45. +10 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.String_FormatSpecifier.IsWhiteSpace.js
  46. +26 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.String_FormatSpecifier.ParseDecimal.js
  47. +71 −0 ...tWeb.Translator.Test/Expected/CommonMethods/System.String_FormatSpecifier.ParseFormatSpecifier.js
  48. +6 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.SystemException.js
  49. +13 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_0.js
  50. +3 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_1.js
  51. +12 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_3.js
  52. +36 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_5.js
  53. +4 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder._ctor.js
  54. +3 −0 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.toString.js
  55. +2 −6 test/DotWeb.Translator.Test/Expected/DecorationTest/TestJsAnonymous.js
  56. +2 −6 test/DotWeb.Translator.Test/Expected/DecorationTest/TestJsNamespace.js
  57. +6 −29 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/AnonymousType.js
  58. +20 −375 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ArgumentException.js
  59. +3 −7 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/CallTakeParameters.js
  60. +2 −16 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/Callback.js
  61. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ClientScript.js
  62. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/CreateInnerObject.js
  63. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/CreateOuterObject.js
  64. +3 −19 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ExpectExceptionTest.js
  65. +1 −1 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/GitHub_Issue6.js
  66. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/Indexer.js
  67. +6 −29 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/AnonymousType.js
  68. +20 −375 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/ArgumentException.js
  69. +3 −7 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/CallTakeParameters.js
  70. +2 −16 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/Callback.js
  71. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/ClientScript.js
  72. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/CreateInnerObject.js
  73. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/CreateOuterObject.js
  74. +3 −19 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/ExpectExceptionTest.js
  75. +1 −1 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/GitHub_Issue6.js
  76. +2 −6 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/Indexer.js
  77. +18 −348 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/StringFormat.js
  78. +68 −472 test/DotWeb.Translator.Test/Expected/GeneralTests/Release/TestDictionaryEnumerator.js
  79. +3 −3 test/DotWeb.Translator.Test/Expected/GraphBuilderTest/ArgumentException.txt
  80. +1 −1 test/DotWeb.Translator.Test/Expected/GraphBuilderTest/OneBlock.txt
  81. +2 −2 test/DotWeb.Translator.Test/Expected/GraphBuilderTest/SimpleIf.txt
  82. +6 −6 test/DotWeb.Translator.Test/Expected/GraphBuilderTest/Switch.txt
  83. +13 −13 test/DotWeb.Translator.Test/Expected/GraphBuilderTest/TryCatchFinally.txt
  84. +4 −4 test/DotWeb.Translator.Test/Expected/GraphBuilderTest/WhileBreak.txt
  85. +19 −80 test/DotWeb.Translator.Test/Expected/Loops/MultiReturns3.js
  86. +104 −165 test/DotWeb.Translator.Test/Expected/SystemTest/TestDictionary.js
  87. +2 −6 test/DotWeb.Translator.Test/Expected/SystemTest/TestGenericMethod.js
  88. +12 −14 test/DotWeb.Translator.Test/Expected/SystemTest/TestKeyValuePair.js
  89. +9 −13 test/DotWeb.Translator.Test/Expected/SystemTest/TestList.js
  90. +7 −23 test/DotWeb.Translator.Test/Expected/SystemTest/TestListEnumerator.js
  91. +8 −26 test/DotWeb.Translator.Test/Expected/SystemTest/TestString.js
  92. +7 −75 test/DotWeb.Translator.Test/Expected/SystemTest/TestStringBuilderAppend5.js
  93. +3 −2 test/DotWeb.Translator.Test/GraphBuilderTest.cs
  94. +542 −0 test/DotWeb.Translator.Test/Resources/CommonMethods.Designer.cs
  95. +193 −0 test/DotWeb.Translator.Test/Resources/CommonMethods.resx
  96. +70 −11 test/DotWeb.Translator.Test/TranslationTestHelper.cs
  97. +30 −29 test/DotWeb.Translator.Test/TypeSystemTest.cs
View
BIN Depends/Mono.Cecil.Pdb.dll
Binary file not shown.
View
BIN Depends/Mono.Cecil.Pdb.pdb
Binary file not shown.
View
BIN Depends/Mono.Cecil.dll
Binary file not shown.
View
BIN Depends/Mono.Cecil.pdb
Binary file not shown.
View
1 src/DotWeb.Client/DotWeb.Client.csproj
@@ -25,6 +25,7 @@
<RegisterForComInterop>false</RegisterForComInterop>
<NoStdLib>true</NoStdLib>
<NoWarn>626</NoWarn>
+ <DocumentationFile>..\..\build\bin\Debug\DotWeb.Client.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
View
24 src/DotWeb.Decompiler/CodeTypeEvaluator.cs
@@ -79,22 +79,22 @@ public class CodeTypeEvaluator : ICodeExpressionVisitor<TypeReference>
private int GetTypeScore(TypeReference type) {
switch (type.FullName) {
- case Constants.Byte:
- case Constants.SByte:
- case Constants.Char:
+ case "System.Byte":
+ case "System.SByte":
+ case "System.Char":
return 1;
- case Constants.Int16:
- case Constants.UInt16:
+ case "System.Int16":
+ case "System.UInt16":
return 2;
- case Constants.Int32:
- case Constants.UInt32:
+ case "System.Int32":
+ case "System.UInt32":
return 3;
- case Constants.Int64:
- case Constants.UInt64:
+ case "System.Int64":
+ case "System.UInt64":
return 4;
- case Constants.Single:
+ case "System.Single":
return 5;
- case Constants.Double:
+ case "System.Double":
return 6;
}
return 0;
@@ -184,7 +184,7 @@ public class CodeTypeEvaluator : ICodeExpressionVisitor<TypeReference>
var def = method.Resolve();
if (def.IsConstructor)
return method.DeclaringType;
- return def.ReturnType.ReturnType;
+ return def.ReturnType;
}
public TypeReference VisitReturn(CodeArrayInitializeExpression obj) {
View
2 src/DotWeb.Decompiler/Core/BasicBlock.cs
@@ -108,7 +108,7 @@ public class BasicBlock : Node
var variableName = string.Format("R_{0}", index);
var eval = new CodeTypeEvaluator(typeSystem, this.method);
var variableType = eval.Evaluate(item.Expression);
- var variable = new VariableDefinition(variableName, -index, this.method, variableType);
+ var variable = new VariableDefinition(variableName, variableType);
var lhs = new CodeVariableReference(variable);
this.stash[index] = lhs;
View
2 src/DotWeb.Decompiler/Core/ControlFlowGraphBuilder.cs
@@ -140,7 +140,7 @@ public class ControlFlowGraphBuilder
handlerBlock.ExceptionHandler = handler;
this.graph.Orphans.AddUnique(handlerBlock);
- switch (handler.Type) {
+ switch (handler.HandlerType) {
case ExceptionHandlerType.Fault:
case ExceptionHandlerType.Filter:
throw new NotSupportedException();
View
4 src/DotWeb.Decompiler/Core/InstructionExtensions.cs
@@ -86,11 +86,11 @@ public static class InstructionExtensions
case OperandType.InlineR:
case OperandType.InlineVar:
case OperandType.InlineSig:
- case OperandType.InlineParam:
+ case OperandType.InlineArg:
case OperandType.ShortInlineI:
case OperandType.ShortInlineR:
case OperandType.ShortInlineVar:
- case OperandType.ShortInlineParam:
+ case OperandType.ShortInlineArg:
sb.AppendFormat(" {0}", cil.Operand);
break;
case OperandType.InlineTok:
View
15 src/DotWeb.Decompiler/Core/Interpreter.cs
@@ -25,6 +25,7 @@
using Mono.Cecil.Cil;
using Mono.Cecil;
using DotWeb.Utility.Cecil;
+using Mono.Collections.Generic;
namespace DotWeb.Decompiler.Core
{
@@ -55,7 +56,7 @@ public class Interpreter
}
public static CodeVariableReference CreateExceptionVariableReference(MethodDefinition method, TypeReference typeRef) {
- var variable = new VariableDefinition("__ex__", 0, method, typeRef);
+ var variable = new VariableDefinition("__ex__", typeRef);
var code = new CodeVariableReference(variable);
return code;
}
@@ -65,15 +66,15 @@ public class Interpreter
if (this.block.ExceptionHandler != null &&
this.block.ExceptionHandler.TryStart.Offset != this.block.FirstInstruction.Offset &&
- this.block.ExceptionHandler.Type == ExceptionHandlerType.Catch) {
+ this.block.ExceptionHandler.HandlerType == ExceptionHandlerType.Catch) {
Debug.Assert(!this.stack.Any());
// this is a catch handler
// the exception object is expected to be sitting on the top of the stack
// on entry to the catch block
var catchType = this.block.ExceptionHandler.CatchType;
var catchTypeDef = catchType.Resolve();
- this.ExternalMethods.Add(catchTypeDef.Constructors[0]);
+ this.ExternalMethods.Add(catchTypeDef.Methods.Where(x => x.IsConstructor).First());
var exception = CreateExceptionVariableReference(this.method, catchType);
Push(exception);
}
@@ -586,7 +587,7 @@ public class Interpreter
CodeExpression targetObject = GetTargetObject(method, isVirtual);
expr.Method = new CodeMethodReference(targetObject, method);
- if (method.IsConstructor || method.ReturnType.ReturnType.FullName == Constants.Void) {
+ if (method.IsConstructor || method.ReturnType.FullName == "System.Void") {
CodeExpressionStatement stmt = new CodeExpressionStatement(expr);
AddStatment(stmt);
}
@@ -880,7 +881,7 @@ public class Interpreter
//Console.WriteLine("Dup: {0}", variableType);
// HACK: the variable index shouldn't really be used in higher-levels
// so we just set the index to something that won't collide with existing ones.
- var variable = new VariableDefinition(variableName, index + 1024, this.method, variableType);
+ var variable = new VariableDefinition(variableName, variableType);
var lhs = new CodeVariableReference(variable);
AddAssignment(lhs, rhs);
@@ -971,7 +972,7 @@ public class Interpreter
Push(new CodePrimitiveExpression(value));
}
- private void PopParametersInto(ParameterDefinitionCollection parameterDefs, List<CodeExpression> result) {
+ private void PopParametersInto(Collection<ParameterDefinition> parameterDefs, List<CodeExpression> result) {
for (int i = parameterDefs.Count - 1; i >= 0; --i) {
var parameterDef = parameterDefs[i];
var arg = RefinePrimitiveExpression(Pop(), parameterDef.ParameterType);
@@ -1040,7 +1041,7 @@ public class Interpreter
else if (expression is CodeInvokeExpression) {
var reference = ((CodeInvokeExpression)expression).Method.Reference;
if (reference != null)
- return reference.ReturnType.ReturnType.FullName == Constants.Boolean;
+ return reference.ReturnType.FullName == "System.Boolean";
}
return false;
}
View
2 src/DotWeb.Decompiler/Core/TryStructure.cs
@@ -59,7 +59,7 @@ public class TryStructure
foreach (BasicBlock orphan in this.graph.Orphans) {
var first = orphan.Instructions.First();
if (orphan.ExceptionHandler.TryStart == headerBlock.ExceptionHandler.TryStart) {
- switch (orphan.ExceptionHandler.Type) {
+ switch (orphan.ExceptionHandler.HandlerType) {
case ExceptionHandlerType.Catch:
this.Catches.Add(orphan);
CollectNodes(orphan, false);
View
2 src/DotWeb.Hosting.Bridge/HostingServer.cs
@@ -53,7 +53,7 @@ class HostingServer : IHostingServer
public IPEndPoint EndPoint { get { return (IPEndPoint)this.listener.LocalEndpoint; } }
public string PrepareType(string binPath, AssemblyQualifiedTypeName aqtn) {
- var weaver = new HostingWeaver(binPath, binPath, new string[] { binPath }, false);
+ var weaver = new SimpleWeaver(binPath, binPath, new string[] { binPath }, false);
string path = Path.Combine(binPath, aqtn.AssemblyName.Name);
if (!path.EndsWith(".dll")) {
path += ".dll";
View
17 src/DotWeb.Hosting.Weaver/DotWeb.Hosting.Weaver.csproj
@@ -45,26 +45,15 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="CustomAttributeProcessor.cs" />
- <Compile Include="DotWebSystemAssembly.cs" />
- <Compile Include="ExceptionProcessor.cs" />
- <Compile Include="AssemblyProcessor.cs" />
- <Compile Include="ExternalAssembly.cs" />
- <Compile Include="ExternalType.cs" />
- <Compile Include="GenericProcessor.cs" />
- <Compile Include="HostingWeaver.cs" />
- <Compile Include="IResolver.cs" />
- <Compile Include="IType.cs" />
- <Compile Include="MethodProcessor.cs" />
- <Compile Include="OpCodeConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="ScopeProcessor.cs" />
- <Compile Include="TypeProcessor.cs" />
+ <Compile Include="SimpleWeaver.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\DotWeb.Hosting\DotWeb.Hosting.csproj">
View
20 src/DotWeb.Hosting.Weaver/ExternalType.cs
@@ -40,6 +40,18 @@ class ExternalType : IType
BindingFlags.Public |
BindingFlags.NonPublic;
+ private const BindingFlags StaticFlags =
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Static |
+ BindingFlags.Public |
+ BindingFlags.NonPublic;
+
+ private const BindingFlags InstanceFlags =
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Instance |
+ BindingFlags.Public |
+ BindingFlags.NonPublic;
+
public Type Type { get; protected set; }
public ExternalType(IResolver resolver, Type type) {
@@ -57,7 +69,13 @@ class ExternalType : IType
var argDefs = methodRef.Parameters.Cast<ParameterDefinition>();
var types = argDefs.Select(x => ResolveTypeReference(x)).ToArray();
if (methodRef.Name == ConstructorInfo.ConstructorName) {
- var ret = this.Type.GetConstructor(Flags, Type.DefaultBinder, types, null);
+ var ret = this.Type.GetConstructor(InstanceFlags, null, types, null);
+ if (ret == null)
+ throw new NullReferenceException(string.Format("Could not find ctor: {0}", methodRef.ToString()));
+ return ret;
+ }
+ else if (methodRef.Name == ConstructorInfo.TypeConstructorName) {
+ var ret = this.Type.GetConstructor(StaticFlags, null, types, null);
if (ret == null)
throw new NullReferenceException(string.Format("Could not find ctor: {0}", methodRef.ToString()));
return ret;
View
18 src/DotWeb.Hosting.Weaver/SimpleWeaver.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+namespace DotWeb.Hosting.Weaver
+{
+ public class SimpleWeaver
+ {
+ public SimpleWeaver(string inputDir, string outputDir, string[] searchDirs, bool forceBuild) {
+ }
+
+ public Assembly ProcessAssembly(string asmPath) {
+ return null;
+ }
+ }
+}
View
21 src/DotWeb.Translator/AttributeHelper.cs
@@ -35,11 +35,11 @@ public static class AttributeHelper
}
public static string GetJsNamespace(TypeReference typeRef) {
- return GetStringFromAttribute(typeRef, JsNamespace);
+ return GetStringFromAttribute(typeRef.Resolve(), JsNamespace);
}
public static string GetJsAugment(TypeReference typeRef) {
- return GetStringFromAttribute(typeRef, JsAugment);
+ return GetStringFromAttribute(typeRef.Resolve(), JsAugment);
}
public static string GetJsName(MemberReference memberRef) {
@@ -56,7 +56,7 @@ public static class AttributeHelper
var ret = GetBooleanFromAttribute(provider, JsCamelCase);
if (ret.HasValue)
return ret.Value;
- return GetBooleanFromAttribute(memberRef.DeclaringType, JsCamelCase) ?? false;
+ return GetBooleanFromAttribute(memberRef.DeclaringType.Resolve(), JsCamelCase) ?? false;
}
public static bool IsAnonymous(TypeReference type, TypeSystem typeSystem) {
@@ -67,7 +67,7 @@ public static class AttributeHelper
public static bool IsIntrinsic(PropertyReference propertyRef, TypeSystem typeSystem) {
var typeDef = typeSystem.GetTypeDefinition(JsInstrinsic);
return
- typeSystem.IsDefined(propertyRef.Resolve(), typeDef) ||
+ typeSystem.IsDefined(GetProvider(propertyRef), typeDef) ||
typeSystem.IsDefined(propertyRef.DeclaringType.Resolve(), typeDef);
}
@@ -76,9 +76,9 @@ public static class AttributeHelper
if (customAttr == null)
return null;
- var args = customAttr.ConstructorParameters;
+ var args = customAttr.ConstructorArguments;
if (args.Count == 1)
- return (string)args[0];
+ return (string)args[0].Value;
return "";
}
@@ -87,9 +87,9 @@ public static class AttributeHelper
if (customAttr == null)
return null;
- var args = customAttr.ConstructorParameters;
+ var args = customAttr.ConstructorArguments;
if (args.Count == 1)
- return (bool)args[0];
+ return (bool)args[0].Value;
return true;
}
@@ -114,7 +114,10 @@ public static class AttributeHelper
}
var propertyRef = memberRef as PropertyReference;
if (propertyRef != null) {
- return propertyRef.Resolve();
+ var genericParameter = propertyRef.PropertyType as GenericParameter;
+ if (genericParameter != null)
+ return genericParameter;
+ return propertyRef.PropertyType.Resolve();
}
return null;
}
View
6 src/DotWeb.Translator/Generator/JavaScript/JsCodeGenerator.cs
@@ -217,8 +217,8 @@ public class JsCodeGenerator: ICodeStatementVisitor, ICodeMemberVisitor
CodeVariableReference cvr = stmt.Left as CodeVariableReference;
if (cvr != null) {
- if (!locals.ContainsKey(cvr.Variable.Index)) {
- locals.Add(cvr.Variable.Index, cvr);
+ if (!locals.ContainsKey(cvr.Variable.GetName())) {
+ locals.Add(cvr.Variable.GetName(), cvr);
this.writer.Write("var ");
}
}
@@ -502,7 +502,7 @@ public class JsCodeGenerator: ICodeStatementVisitor, ICodeMemberVisitor
}
#endregion
- private readonly Dictionary<int, CodeVariableReference> locals = new Dictionary<int, CodeVariableReference>();
+ private readonly Dictionary<string, CodeVariableReference> locals = new Dictionary<string, CodeVariableReference>();
private readonly JsPrinter printer;
private readonly IndentedTextWriter writer;
private CodeMethodMember currentMethod;
View
15 src/DotWeb.Translator/Generator/JavaScript/JsPrinter.cs
@@ -294,21 +294,22 @@ class JsPrinter : ICodeExpressionVisitor<string>
}
if (methodDef.IsConstructor) {
- if (type.Constructors.Count == 1) {
+ var ctors = type.GetConstructors();
+ if (ctors.Count() == 1) {
return CtorMethodName;
}
else {
- return string.Format("{0}${1}", CtorMethodName, type.Constructors.IndexOf(methodDef));
+ return string.Format("{0}${1}", CtorMethodName, ctors.IndexOf(methodDef));
}
}
else {
- var match = type.Methods.GetMethod(method.Name);
- if (match.Length == 1) {
+ var match = type.GetMethods(method.Name);
+ if (match.Count == 1) {
return GetMemberName(method);
}
else {
// this is to handle overloaded methods (different argument types)
- for (int i = 0; i < match.Length; i++) {
+ for (int i = 0; i < match.Count; i++) {
var item = match[i];
if (item.MetadataToken == method.MetadataToken) {
var name = string.Format("{0}${1}", GetMemberName(method), i);
@@ -344,7 +345,7 @@ class JsPrinter : ICodeExpressionVisitor<string>
}
public string VisitReturn(CodeVariableReference exp) {
- return EncodeName(exp.Variable.Name);
+ return EncodeName(exp.Variable.GetName());
}
public string VisitReturn(CodeLengthReference expr) {
@@ -422,7 +423,7 @@ class JsPrinter : ICodeExpressionVisitor<string>
//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) {
+ if (exp.TargetType.FullName == "System.Int32" && type.FullName != "System.Int32") {
return string.Format("Math.floor({0})", Print(exp.Expression));
}
return Print(exp.Expression);
View
2 src/DotWeb.Translator/TranslationContext.cs
@@ -102,7 +102,7 @@ public class TranslationContext
}
this.generator.WriteTypeConstructor(type);
- var staticCtor = type.Constructors.Cast<MethodDefinition>().SingleOrDefault(x => x.IsStatic);
+ var staticCtor = type.GetStaticConstructor();
if (staticCtor != null) {
var staticCtorMethod = MethodDecompiler.ParseStaticConstructor(this.typeSystem, staticCtor);
if (staticCtorMethod.Statements.Any() || !string.IsNullOrEmpty(staticCtorMethod.NativeCode)) {
View
21 src/DotWeb.Translator/TranslationEngine.cs
@@ -32,7 +32,7 @@ namespace DotWeb.Translator
public class TranslationEngine
{
private JsCodeGenerator generator;
- private GlobalAssemblyResolver resolver = new GlobalAssemblyResolver();
+ private DotWeb.Utility.Cecil.GlobalAssemblyResolver resolver = new DotWeb.Utility.Cecil.GlobalAssemblyResolver();
private TypeSystem typeSystem;
public TranslationEngine(TextWriter writer, bool writeHeader, string path) {
@@ -43,18 +43,19 @@ public class TranslationEngine
private string[] TranslateType(TypeDefinition type) {
var context = new TranslationContext(this.typeSystem, this.generator);
- var method = type.Constructors.GetConstructor(false, Type.EmptyTypes);
+ var method = type.GetConstructor(null);
var asmDependencies = new List<AssemblyDefinition>();
context.GenerateMethod(method, true, asmDependencies);
this.generator.WriteEntryPoint(type);
- string[] ret = new string[asmDependencies.Count];
- for (int i = 0; i < ret.Length; i++) {
- var asm = asmDependencies[i];
- var path = asm.MainModule.Image.FileInformation.FullName;
- ret[i] = path;
- }
- return ret;
+ //string[] ret = new string[asmDependencies.Count];
+ //for (int i = 0; i < ret.Length; i++) {
+ // var asm = asmDependencies[i];
+ // var path = asm.MainModule.Image.FileInformation.FullName;
+ // ret[i] = path;
+ //}
+ //return ret;
+ return asmDependencies.Select(x => x.Name.Name).ToArray();
}
/// <summary>
@@ -65,7 +66,7 @@ public class TranslationEngine
/// <returns></returns>
public string[] TranslateType(AssemblyQualifiedTypeName aqtn) {
var asm = this.typeSystem.LoadAssembly(aqtn.AssemblyName.FullName);
- var typeDef = asm.MainModule.Types[aqtn.TypeName];
+ var typeDef = asm.MainModule.GetType(aqtn.TypeName);
return TranslateType(typeDef);
}
}
View
11 src/DotWeb.Utility/AssociatedProperty.cs
@@ -17,6 +17,7 @@
using System.Reflection;
using Mono.Cecil;
+using System.Linq;
namespace DotWeb.Utility
{
@@ -34,24 +35,26 @@ public class ReflectedAssociatedProperty
public static class AssociatedPropertyExtensions
{
+ public static PropertyDefinition GetProperty(this TypeDefinition type, string name) {
+ return type.Properties.Where(x => x.Name == name).FirstOrDefault();
+ }
+
public static MonoAssociatedProperty GetMonoAssociatedProperty(this MethodDefinition method) {
if (method.IsSpecialName) {
var type = method.DeclaringType;
if (method.Name.StartsWith("get_")) {
string propName = method.Name.Substring("get_".Length);
- var properties = type.Properties.GetProperties(propName);
return new MonoAssociatedProperty {
- Definition = properties[0],
+ Definition = type.GetProperty(propName),
IsGetter = true
};
}
if (method.Name.StartsWith("set_")) {
string propName = method.Name.Substring("set_".Length);
- var properties = type.Properties.GetProperties(propName);
return new MonoAssociatedProperty {
- Definition = properties[0],
+ Definition = type.GetProperty(propName),
IsGetter = false
};
}
View
71 src/DotWeb.Utility/Cecil/Extensions.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Cecil;
+using Mono.Collections.Generic;
+using Mono.Cecil.Cil;
+
+namespace DotWeb.Utility.Cecil
+{
+ public static class Extensions
+ {
+ public static Collection<MethodDefinition> GetConstructors(this TypeDefinition type) {
+ var ret = new Collection<MethodDefinition>();
+ foreach (var method in type.Methods) {
+ if (method.IsConstructor)
+ ret.Add(method);
+ }
+ return ret;
+ }
+
+ public static Collection<MethodDefinition> GetMethods(this TypeDefinition type, string name) {
+ var ret = new Collection<MethodDefinition>();
+ foreach (var method in type.Methods) {
+ if (method.Name == name)
+ ret.Add(method);
+ }
+ return ret;
+ }
+
+ public static Collection<MethodDefinition> GetMethods(this TypeDefinition type)
+ {
+ var ret = new Collection<MethodDefinition>();
+ foreach (var method in type.Methods) {
+ if(!method.IsConstructor)
+ ret.Add(method);
+ }
+ return ret;
+ }
+
+ public static MethodDefinition GetStaticConstructor(this TypeDefinition type) {
+ return type.Methods.FirstOrDefault(x => x.IsConstructor && x.IsStatic);
+ }
+
+ public static MethodDefinition GetConstructor(this TypeDefinition type, TypeReference[] parameterTypes) {
+ var ctors = type.GetConstructors();
+ return ctors.SingleOrDefault(x => ParameterTypesMatch(x.Parameters, parameterTypes));
+ }
+
+ private static bool ParameterTypesMatch(Collection<ParameterDefinition> lhs, TypeReference[] rhs) {
+ if (rhs == null)
+ return lhs.Count == 0;
+
+ if (lhs.Count != rhs.Length)
+ return false;
+
+ for (int i = 0; i < lhs.Count; i++) {
+ if (lhs[i].ParameterType != rhs[i])
+ return false;
+ }
+
+ return true;
+ }
+
+ public static string GetName(this VariableReference variable) {
+ if (string.IsNullOrEmpty(variable.Name))
+ return "V_" + variable.Index;
+ return variable.Name;
+ }
+ }
+}
View
257 src/DotWeb.Utility/Cecil/GlobalAssemblyResolver.cs
@@ -18,9 +18,265 @@
using System;
using System.Collections.Generic;
using Mono.Cecil;
+using System.IO;
+using System.Text;
+using Mono.Cecil.Cil;
+using System.Reflection;
namespace DotWeb.Utility.Cecil
{
+ public abstract class BaseAssemblyResolver : IAssemblyResolver
+ {
+ static readonly bool on_mono = Type.GetType("Mono.Runtime") != null;
+
+ readonly List<string> directories;
+ readonly List<string> gac_paths;
+
+ private ISymbolReaderProvider provider;
+
+ public void AddSearchDirectory(string directory) {
+ directories.Add(directory);
+ }
+
+ public void RemoveSearchDirectory(string directory) {
+ directories.Remove(directory);
+ }
+
+ public virtual AssemblyDefinition Resolve(string fullName) {
+ return Resolve(AssemblyNameReference.Parse(fullName));
+ }
+
+ protected BaseAssemblyResolver() {
+ directories = new List<string> { ".", "bin" };
+ gac_paths = GetGacPaths();
+ this.provider = GetPlatformReaderProvider();
+ }
+
+ static readonly string symbol_kind = Type.GetType("Mono.Runtime") != null ? "Mdb" : "Pdb";
+
+ private static ISymbolReaderProvider GetPlatformReaderProvider() {
+ var type = GetPlatformType(string.Format("Mono.Cecil.{0}.{0}ReaderProvider", symbol_kind));
+ if (type == null)
+ return null;
+
+ return (ISymbolReaderProvider)Activator.CreateInstance(type);
+ }
+
+ private static Type GetPlatformType(string fullname) {
+ var cecil_name = typeof(AssemblyDefinition).Assembly.GetName();
+ var name = new AssemblyName {
+ Name = "Mono.Cecil." + symbol_kind,
+ Version = cecil_name.Version,
+ };
+ name.SetPublicKeyToken(cecil_name.GetPublicKeyToken());
+
+ var assembly = Assembly.Load(name);
+ if (assembly != null)
+ return assembly.GetType(fullname);
+ return null;
+ }
+
+ AssemblyDefinition GetAssembly(string file, bool readSymbols) {
+ var readerParameters = new ReaderParameters {
+ AssemblyResolver = this,
+ SymbolReaderProvider = readSymbols ? this.provider : null
+ };
+
+ return ModuleDefinition.ReadModule(file, readerParameters).Assembly;
+ }
+
+ public virtual AssemblyDefinition Resolve(AssemblyNameReference name) {
+ var assembly = SearchDirectory(name, directories);
+ if (assembly != null)
+ return assembly;
+
+ var framework_dir = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName);
+
+ if (IsZero(name.Version)) {
+ assembly = SearchDirectory(name, new[] { framework_dir });
+ if (assembly != null)
+ return assembly;
+ }
+
+ if (name.Name == "mscorlib") {
+ assembly = GetCorlib(name);
+ if (assembly != null)
+ return assembly;
+ }
+
+ assembly = GetAssemblyInGac(name);
+ if (assembly != null)
+ return assembly;
+
+ assembly = SearchDirectory(name, new[] { framework_dir });
+ if (assembly != null)
+ return assembly;
+
+ throw new FileNotFoundException("Could not resolve: " + name);
+ }
+
+ AssemblyDefinition SearchDirectory(AssemblyNameReference name, IEnumerable<string> directories) {
+ var extensions = new[] { ".exe", ".dll" };
+ foreach (var directory in directories) {
+ foreach (var extension in extensions) {
+ string file = Path.Combine(directory, name.Name + extension);
+ if (File.Exists(file))
+ return GetAssembly(file, true);
+ }
+ }
+
+ return null;
+ }
+
+ static bool IsZero(Version version) {
+ return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0;
+ }
+
+ AssemblyDefinition GetCorlib(AssemblyNameReference reference) {
+ var version = reference.Version;
+ var corlib = typeof(object).Assembly.GetName();
+
+ if (corlib.Version == version || IsZero(version))
+ return GetAssembly(typeof(object).Module.FullyQualifiedName, false);
+
+ var path = Directory.GetParent(
+ Directory.GetParent(
+ typeof(object).Module.FullyQualifiedName).FullName
+ ).FullName;
+
+ if (on_mono) {
+ if (version.Major == 1)
+ path = Path.Combine(path, "1.0");
+ else if (version.Major == 2) {
+ if (version.MajorRevision == 5)
+ path = Path.Combine(path, "2.1");
+ else
+ path = Path.Combine(path, "2.0");
+ }
+ else if (version.Major == 4)
+ path = Path.Combine(path, "4.0");
+ else
+ throw new NotSupportedException("Version not supported: " + version);
+ }
+ else {
+ switch (version.Major) {
+ case 1:
+ if (version.MajorRevision == 3300)
+ path = Path.Combine(path, "v1.0.3705");
+ else
+ path = Path.Combine(path, "v1.0.5000.0");
+ break;
+ case 2:
+ path = Path.Combine(path, "v2.0.50727");
+ break;
+ case 4:
+ path = Path.Combine(path, "v4.0.30319");
+ break;
+ default:
+ throw new NotSupportedException("Version not supported: " + version);
+ }
+ }
+
+ var file = Path.Combine(path, "mscorlib.dll");
+ if (File.Exists(file))
+ return GetAssembly(file, false);
+
+ return null;
+ }
+
+ static List<string> GetGacPaths() {
+ if (on_mono)
+ return GetDefaultMonoGacPaths();
+
+ var paths = new List<string>(2);
+ var windir = Environment.GetEnvironmentVariable("WINDIR");
+ if (windir == null)
+ return paths;
+
+ paths.Add(Path.Combine(windir, "assembly"));
+ paths.Add(Path.Combine(windir, Path.Combine("Microsoft.NET", "assembly")));
+ return paths;
+ }
+
+ static List<string> GetDefaultMonoGacPaths() {
+ var paths = new List<string>(1);
+ var gac = GetCurrentMonoGac();
+ if (gac != null)
+ paths.Add(gac);
+
+ var gac_paths_env = Environment.GetEnvironmentVariable("MONO_GAC_PREFIX");
+ if (string.IsNullOrEmpty(gac_paths_env))
+ return paths;
+
+ var prefixes = gac_paths_env.Split(Path.PathSeparator);
+ foreach (var prefix in prefixes) {
+ if (string.IsNullOrEmpty(prefix))
+ continue;
+
+ var gac_path = Path.Combine(Path.Combine(Path.Combine(prefix, "lib"), "mono"), "gac");
+ if (Directory.Exists(gac_path) && !paths.Contains(gac))
+ paths.Add(gac_path);
+ }
+
+ return paths;
+ }
+
+ static string GetCurrentMonoGac() {
+ return Path.Combine(Directory.GetParent(typeof(object).Module.FullyQualifiedName).FullName, "gac");
+ }
+
+ AssemblyDefinition GetAssemblyInGac(AssemblyNameReference reference) {
+ if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
+ return null;
+
+ if (on_mono)
+ return GetAssemblyInMonoGac(reference);
+
+ return GetAssemblyInNetGac(reference);
+ }
+
+ AssemblyDefinition GetAssemblyInMonoGac(AssemblyNameReference reference) {
+ for (int i = 0; i < gac_paths.Count; i++) {
+ var gac_path = gac_paths[i];
+ var file = GetAssemblyFile(reference, string.Empty, gac_path);
+ if (File.Exists(file))
+ return GetAssembly(file, false);
+ }
+
+ return null;
+ }
+
+ AssemblyDefinition GetAssemblyInNetGac(AssemblyNameReference reference) {
+ var gacs = new[] { "GAC_MSIL", "GAC_32", "GAC" };
+ var prefixes = new[] { string.Empty, "v4.0_" };
+
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < gacs.Length; j++) {
+ var gac = Path.Combine(gac_paths[i], gacs[j]);
+ var file = GetAssemblyFile(reference, prefixes[i], gac);
+ if (Directory.Exists(gac) && File.Exists(file))
+ return GetAssembly(file, false);
+ }
+ }
+
+ return null;
+ }
+
+ static string GetAssemblyFile(AssemblyNameReference reference, string prefix, string gac) {
+ var gac_folder = new StringBuilder();
+ gac_folder.Append(prefix);
+ gac_folder.Append(reference.Version);
+ gac_folder.Append("__");
+ for (int i = 0; i < reference.PublicKeyToken.Length; i++)
+ gac_folder.Append(reference.PublicKeyToken[i].ToString("x2"));
+
+ return Path.Combine(
+ Path.Combine(
+ Path.Combine(gac, reference.Name), gac_folder.ToString()),
+ reference.Name + ".dll");
+ }
+ }
+
public class GlobalAssemblyResolver : BaseAssemblyResolver
{
private Dictionary<string, AssemblyDefinition> cache = new Dictionary<string, AssemblyDefinition>();
@@ -33,7 +289,6 @@ public class GlobalAssemblyResolver : BaseAssemblyResolver
if (ret.Name.FullName != name.FullName) {
this.cache.Add(name.FullName, ret);
}
- ret.Resolver = this;
}
return ret;
}
View
6 src/DotWeb.Utility/Cecil/MethodReferenceExtenstions.cs
@@ -25,10 +25,8 @@ namespace DotWeb.Utility.Cecil
public static class MethodReferenceExtenstions
{
private static string GetMethodSignature(MethodReference method, bool prependTypeName) {
- int sentinel = method.GetSentinel();
-
var sb = new StringBuilder();
- sb.Append(method.ReturnType.ReturnType.FullName);
+ sb.Append(method.ReturnType.FullName);
sb.Append(" ");
if (prependTypeName) {
sb.Append(method.DeclaringType.FullName);
@@ -41,7 +39,7 @@ public static class MethodReferenceExtenstions
if (i > 0)
sb.Append(",");
- if (i == sentinel)
+ if (method.Parameters[i].ParameterType.IsSentinel)
sb.Append("...,");
sb.Append(method.Parameters[i].ParameterType.FullName);
View
6 src/DotWeb.Utility/Cecil/TypeDefinitionCache.cs
@@ -30,12 +30,12 @@ public static class ConstantTypeNames
public class TypeDefinitionCache
{
public TypeDefinitionCache(TypeSystem typeSystem) {
- this.Object = typeSystem.GetTypeDefinition(Constants.Object);
+ this.Object = typeSystem.GetTypeDefinition("System.Object");
this.JsObject = typeSystem.GetTypeDefinition(ConstantTypeNames.JsObject);
this.Delegate = typeSystem.GetTypeDefinition(ConstantTypeNames.Delegate);
this.Exception = typeSystem.GetTypeDefinition(ConstantTypeNames.Exception);
- this.Boolean = typeSystem.GetTypeDefinition(Constants.Boolean);
- this.Int32 = typeSystem.GetTypeDefinition(Constants.Int32);
+ this.Boolean = typeSystem.GetTypeDefinition("System.Boolean");
+ this.Int32 = typeSystem.GetTypeDefinition("System.Int32");
}
public TypeDefinition Object { get; private set; }
View
60 src/DotWeb.Utility/Cecil/TypeSystem.cs
@@ -40,20 +40,14 @@ public class VirtualsDictionary
genericTypesByName.Add(genericParameter.Name, genericArgument);
}
- var returnType = methodRef.ReturnType.ReturnType;
+ var returnType = methodRef.ReturnType;
if (returnType is GenericParameter) {
// try to resolve the type based on the context of the declaringType
returnType = genericTypesByName[returnType.Name];
}
- var reference = new MethodReference(
- methodRef.Name,
- typeDef,
- returnType,
- methodRef.HasThis,
- methodRef.ExplicitThis,
- MethodCallingConvention.Generic);
-
+ var reference = new MethodReference(methodRef.Name, returnType);
+ reference.DeclaringType = methodRef.DeclaringType;
foreach (ParameterDefinition parameter in methodRef.Parameters) {
var parameterType = parameter.ParameterType;
var genericParameter = parameterType as GenericParameter;
@@ -199,7 +193,7 @@ public static class Names
}
}
- private void ProcessType(TypeDefinition typeDef) {
+ public void ProcessType(TypeDefinition typeDef) {
var virtuals = new VirtualsDictionary();
virtuals.CollectVirtualMethods(typeDef);
@@ -217,10 +211,14 @@ public static class Names
}
ProcessInterfaces(virtuals, typeDef);
+
+ foreach (var nestedType in typeDef.NestedTypes) {
+ ProcessType(nestedType);
+ }
}
public TypeDefinition GetTypeDefinition(string typeName) {
- return this.asmSystem.MainModule.Types[typeName];
+ return this.asmSystem.MainModule.GetType(typeName);
}
public TypeDefinition GetTypeDefinition(Type type) {
@@ -229,43 +227,43 @@ public static class Names
public static Type GetReflectionType(TypeReference type) {
switch (type.FullName) {
- case Constants.Boolean:
+ case "System.Boolean":
return typeof(Boolean);
- case Constants.Byte:
+ case "System.Byte":
return typeof(Byte);
- case Constants.Char:
+ case "System.Char":
return typeof(Char);
- case Constants.Double:
+ case "System.Double":
return typeof(Double);
- case Constants.Enum:
+ case "System.Enum":
return typeof(Enum);
- case Constants.Int16:
+ case "System.Int16":
return typeof(Int16);
- case Constants.Int32:
+ case "System.Int32":
return typeof(Int32);
- case Constants.Int64:
+ case "System.Int64":
return typeof(Int64);
- case Constants.IntPtr:
+ case "System.IntPtr":
return typeof(IntPtr);
- case Constants.Object:
+ case "System.Object":
return typeof(Object);
- case Constants.SByte:
+ case "System.SByte":
return typeof(SByte);
- case Constants.Single:
+ case "System.Single":
return typeof(Single);
- case Constants.String:
+ case "System.String":
return typeof(String);
- case Constants.Type:
+ case "System.Type":
return typeof(Type);
- case Constants.UInt16:
+ case "System.UInt16":
return typeof(UInt16);
- case Constants.UInt32:
+ case "System.UInt32":
return typeof(UInt32);
- case Constants.UInt64:
+ case "System.UInt64":
return typeof(UInt64);
- case Constants.UIntPtr:
+ case "System.UIntPtr":
return typeof(UIntPtr);
- case Constants.Void:
+ case "System.Void":
return typeof(void);
case ConstantTypeNames.Delegate:
return typeof(Delegate);
@@ -287,7 +285,7 @@ public static class Names
}
public bool IsDefined(ICustomAttributeProvider provider, string attributeTypeName) {
- TypeReference attributeType = asmSystem.MainModule.Types[attributeTypeName];
+ TypeReference attributeType = asmSystem.MainModule.GetType(attributeTypeName);
return IsDefined(provider, attributeType);
}
View
7 src/DotWeb.Utility/DotWeb.Utility.csproj
@@ -33,14 +33,10 @@
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Mono.Cecil, Version=0.6.9.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Mono.Cecil, Version=0.9.3.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Depends\Mono.Cecil.dll</HintPath>
</Reference>
- <Reference Include="Mono.Cecil.Pdb, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\Depends\Mono.Cecil.Pdb.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -56,6 +52,7 @@
<Compile Include="AssociatedProperty.cs" />
<Compile Include="AttributeExtensions.cs" />
<Compile Include="BitVector.cs" />
+ <Compile Include="Cecil\Extensions.cs" />
<Compile Include="Cecil\GlobalAssemblyResolver.cs" />
<Compile Include="Cecil\MethodReferenceExtenstions.cs" />
<Compile Include="Cecil\TypeDefinitionCache.cs" />
View
2 src/DotWebWeaver/Program.cs
@@ -39,7 +39,7 @@ class Program
string inputDir = Path.GetDirectoryName(inputPath);
Console.WriteLine("Weaving {0}", inputPath);
- var weaver = new HostingWeaver(inputDir, inputDir, searchDirs, false);
+ var weaver = new SimpleWeaver(inputDir, inputDir, searchDirs, false);
weaver.ProcessAssembly(inputPath);
}
}
View
2 test/DotWeb.Hosting.Test/HostingWeaverTest.cs
@@ -58,7 +58,7 @@ class HostHarness : IDotWebHost
public HostingWeaverTest() {
var thisAsm = Assembly.GetExecutingAssembly();
string dir = Path.GetDirectoryName(thisAsm.Location);
- var weaver = new HostingWeaver(dir, dir, new string[] { dir }, true);
+ var weaver = new SimpleWeaver(dir, dir, new string[] { dir }, true);
string asmPath = "DotWeb.Weaver.Test.Script.dll";
weaver.ProcessAssembly(asmPath);
View
33 test/DotWeb.Translator.Test/DotWeb.Translator.Test.csproj
@@ -66,6 +66,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Arrays.resx</DependentUpon>
</Compile>
+ <Compile Include="Resources\CommonMethods.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>CommonMethods.resx</DependentUpon>
+ </Compile>
<Compile Include="Resources\Conditionals.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -129,6 +134,30 @@
<Content Include="Expected\Arrays\CreateIntArray.js" />
<Content Include="Expected\Arrays\CreateStringArray.js" />
<Content Include="Expected\Arrays\CreateArrayOfArrays.js" />
+ <Content Include="Expected\CommonMethods\System.Collections.Generic.Dictionary_2.Init.js" />
+ <Content Include="Expected\CommonMethods\System.Collections.Generic.Dictionary_2.js" />
+ <Content Include="Expected\CommonMethods\System.Collections.Generic.Dictionary_2.InitArrays.js" />
+ <Content Include="Expected\CommonMethods\System.ArgumentOutOfRangeException.get_Message.js" />
+ <Content Include="Expected\CommonMethods\System.ArgumentException.get_Message.js" />
+ <Content Include="Expected\CommonMethods\System.Exception.get_Message.js" />
+ <Content Include="Expected\CommonMethods\String.format_0.js" />
+ <Content Include="Expected\CommonMethods\System.String_FormatSpecifier.IsWhiteSpace.js" />
+ <Content Include="Expected\CommonMethods\System.Text.StringBuilder.Append_3.js" />
+ <Content Include="Expected\CommonMethods\System.Exception.toString.js" />
+ <Content Include="Expected\CommonMethods\System.FormatException.js" />
+ <Content Include="Expected\CommonMethods\System.SystemException.js" />
+ <Content Include="Expected\CommonMethods\System.Exception.js" />
+ <Content Include="Expected\CommonMethods\System.Text.StringBuilder._ctor.js" />
+ <Content Include="Expected\CommonMethods\System.Console.WriteLine_1.js" />
+ <Content Include="Expected\CommonMethods\System.Console.WriteLine_0.js" />
+ <Content Include="Expected\CommonMethods\System.Text.StringBuilder.toString.js" />
+ <Content Include="Expected\CommonMethods\System.Text.StringBuilder.Append_1.js" />
+ <Content Include="Expected\CommonMethods\System.String_FormatSpecifier.ParseFormatSpecifier.js" />
+ <Content Include="Expected\CommonMethods\String._Substring_1.js" />
+ <Content Include="Expected\CommonMethods\System.String_FormatSpecifier.ParseDecimal.js" />
+ <Content Include="Expected\CommonMethods\System.Text.StringBuilder.Append_5.js" />
+ <Content Include="Expected\CommonMethods\String.formatHelper.js" />
+ <Content Include="Expected\CommonMethods\System.Text.StringBuilder.Append_0.js" />
<Content Include="Expected\Conditionals\CharLiteralIf.js" />
<Content Include="Expected\Conditionals\Debug\CharLiteralIf.js" />
<Content Include="Expected\Conditionals\Debug\IfAndAnd.js" />
@@ -315,6 +344,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="Resources\CommonMethods.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>CommonMethods.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
<EmbeddedResource Include="Resources\Conditionals.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Conditionals.Designer.cs</LastGenOutput>
View
29 test/DotWeb.Translator.Test/Expected/CommonMethods/String._Substring_1.js
@@ -0,0 +1,29 @@
+String.prototype._Substring$1 = function(startIndex, length) {
+ var CS$4$0001 = length >= 0;
+ if (!CS$4$0001) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("length", "Cannot be negative.");
+ }
+ CS$4$0001 = startIndex >= 0;
+ if (!CS$4$0001) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("startIndex", "Cannot be negative.");
+ }
+ CS$4$0001 = startIndex <= this.length;
+ if (!CS$4$0001) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("startIndex", "Cannot exceed length of string.");
+ }
+ CS$4$0001 = startIndex <= (this.length - length);
+ if (!CS$4$0001) {
+ throw new System.ArgumentOutOfRangeException().$ctor$3("length", "startIndex + length > this.length");
+ }
+ if (!startIndex) {
+ var R_1 = length != this.length;
+ }
+ else {
+ R_1 = 1;
+ }
+ CS$4$0001 = R_1;
+ if (!CS$4$0001) {
+ return this;
+ }
+ return this.substring(startIndex, startIndex + length);
+};
View
91 test/DotWeb.Translator.Test/Expected/CommonMethods/String.formatHelper.js
@@ -0,0 +1,91 @@
+String.formatHelper = function(result, format, args) {
+ var CS$4$0001 = format != null;
+ if (!CS$4$0001) {
+ throw new System.ArgumentNullException().$ctor$1("format");
+ }
+ CS$4$0001 = args != null;
+ if (!CS$4$0001) {
+ throw new System.ArgumentNullException().$ctor$1("args");
+ }
+ CS$4$0001 = result != null;
+ if (!CS$4$0001) {
+ result = new System.Text.StringBuilder().$ctor();
+ }
+ var ptr = 0;
+ var start = ptr;
+ while (true) {
+ CS$4$0001 = ptr < format.length;
+ if (!CS$4$0001) {
+ break;
+ }
+ var D_0 = ptr;
+ ptr = D_0 + 1;
+ var ch = format.charAt(D_0);
+ CS$4$0001 = ch != '{';
+ if (!CS$4$0001) {
+ result.Append$5(format, start, (ptr - start) - 1);
+ CS$4$0001 = format.charAt(ptr) != '{';
+ if (!CS$4$0001) {
+ var D_2 = ptr;
+ ptr = D_2 + 1;
+ start = D_2;
+ continue;
+ }
+ var specifier = new System.String_FormatSpecifier().$ctor(format, ptr);
+ ptr = specifier.ptr;
+ CS$4$0001 = specifier.n < args.length;
+ if (!CS$4$0001) {
+ 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 arg = args[specifier.n];
+ CS$4$0001 = arg != null;
+ if (!CS$4$0001) {
+ var str = "";
+ }
+ str = arg.toString();
+ CS$4$0001 = specifier.width <= str.length;
+ if (!CS$4$0001) {
+ var padlen = specifier.width - str.length;
+ CS$4$0001 = !specifier.left_align;
+ if (!CS$4$0001) {
+ result.Append$0(str);
+ result.Append$3(' ', padlen);
+ }
+ else {
+ result.Append$3(' ', padlen);
+ result.Append$0(str);
+ }
+ }
+ else {
+ result.Append$0(str);
+ }
+ start = ptr;
+ CS$4$0001 = R_1;
+ if (!CS$4$0001) {
+ result.Append$5(format, start, (ptr - start) - 1);
+ var D_1 = ptr;
+ ptr = D_1 + 1;
+ start = D_1;
+ }
+ else {
+ CS$4$0001 = ch != '}';
+ if (!CS$4$0001) {
+ throw new System.FormatException().$ctor$1("Input string was not in a correct format.");
+ }
+ }
+ }
+ else {
+ if ((ch == '}') && (ptr < format.length)) {
+ var R_1 = format.charAt(ptr) != '}';
+ }
+ else {
+ R_1 = 1;
+ }
+ }
+ }
+ CS$4$0001 = start >= format.length;
+ if (!CS$4$0001) {
+ result.Append$5(format, start, format.length - start);
+ }
+ return result;
+};
View
6 test/DotWeb.Translator.Test/Expected/CommonMethods/String.format_0.js
@@ -0,0 +1,6 @@
+String.format$0 = function(format, arg0) {
+ var CS$0$0001 = $Array(1, null);
+ CS$0$0001[0] = arg0;
+ var sb = String.formatHelper(null, format, CS$0$0001);
+ return sb.toString();
+};
View
14 test/DotWeb.Translator.Test/Expected/CommonMethods/System.ArgumentException.get_Message.js
@@ -0,0 +1,14 @@
+System.ArgumentException.prototype.get_Message = function() {
+ var message = this.$super.get_Message();
+ if (this.get_ParamName()) {
+ var R_1 = this.get_ParamName().length == 0;
+ }
+ else {
+ R_1 = 1;
+ }
+ var CS$4$0001 = R_1;
+ if (!CS$4$0001) {
+ return message + "\nParameter name: " + this.get_ParamName();
+ }
+ return message;
+};
View
13 ....Translator.Test/Expected/CommonMethods/System.ArgumentOutOfRangeException.get_Message.js
@@ -0,0 +1,13 @@
+System.ArgumentOutOfRangeException.prototype.get_Message = function() {
+ var message = this.$super.get_Message();
+ var CS$4$0001 = this.get_ActualValue() != null;
+ if (!CS$4$0001) {
+ return message;
+ }
+ var str2 = "Actual value was " + this.get_ActualValue().toString();
+ CS$4$0001 = message != null;
+ if (!CS$4$0001) {
+ return str2;
+ }
+ return message + "\n" + str2;
+};
View
21 ...eb.Translator.Test/Expected/CommonMethods/System.Collections.Generic.Dictionary_2.Init.js
@@ -0,0 +1,21 @@
+System.Collections.Generic.Dictionary$2.prototype.Init = function(capacity, hcp) {
+ var CS$4$0000 = capacity >= 0;
+ if (!CS$4$0000) {
+ throw new System.ArgumentOutOfRangeException().$ctor$1("capacity");
+ }
+ var R_1 = this;
+ if (!hcp) {
+ var R_2 = System.Collections.Generic.EqualityComparer$1.get_Default();
+ }
+ else {
+ R_2 = hcp;
+ }
+ R_1.hcp = R_2;
+ CS$4$0000 = capacity != 0;
+ if (!CS$4$0000) {
+ capacity = 10;
+ }
+ capacity = Math.floor(capacity / 0.9) + 1;
+ this.InitArrays(capacity);
+ this.generation = 0;
+};
View
19 ...nslator.Test/Expected/CommonMethods/System.Collections.Generic.Dictionary_2.InitArrays.js
@@ -0,0 +1,19 @@
+System.Collections.Generic.Dictionary$2.prototype.InitArrays = function(size) {
+ this.table = $Array(size, 0);
+ this.linkSlots = $Array(size, null);
+ this.emptySlot = -1;
+ this.keySlots = $Array(size, null);
+ this.valueSlots = $Array(size, null);
+ this.touchedSlots = 0;
+ this.threshold = Math.floor(this.table.length * 0.9);
+ if (!this.threshold) {
+ var R_1 = this.table.length <= 0;
+ }
+ else {
+ R_1 = 1;
+ }
+ var CS$4$0000 = R_1;
+ if (!CS$4$0000) {
+ this.threshold = 1;
+ }
+};
View
10 .../DotWeb.Translator.Test/Expected/CommonMethods/System.Collections.Generic.Dictionary_2.js
@@ -0,0 +1,10 @@
+$Class(null, 'System.Collections.Generic', 'Dictionary$2', { table: null, linkSlots: null, keySlots: null, valueSlots: null, touchedSlots: 0, emptySlot: 0, count: 0, threshold: 0, hcp: null, generation: 0 });
+
+(function() {
+ System.Collections.Generic.Dictionary$2.INITIAL_SIZE = 10;
+ System.Collections.Generic.Dictionary$2.DEFAULT_LOAD_FACTOR = 0.9;
+ System.Collections.Generic.Dictionary$2.NO_SLOT = -1;
+ System.Collections.Generic.Dictionary$2.HASH_FLAG = -2147483648;
+ var D_0 = [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];
+ System.Collections.Generic.Dictionary$2.primeTable = D_0;
+})();
View
3 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Console.WriteLine_0.js
@@ -0,0 +1,3 @@
+System.Console.WriteLine$0 = function(value) {
+ System.Console.WriteLine$1(value.toString());
+};
View
3 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Console.WriteLine_1.js
@@ -0,0 +1,3 @@
+System.Console.WriteLine$1 = function(value) {
+ console.log(value);
+};
View
7 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Exception.get_Message.js
@@ -0,0 +1,7 @@
+System.Exception.prototype.get_Message = function() {
+ var CS$4$0001 = this.message != null;
+ if (!CS$4$0001) {
+ this.message = String.format$0("Exception of type '{0}' was thrown.", this.$typename);
+ }
+ return this.message;
+};
View
10 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Exception.js
@@ -0,0 +1,10 @@
+$Class(null, 'System', 'Exception', { message: null, _InnerException_k__BackingField: null, _Source_k__BackingField: null, _StackTrace_k__BackingField: null });
+
+System.Exception.prototype.set_Message = function(value) {
+ this.message = value;
+};
+
+System.Exception.prototype.$ctor$1 = function(message) {
+ this.set_Message(message);
+ return this;
+};
View
12 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Exception.toString.js
@@ -0,0 +1,12 @@
+System.Exception.prototype.toString = function() {
+ var result = new System.Text.StringBuilder().$ctor();
+ result.Append$0(this.$typename);
+ result.Append$0(": ").Append$0(this.get_Message());
+ var CS$4$0001 = this.get_InnerException() == null;
+ if (!CS$4$0001) {
+ result.Append$0(" ---> ").Append$0(this.get_InnerException().toString());
+ result.AppendLine$0();
+ result.Append$0(" --- End of inner exception stack trace ---");
+ }
+ return result.toString();
+};
View
6 test/DotWeb.Translator.Test/Expected/CommonMethods/System.FormatException.js
@@ -0,0 +1,6 @@
+$Class(System.SystemException, 'System', 'FormatException');
+
+System.FormatException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
+ return this;
+};
View
10 ...tWeb.Translator.Test/Expected/CommonMethods/System.String_FormatSpecifier.IsWhiteSpace.js
@@ -0,0 +1,10 @@
+System.String_FormatSpecifier.prototype.IsWhiteSpace = function() {
+ var ch = this.str.charCodeAt(this.ptr);
+ if ((((ch < 9) || (ch > 13)) && (ch != 32)) && (ch != 133)) {
+ var R_1 = ch == 8287;
+ }
+ else {
+ R_1 = 1;
+ }
+ return R_1;
+};
View
26 ...tWeb.Translator.Test/Expected/CommonMethods/System.String_FormatSpecifier.ParseDecimal.js
@@ -0,0 +1,26 @@
+System.String_FormatSpecifier.prototype.ParseDecimal = function() {
+ var p = this.ptr;
+ var n = 0;
+ while (true) {
+ var CS$4$0001 = true;
+ var ch = this.str.charCodeAt(p);
+ if (ch >= 48) {
+ var R_1 = 57 >= ch;
+ }
+ else {
+ R_1 = 0;
+ }
+ CS$4$0001 = R_1;
+ if (!CS$4$0001) {
+ break;
+ }
+ n = ((n * 10) + ch) - 48;
+ p = p + 1;
+ }
+ CS$4$0001 = p != this.ptr;
+ if (!CS$4$0001) {
+ return -1;
+ }
+ this.ptr = p;
+ return n;
+};
View
71 ...nslator.Test/Expected/CommonMethods/System.String_FormatSpecifier.ParseFormatSpecifier.js
@@ -0,0 +1,71 @@
+System.String_FormatSpecifier.prototype.ParseFormatSpecifier = function() {
+ try {
+ this.n = this.ParseDecimal();
+ var CS$4$0000 = this.n >= 0;
+ if (!CS$4$0000) {
+ throw new System.FormatException().$ctor$1("Invalid argument specifier.");
+ }
+ CS$4$0000 = this.str.charAt(this.ptr) != ',';
+ if (!CS$4$0000) {
+ this.ptr = this.ptr + 1;
+ while (true) {
+ CS$4$0000 = this.IsWhiteSpace();
+ if (!CS$4$0000) {
+ break;
+ }
+ this.ptr = this.ptr + 1;
+ }
+ var start = this.ptr;
+ var len = this.ptr - start;
+ this.format = this.str._Substring$1(start, len);
+ this.left_align = this.str.charAt(this.ptr) == '-';
+ CS$4$0000 = !this.left_align;
+ if (!CS$4$0000) {
+ this.ptr = this.ptr + 1;
+ }
+ this.width = this.ParseDecimal();
+ CS$4$0000 = this.width >= 0;
+ if (!CS$4$0000) {
+ throw new System.FormatException().$ctor$1("Invalid width specifier.");
+ }
+ }
+ else {
+ this.width = 0;
+ this.left_align = false;
+ this.format = "";
+ }
+ CS$4$0000 = this.str.charAt(this.ptr) != ':';
+ if (!CS$4$0000) {
+ var D_0 = this.ptr + 1;
+ var CS$0$0001 = D_0;
+ this.ptr = D_0;
+ start = CS$0$0001;
+ while (true) {
+ CS$4$0000 = this.str.charAt(this.ptr) != '}';
+ if (!CS$4$0000) {
+ break;
+ }
+ this.ptr = this.ptr + 1;
+ }
+ this.format = this.format + this.str._Substring$1(start, this.ptr - start);
+ }
+ else {
+ this.format = null;
+ }
+ var D_1 = this.ptr;
+ CS$0$0001 = D_1;
+ this.ptr = D_1 + 1;
+ CS$4$0000 = this.str.charAt(CS$0$0001) == '}';
+ if (!CS$4$0000) {
+ 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__;
+ }
+ }
+};
View
6 test/DotWeb.Translator.Test/Expected/CommonMethods/System.SystemException.js
@@ -0,0 +1,6 @@
+$Class(System.Exception, 'System', 'SystemException');
+
+System.SystemException.prototype.$ctor$1 = function(message) {
+ this.$super.$ctor$1(message);
+ return this;
+};
View
13 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_0.js
@@ -0,0 +1,13 @@
+System.Text.StringBuilder.prototype.Append$0 = function(value) {
+ var CS$4$0001 = value != null;
+ if (!CS$4$0001) {
+ return this;
+ }
+ CS$4$0001 = value.length != 0;
+ if (!CS$4$0001) {
+ this.value = value;
+ return this;
+ }
+ this.value = this.value + value;
+ return this;
+};
View
3 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_1.js
@@ -0,0 +1,3 @@
+System.Text.StringBuilder.prototype.Append$1 = function(value) {
+ return this.Append$0(value.toString());
+};
View
12 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_3.js
@@ -0,0 +1,12 @@
+System.Text.StringBuilder.prototype.Append$3 = function(value, repeatCount) {
+ var i = 0;
+ while (true) {
+ var CS$4$0001 = i < repeatCount;
+ if (!CS$4$0001) {
+ break;
+ }
+ this.Append$1(value);
+ i = i + 1;
+ }
+ return this;
+};
View
36 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.Append_5.js
@@ -0,0 +1,36 @@
+System.Text.StringBuilder.prototype.Append$5 = function(value, startIndex, count) {
+ var CS$4$0001 = value != null;
+ if (!CS$4$0001) {
+ if (startIndex) {
+ var R_1 = count == 0;
+ }
+ else {
+ R_1 = 1;
+ }
+ CS$4$0001 = R_1;
+ if (!CS$4$0001) {
+ throw new System.ArgumentNullException().$ctor$1("value");
+ }
+ return this;
+ }
+ if ((count >= 0) && (startIndex >= 0)) {
+ R_1 = startIndex <= (value.length - count);
+ }
+ else {
+ R_1 = 0;
+ }
+ CS$4$0001 = R_1;
+ if (!CS$4$0001) {
+ throw new System.ArgumentOutOfRangeException().$ctor$0();
+ }
+ var i = startIndex;
+ while (true) {
+ CS$4$0001 = i < (startIndex + count);
+ if (!CS$4$0001) {
+ break;
+ }
+ this.Append$1(value.charAt(i));
+ i = i + 1;
+ }
+ return this;
+};
View
4 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder._ctor.js
@@ -0,0 +1,4 @@
+System.Text.StringBuilder.prototype.$ctor = function() {
+ this.value = "";
+ return this;
+};
View
3 test/DotWeb.Translator.Test/Expected/CommonMethods/System.Text.StringBuilder.toString.js
@@ -0,0 +1,3 @@
+System.Text.StringBuilder.prototype.toString = function() {
+ return this.value;
+};
View
8 test/DotWeb.Translator.Test/Expected/DecorationTest/TestJsAnonymous.js
@@ -1,12 +1,8 @@
$Class(null, 'System', 'Console');
-System.Console.WriteLine$1 = function(value) {
- console.log(value);
-};
+//>System.Console.WriteLine$1
-System.Console.WriteLine$0 = function(value) {
- System.Console.WriteLine$1(value.toString());
-};
+//>System.Console.WriteLine$0
$Class(null, 'H8', 'DecorationTests');
View
8 test/DotWeb.Translator.Test/Expected/DecorationTest/TestJsNamespace.js
@@ -28,13 +28,9 @@ Foo.FooNamespaceTest.prototype.get_Value = function() {
$Class(null, 'System', 'Console');
-System.Console.WriteLine$1 = function(value) {
- console.log(value);
-};
+//>System.Console.WriteLine$1
-System.Console.WriteLine$0 = function(value) {
- System.Console.WriteLine$1(value.toString());
-};
+//>System.Console.WriteLine$0
$Class(null, 'H8', 'DecorationTests');
View
35 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/AnonymousType.js
@@ -12,32 +12,13 @@ __f__AnonymousType0$2.prototype.get_Key = function() {
$Class(null, 'System.Text', 'StringBuilder', { value: null });
-System.Text.StringBuilder.prototype.$ctor = function() {
- this.value = "";
- return this;
-};
+//>System.Text.StringBuilder.$ctor
-System.Text.StringBuilder.prototype.Append$0 = function(value) {
- var V_1 = value != null;
- if (!V_1) {
- return this;
- }
- V_1 = value.length != 0;
- if (!V_1) {
- this.value = value;
- return this;
- }
- this.value = this.value + value;
- return this;
-};
+//>System.Text.StringBuilder.Append$0
-System.Text.StringBuilder.prototype.toString = function() {
- return this.value;
-};
+//>System.Text.StringBuilder.toString
-System.Text.StringBuilder.prototype.Append$1 = function(value) {
- return this.Append$0(value.toString());
-};
+//>System.Text.StringBuilder.Append$1
__f__AnonymousType0$2.prototype.toString = function() {
var V_0 = new System.Text.StringBuilder().$ctor();
@@ -51,13 +32,9 @@ __f__AnonymousType0$2.prototype.toString = function() {
$Class(null, 'System', 'Console');
-System.Console.WriteLine$1 = function(value) {
- console.log(value);
-};
+//>System.Console.WriteLine$1
-System.Console.WriteLine$0 = function(value) {
- System.Console.WriteLine$1(value.toString());
-};
+//>System.Console.WriteLine$0
__f__AnonymousType0$2.prototype.get_Value = function() {
return this._Value_i__Field;
View
395 test/DotWeb.Translator.Test/Expected/GeneralTests/Debug/ArgumentException.js
@@ -1,20 +1,6 @@
-$Class(null, 'System', 'Exception', { message: null, _InnerException_k__BackingField: null, _Source_k__BackingField: null, _StackTrace_k__BackingField: null });
+//>System.Exception
-System.Exception.prototype.set_Message = function(value) {
- this.message = value;
-};
-
-System.Exception.prototype.$ctor$1 = function(message) {
- this.set_Message(message);
- return this;
-};
-
-$Class(System.Exception, 'System', 'SystemException');
-
-System.SystemException.prototype.$ctor$1 = function(message) {
- this.$super.$ctor$1(message);
- return this;
-};
+//>System.SystemException
$Class(System.SystemException, 'System', 'ArgumentException', { _ParamName_k__BackingField: null });
@@ -25,35 +11,13 @@ System.ArgumentException.prototype.$ctor$0 = function() {
$Class(null, 'System.Text', 'StringBuilder', { value: null });
-System.Text.StringBuilder.prototype.$ctor = function() {
- this.value = "";
- return this;
-};
-
-$Class(System.SystemException, 'System', 'FormatException');
+//>System.Text.StringBuilder.$ctor
-System.FormatException.prototype.$ctor$1 = function(message) {
- this.$super.$ctor$1(message);
- return this;
-};
+//>System.FormatException
-System.Text.StringBuilder.prototype.toString = function() {
- return this.value;
-};
+//>System.Text.StringBuilder.toString
-System.Text.StringBuilder.prototype.Append$0 = function(value) {
- var V_1 = value != null;
- if (!V_1) {
- return this;
- }
- V_1 = value.length != 0;
- if (!V_1) {
- this.value = value;
- return this;
- }
- this.value = this.value + value;
- return this;
-};
+//>System.Text.StringBuilder.Append$0
System.Exception.prototype.get_InnerException = function() {
return this._InnerException_k__BackingField;
@@ -63,22 +27,9 @@ 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.Exception.toString
-System.Text.StringBuilder.prototype.Append$1 = function(value) {
- return this.Append$0(value.toString());
-};
+//>System.Text.StringBuilder.Append$1
System.ArgumentException.prototype.$ctor$1 = function(message) {
this.$super.$ctor$1(message);
@@ -117,82 +68,13 @@ System.ArgumentNullException.prototype.$ctor$1 = function(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");
- }
- return this;
- }
- 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;
- }
- return this;
-};
+//>System.Text.StringBuilder.Append$5
$Class(null, 'System', 'String_FormatSpecifier', { str: null, ptr: 0, n: 0, width: 0, left_align: 0, format: null });