当把jscript.net翻译成c# 可以看出实际上是把js.net“解释”,再解释执行(但凡与js天生的灵活性相关的都用类似反射的方法来赋值)- using System;
- using System.Windows.Forms;
- using Microsoft.JScript;
- using Microsoft.JScript.Vsa;
-
- namespace Jscript_Net_Test;
-
- [Serializable]
- public class ES1ToES3 : INeedEngine
- {
- public object a;
-
- [NonSerialized]
- private VsaEngine vsa_0020Engine;
-
- static ES1ToES3()
- {
- }//Error decoding local variables: Signature type sequence must have at least one element.
-
-
- private void _002Einit()
- {
- //Error decoding local variables: Signature type sequence must have at least one element.
- a = "Windows Script Host||IE-Jscript";
- }
-
- public virtual void A()
- {
- //IL_0005: Unknown result type (might be due to invalid IL or missing references)
- //IL_000c: Expected O, but got Unknown
- //IL_0034: Unknown result type (might be due to invalid IL or missing references)
- //IL_003a: Expected O, but got Unknown
- //IL_0076: Unknown result type (might be due to invalid IL or missing references)
- //IL_007c: Expected O, but got Unknown
- //IL_0089: Unknown result type (might be due to invalid IL or missing references)
- //IL_008f: Expected O, but got Unknown
- //IL_0112: Unknown result type (might be due to invalid IL or missing references)
- //IL_0134: Unknown result type (might be due to invalid IL or missing references)
- //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
- //IL_01d0: Expected O, but got Unknown
- //IL_01e7: Unknown result type (might be due to invalid IL or missing references)
- //IL_01f3: Unknown result type (might be due to invalid IL or missing references)
- //IL_020b: Expected O, but got Unknown
- LateBinding val = new LateBinding("tan");
- FunctionObject val2 = FunctionExpression.JScriptFunctionExpression(typeof(ES1ToES3).TypeHandle, "anonymous 0", "A.anonymous 0", new string[0], (JSLocalField[])(object)new JSLocalField[1]
- {
- new JSLocalField("return value", typeof(bool).TypeHandle, 0)
- }, false, false, "function(){\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}", ((INeedEngine)this).GetEngine());
- FunctionObject val3 = FunctionExpression.JScriptFunctionExpression(typeof(ES1ToES3).TypeHandle, "anonymous 2", "A.anonymous 2", new string[0], (JSLocalField[])(object)new JSLocalField[2]
- {
- new JSLocalField("i", typeof(double).TypeHandle, 0),
- new JSLocalField("return value", typeof(ScriptFunction).TypeHandle, 1)
- }, true, false, "function(){\r\n\t\t\t\tvar i=0\r\n\t\t\t\treturn function(){\r\n\t\t\t\t\treturn i++;\r\n\t\t\t\t}\r\n\t\t\t}", ((INeedEngine)this).GetEngine());
- string text = "Jscript";
- double num = 5.6;
- double num2 = 7.0;
- object value = DBNull.Value;
- object obj = null;
- StringObject val4 = GlobalObject.String.CreateInstance(new object[1] { "hello" });
- num = GlobalObject.parseFloat((object)num);
- num2 = GlobalObject.parseInt((object)num2, (object)Missing.Value);
- MessageBox.Show(BooleanPrototype.toString((object)(StrictEquality.JScriptStrictEquals((object)"hello", (object)val4) ? true : false)));
- MessageBox.Show(BooleanPrototype.toString((object)(Equality.JScriptEquals((object)"hello", (object)val4) ? true : false)));
- JSObject obj2 = ((INeedEngine)this).GetEngine().GetOriginalObjectConstructor().ConstructObject();
- object[] obj3 = new object[7]
- {
- "a",
- 1,
- GlobalObject.Array.CreateInstance(new object[1] { 1 }),
- GlobalObject.Function.CreateInstance(new object[1] { "return 1" }),
- null,
- null,
- null
- };
- val.obj = GlobalObject.Math;
- obj3[4] = val.GetNonMissingValue();
- obj3[5] = GlobalObject.Date.CreateInstance(new object[0]);
- obj3[6] = (object)new Closure(val2);
- obj2.SetMemberValue2("array", (object)Globals.ConstructArrayLiteral(obj3));
- object obj4 = obj2;
- object obj5 = LateBinding.CallValue((object)((IActivationObject)((INeedEngine)this).GetEngine().ScriptObjectStackTop()).GetGlobalScope(), (object)new Closure(val3), new object[0], false, false, ((INeedEngine)this).GetEngine());
- With.JScriptWith((object)GlobalObject.Math, ((INeedEngine)this).GetEngine());
- try
- {
- double num3 = MathObject.tan(1.0);
- }
- finally
- {
- ((INeedEngine)this).GetEngine().PopScriptObject();
- }
- }
-
- [JSFunction(/*Could not decode attribute arguments.*/)]
- public static bool A_002Eanonymous_00200(object @this, VsaEngine vsa_0020Engine)
- {
- return true;
- }
-
- [JSFunction(/*Could not decode attribute arguments.*/)]
- public static ScriptFunction A_002Eanonymous_00202(object @this, VsaEngine vsa_0020Engine)
- {
- //IL_0028: Unknown result type (might be due to invalid IL or missing references)
- //IL_002e: Expected O, but got Unknown
- //IL_003b: Unknown result type (might be due to invalid IL or missing references)
- //IL_0041: Expected O, but got Unknown
- //IL_0053: Unknown result type (might be due to invalid IL or missing references)
- //IL_0059: Expected O, but got Unknown
- //IL_0064: Unknown result type (might be due to invalid IL or missing references)
- FunctionObject val = FunctionExpression.JScriptFunctionExpression(typeof(ES1ToES3).TypeHandle, "anonymous 1", "A.anonymous 2.anonymous 1", new string[0], (JSLocalField[])(object)new JSLocalField[2]
- {
- new JSLocalField("return value", typeof(double).TypeHandle, 0),
- new JSLocalField("i", typeof(double).TypeHandle, 1)
- }, false, false, "function(){\r\n\t\t\t\t\treturn i++;\r\n\t\t\t\t}", vsa_0020Engine);
- double num = 0.0;
- ScriptFunction val2 = (ScriptFunction)new Closure(val);
- object[] localVars = ((StackFrame)vsa_0020Engine.ScriptObjectStackTop()).localVars;
- localVars[0] = num;
- localVars[1] = val2;
- return val2;
- }
-
- [JSFunction(/*Could not decode attribute arguments.*/)]
- public static double A_002Eanonymous_00202_002Eanonymous_00201(object @this, VsaEngine vsa_0020Engine)
- {
- //IL_000c: Unknown result type (might be due to invalid IL or missing references)
- //IL_0045: Unknown result type (might be due to invalid IL or missing references)
- ScriptObject parent = vsa_0020Engine.ScriptObjectStackTop().GetParent();
- double num = Convert.ToNumber(((StackFrame)parent).localVars[0]);
- parent.GetParent().GetParent();
- double num2;
- num = (num2 = num) + 1.0;
- double result = num2;
- ScriptObject parent2 = vsa_0020Engine.ScriptObjectStackTop().GetParent();
- ((StackFrame)parent2).localVars[0] = num;
- parent2.GetParent().GetParent();
- return result;
- }
-
- public ES1ToES3()
- {
- //Error decoding local variables: Signature type sequence must have at least one element.
- _002Einit();
- }
-
- private override VsaEngine GetEngine()
- {
- //Error decoding local variables: Signature type sequence must have at least one element.
- if (vsa_0020Engine == null)
- {
- vsa_0020Engine = VsaEngine.CreateEngineWithType(typeof(ES1ToES3).TypeHandle);
- }
-
- return vsa_0020Engine;
- }
-
- private override void SetEngine(VsaEngine P_0)
- {
- //Error decoding local variables: Signature type sequence must have at least one element.
- vsa_0020Engine = P_0;
- }
- }
复制代码
|