Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/HaxeFoundation/as3hx into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
Slava Buynov committed Nov 21, 2017
2 parents d79cf07 + 1b60f05 commit f46c7f9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"version": "1.0.6",
"classPath": "src",
"releasenote": "Continued improvements",
"contributors": [ "singmajesty" ],
"contributors": [ "singmajesty", "mastef" ],
"dependencies": {}
}
8 changes: 6 additions & 2 deletions src/as3hx/Writer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Writer
var context : Map<String,String>;
var contextStack : Array<Map<String,String>>;
var inArrayAccess : Bool;
var inEField : Bool;
var inE4XFilter : Bool;
var inLvalAssign : Bool; // current expr is lvalue in assignment (expr = valOfSomeSort)
var rvalue : Expr;
Expand All @@ -51,6 +52,7 @@ class Writer
this.context = new Map();
this.contextStack = new Array();
this.inArrayAccess = false;
this.inEField = false;
this.inE4XFilter = false;
this.inLvalAssign = false;
this.lineIsDirty = false;
Expand Down Expand Up @@ -1008,7 +1010,7 @@ class Writer
var isString = (itype == "String");
var oldInLVA = inLvalAssign;
inLvalAssign = false;
if(oldInLVA)
if(oldInLVA && !inEField)
write("Reflect.setField(");
else
write("Reflect.field(");
Expand All @@ -1018,7 +1020,7 @@ class Writer
if(!isString) write("Std.string(");
writeExpr(index);
if(!isString) write(")");
if(oldInLVA) {
if(oldInLVA && !inEField) {
write(", ");
writeExpr(rvalue);
rvalue = null;
Expand Down Expand Up @@ -1548,6 +1550,7 @@ class Writer
write(".node");
write("." + f + ".innerData");
} else {
inEField = true;
switch(e) {
case EField(e2, f2):
//write("/* -- " +e2+ " " +getExprType(e2)+" */");
Expand Down Expand Up @@ -1596,6 +1599,7 @@ class Writer
writeExpr(e);
write("." + f);
}
inEField = false;
inArrayAccess = old;
return Semi;
}
Expand Down
15 changes: 15 additions & 0 deletions test/issues/Issue314.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package {
public class Issue303 {
public function Issue303() {}
public function hide1(param1:*) : *
{
this[param1] = false;
this[param1].visible = false;
}
public function hide2(param1:*) : *
{
this[param1] = "nothing";
this[param1].collision.currentObject = "nothing";
}
}
}
17 changes: 17 additions & 0 deletions test/issues/Issue314.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

class Issue303
{
public function new()
{
}
public function hide1(param1 : Dynamic) : Dynamic
{
Reflect.setField(this, Std.string(param1), false);
Reflect.field(this, Std.string(param1)).visible = false;
}
public function hide2(param1 : Dynamic) : Dynamic
{
Reflect.setField(this, Std.string(param1), "nothing");
Reflect.field(this, Std.string(param1)).collision.currentObject = "nothing";
}
}
5 changes: 5 additions & 0 deletions test/unit/as3hx/AS3HXTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ class AS3HXTest {
generate("Issue303.as", "Issue303.hx");
}

@Test("this[param1].something = false")
public function issue314() {
generate("Issue314.as", "Issue314.hx");
}

function generate(as3FileName:String, expectedHaxeFileName:String) {
var issuesDirectory = FileSystem.absolutePath("test/issues");
var generatedDirectoryPath = '$issuesDirectory/generated';
Expand Down

0 comments on commit f46c7f9

Please sign in to comment.