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/JSIL.JSObjectHelper.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JSObjectHelper.js
new file mode 100644
index 000000000..82162dba7
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JSObjectHelper.js
@@ -0,0 +1,497 @@
+(function JsObjectHelpers$Members() {
+ var $, $thisType;
+
+ function JsObjectHelpers_As$b1(T, obj) {
+ return T.$As(obj);
+ };
+
+ function JsObjectHelpers_AssumeType$b1(T, obj) {
+ return obj;
+ };
+
+ function JsObjectHelpers_Call(target, key) {
+ return target[key]();
+ };
+
+ function JsObjectHelpers_Call$b1(TArg1, target, key, arg1) {
+ return target[key](arg1);
+ };
+
+ function JsObjectHelpers_Call$b2(TArg1, TArg2, target, key, arg1, arg2) {
+ return target[key](arg1, arg2);
+ };
+
+ function JsObjectHelpers_Call$b3(TArg1, TArg2, TArg3, target, key, arg1, arg2, arg3) {
+ return target[key](arg1, arg2, arg3);
+ };
+
+ function JsObjectHelpers_Call$b4(TArg1, TArg2, TArg3, TArg4, target, key, arg1, arg2, arg3, arg4) {
+ return target[key](arg1, arg2, arg3, arg4);
+ };
+
+ function JsObjectHelpers_Call$b5(TArg1, TArg2, TArg3, TArg4, TArg5, target, key, arg1, arg2, arg3, arg4, arg5) {
+ return target[key](arg1, arg2, arg3, arg4, arg5);
+ };
+
+ function JsObjectHelpers_Call$b6(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, target, key, arg1, arg2, arg3, arg4, arg5, arg6) {
+ return target[key](arg1, arg2, arg3, arg4, arg5, arg6);
+ };
+
+ function JsObjectHelpers_Call$b7(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, target, key, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
+ return target[key](arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+ };
+
+ function JsObjectHelpers_Call$b8(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, target, key, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
+ return target[key](arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ };
+
+ function JsObjectHelpers_Cast$b1(T, obj) {
+ return T.$Cast(obj);
+ };
+
+ function JsObjectHelpers_Delete(target, key) {
+ delete target[key];
+ };
+
+ function JsObjectHelpers_Get(target, key) {
+ return target[key];
+ };
+
+ function JsObjectHelpers_In(target, key) {
+ return key in target;
+ };
+
+ function JsObjectHelpers_Invoke(target) {
+ return target();
+ };
+
+ function JsObjectHelpers_Invoke$b1(TArg1, target, arg1) {
+ return target(arg1);
+ };
+
+ function JsObjectHelpers_Invoke$b2(TArg1, TArg2, target, arg1, arg2) {
+ return target(arg1, arg2);
+ };
+
+ function JsObjectHelpers_Invoke$b3(TArg1, TArg2, TArg3, target, arg1, arg2, arg3) {
+ return target(arg1, arg2, arg3);
+ };
+
+ function JsObjectHelpers_Invoke$b4(TArg1, TArg2, TArg3, TArg4, target, arg1, arg2, arg3, arg4) {
+ return target(arg1, arg2, arg3, arg4);
+ };
+
+ function JsObjectHelpers_Invoke$b5(TArg1, TArg2, TArg3, TArg4, TArg5, target, arg1, arg2, arg3, arg4, arg5) {
+ return target(arg1, arg2, arg3, arg4, arg5);
+ };
+
+ function JsObjectHelpers_Invoke$b6(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, target, arg1, arg2, arg3, arg4, arg5, arg6) {
+ return target(arg1, arg2, arg3, arg4, arg5, arg6);
+ };
+
+ function JsObjectHelpers_Invoke$b7(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, target, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
+ return target(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+ };
+
+ function JsObjectHelpers_Invoke$b8(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, target, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
+ return target(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ };
+
+ function JsObjectHelpers_Is$b1(T, obj) {
+ return T.$Is(obj);
+ };
+
+ function JsObjectHelpers_New(target) {
+ return new target();
+ };
+
+ function JsObjectHelpers_New$b1(TArg1, target, arg1) {
+ return new target(arg1);
+ };
+
+ function JsObjectHelpers_New$b2(TArg1, TArg2, target, arg1, arg2) {
+ return new target(arg1, arg2);
+ };
+
+ function JsObjectHelpers_New$b3(TArg1, TArg2, TArg3, target, arg1, arg2, arg3) {
+ return new target(arg1, arg2, arg3);
+ };
+
+ function JsObjectHelpers_New$b4(TArg1, TArg2, TArg3, TArg4, target, arg1, arg2, arg3, arg4) {
+ return new target(arg1, arg2, arg3, arg4);
+ };
+
+ function JsObjectHelpers_New$b5(TArg1, TArg2, TArg3, TArg4, TArg5, target, arg1, arg2, arg3, arg4, arg5) {
+ return new target(arg1, arg2, arg3, arg4, arg5);
+ };
+
+ function JsObjectHelpers_New$b6(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, target, arg1, arg2, arg3, arg4, arg5, arg6) {
+ return new target(arg1, arg2, arg3, arg4, arg5, arg6);
+ };
+
+ function JsObjectHelpers_New$b7(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, target, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
+ return new target(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+ };
+
+ function JsObjectHelpers_New$b8(TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, target, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
+ return new target(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ };
+
+ function JsObjectHelpers_Set$b1(TValue, target, key, value) {
+ target[key] = value;
+ };
+
+ JSIL.MakeStaticClass("JSIL.JsObjectHelpers", true, [], function ($ib) {
+ $ = $ib;
+
+ $.Method({ Static: true, Public: true }, "As",
+ new JSIL.MethodSignature("!!0", [$jsilcore.TypeRef("JSIL.JsObject")], ["T"]),
+ JsObjectHelpers_As$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "AssumeType",
+ new JSIL.MethodSignature("!!0", [$jsilcore.TypeRef("JSIL.JsObject")], ["T"]),
+ JsObjectHelpers_AssumeType$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$jsilcore.TypeRef("JSIL.JsObject"), $.String]),
+ JsObjectHelpers_Call
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0"
+ ], ["TArg1"]),
+ JsObjectHelpers_Call$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1"
+ ], ["TArg1", "TArg2"]),
+ JsObjectHelpers_Call$b2
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1",
+ "!!2"
+ ], ["TArg1", "TArg2", "TArg3"]),
+ JsObjectHelpers_Call$b3
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1",
+ "!!2", "!!3"
+ ], ["TArg1", "TArg2", "TArg3", "TArg4"]),
+ JsObjectHelpers_Call$b4
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1",
+ "!!2", "!!3",
+ "!!4"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5"
+ ]),
+ JsObjectHelpers_Call$b5
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1",
+ "!!2", "!!3",
+ "!!4", "!!5"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6"
+ ]),
+ JsObjectHelpers_Call$b6
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1",
+ "!!2", "!!3",
+ "!!4", "!!5",
+ "!!6"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6", "TArg7"
+ ]),
+ JsObjectHelpers_Call$b7
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Call",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0", "!!1",
+ "!!2", "!!3",
+ "!!4", "!!5",
+ "!!6", "!!7"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6", "TArg7", "TArg8"
+ ]),
+ JsObjectHelpers_Call$b8
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Cast",
+ new JSIL.MethodSignature("!!0", [$jsilcore.TypeRef("JSIL.JsObject")], ["T"]),
+ JsObjectHelpers_Cast$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Delete",
+ new JSIL.MethodSignature(null, [$jsilcore.TypeRef("JSIL.JsObject"), $.String]),
+ JsObjectHelpers_Delete
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Get",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$jsilcore.TypeRef("JSIL.JsObject"), $.String]),
+ JsObjectHelpers_Get
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "In",
+ new JSIL.MethodSignature($.Boolean, [$jsilcore.TypeRef("JSIL.JsObject"), $.String]),
+ JsObjectHelpers_In
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$jsilcore.TypeRef("JSIL.JsObject+JsFunction")]),
+ JsObjectHelpers_Invoke
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0"], ["TArg1"]),
+ JsObjectHelpers_Invoke$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1"
+ ], ["TArg1", "TArg2"]),
+ JsObjectHelpers_Invoke$b2
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2"
+ ], ["TArg1", "TArg2", "TArg3"]),
+ JsObjectHelpers_Invoke$b3
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3"
+ ], ["TArg1", "TArg2", "TArg3", "TArg4"]),
+ JsObjectHelpers_Invoke$b4
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5"
+ ]),
+ JsObjectHelpers_Invoke$b5
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4",
+ "!!5"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6"
+ ]),
+ JsObjectHelpers_Invoke$b6
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4",
+ "!!5", "!!6"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6", "TArg7"
+ ]),
+ JsObjectHelpers_Invoke$b7
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Invoke",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4",
+ "!!5", "!!6",
+ "!!7"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6", "TArg7", "TArg8"
+ ]),
+ JsObjectHelpers_Invoke$b8
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Is",
+ new JSIL.MethodSignature($.Boolean, [$jsilcore.TypeRef("JSIL.JsObject")], ["T"]),
+ JsObjectHelpers_Is$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$jsilcore.TypeRef("JSIL.JsObject+JsFunction")]),
+ JsObjectHelpers_New
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0"], ["TArg1"]),
+ JsObjectHelpers_New$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1"
+ ], ["TArg1", "TArg2"]),
+ JsObjectHelpers_New$b2
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2"
+ ], ["TArg1", "TArg2", "TArg3"]),
+ JsObjectHelpers_New$b3
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3"
+ ], ["TArg1", "TArg2", "TArg3", "TArg4"]),
+ JsObjectHelpers_New$b4
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5"
+ ]),
+ JsObjectHelpers_New$b5
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4",
+ "!!5"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6"
+ ]),
+ JsObjectHelpers_New$b6
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4",
+ "!!5", "!!6"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6", "TArg7"
+ ]),
+ JsObjectHelpers_New$b7
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "New",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [
+ $jsilcore.TypeRef("JSIL.JsObject+JsFunction"), "!!0",
+ "!!1", "!!2",
+ "!!3", "!!4",
+ "!!5", "!!6",
+ "!!7"
+ ], [
+ "TArg1", "TArg2", "TArg3", "TArg4",
+ "TArg5", "TArg6", "TArg7", "TArg8"
+ ]),
+ JsObjectHelpers_New$b8
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+ $.Method({ Static: true, Public: true }, "Set",
+ new JSIL.MethodSignature(null, [
+ $jsilcore.TypeRef("JSIL.JsObject"), $.String,
+ "!!0"
+ ], ["TValue"]),
+ JsObjectHelpers_Set$b1
+ )
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+
+ return function (newThisType) { $thisType = newThisType; };
+ })
+ .Attribute($jsilcore.TypeRef("System.Runtime.CompilerServices.ExtensionAttribute"));
+
+})();
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JsObject.JSFunction.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JsObject.JSFunction.js
new file mode 100644
index 000000000..6104a4f0f
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JsObject.JSFunction.js
@@ -0,0 +1,29 @@
+(function JsFunction$Members() {
+ var $, $thisType;
+ var $T00 = function () {
+ return ($T00 = JSIL.Memoize($jsilcore.JSIL.JsObject))();
+ };
+
+ function JsFunction__ctor() {
+ $T00().prototype._ctor.call(this);
+ };
+
+ JSIL.MakeType({
+ BaseType: $jsilcore.TypeRef("JSIL.JsObject"),
+ Name: "JSIL.JsObject+JsFunction",
+ IsPublic: false,
+ IsReferenceType: true,
+ MaximumConstructorArguments: 0,
+ }, function ($ib) {
+ $ = $ib;
+
+ $.Method({ Static: false, Public: false }, ".ctor",
+ JSIL.MethodSignature.Void,
+ JsFunction__ctor
+ );
+
+
+ return function (newThisType) { $thisType = newThisType; };
+ });
+
+})();
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JsObject.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JsObject.js
new file mode 100644
index 000000000..c1c09401d
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.JsObject.js
@@ -0,0 +1,34 @@
+(function JsObject$Members() {
+ var $, $thisType;
+
+ function JsObject__ctor() {
+ };
+
+ function JsObject_Global(key) {
+ return JSIL.GlobalNamespace[key];
+ };
+
+ JSIL.MakeType({
+ BaseType: $jsilcore.TypeRef("System.Object"),
+ Name: "JSIL.JsObject",
+ IsPublic: true,
+ IsReferenceType: true,
+ MaximumConstructorArguments: 0,
+ }, function ($ib) {
+ $ = $ib;
+
+ $.Method({ Static: false, Public: false }, ".ctor",
+ JSIL.MethodSignature.Void,
+ JsObject__ctor
+ );
+
+ $.Method({ Static: true, Public: true }, "Global",
+ new JSIL.MethodSignature($.Type, [$.String]),
+ JsObject_Global
+ );
+
+
+ return function (newThisType) { $thisType = newThisType; };
+ });
+
+})();
\ No newline at end of file
diff --git a/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.Services.js b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.Services.js
new file mode 100644
index 000000000..b7a7235e4
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Classes/JSIL.Services.js
@@ -0,0 +1,20 @@
+(function Services$Members() {
+ var $, $thisType;
+
+ function Services_Get(serviceName, throwIfMissing) {
+ return JSIL.Host.getService(serviceName, !throwIfMissing);
+ };
+
+ JSIL.MakeStaticClass("JSIL.Services", true, [], function ($ib) {
+ $ = $ib;
+
+ $.Method({ Static: true, Public: true }, "Get",
+ new JSIL.MethodSignature($jsilcore.TypeRef("JSIL.JsObject"), [$.String, $.Boolean]),
+ Services_Get
+ );
+
+
+ return function (newThisType) { $thisType = newThisType; };
+ });
+
+})();
\ 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..b63e34e3e
--- /dev/null
+++ b/JSIL.Libraries/Includes/Bootstrap/Dynamic/Main.js
@@ -0,0 +1,27 @@
+"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/JSIL.JsObject.js"); writeln();
+//? include("Classes/JSIL.JsObject.JSFunction.js"); writeln();
+//? include("Classes/JSIL.JSObjectHelper.js"); writeln();
+
+//? 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..f201ba364 100644
--- a/JSIL.Libraries/JSIL.Libraries.csproj
+++ b/JSIL.Libraries/JSIL.Libraries.csproj
@@ -38,6 +38,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -277,6 +289,7 @@
+
@@ -339,6 +352,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..27a5bfafd 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();
@@ -849,61 +848,42 @@ JSExpression[] arguments
JSExpression commaFirstClause = null;
IDictionary argumentsDict = null;
- if (arguments.Length > 1) {
- var argumentsExpression = arguments[1];
- var argumentsArray = argumentsExpression as JSNewArrayExpression;
-
- if (method == null || method.Method.Parameters[1].ParameterType is GenericParameter) {
- // This call was made dynamically or through generic version of method, so the parameters are not an array.
-
- argumentsDict = new Dictionary();
-
- for (var i = 0; i < (arguments.Length - 1); i++)
- argumentsDict.Add(String.Format("{0}", i), arguments[i + 1]);
- } else if (argumentsArray == null) {
- // The array is static so we need to pull elements out of it after assigning it a name.
- // FIXME: Only handles up to 40 elements.
- var argumentsExpressionType = argumentsExpression.GetActualType(TypeSystem);
- var temporaryVariable = MakeTemporaryVariable(argumentsExpressionType);
- var temporaryAssignment = new JSBinaryOperatorExpression(JSOperator.Assignment, temporaryVariable, argumentsExpression, argumentsExpressionType);
-
- commaFirstClause = temporaryAssignment;
-
- argumentsDict = new Dictionary();
-
- for (var i = 0; i < 40; i++)
- argumentsDict.Add(String.Format("{0}", i), new JSIndexerExpression(temporaryVariable, JSLiteral.New(i)));
- } else {
- var argumentsArrayExpression = argumentsArray.SizeOrArrayInitializer as JSArrayExpression;
-
- if (argumentsArrayExpression == null)
- throw new NotImplementedException("Literal array must have values");
-
- argumentsDict = new Dictionary();
-
- int i = 0;
- foreach (var value in argumentsArrayExpression.Values) {
- argumentsDict.Add(String.Format("{0}", i), value);
+ if (arguments.Length > 1)
+ {
+ argumentsDict = new Dictionary();
- i += 1;
- }
- }
+ for (var i = 0; i < (arguments.Length - 1); i++)
+ argumentsDict.Add(String.Format("{0}", i), arguments[i + 1]);
}
var verbatimLiteral = new JSVerbatimLiteral(
methodName, expression.Value, argumentsDict
);
- if (commaFirstClause != null)
- return new JSCommaExpression(commaFirstClause, verbatimLiteral);
- else
- return verbatimLiteral;
+ return verbatimLiteral;
} else {
throw new NotImplementedException("Verbatim method not implemented: " + methodName);
}
break;
}
+ case "JSIL.JSObject":
+ {
+ if (methodName == "Global")
+ {
+ var expression = arguments[0] as JSStringLiteral;
+ if (expression != null)
+ return new JSDotExpression(
+ JSIL.GlobalNamespace, new JSStringIdentifier(expression.Value, TypeSystem.Object, true)
+ );
+ else
+ return new JSIndexerExpression(
+ JSIL.GlobalNamespace, arguments[0], TypeSystem.Object
+ );
+ }
+ break;
+ }
+
case "JSIL.JSGlobal": {
if (methodName == "get_Item") {
var expression = arguments[0] as JSStringLiteral;
@@ -1391,52 +1371,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 +2295,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 +3460,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..d0d7565d8 160000
--- a/Meta
+++ b/Meta
@@ -1 +1 @@
-Subproject commit 7ab12f0b00b837f7e71ddec7b578225bd4b680db
+Subproject commit d0d7565d81bad9febf30d2a5eb6e3fe719c95e72
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/BinaryTestCases/DynamicComplex.exe b/Tests/BinaryTestCases/DynamicComplex.exe
deleted file mode 100644
index f38afb236..000000000
Binary files a/Tests/BinaryTestCases/DynamicComplex.exe and /dev/null differ
diff --git a/Tests/ComparisonTests.cs b/Tests/ComparisonTests.cs
index c8d74c807..fb0565016 100644
--- a/Tests/ComparisonTests.cs
+++ b/Tests/ComparisonTests.cs
@@ -129,6 +129,7 @@ protected IEnumerable DynamicsSource () {
@"TestCases\DynamicSetIndex.cs",
@"TestCases\DynamicStaticOverloadedMethods.cs",
@"TestCases\DynamicUnaryOperators.cs",
+ @"TestCases\DynamicJsAPI.cs",
}, null, new AssemblyCache()
);
}
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..f0b518e28 100644
--- a/Tests/MetadataTests.cs
+++ b/Tests/MetadataTests.cs
@@ -446,23 +446,10 @@ 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());
}
}
- // Mono compiles this to different IL.
- [Test]
- public void ComplexDynamicsMonoBinary () {
- try {
- GetJavascript(
- @"BinaryTestCases\DynamicComplex.exe"
- );
-
- Assert.Fail("Translated JS ran successfully");
- } catch (JavaScriptEvaluatorException jse) {
- Assert.IsTrue(jse.ToString().Contains("TypeError: obj is undefined"), jse.ToString());
- }
- }
// Mono generates really weird control flow for this
[Test]
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/Eval.cs b/Tests/SpecialTestCases/Eval.cs
index 671d22627..ea31fd60f 100644
--- a/Tests/SpecialTestCases/Eval.cs
+++ b/Tests/SpecialTestCases/Eval.cs
@@ -3,9 +3,10 @@
public static class Program {
public static int Foo () {
- var result = Builtins.Eval("2") ?? 1;
-
- return (int)result;
+ if (Builtins.IsJavascript) {
+ return Builtins.Eval("2").AssumeType();
+ }
+ return 1;
}
public static void Main (string[] args) {
diff --git a/Tests/SpecialTestCases/IndexBuiltinByName.cs b/Tests/SpecialTestCases/IndexBuiltinByName.cs
index 1a93e64b9..8bdec68ba 100644
--- a/Tests/SpecialTestCases/IndexBuiltinByName.cs
+++ b/Tests/SpecialTestCases/IndexBuiltinByName.cs
@@ -3,19 +3,22 @@
public static class Program {
public static void Main (string[] args) {
- const string pri = "pri";
- string nt = "nt";
+ if (Builtins.IsJavascript)
+ {
+ const string pri = "pri";
+ string nt = "nt";
- var p = Builtins.Global[pri + nt] as dynamic;
- if (p != null)
- p("printed");
+ var p = Builtins.Global[pri + nt] as dynamic;
+ if (p != null)
+ p("printed");
- if (Builtins.Local["p"] != null)
- (Builtins.Local["p"] as dynamic)("printed again");
+ if (Builtins.Local["p"] != null)
+ (Builtins.Local["p"] as dynamic)("printed again");
- var q = Builtins.Global["quit"] as dynamic;
- if (q != null)
- q();
+ var q = Builtins.Global["quit"] as dynamic;
+ if (q != null)
+ q();
+ }
Console.WriteLine("test");
}
diff --git a/Tests/SpecialTestCases/Verbatim.cs b/Tests/SpecialTestCases/Verbatim.cs
index 1031dcab4..8145ca54e 100644
--- a/Tests/SpecialTestCases/Verbatim.cs
+++ b/Tests/SpecialTestCases/Verbatim.cs
@@ -2,13 +2,15 @@
using JSIL;
public static class Program {
- public static int Add (int a, int b) {
- return Verbatim.Expression("a + b");
+ public static int Add (int a, int b)
+ {
+ return Builtins.IsJavascript ? Verbatim.Expression("a + b").AssumeType() : 0;
}
public static void Main (string[] args) {
Console.WriteLine(Add(1, 3));
- Verbatim.Expression("return");
+ if (Builtins.IsJavascript)
+ Verbatim.Expression("return");
Console.WriteLine(2);
}
}
\ No newline at end of file
diff --git a/Tests/SpecialTestCases/VerbatimThis.cs b/Tests/SpecialTestCases/VerbatimThis.cs
index ba2444713..9f1ec56fe 100644
--- a/Tests/SpecialTestCases/VerbatimThis.cs
+++ b/Tests/SpecialTestCases/VerbatimThis.cs
@@ -4,7 +4,7 @@
public static class Program {
public class CustomType {
public CustomType () {
- Console.WriteLine("{0}", Builtins.This ?? "");
+ Console.WriteLine("{0}", Builtins.This);
}
}
diff --git a/Tests/SpecialTestCases/VerbatimVariables.cs b/Tests/SpecialTestCases/VerbatimVariables.cs
index eb1ffc1c3..f0e478249 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 = Verbatim.Expression("$0 + $1", a, b).AssumeType();
Console.WriteLine(i);
}
}
\ No newline at end of file
diff --git a/Tests/SpecialTestCases/VerbatimVariablesExistingArray.cs b/Tests/SpecialTestCases/VerbatimVariablesExistingArray.cs
deleted file mode 100644
index 8478db339..000000000
--- a/Tests/SpecialTestCases/VerbatimVariablesExistingArray.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using JSIL;
-
-public static class Program {
- static object[] A1 = new object[] { "hello" };
- static object[] A2 = new object[] { 2, 5 };
-
- public static void Main (string[] args) {
- Verbatim.Expression("print($0)", A1);
- Console.WriteLine(Verbatim.Expression("$0 + $1", A2));
- }
-}
\ No newline at end of file
diff --git a/Tests/TestCases/DynamicJsAPI.cs b/Tests/TestCases/DynamicJsAPI.cs
new file mode 100644
index 000000000..1ffb25041
--- /dev/null
+++ b/Tests/TestCases/DynamicJsAPI.cs
@@ -0,0 +1,17 @@
+using System;
+using JSIL;
+
+public static class Program {
+ public static void Main (string[] args) {
+ if (Builtins.IsJavascript)
+ {
+ dynamic a = 5;
+ var b = Verbatim.Expression("{GetValue: function(value) { return value + 10}}");
+ Console.WriteLine(JsObjectHelpers.Call