diff --git a/haxe/goclass.go b/haxe/goclass.go index e858bcb921c..b5798acd76f 100644 --- a/haxe/goclass.go +++ b/haxe/goclass.go @@ -134,9 +134,11 @@ func (langType) Const(lit ssa.Const, position string) (typ, val string) { } switch lit.Type().Underlying().(*types.Basic).Kind() { case types.Uint, types.Uint32, types.Uint16, types.Uint8: - if l == -1 { - return "Int", - " #if js untyped __js__(\"0xffffffff\") #elseif php untyped __php__(\"0xffffffff\") #else (-1) #end " + if l < 0 { + q := uint64(l) & 0xFFFFFFFF + return "Int", fmt.Sprintf( + " #if js untyped __js__(\"0x%x\") #elseif php untyped __php__(\"0x%x\") #else 0x%x #end ", + q, q, q) } else { return "Int", fmt.Sprintf(" (%d) ", l) } diff --git a/haxe/ops.go b/haxe/ops.go index 33c7056331e..98aaba8af92 100644 --- a/haxe/ops.go +++ b/haxe/ops.go @@ -235,7 +235,7 @@ func (l langType) codeBinOp(op string, v1, v2 interface{}, errorInfo string) str op = ">>>" // logical right shift if unsigned } } - ret = "(" + v1string + op + v2string + ")" + ret = "({var _v1:Int=" + v1string + "; var _v2:Int=" + v2string + "; _v2==0?_v1:_v1" + op + "_v2;})" //NoOp if v2==0 case "/": switch v1.(ssa.Value).Type().Underlying().(*types.Basic).Kind() { case types.Int8: