sq / JSIL

CIL to Javascript Compiler
http://jsil.org/
Other
1.73k stars 241 forks source link

Uncaught TypeError: Cannot read property 'X' of undefined #279

Open robot9706 opened 11 years ago

robot9706 commented 11 years ago

Hello! I just wanted to port a really simple XNA 4.0 project to JS and when I try to run it in my browser (Google Chrome) it throws me this error: "Uncaught TypeError: Cannot read property 'X' of undefined". Stack trace:

Microsoft_Xna_Framework_Vector2_op_Addition$lbvec$cmvec$rb Microsoft.Xna.Framework.Vector2.op_Addition[vec,vec]:6
Game1_Update XnaJSILTest,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:149
Game_TimedUpdate XNA4.js:1337
Game_VariableTimeStep XNA4.js:1442
Game_TimeStep XNA4.js:1519
Game_Step

Here's the "Microsoft.Xna.Framework.Vector2.op_Addition[vec,vec]" code:

(function() {
//# sourceURL=jsil://closure/Microsoft.Xna.Framework.Vector2.op_Addition[vec,vec]
"use strict";
function Microsoft_Xna_Framework_Vector2_op_Addition$lbvec$cmvec$rb(lhs, rhs) {
    return new this.$instance(
    +(lhs.X + rhs.X),
    +(lhs.Y + rhs.Y)
    );
    };
        return Microsoft_Xna_Framework_Vector2_op_Addition$lbvec$cmvec$rb;
})

Here's the Xna Project and the converted code if it helps: http://www.mediafire.com/download/awtrsae7aeq1d7g/XnaJsPort.zip img

kg commented 11 years ago

That's most likely caused by some other unimplemented method called earlier on, that then returned undefined. Then when you pass undefined into the addition operator, it fails. Check the log to see what's unimplemented?

robot9706 commented 11 years ago

I think I found something:

Error: The external method 'Microsoft.Xna.Framework.Vector2 op_Multiply(Microsoft.Xna.Framework.Vector2, System.Single)' of type 'Microsoft.Xna.Framework.Vector2' has not been implemented.
    at Function.ExternalMemberStub (file:///C:/Users/Me/Desktop/XnaGameHTML5/Libraries/JSIL.Core.js:1222:17)
    at MethodSignature_CallStatic$0$2 [as CallStatic] (jsil://closure/MethodSignature.CallStatic$0$2:10:19)
    at Object.Game1_Update (file:///C:/Users/Me :D/Desktop/XnaGameHTML5/Game/XnaJSILTest,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:151:60)
    at Object.Game_TimedUpdate [as _TimedUpdate] (file:///C:/Users/asd/Desktop/XnaGameHTML5/Libraries/XNA/XNA4.js:1337:10)
    at Object.Game_VariableTimeStep [as _VariableTimeStep] (file:///C:/Users/asd/Desktop/XnaGameHTML5/Libraries/XNA/XNA4.js:1442:10)
    at Object.Game_TimeStep [as _TimeStep] (file:///C:/Users/asd/Desktop/XnaGameHTML5/Libraries/XNA/XNA4.js:1519:14)
    at Object.Game_Step [as _Step] (file:///C:/Users/asd/Desktop/XnaGameHTML5/Libraries/XNA/XNA4.js:1509:10)
kg commented 11 years ago

Yeah, that's probably it. Odd, I thought i implemented that. I'll take a look.

robot9706 commented 11 years ago

Ok, Thanks :)