diff --git a/JSIL.Libraries/Includes/Bootstrap/Core/Main.js b/JSIL.Libraries/Includes/Bootstrap/Core/Main.js
index 65f519cd5..93cb6a8f9 100644
--- a/JSIL.Libraries/Includes/Bootstrap/Core/Main.js
+++ b/JSIL.Libraries/Includes/Bootstrap/Core/Main.js
@@ -120,19 +120,33 @@ JSIL.MakeClass("System.ComponentModel.TypeConverter", "System.ComponentModel.Exp
JSIL.MakeDelegate("System.Action", true, [], JSIL.MethodSignature.Void);
JSIL.MakeDelegate("System.Action`1", true, ["T"], new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T", "System.Action`1").in()]));
-JSIL.MakeDelegate("System.Action`2", true, ["T1", "T2"], new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T1", "System.Action`2").in(), new JSIL.GenericParameter("T2", "System.Action`2").in()]));
-JSIL.MakeDelegate("System.Action`3", true, ["T1", "T2", "T3"], new JSIL.MethodSignature(null, [
- new JSIL.GenericParameter("T1", "System.Action`3").in(), new JSIL.GenericParameter("T2", "System.Action`3").in(),
- new JSIL.GenericParameter("T3", "System.Action`3").in()
-]));
-
JSIL.MakeDelegate("System.Func`1", true, ["TResult"], new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", "System.Func`1").out(), null));
JSIL.MakeDelegate("System.Func`2", true, ["T", "TResult"], new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", "System.Func`2").out(), [new JSIL.GenericParameter("T", "System.Func`2").in()]));
-JSIL.MakeDelegate("System.Func`3", true, ["T1", "T2", "TResult"], new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", "System.Func`3").out(), [new JSIL.GenericParameter("T1", "System.Func`3").in(), new JSIL.GenericParameter("T2", "System.Func`3").in()]));
-JSIL.MakeDelegate("System.Func`4", true, ["T1", "T2", "T3", "TResult"], new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", "System.Func`4").out(), [
- new JSIL.GenericParameter("T1", "System.Func`4").in(), new JSIL.GenericParameter("T2", "System.Func`4").in(),
- new JSIL.GenericParameter("T3", "System.Func`4").in()
-]));
+
+(function() {
+ for (var i = 2; i <= 16; i++) {
+ var actionName = "System.Action`" + i;
+ var funcName = "System.Func`" + (i + 1);
+ var genericArgsForActions = [];
+ var genericArgsForFunctions = [];
+
+ var inputForActions = [];
+ var inputForFunctions = [];
+ for (var j = 0; j < i; j++) {
+ var name = "T" + (j + 1);
+ genericArgsForActions.push(name);
+ genericArgsForFunctions.push(name);
+
+ inputForActions.push(new JSIL.GenericParameter(name, actionName).in());
+ inputForFunctions.push(new JSIL.GenericParameter(name, funcName).in());
+ }
+
+ genericArgsForFunctions.push("TResult");
+
+ JSIL.MakeDelegate(actionName, true, genericArgsForActions, new JSIL.MethodSignature(null, inputForActions));
+ JSIL.MakeDelegate(funcName, true, genericArgsForFunctions, new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", funcName).out(), inputForFunctions));
+ }
+})();
JSIL.MakeDelegate("System.Predicate`1", true, ["in T"], new JSIL.MethodSignature($jsilcore.TypeRef("System.Boolean"), [new JSIL.GenericParameter("T", "System.Predicate`1").in()]));
@@ -331,4 +345,4 @@ JSIL.MakeInterface(
$.Method({}, "CleanUpManagedData", JSIL.MethodSignature.Action($.Object));
$.Method({}, "GetNativeDataSize", JSIL.MethodSignature.Return($.Int32));
}, []);
-//? }
+//? }
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/Microsoft.CSharp.RuntimeBinder.Binder.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/Microsoft.CSharp.RuntimeBinder.Binder.js
new file mode 100644
index 000000000..add8b3cb4
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/Microsoft.CSharp.RuntimeBinder.Binder.js
@@ -0,0 +1,235 @@
+JSIL.MakeStaticClass("Microsoft.CSharp.RuntimeBinder.Binder", true, [], function($) {
+ $.RawMethod(true, "BinaryOperation",
+ function(flags, operation, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Add || operation === $jsilcore.System.Linq.Expressions.ExpressionType.AddChecked) {
+ binder.Method = function (callSite, left, right) {
+ return left+right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.And) {
+ binder.Method = function (callSite, left, right) {
+ return left & right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.AndAlso) {
+ binder.Method = function (callSite, left, right) {
+ return left && right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Divide) {
+ binder.Method = function (callSite, left, right) {
+ return left / right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Equal) {
+ binder.Method = function (callSite, left, right) {
+ return left == right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.ExclusiveOr) {
+ binder.Method = function (callSite, left, right) {
+ return left ^ right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.GreaterThan) {
+ binder.Method = function (callSite, left, right) {
+ return left > right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.GreaterThanOrEqual) {
+ binder.Method = function (callSite, left, right) {
+ return left >= right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.LeftShift) {
+ binder.Method = function (callSite, left, right) {
+ return left << right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.LessThan) {
+ binder.Method = function (callSite, left, right) {
+ return left < right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.LessThanOrEqual) {
+ binder.Method = function (callSite, left, right) {
+ return left <= right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Modulo) {
+ binder.Method = function (callSite, left, right) {
+ return left % right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Multiply || operation === $jsilcore.System.Linq.Expressions.ExpressionType.MultiplyChecked) {
+ binder.Method = function (callSite, left, right) {
+ return left * right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.NotEqual) {
+ binder.Method = function (callSite, left, right) {
+ return left != right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Or) {
+ binder.Method = function (callSite, left, right) {
+ return left | right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.OrElse) {
+ binder.Method = function (callSite, left, right) {
+ return left || right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.RightShift) {
+ binder.Method = function (callSite, left, right) {
+ return left >> right;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Subtract || operation === $jsilcore.System.Linq.Expressions.ExpressionType.SubtractChecked) {
+ binder.Method = function (callSite, left, right) {
+ return left - right;
+ };
+ } else {
+ throw new Error("Binary operator is not supported.");
+ }
+ return binder;
+ });
+
+ $.RawMethod(true, "Convert",
+ function(flags, type, context) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ binder.Method = function (callSite, target) {
+ return type.__PublicInterface__.$Cast(target);
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "GetIndex",
+ function(flags, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ var isStaticCall = (argumentInfo[0].Flags & $jsilcore.Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.IsStaticType) > 0;
+ binder.Method = function (callSite, target) {
+ var realTarget = (isStaticCall ? target.__PublicInterface__ : target);
+ if ("get_Item" in realTarget) {
+ return realTarget["get_Item"].apply(realTarget, Array.prototype.slice.call(arguments, 2));
+ } else {
+ // TODO: Jagged arrays support
+ if (arguments.length === 3) {
+ return realTarget[arguments[2]];
+ } else {
+ throw new Error("Cannot use multi-dimensional indexer for object without indexed property.");
+ }
+ }
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "GetMember",
+ function (flags, name, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ var isStaticCall = (argumentInfo[0].Flags & $jsilcore.Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.IsStaticType) > 0;
+ binder.Method = function (callSite, target) {
+ var realTarget = (isStaticCall ? target.__PublicInterface__ : target);
+ if (("get_" + name) in realTarget) {
+ return realTarget["get_" + name]();
+ } else {
+ return realTarget[name];
+ }
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "Invoke",
+ function (flags, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ binder.Method = function (callSite, target) {
+ return target.apply(null, Array.prototype.slice.call(arguments, 2));
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "InvokeConstructor",
+ function(flags, context, argumentInfo) {
+ throw new Error("Not implemented");
+ });
+
+ $.RawMethod(true, "InvokeMember",
+ function (flags, name, typeArguments, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ var isStaticCall = (argumentInfo[0].Flags & $jsilcore.Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.IsStaticType) > 0;
+ if (typeArguments !== null) {
+ var useMemberName = name + "$b" + typeArguments.length;
+ binder.Method = function (callSite, target) {
+ var realTarget = (isStaticCall ? target.__PublicInterface__ : target);
+ return realTarget[useMemberName].apply(realTarget, typeArguments).apply(realTarget, Array.prototype.slice.call(arguments, 2));
+ };
+ } else {
+ binder.Method = function (callSite, target) {
+ var realTarget = (isStaticCall ? target.__PublicInterface__ : target);
+ return realTarget[name].apply(realTarget, Array.prototype.slice.call(arguments, 2));
+ };
+ }
+ return binder;
+ });
+
+ $.RawMethod(true, "IsEvent",
+ function(flags, name, context) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ binder.Method = function () {
+ return false;
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "SetIndex",
+ function(flags, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ var isStaticCall = (argumentInfo[0].Flags & $jsilcore.Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.IsStaticType) > 0;
+ binder.Method = function (callSite, target) {
+ var realTarget = (isStaticCall ? target.__PublicInterface__ : target);
+ if ("set_Item" in realTarget) {
+ return realTarget["set_Item"].apply(realTarget, Array.prototype.slice.call(arguments, 2));
+ } else {
+ // TODO: Jagged arrays support
+ if (arguments.length === 4) {
+ realTarget[arguments[2]] = arguments[3];
+ } else {
+ throw new Error("Cannot use multi-dimensional indexer for object without indexed property.");
+ }
+ }
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "SetMember",
+ function(flags, name, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ var isStaticCall = (argumentInfo[0].Flags & $jsilcore.Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.IsStaticType) > 0;
+ binder.Method = function(callSite, target, value) {
+ var realTarget = (isStaticCall ? target.__PublicInterface__ : target);
+ if (("set_" + name) in realTarget) {
+ return realTarget["set_" + name](value);
+ } else {
+ realTarget[name] = value;
+ }
+ };
+ return binder;
+ });
+
+ $.RawMethod(true, "UnaryOperation",
+ function(flags, operation, context, argumentInfo) {
+ var binder = new $jsilcore.System.Runtime.CompilerServices.CallSiteBinder();
+ if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.UnaryPlus) {
+ binder.Method = function(callSite, target) {
+ return target;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Negate || operation === $jsilcore.System.Linq.Expressions.ExpressionType.NegateChecked) {
+ binder.Method = function (callSite, target) {
+ return -target;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.Not) {
+ binder.Method = function (callSite, target) {
+ if (typeof(target) === "boolean") {
+ return ~target;
+ }
+ return ~target;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.IsTrue) {
+ binder.Method = function (callSite, target) {
+ return target === true;
+ };
+ } else if (operation === $jsilcore.System.Linq.Expressions.ExpressionType.IsFalse) {
+ binder.Method = function (callSite, target) {
+ return target === false;
+ };
+ } else {
+ throw new Error("Unary operator is not supported.");
+ }
+ return binder;
+ });
+});
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.js
new file mode 100644
index 000000000..50753106f
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.js
@@ -0,0 +1,21 @@
+JSIL.MakeClass("System.Object", "Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo", true, [], function ($) {
+ $.Method({ Static: false, Public: true }, ".ctor",
+ new JSIL.MethodSignature(null, [], []),
+ function () {
+ }
+ );
+
+ $.Method({ Static: true, Public: true }, "Create",
+ new JSIL.MethodSignature($.Type, [$jsilcore.TypeRef("Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags"), $.String], []),
+ function CSharpArgumentInfo_Create(flags, name) {
+ var info = new $jsilcore.Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo();
+ info.Flags = flags;
+ info.Name = name;
+ return info;
+ }
+ );
+
+ $.Field({ Public: false, Static: false }, "Flags", $jsilcore.TypeRef("Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags"));
+ $.Field({ Public: false, Static: false }, "Name", $.String);
+
+});
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/System.Runtime.CompilerServices.CallSite.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/System.Runtime.CompilerServices.CallSite.js
new file mode 100644
index 000000000..bea41c40f
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/System.Runtime.CompilerServices.CallSite.js
@@ -0,0 +1,15 @@
+JSIL.MakeClass("System.Object", "System.Runtime.CompilerServices.CallSite", true, [], function ($) {
+});
+
+JSIL.MakeClass("System.Object", "System.Runtime.CompilerServices.CallSite`1", true, ["T"], function ($) {
+ $.Method({ Static: true, Public: true }, "Create",
+ new JSIL.MethodSignature($.Type, [$jsilcore.TypeRef("System.Runtime.CompilerServices.CallSiteBinder")], []),
+ function(binder) {
+ var callSite = new this();
+ callSite.Target = binder.Method;
+ return callSite;
+ }
+ );
+
+ $.Field({ Public: false, Static: false }, "Target", new JSIL.GenericParameter("T", "System.Runtime.CompilerServices.CallSite`1"));
+});
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/System.Runtime.CompilerServices.CallSiteBinder.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/System.Runtime.CompilerServices.CallSiteBinder.js
new file mode 100644
index 000000000..5f3763c97
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/System.Runtime.CompilerServices.CallSiteBinder.js
@@ -0,0 +1,2 @@
+JSIL.MakeClass("System.Object", "System.Runtime.CompilerServices.CallSiteBinder", true, [], function($) {
+});
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.js
new file mode 100644
index 000000000..eff2b3ee8
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.js
@@ -0,0 +1,11 @@
+JSIL.MakeEnum(
+ "Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags", true, {
+ None: 0,
+ UseCompileTimeType: 1,
+ Constant: 2,
+ NamedArgument: 4,
+ IsRef: 8,
+ IsOut: 16,
+ IsStaticType: 32
+ }, true
+);
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.js
new file mode 100644
index 000000000..73868bac2
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.js
@@ -0,0 +1,14 @@
+JSIL.MakeEnum(
+ "Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags", true, {
+ None: 0,
+ CheckedContext: 1,
+ InvokeSimpleName: 2,
+ InvokeSpecialName: 4,
+ BinaryOperationLogical: 8,
+ ConvertExplicit: 16,
+ ConvertArrayIndex: 32,
+ ResultIndexed: 64,
+ ValueFromCompoundAssignment: 128,
+ ResultDiscarded: 256
+ }, true
+);
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/System.Linq.Expressions.ExpressionType.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/System.Linq.Expressions.ExpressionType.js
new file mode 100644
index 000000000..0d9ee9bbd
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Enums/System.Linq.Expressions.ExpressionType.js
@@ -0,0 +1,89 @@
+JSIL.MakeEnum(
+ "System.Linq.Expressions.ExpressionType", true, {
+ Add: 0,
+ AddChecked: 1,
+ And: 2,
+ AndAlso: 3,
+ ArrayLength: 4,
+ ArrayIndex: 5,
+ Call: 6,
+ Coalesce: 7,
+ Conditional: 8,
+ Constant: 9,
+ Convert: 10,
+ ConvertChecked: 11,
+ Divide: 12,
+ Equal: 13,
+ ExclusiveOr: 14,
+ GreaterThan: 15,
+ GreaterThanOrEqual: 16,
+ Invoke: 17,
+ Lambda: 18,
+ LeftShift: 19,
+ LessThan: 20,
+ LessThanOrEqual: 21,
+ ListInit: 22,
+ MemberAccess: 23,
+ MemberInit: 24,
+ Modulo: 25,
+ Multiply: 26,
+ MultiplyChecked: 27,
+ Negate: 28,
+ UnaryPlus: 29,
+ NegateChecked: 30,
+ New: 31,
+ NewArrayInit: 32,
+ NewArrayBounds: 33,
+ Not: 34,
+ NotEqual: 35,
+ Or: 36,
+ OrElse: 37,
+ Parameter: 38,
+ Power: 39,
+ Quote: 40,
+ RightShift: 41,
+ Subtract: 42,
+ SubtractChecked: 43,
+ TypeAs: 44,
+ TypeIs: 45,
+ Assign: 46,
+ Block: 47,
+ DebugInfo: 48,
+ Decrement: 49,
+ Dynamic: 50,
+ Default: 51,
+ Extension: 52,
+ Goto: 53,
+ Increment: 54,
+ Index: 55,
+ Label: 56,
+ RuntimeVariables: 57,
+ Loop: 58,
+ Switch: 59,
+ Throw: 60,
+ Try: 61,
+ Unbox: 62,
+ AddAssign: 63,
+ AndAssign: 64,
+ DivideAssign: 65,
+ ExclusiveOrAssign: 66,
+ LeftShiftAssign: 67,
+ ModuloAssign: 68,
+ MultiplyAssign: 69,
+ OrAssign: 70,
+ PowerAssign: 71,
+ RightShiftAssign: 72,
+ SubtractAssign: 73,
+ AddAssignChecked: 74,
+ MultiplyAssignChecked: 75,
+ SubtractAssignChecked: 76,
+ PreIncrementAssign: 77,
+ PreDecrementAssign: 78,
+ PostIncrementAssign: 79,
+ PostDecrementAssign: 80,
+ TypeEqual: 81,
+ OnesComplement: 82,
+ IsTrue: 83,
+ IsFalse: 84
+ }, true
+);
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Main.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Main.js
new file mode 100644
index 000000000..525560f37
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Main.js
@@ -0,0 +1,23 @@
+"use strict";
+
+if (typeof (JSIL) === "undefined")
+ throw new Error("JSIL.Core is required");
+
+if (!$jsilcore)
+ throw new Error("JSIL.Core is required");
+
+JSIL.DeclareNamespace("System.Runtime.CompilerServices");
+JSIL.DeclareNamespace("Microsoft");
+JSIL.DeclareNamespace("Microsoft.CSharp");
+JSIL.DeclareNamespace("Microsoft.CSharp.RuntimeBinder");
+JSIL.DeclareNamespace("System.Linq");
+JSIL.DeclareNamespace("System.Linq.Expressions");
+
+//? include("Classes/System.Runtime.CompilerServices.CallSite.js"); writeln();
+//? include("Classes/System.Runtime.CompilerServices.CallSiteBinder.js"); writeln();
+//? include("Classes/Microsoft.CSharp.RuntimeBinder.Binder.js"); writeln();
+//? include("Classes/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.js"); writeln();
+
+//? include("Enums/Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.js"); writeln();
+//? include("Enums/Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.js"); writeln();
+//? include("Enums/System.Linq.Expressions.ExpressionType.js"); writeln();
\ No newline at end of file
diff --git a/JSIL.Libraries/JSIL.Libraries.csproj b/JSIL.Libraries/JSIL.Libraries.csproj
index 6677acd65..7af588ac0 100644
--- a/JSIL.Libraries/JSIL.Libraries.csproj
+++ b/JSIL.Libraries/JSIL.Libraries.csproj
@@ -38,6 +38,14 @@
+
+
+
+
+
+
+
+
@@ -277,6 +285,7 @@
+
@@ -339,6 +348,7 @@
JSIL.mscorlib
+
diff --git a/JSIL.Libraries/Sources/JSIL.Bootstrap.Dynamic.js b/JSIL.Libraries/Sources/JSIL.Bootstrap.Dynamic.js
new file mode 100644
index 000000000..b2bd02886
--- /dev/null
+++ b/JSIL.Libraries/Sources/JSIL.Bootstrap.Dynamic.js
@@ -0,0 +1,2 @@
+//? __out.GENERATE_STUBS=true;
+//? include("../Includes/Bootstrap/Dynamic/Main.js");
\ No newline at end of file
diff --git a/JSIL.Libraries/Sources/JSIL.Core.js b/JSIL.Libraries/Sources/JSIL.Core.js
index ce936be8a..f9f13ebe2 100644
--- a/JSIL.Libraries/Sources/JSIL.Core.js
+++ b/JSIL.Libraries/Sources/JSIL.Core.js
@@ -491,12 +491,13 @@ JSIL.GetAssembly = function (assemblyName, requireExisting) {
var isSystemCore = (shortName === "System.Core") || (assemblyName.indexOf("System.Core,") === 0);
var isSystemXml = (shortName === "System.Xml") || (assemblyName.indexOf("System.Xml,") === 0);
var isJsilMeta = (shortName === "JSIL.Meta") || (assemblyName.indexOf("JSIL.Meta,") === 0);
+ var isMicrosoftCSharp = (shortName === "Microsoft.CSharp") || (assemblyName.indexOf("Microsoft.CSharp,") === 0);
// Create a new private global namespace for the new assembly
var template = {};
// Ensure that BCL private namespaces inherit from the JSIL namespace.
- if (isMscorlib || isSystem || isSystemCore || isSystemXml || isJsilMeta)
+ if (isMscorlib || isSystem || isSystemCore || isSystemXml || isJsilMeta || isMicrosoftCSharp)
template = $jsilcore || {};
var result = JSIL.CreateSingletonObject(template);
diff --git a/JSIL.Libraries/Sources/JSIL.js b/JSIL.Libraries/Sources/JSIL.js
index 42cb28047..6d36d9b0d 100644
--- a/JSIL.Libraries/Sources/JSIL.js
+++ b/JSIL.Libraries/Sources/JSIL.js
@@ -288,6 +288,7 @@ var $jsilloaderstate = {
environment.loadScript(libraryRoot + "JSIL.Bootstrap.Linq.js");
}
environment.loadScript(libraryRoot + "JSIL.Bootstrap.Async.js");
+ environment.loadScript(libraryRoot + "JSIL.Bootstrap.Dynamic.js");
if (config.xml || environment.getUserSetting("xml"))
environment.loadScript(libraryRoot + "JSIL.XML.js");
diff --git a/JSIL/AST/JSExpressionTypes.cs b/JSIL/AST/JSExpressionTypes.cs
index 5cffc0e29..e7fed2dce 100644
--- a/JSIL/AST/JSExpressionTypes.cs
+++ b/JSIL/AST/JSExpressionTypes.cs
@@ -1040,8 +1040,14 @@ public override bool Equals (object o) {
return base.Equals(o);
}
- public override TypeReference GetActualType (TypeSystem typeSystem) {
- return Field.Field.FieldType;
+ public override TypeReference GetActualType(TypeSystem typeSystem)
+ {
+ if (PackedArrayUtil.IsPackedArrayType(Field.Field.FieldType))
+ {
+ return Field.Field.FieldType;
+ }
+
+ return base.GetActualType(typeSystem);
}
public override string ToString () {
diff --git a/JSIL/AST/JSIdentifierTypes.cs b/JSIL/AST/JSIdentifierTypes.cs
index 631aea37a..3965262b3 100644
--- a/JSIL/AST/JSIdentifierTypes.cs
+++ b/JSIL/AST/JSIdentifierTypes.cs
@@ -234,7 +234,7 @@ public override string Identifier {
}
public override TypeReference GetActualType (TypeSystem typeSystem) {
- return Field.ReturnType;
+ return TypeAnalysis.GetFieldType(Reference);
}
// FIXME: Is this right?
diff --git a/JSIL/DynamicCallSites.cs b/JSIL/DynamicCallSites.cs
deleted file mode 100644
index 2c561b990..000000000
--- a/JSIL/DynamicCallSites.cs
+++ /dev/null
@@ -1,581 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Text;
-using ICSharpCode.Decompiler.ILAst;
-using JSIL.Ast;
-using Microsoft.CSharp.RuntimeBinder;
-using Mono.Cecil;
-
-namespace JSIL {
- internal class DynamicCallSiteInfoCollection {
- protected readonly Dictionary CallSites = new Dictionary();
- protected readonly Dictionary Aliases = new Dictionary();
-
- public bool Get (ILVariable localVariable, out DynamicCallSiteInfo info) {
- FieldReference storageField;
-
- if (Aliases.TryGetValue(localVariable.Name, out storageField))
- return Get(storageField, out info);
-
- info = null;
- return false;
- }
-
- public bool Get (FieldReference storageField, out DynamicCallSiteInfo info) {
- return CallSites.TryGetValue(storageField.FullName, out info);
- }
-
- public DynamicCallSiteInfo InitializeCallSite (FieldReference storageField, string bindingType, TypeReference targetType, JSExpression[] arguments) {
- DynamicCallSiteInfo callSiteInfo;
-
- switch (bindingType) {
- case "GetIndex":
- callSiteInfo = new DynamicCallSiteInfo.GetIndex(targetType, arguments);
- break;
- case "SetIndex":
- callSiteInfo = new DynamicCallSiteInfo.SetIndex(targetType, arguments);
- break;
- case "GetMember":
- callSiteInfo = new DynamicCallSiteInfo.GetMember(targetType, arguments);
- break;
- case "SetMember":
- callSiteInfo = new DynamicCallSiteInfo.SetMember(targetType, arguments);
- break;
- case "Invoke":
- callSiteInfo = new DynamicCallSiteInfo.Invoke(targetType, arguments);
- break;
- case "InvokeMember":
- callSiteInfo = new DynamicCallSiteInfo.InvokeMember(targetType, arguments);
- break;
- case "UnaryOperation":
- callSiteInfo = new DynamicCallSiteInfo.UnaryOperation(targetType, arguments);
- break;
- case "BinaryOperation":
- callSiteInfo = new DynamicCallSiteInfo.BinaryOperation(targetType, arguments);
- break;
- case "Convert":
- callSiteInfo = new DynamicCallSiteInfo.Convert(targetType, arguments);
- break;
- default:
- throw new NotImplementedException(String.Format("Call sites of type '{0}' not implemented.", bindingType));
- }
-
- return CallSites[storageField.FullName] = callSiteInfo;
- }
-
- public void SetAlias (ILVariable variable, FieldReference fieldReference) {
- Aliases[variable.Name] = fieldReference;
- }
- }
-
- internal abstract class DynamicCallSiteInfo {
- public readonly TypeReference ReturnType;
- protected readonly JSExpression[] Arguments;
-
- protected DynamicCallSiteInfo (TypeReference targetType, JSExpression[] arguments) {
- Arguments = arguments;
-
- var targetTypeName = targetType.FullName;
- var git = targetType as GenericInstanceType;
-
- if (targetTypeName.StartsWith("System.Action`")) {
- ReturnType = null;
- } else if (targetTypeName.StartsWith("System.Func`")) {
- ReturnType = git.GenericArguments[git.GenericArguments.Count - 1];
- } else {
- throw new NotImplementedException(String.Format(
- "This type of call site target is not implemented: {0}",
- targetTypeName
- ));
- }
-
- if ((BinderFlags & CSharpBinderFlags.ResultDiscarded) == CSharpBinderFlags.ResultDiscarded)
- ReturnType = null;
- }
-
- protected JSExpression FixupThisArgument (JSExpression thisArgument, TypeSystem typeSystem) {
- var expectedType = thisArgument.GetActualType(typeSystem);
- if (expectedType.FullName == "System.Type")
- return new JSPublicInterfaceOfExpression(thisArgument);
-
- return thisArgument;
- }
-
- protected TypeReference UnwrapType (JSExpression expression) {
- var type = expression as JSType;
-
- var invocation = expression as JSInvocationExpression;
- if (invocation != null) {
- var firstArg = invocation.Arguments.FirstOrDefault();
- type = firstArg as JSType;
- }
-
- if (type != null)
- return type.Type;
-
- throw new NotImplementedException(String.Format(
- "Unrecognized type expression: {0}",
- expression
- ));
- }
-
- public abstract JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments);
-
- public CSharpBinderFlags BinderFlags {
- get {
- return (CSharpBinderFlags)((JSEnumLiteral)Arguments[0]).Value;
- }
- }
-
- public class InvokeMember : DynamicCallSiteInfo {
- public InvokeMember (TypeReference targetType, JSExpression[] arguments)
- : base (targetType, arguments) {
- }
-
- public string MemberName {
- get {
- return ((JSStringLiteral)Arguments[1]).Value;
- }
- }
-
- public JSExpression[] TypeArguments {
- get {
- var newarray = Arguments[2] as JSNewArrayExpression;
- if (newarray == null)
- return null;
-
- var array = (JSArrayExpression)newarray.SizeOrArrayInitializer;
- return array.Values.ToArray();
- }
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[3]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[4];
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var thisArgument = FixupThisArgument(arguments[1], translator.TypeSystem);
-
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- var argumentValues = arguments.Skip(2).ToArray();
- var memberName = MemberName;
-
- if ((TypeArguments != null) && (TypeArguments.Length > 0)) {
- memberName += "`" + TypeArguments.Length;
- }
-
- var thisArgumentKnownType = JSType.ExtractType(thisArgument);
- if (thisArgumentKnownType != null) {
- var replacement = translator.DoJSILMethodReplacement(
- thisArgumentKnownType.FullName, memberName,
- null,
- // FIXME
- null,
- argumentValues
- );
- if (replacement != null)
- return replacement;
- }
-
- return JSInvocationExpression.InvokeMethod(
- new JSFakeMethod(
- memberName, returnType,
- (from av in argumentValues select av.GetActualType(translator.TypeSystem)).ToArray(),
- translator.MethodTypes, TypeArguments,
- escape: true
- ), thisArgument,
- arguments.Skip(2).ToArray()
- );
- }
- }
-
- public class Invoke : DynamicCallSiteInfo {
- public Invoke (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[1]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[2];
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var thisArgument = arguments[1];
-
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- return new JSDelegateInvocationExpression(
- JSChangeTypeExpression.New(thisArgument, returnType, translator.TypeSystem),
- returnType, arguments.Skip(2).ToArray()
- );
- }
- }
-
- public class UnaryOperation : DynamicCallSiteInfo {
- public UnaryOperation (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public ExpressionType Operation {
- get {
- return (ExpressionType)((JSEnumLiteral)Arguments[1]).Value;
- }
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[2]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[3];
- }
- }
-
- public static JSUnaryOperator GetOperator (ExpressionType et) {
- switch (et) {
- case ExpressionType.Negate:
- case ExpressionType.NegateChecked:
- return JSOperator.Negation;
- case ExpressionType.Not:
- return JSOperator.BitwiseNot;
- case ExpressionType.IsTrue:
- return JSOperator.IsTrue;
- default:
- throw new NotImplementedException(String.Format("The unary operator '{0}' is not implemented.", et));
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- switch (Operation) {
- case ExpressionType.IsTrue:
- returnType = translator.TypeSystem.Boolean;
- break;
- }
-
- return new JSUnaryOperatorExpression(
- GetOperator(Operation),
- arguments[1],
- returnType
- );
- }
- }
-
- public class BinaryOperation : DynamicCallSiteInfo {
- public BinaryOperation (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public ExpressionType Operation {
- get {
- return (ExpressionType)((JSEnumLiteral)Arguments[1]).Value;
- }
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[2]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[3];
- }
- }
-
- public static JSBinaryOperator GetOperator (ExpressionType et) {
- switch (et) {
- case ExpressionType.Add:
- case ExpressionType.AddChecked:
- return JSOperator.Add;
- case ExpressionType.And:
- return JSOperator.BitwiseAnd;
- case ExpressionType.AndAlso:
- return JSOperator.LogicalAnd;
- case ExpressionType.Divide:
- return JSOperator.Divide;
- case ExpressionType.Equal:
- return JSOperator.Equal;
- case ExpressionType.ExclusiveOr:
- return JSOperator.BitwiseXor;
- case ExpressionType.GreaterThan:
- return JSOperator.GreaterThan;
- case ExpressionType.GreaterThanOrEqual:
- return JSOperator.GreaterThanOrEqual;
- case ExpressionType.LeftShift:
- return JSOperator.ShiftLeft;
- case ExpressionType.LessThan:
- return JSOperator.LessThan;
- case ExpressionType.LessThanOrEqual:
- return JSOperator.LessThanOrEqual;
- case ExpressionType.Modulo:
- return JSOperator.Remainder;
- case ExpressionType.Multiply:
- case ExpressionType.MultiplyChecked:
- return JSOperator.Multiply;
- case ExpressionType.NotEqual:
- return JSOperator.NotEqual;
- case ExpressionType.Or:
- return JSOperator.BitwiseOr;
- case ExpressionType.OrElse:
- return JSOperator.LogicalOr;
- case ExpressionType.RightShift:
- return JSOperator.ShiftRight;
- case ExpressionType.Subtract:
- case ExpressionType.SubtractChecked:
- return JSOperator.Subtract;
- case ExpressionType.AddAssign:
- case ExpressionType.AddAssignChecked:
- return JSOperator.AddAssignment;
- case ExpressionType.AndAssign:
- return JSOperator.BitwiseAndAssignment;
- case ExpressionType.DivideAssign:
- return JSOperator.DivideAssignment;
- case ExpressionType.ExclusiveOrAssign:
- return JSOperator.BitwiseXorAssignment;
- case ExpressionType.LeftShiftAssign:
- return JSOperator.ShiftLeftAssignment;
- case ExpressionType.ModuloAssign:
- return JSOperator.RemainderAssignment;
- case ExpressionType.MultiplyAssign:
- return JSOperator.MultiplyAssignment;
- case ExpressionType.MultiplyAssignChecked:
- case ExpressionType.OrAssign:
- return JSOperator.BitwiseOrAssignment;
- case ExpressionType.RightShiftAssign:
- return JSOperator.ShiftRightAssignment;
- case ExpressionType.SubtractAssign:
- case ExpressionType.SubtractAssignChecked:
- return JSOperator.SubtractAssignment;
- default:
- throw new NotImplementedException(String.Format("The binary operator '{0}' is not implemented.", et));
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- switch (Operation) {
- case ExpressionType.Equal:
- case ExpressionType.NotEqual:
- case ExpressionType.LessThan:
- case ExpressionType.GreaterThan:
- case ExpressionType.LessThanOrEqual:
- case ExpressionType.GreaterThanOrEqual:
- returnType = translator.TypeSystem.Boolean;
- break;
- }
-
- return new JSBinaryOperatorExpression(
- GetOperator(Operation),
- arguments[1], arguments[2],
- returnType
- );
- }
- }
-
- public class Convert : DynamicCallSiteInfo {
- public Convert (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public TypeReference TargetType {
- get {
- return UnwrapType(Arguments[1]);
- }
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[2]);
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- return JSCastExpression.New(
- arguments[1],
- TargetType,
- translator.TypeSystem
- );
- }
- }
-
- public class GetMember : DynamicCallSiteInfo {
- public GetMember (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public string MemberName {
- get {
- return ((JSStringLiteral)Arguments[1]).Value;
- }
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[2]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[3];
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var thisArgument = FixupThisArgument(arguments[1], translator.TypeSystem);
-
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- return JSDotExpression.New(
- thisArgument,
- new JSStringIdentifier(MemberName, returnType, true)
- );
- }
- }
-
- public class SetMember : DynamicCallSiteInfo {
- public SetMember (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public string MemberName {
- get {
- return ((JSStringLiteral)Arguments[1]).Value;
- }
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[2]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[3];
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var thisArgument = FixupThisArgument(arguments[1], translator.TypeSystem);
-
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- return new JSBinaryOperatorExpression(
- JSOperator.Assignment,
- JSDotExpression.New(
- thisArgument,
- new JSStringIdentifier(MemberName, returnType, true)
- ),
- arguments[2], returnType
- );
- }
- }
-
- public class GetIndex : DynamicCallSiteInfo {
- public GetIndex (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[1]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[2];
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var thisArgument = arguments[1];
-
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- return new JSIndexerExpression(
- thisArgument,
- arguments[2],
- returnType
- );
- }
- }
-
- public class SetIndex : DynamicCallSiteInfo {
- public SetIndex (TypeReference targetType, JSExpression[] arguments)
- : base(targetType, arguments) {
- }
-
- public TypeReference UsageContext {
- get {
- return UnwrapType(Arguments[1]);
- }
- }
-
- public JSExpression ArgumentInfo {
- get {
- return Arguments[2];
- }
- }
-
- public override JSExpression Translate (ILBlockTranslator translator, JSExpression[] arguments) {
- var thisArgument = arguments[1];
-
- var returnType = ReturnType;
- if (returnType == null)
- returnType = translator.TypeSystem.Void;
-
- return new JSBinaryOperatorExpression(
- JSOperator.Assignment,
- new JSIndexerExpression(
- thisArgument,
- arguments[2],
- returnType
- ),
- arguments[3], returnType
- );
- }
- }
- }
-}
diff --git a/JSIL/ILBlockTranslator.cs b/JSIL/ILBlockTranslator.cs
index 1afa71240..91c07d566 100644
--- a/JSIL/ILBlockTranslator.cs
+++ b/JSIL/ILBlockTranslator.cs
@@ -28,7 +28,6 @@ public class ILBlockTranslator {
public readonly JavascriptFormatter Output = null;
public readonly Dictionary Variables = new Dictionary();
- internal readonly DynamicCallSiteInfoCollection DynamicCallSites = new DynamicCallSiteInfoCollection();
protected readonly Dictionary RenamedVariables = new Dictionary();
private readonly Dictionary IndirectVariables = new Dictionary();
@@ -1391,52 +1390,8 @@ public JSExpression TranslateNode (ILExpression expression) {
return result;
}
- protected bool TranslateCallSiteConstruction (ILCondition condition, out JSStatement result) {
- result = null;
-
- var cond = condition.Condition;
- if (cond.Code != ILCode.LogicNot)
- return false;
-
- if (cond.Arguments.Count <= 0)
- return false;
-
- if (cond.Arguments[0].Code != ILCode.GetCallSite)
- return false;
-
- if (condition.TrueBlock == null)
- return false;
-
- if (condition.TrueBlock.Body.Count != 1)
- return false;
-
- if (condition.TrueBlock.Body[0] is ILExpression) {
- var callSiteExpression = (ILExpression)condition.TrueBlock.Body[0];
- var callSiteType = callSiteExpression.Arguments[0].ExpectedType;
- var binderExpression = callSiteExpression.Arguments[0].Arguments[0];
- var binderMethod = (MethodReference)binderExpression.Operand;
- var arguments = Translate(binderExpression.Arguments);
- var targetType = ((IGenericInstance)callSiteType).GenericArguments[0];
-
- DynamicCallSites.InitializeCallSite(
- (FieldReference)cond.Arguments[0].Operand,
- binderMethod.Name,
- targetType,
- arguments.ToArray()
- );
-
- result = new JSNullStatement();
- return true;
- }
-
- result = null;
- return false;
- }
-
public JSStatement TranslateNode (ILCondition condition) {
JSStatement result = null;
- if (TranslateCallSiteConstruction(condition, out result))
- return result;
JSStatement falseBlock = null;
if ((condition.FalseBlock != null) && (condition.FalseBlock.Body.Count > 0))
@@ -2359,10 +2314,8 @@ protected JSExpression Translate_Ldloca (ILExpression node, ILVariable variable)
}
protected JSExpression Translate_Stloc (ILExpression node, ILVariable variable) {
- if (node.Arguments[0].Code == ILCode.GetCallSite)
- DynamicCallSites.SetAlias(variable, (FieldReference)node.Arguments[0].Operand);
-
// GetCallSite and CreateCallSite produce null expressions, so we want to ignore assignments containing them
+ // TODO: We have nor more GetCallSite and CreateCallSite. Do we need this check?
var value = TranslateNode(node.Arguments[0]);
if ((value.IsNull) && !(value is JSUntranslatableExpression) && !(value is JSIgnoredExpression))
return new JSNullExpression();
@@ -3526,54 +3479,6 @@ protected JSExpression Translate_Callvirt (ILExpression node, MethodReference me
return result;
}
- protected JSExpression Translate_InvokeCallSiteTarget (ILExpression node, MethodReference method) {
- ILExpression ldtarget, ldcallsite;
-
- ldtarget = node.Arguments[0];
- if (ldtarget.Code == ILCode.Ldloc) {
- ldcallsite = node.Arguments[1];
- } else if (ldtarget.Code == ILCode.Ldfld) {
- ldcallsite = ldtarget.Arguments[0];
- } else {
- throw new NotImplementedException(String.Format(
- "Unknown call site pattern: Invalid load of target {0}", ldtarget
- ));
- }
-
- DynamicCallSiteInfo callSite;
-
- if (ldcallsite.Code == ILCode.Ldloc) {
- if (!DynamicCallSites.Get((ILVariable)ldcallsite.Operand, out callSite))
- return new JSUntranslatableExpression(node);
- } else if (ldcallsite.Code == ILCode.GetCallSite) {
- if (!DynamicCallSites.Get((FieldReference)ldcallsite.Operand, out callSite))
- return new JSUntranslatableExpression(node);
- } else {
- throw new NotImplementedException(String.Format(
- "Unknown call site pattern: Invalid load of callsite {0}", ldcallsite
- ));
- }
-
- var invocationArguments = Translate(node.Arguments.Skip(1));
- return callSite.Translate(this, invocationArguments.ToArray());
- }
-
- protected JSExpression Translate_GetCallSite (ILExpression node, FieldReference field) {
- return new JSNullExpression();
- }
-
- protected JSExpression Translate_GetCallSiteBinder (ILExpression node) {
- return new JSNullExpression();
- }
-
- protected JSExpression Translate_GetCallSiteBinder (ILExpression node, object o) {
- return new JSNullExpression();
- }
-
- protected JSExpression Translate_CreateCallSite (ILExpression node, FieldReference field) {
- return new JSNullExpression();
- }
-
protected JSExpression Translate_CallGetter (ILExpression node, MethodReference getter) {
var result = Translate_Call(node, getter);
diff --git a/JSIL/JSIL.csproj b/JSIL/JSIL.csproj
index 0be506ef6..d31ae999d 100644
--- a/JSIL/JSIL.csproj
+++ b/JSIL/JSIL.csproj
@@ -72,7 +72,6 @@
-
diff --git a/JSIL/TypeInformation.cs b/JSIL/TypeInformation.cs
index f04376965..66dd44b29 100644
--- a/JSIL/TypeInformation.cs
+++ b/JSIL/TypeInformation.cs
@@ -1127,8 +1127,7 @@ protected IMemberInfo AddProxyMember (ProxyInfo proxy, EventDefinition evt) {
static readonly Regex IgnoredKeywordRegex = new Regex(
@"\|" +
- @"Runtime\.CompilerServices\.CallSite|\|__SiteContainer|" +
- @"__DynamicSite",
+ @"\",
RegexOptions.Compiled
);
@@ -1182,26 +1181,11 @@ public string FullName {
}
public static bool IsIgnoredName (string shortName) {
- foreach (Match m2 in IgnoredKeywordRegex.Matches(shortName)) {
- if (m2.Success) {
- var length = m2.Length;
- var index = m2.Index;
- if (
- (length >= 2) &&
- (shortName[index] == '_') &&
- (shortName[index + 1] == '_')
- ) {
- switch (m2.Value) {
- case "__DynamicSite":
- case "__SiteContainer":
- return true;
-
- default:
- return false;
- }
- } else {
- return true;
- }
+ foreach (Match m2 in IgnoredKeywordRegex.Matches(shortName))
+ {
+ if (m2.Success)
+ {
+ return true;
}
}
diff --git a/Meta b/Meta
index 7ab12f0b0..b185a3d1a 160000
--- a/Meta
+++ b/Meta
@@ -1 +1 @@
-Subproject commit 7ab12f0b00b837f7e71ddec7b578225bd4b680db
+Subproject commit b185a3d1a30e6d580456e6d78eaf07f0b06a13bb
diff --git a/Proxies/SuppressDeclaration.cs b/Proxies/SuppressDeclaration.cs
index 847b624c3..70d84963b 100644
--- a/Proxies/SuppressDeclaration.cs
+++ b/Proxies/SuppressDeclaration.cs
@@ -37,7 +37,7 @@
typeof (IList<>),
typeof (IEnumerable),
typeof (ICollection),
- typeof (IList),
+ typeof (IList)
},
inheritable: false)]
[JSSuppressTypeDeclaration]
@@ -56,7 +56,13 @@ public class SuppressDeclarationByType
"System.Reflection.RuntimePropertyInfo",
"System.Reflection.RuntimeEventInfo",
"System.Reflection.RuntimeParameterInfo",
- "System.Empty"
+ "System.Empty",
+
+ "Microsoft.CSharp.RuntimeBinder.Binder",
+ "Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo",
+ "System.Runtime.CompilerServices.CallSite",
+ "System.Runtime.CompilerServices.CallSite`1",
+ "System.Runtime.CompilerServices.CallSiteBinder"
},
inheritable: false)]
[JSSuppressTypeDeclaration]
diff --git a/Tests/FailingTests.cs b/Tests/FailingTests.cs
index f52c3e149..1ccc22c0a 100644
--- a/Tests/FailingTests.cs
+++ b/Tests/FailingTests.cs
@@ -84,5 +84,23 @@ public void FailingTestCases (object[] parameters) {
protected IEnumerable FailingTestCasesSource () {
return FolderTestSource("FailingTestCases", MakeDefaultProvider(), new AssemblyCache());
}
+
+ [Test]
+ public void VerbatimDynamic()
+ {
+ try
+ {
+ var js = GetJavascript(
+ @"SpecialTestCases\Issue548.cs",
+ "{\"obj1\":\"{}\"}"
+ );
+ }
+ catch (Exception)
+ {
+ return;
+ }
+
+ Assert.Fail("Test passed when it should have failed");
+ }
}
}
\ No newline at end of file
diff --git a/Tests/FormattingTests.cs b/Tests/FormattingTests.cs
index a355c4f3b..6936a4764 100644
--- a/Tests/FormattingTests.cs
+++ b/Tests/FormattingTests.cs
@@ -819,30 +819,6 @@ public void InterfaceVariance () {
}
}
- [Test]
- public void CallSiteVariablesEliminated () {
- var output = "a\r\n6";
- var generatedJs = GetJavascript(
- @"TestCases\DynamicReturnTypes.cs",
- output, () => {
- var cfg = MakeConfiguration();
- cfg.CodeGenerator.CacheTypeExpressions = true;
- return cfg;
- }
- );
-
- try {
- Assert.IsFalse(
- generatedJs.Contains(".CallSite"),
- "A CallSite was not fully eliminated"
- );
- } catch {
- Console.WriteLine(generatedJs);
-
- throw;
- }
- }
-
[Test]
public void SpuriousIntegerHints () {
var output = "0F0F\r\n7773";
diff --git a/Tests/MetadataTests.cs b/Tests/MetadataTests.cs
index 09b13bd98..a54799370 100644
--- a/Tests/MetadataTests.cs
+++ b/Tests/MetadataTests.cs
@@ -446,7 +446,7 @@ public void ComplexDynamics () {
Assert.Fail("Translated JS ran successfully");
} catch (JavaScriptEvaluatorException jse) {
- Assert.IsTrue(jse.ToString().Contains("TypeError: document is undefined"), jse.ToString());
+ Assert.IsTrue(jse.ToString().Contains("TypeError: realTarget is undefined"), jse.ToString());
}
}
@@ -460,7 +460,7 @@ public void ComplexDynamicsMonoBinary () {
Assert.Fail("Translated JS ran successfully");
} catch (JavaScriptEvaluatorException jse) {
- Assert.IsTrue(jse.ToString().Contains("TypeError: obj is undefined"), jse.ToString());
+ Assert.IsTrue(jse.ToString().Contains("TypeError: realTarget is undefined"), jse.ToString());
}
}
diff --git a/Tests/SimpleTestCases/Issue913.cs b/Tests/SimpleTestCases/Issue913.cs
new file mode 100644
index 000000000..53ea7744d
--- /dev/null
+++ b/Tests/SimpleTestCases/Issue913.cs
@@ -0,0 +1,26 @@
+using System;
+
+public static class Program
+{
+ public static class TmpClss
+ {
+ public static T CallSite;
+ };
+
+ public static void Main(string[] args)
+ {
+ if (TmpClss.CallSite == null)
+ {
+ TmpClss.CallSite = () => Console.WriteLine("!");
+ }
+ var action = TmpClss.CallSite;
+ RunMe();
+
+ action();
+ }
+
+ public static void RunMe()
+ {
+ TmpClss.CallSite = () => Console.WriteLine("!!");
+ }
+}
\ No newline at end of file
diff --git a/Tests/SimpleTests.csproj b/Tests/SimpleTests.csproj
index 1b72af50b..e6b0e5184 100644
--- a/Tests/SimpleTests.csproj
+++ b/Tests/SimpleTests.csproj
@@ -139,6 +139,7 @@
+
diff --git a/Tests/SpecialTestCases/Issue548.cs b/Tests/SpecialTestCases/Issue548.cs
index d4b88bb18..18634f355 100644
--- a/Tests/SpecialTestCases/Issue548.cs
+++ b/Tests/SpecialTestCases/Issue548.cs
@@ -3,8 +3,8 @@
public static class Program {
public static void Main (string[] args) {
- var obj1 = Verbatim.Expression("{}");
- var obj2 = Verbatim.Expression("{obj1: JSON.stringify($0)}", obj1);
+ var obj1 = (dynamic)Verbatim.Expression("{}");
+ var obj2 = (dynamic)Verbatim.Expression("{obj1: JSON.stringify($0)}", obj1);
Console.WriteLine(Verbatim.Expression("JSON.stringify($0)", obj2));
}
}
\ No newline at end of file
diff --git a/Tests/SpecialTestCases/Verbatim.cs b/Tests/SpecialTestCases/Verbatim.cs
index 1031dcab4..e0276dc42 100644
--- a/Tests/SpecialTestCases/Verbatim.cs
+++ b/Tests/SpecialTestCases/Verbatim.cs
@@ -3,7 +3,7 @@
public static class Program {
public static int Add (int a, int b) {
- return Verbatim.Expression("a + b");
+ return (int)(Verbatim.Expression("a + b") ?? 0);
}
public static void Main (string[] args) {
diff --git a/Tests/SpecialTestCases/VerbatimVariables.cs b/Tests/SpecialTestCases/VerbatimVariables.cs
index eb1ffc1c3..9488af7ca 100644
--- a/Tests/SpecialTestCases/VerbatimVariables.cs
+++ b/Tests/SpecialTestCases/VerbatimVariables.cs
@@ -7,7 +7,7 @@ public static void Main (string[] args) {
var a = 2;
var b = 5;
Console.WriteLine(Verbatim.Expression("$0 + $1", a, b));
- int i = Verbatim.Expression("$0 + $1", a, b);
+ int i = (int)(Verbatim.Expression("$0 + $1", a, b) ?? 0);
Console.WriteLine(i);
}
}
\ No newline at end of file
diff --git a/Tests/VerbatimTests.cs b/Tests/VerbatimTests.cs
index ac14ded6b..7fe7f7784 100644
--- a/Tests/VerbatimTests.cs
+++ b/Tests/VerbatimTests.cs
@@ -78,13 +78,5 @@ public void VerbatimVariablesExistingArray () {
"hello\r\n7"
);
}
-
- [Test]
- public void VerbatimDynamic () {
- var js = GetJavascript(
- @"SpecialTestCases\Issue548.cs",
- "{\"obj1\":\"{}\"}"
- );
- }
}
}
diff --git a/Upstream/ILSpy b/Upstream/ILSpy
index b445b9a7e..244f5dfd8 160000
--- a/Upstream/ILSpy
+++ b/Upstream/ILSpy
@@ -1 +1 @@
-Subproject commit b445b9a7ee5412c86a77ab594e7a6bf2ff24ea6d
+Subproject commit 244f5dfd8bac869ace799cc4e970fbdc8eba43e0