Skip to content

Commit

Permalink
Fixed conversion of typeof 3. fixes #300 (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavaRa authored Nov 13, 2017
1 parent b90f584 commit b0aff57
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 120 deletions.
9 changes: 5 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
## dev
- Fixed conversion of `typeof 3`. fixes #300
- Fixed conversion of `function(i:int = 1e5)`. fixes #303
- Fixed conversion of `function(i:int = 1.5)`. fixes #302
- Fixed conversion of `1.79E+308`. fixes #298
- Fixed conversion of `array[index]['key']`. fixes #261
- Fixed conversion of `setTimeout(callback, (a + b) * 1000)`. fixes #293
- Fixed conversion of `parseInt('0xFFFFFF', 16)`. fixes #265

## 2017-10-24(1.0.6)
- Fixed conversion of `default` keyword within `switch` statements. fixes #273
- Fixed conversion of `for(i; i < max; i++)`. fixes #285
Expand Down Expand Up @@ -71,7 +72,7 @@
- Inline alert message in generated code when trying to `delete` Dictionary keys
- Loops will be converted to `while` instead of `for` for proper iteration variable modification
- Only first character of package will be transformed to lower case

## 2016-08-05(1.0.3)
- Fixed call for `haxe.Json.parse` instead of `JSON.parse` (closes issue #83)
- Fixed casting of `uint(1)` (closes issue #85)
Expand Down Expand Up @@ -155,13 +156,13 @@
## 2011-10-14 - Russell
- cleaned formatting on comments
- added === support (missed)
- added -no-cast-guess
- added -no-cast-guess

## 2011-10-12 - Russell
- added comments
- fixed static var initializations were not output
- added output for the "as" keyword
- fixed "interface extends" to "interface implements"
- fixed "interface extends" to "interface implements"
- fixed interface functions were outputting empty bodies
- added ETernary
- fixed formatting on if...else
Expand Down
6 changes: 3 additions & 3 deletions src/as3hx/Tokenizer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Tokenizer {
var ops : Array<Bool>;
var idents : Array<Bool>;
var tokens : haxe.ds.GenericStack<Token>;

public function new(s:haxe.io.Input) {
line = 1;
pc = 1;
Expand Down Expand Up @@ -115,7 +115,7 @@ class Tokenizer {
}

public function token() : Token {
if( !tokens.isEmpty() )
if( !tokens.isEmpty() )
return tokens.pop();

var char = nextChar();
Expand Down Expand Up @@ -446,7 +446,7 @@ class Tokenizer {
}
return b.getBytes().toString();
}

public function end() {
Debug.openDebug("function end()", line, true);
while( ParserUtils.opt(this, TSemicolon) ) {
Expand Down
15 changes: 7 additions & 8 deletions src/as3hx/parsers/StructureParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,13 @@ class StructureParser {
case "typeof":
var e = parseExpr(false);
switch(e) {
case EBinop(op, e1, e2, n):
//if(op != "==" && op != "!=")
// ParserUtils.unexpected(TOp(op));
case EParent(e1):
case EIdent(id):
null;
default:
ParserUtils.unexpected(TId(Std.string(e)));
case EBinop(_, _, _, _):
//if(op != "==" && op != "!=")
// ParserUtils.unexpected(TOp(op));
case EParent(_):
case EIdent(_):
case EConst(_):
default: ParserUtils.unexpected(TId(Std.string(e)));
}
ETypeof(e);
case "delete":
Expand Down
9 changes: 9 additions & 0 deletions test/issues/Issue.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package {
public class Issue103 {
public function Issue103() {
var string:String = "";
var boolean:Boolean = true;
var number:Number = 10.1;
}
}
}
10 changes: 10 additions & 0 deletions test/issues/Issue.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

class Issue103
{
public function new()
{
var string : String = "";
var boolean : Bool = true;
var number : Float = 10.1;
}
}
7 changes: 7 additions & 0 deletions test/issues/Issue300.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package {
public class Issue300 {
public function Issue300() {
trace(typeof 3);
}
}
}
8 changes: 8 additions & 0 deletions test/issues/Issue300.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

class Issue300
{
public function new()
{
trace(as3hx.Compat.typeof(3));
}
}
Loading

0 comments on commit b0aff57

Please sign in to comment.