The special case for `typeof` is still necessary just as I've described
in the comments for visitUnaryExpression:
// Details: noteCallSite() may change the expression to =>
// `typeof ($lzsc$a.lineno = 42, <ID>)`
// If <ID> is not defined in the lexical environment, the comma expression
// throws a ReferenceError when it is evaluated. Therefore we can't allow
// noteCallSite() for identifiers here.
If <ID> is not defined in the lexical enviroment, `typeof <ID>` yields
"undefined", but `typeof ($lzsc$a.lineno = 42, <ID>)` would throw a
ReferenceError because the comma expression is evaluated before the
`typeof` operator is applied.
On 4/6/2011 10:30 PM, P T Withington wrote:
Approved. This is nice to get cleaned up.
Side note, not sure we still need the special-casing of `typeof` any more.
CodeGenerator used to insert 'assembly language' tests to signal an error any
time the evaluation of a variable was `undefined`. Way back when, the only
approved way to avoid this check if you really wanted to see if a variable was
undefined was to write `typeof foo == 'undefined'`. Since we're not emitting
those checks any more (and it is perfectly legal for a variable to evaluate to
undefined), we should be able to leave out that special case now.
[It _is_ an error to reference a non-existent variable, but the special case
code can't do anything about that.]
On 2011-04-06, at 11:54, André Bargull wrote:
Change bargull-20110406-rsz by bargull@Bargull02 on 2011-04-06 17:20:38
in /home/anba/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Remove stale "undefined reference checker" code in JavascriptGenerator
Bugs Fixed: LPP-9874 (Broken "undefined reference checker" code in
JavascriptGenerator produces excessive try-catch blocks)
Technical Reviewer: ptw
QA Reviewer: (pending)
Details:
JavascriptGenerator:
- checkUndefinedFunction() and checkUndefinedMethod() are no longer used, can
be removed safely to reduce maintenance overhead
- visitPrefixExpression(), visitPostfixExpression() and visitAssignmentExpression() expanded the
code if free references are present to support the "undefined reference checker", but the
"undefined reference checker" is merely a leftover from CodeGenerator and not actually
implemented in JavascriptGenerator, therefore the complete code expansion is not necessary (anymore)
- XfixInstrs and AssignOpTable are only support maps and now no longer used ->
removed
- identifierPattern, another unused variable -> removed
- translateReferenceForCall(SimpleNode) was never called -> removed
- translateReferenceForCall(SimpleNode,boolean,SimpleNode) removed outcommented
code
- visitUnaryExpression(), removed ASTPropertyValueReference and ASTPropertyIdentifierReference from whitelist
for "typeof" operator, only ASTIdentifier is important for "typeof". The other two ast
types are only necessary for swf8, consider "typeof ({}).foo" which shouldn't emit an undefined
reference warning
JavascriptGenerator$JavascriptReference:
- removed referenceCount argument of constructor -> not used, swf8-specific
ParseTreePrinter:
- don't call maybeAddParens() for second child of
ASTPropertyIdentifierReference, because the second child is _always_ an
ASTIdentifier and maybeAddParens() is a no-op for ASTIdentifier
Tests:
smokecheck x (dhtml,swf10)
Files:
M WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/bargull-20110406-rsz.tar