Skip to content

Commit

Permalink
partial fix for HaxeFoundation#20 uint/32 "-ve" constants and >>0 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
elliott5 committed Feb 12, 2014
1 parent 3837a4a commit 1229c89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions haxe/goclass.go
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion haxe/ops.go
Expand Up @@ -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:
Expand Down

0 comments on commit 1229c89

Please sign in to comment.