vehre / aspa_cscc

Convert ASP pages to "pure" html/JS/PHP pages. Based on ASPA with conversion of client side VBscript to Javascript
Other
5 stars 1 forks source link

Handle unassigned variables with object and function wrappers for operations and types #27

Open jhiswin opened 10 years ago

jhiswin commented 10 years ago

Issue Overview: So far, definite assignment analysis (useBeforeInit) has issues that make it impractical and it isn't completely reliable.

So, implementing add(a,b), minus(a,b), concat(a,b) and compareTo(a,b), and etc seems to be the only automated solution. This can also benefit by fixing problems with primitive type coercion, which is different in VBScript and Javascript. eg: 0 + "1" is 1 in VBScript

Performance and Work time: Overhead should not be too much of an issue in modern browsers, and after using Closure Compiler (which can inline many of these calls with type analysis in Rhino). Functions should be trivial, and only needs to check for typeof === "undefined", and replace with corresponding value. Undefined wrapper may not even be necessary. This can also be used to fix issue #26

VBScript Behavior: Undefined variable behavior in VBScript: undefined == 0 undefined == "" 10 + undefined == 10 "" + undefined == "" undefined - 10 == -10 undefined is nothing

Solution: Translate a + b to add(a,b) if a = b then to if(compareTo(a,b)) a & b to concat(a,b) Use typeof a === "undefined" to handle behavior.