replace all reference of float to float64

now works with last version of go
This commit is contained in:
legoff.laurent 2011-02-02 21:38:05 +00:00
parent 07bd88f868
commit af5f13b7f4
11 changed files with 56 additions and 55 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 KiB

After

Width:  |  Height:  |  Size: 264 KiB

View file

@ -3,12 +3,13 @@ package main
import (
"fmt"
)
func main() {
toto := make([]int, 2, 2)
toto[0] = 1
toto[1] = 2
fmt.Printf("%v\n", toto);
fmt.Printf("%v\n", toto)
toto = toto[0:0]
fmt.Printf("%v\n", toto);
fmt.Printf("%v\n", cap(toto));
fmt.Printf("%v\n", toto)
fmt.Printf("%v\n", cap(toto))
}

View file

@ -46,6 +46,6 @@ func main() {
interpreter := postscript.NewInterpreter(gc)
interpreter.ExecuteFile("../../test_files/tiger.ps")
dt := time.Nanoseconds() - lastTime
fmt.Printf("Draw image: %f ms\n", float(dt)*1e-6)
fmt.Printf("Draw image: %f ms\n", float64(dt)*1e-6)
saveToPngFile("../../TestPostscript.png", i)
}

View file

@ -96,7 +96,7 @@ func (interpreter *Interpreter) scan(scanner *Scanner, token int) {
// procedure
interpreter.Push(interpreter.scanProcedure(scanner))
} else if token == Float || token == Int {
f, err := strconv.Atof(scanner.TokenText())
f, err := strconv.Atof64(scanner.TokenText())
if err != nil {
log.Printf("Float expected: %s\n", scanner.TokenText())
interpreter.Push(scanner.TokenText())
@ -262,9 +262,9 @@ func (interpreter *Interpreter) ClearOperands() {
// misc pop
func (interpreter *Interpreter) PopFloat() float {
func (interpreter *Interpreter) PopFloat() float64 {
operand := interpreter.Pop()
return operand.(float)
return operand.(float64)
}
func (interpreter *Interpreter) PopInt() int {

View file

@ -11,7 +11,7 @@ func array(interpreter *Interpreter) {
}
//array length int -> Return number of elements in array
func lengtharray(interpreter *Interpreter) {
interpreter.Push(float(len(interpreter.Pop().([]Value))))
interpreter.Push(float64(len(interpreter.Pop().([]Value))))
}
//array index get any -> Return array element indexed by index
func getarray(interpreter *Interpreter) {

View file

@ -9,7 +9,7 @@ import (
// type dicriminant
func commonCopy(interpreter *Interpreter) {
switch v := interpreter.Peek().(type) {
case float:
case float64:
copystack(interpreter)
case Dictionary:
copydict(interpreter)

View file

@ -14,12 +14,12 @@ func dict(interpreter *Interpreter) {
//dict length int -> Return number of entries in dict
func lengthdict(interpreter *Interpreter) {
dictionary := interpreter.Pop().(Dictionary)
interpreter.Push(float(len(dictionary)))
interpreter.Push(float64(len(dictionary)))
}
//dict maxlength int -> Return current capacity of dict
func maxlength(interpreter *Interpreter) {
interpreter.Pop()
interpreter.Push(float(999999999)) // push arbitrary value
interpreter.Push(float64(999999999)) // push arbitrary value
}
//dict begin -> Push dict on dictionary stack
func begin(interpreter *Interpreter) {
@ -133,7 +133,7 @@ func statusdict(interpreter *Interpreter) {
}
// countdictstack int -> Count elements on dictionary stack
func countdictstack(interpreter *Interpreter) {
interpreter.Push(float(interpreter.DictionaryStackSize()))
interpreter.Push(float64(interpreter.DictionaryStackSize()))
}
//array dictstack subarray -> Copy dictionary stack into array
func dictstack(interpreter *Interpreter) {

View file

@ -116,14 +116,14 @@ func setrgbcolor(interpreter *Interpreter) {
interpreter.GetGraphicContext().SetFillColor(color)
}
func hsbtorgb(hue, saturation, brightness float) (red, green, blue int) {
var fr, fg, fb float
func hsbtorgb(hue, saturation, brightness float64) (red, green, blue int) {
var fr, fg, fb float64
if saturation == 0 {
fr, fg, fb = brightness, brightness, brightness
} else {
H := (hue - float(math.Floor(float64(hue)))) * 6
I := int(math.Floor(float64(H)))
F := H - float(I)
H := (hue - math.Floor(hue)) * 6
I := int(math.Floor(H))
F := H - float64(I)
M := brightness * (1 - saturation)
N := brightness * (1 - saturation*F)
K := brightness * (1 - saturation*(1-F))
@ -335,10 +335,10 @@ func concatmatrix(interpreter *Interpreter) {
func transform(interpreter *Interpreter) {
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
var y float64
if !ok {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
y = value.(float64)
} else {
y = interpreter.PopFloat()
}
@ -351,10 +351,10 @@ func transform(interpreter *Interpreter) {
func itransform(interpreter *Interpreter) {
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
var y float64
if !ok {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
y = value.(float64)
} else {
y = interpreter.PopFloat()
}
@ -367,15 +367,15 @@ func itransform(interpreter *Interpreter) {
func translate(interpreter *Interpreter) {
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
var y float64
if !ok {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
y = value.(float64)
} else {
y = interpreter.PopFloat()
}
x := interpreter.PopFloat()
if(!ok) {
if !ok {
interpreter.GetGraphicContext().Translate(x, y)
} else {
matrix = draw2d.NewTranslationMatrix(x, y).Multiply(matrix)
@ -386,14 +386,14 @@ func translate(interpreter *Interpreter) {
func rotate(interpreter *Interpreter) {
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var angle float
if(!ok) {
var angle float64
if !ok {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
angle = value.(float) * math.Pi / 180
angle = value.(float64) * math.Pi / 180
} else {
angle = interpreter.PopFloat() * math.Pi / 180
}
if(!ok) {
if !ok {
interpreter.GetGraphicContext().Rotate(angle)
} else {
matrix = draw2d.NewRotationMatrix(angle).Multiply(matrix)
@ -404,15 +404,15 @@ func rotate(interpreter *Interpreter) {
func scale(interpreter *Interpreter) {
value := interpreter.Pop()
matrix, ok := value.(draw2d.MatrixTransform)
var y float
if(!ok) {
var y float64
if !ok {
matrix = interpreter.GetGraphicContext().GetMatrixTransform()
y = value.(float)
y = value.(float64)
} else {
y = interpreter.PopFloat()
}
x := interpreter.PopFloat()
if(!ok) {
if !ok {
interpreter.GetGraphicContext().Scale(x, y)
} else {
matrix = draw2d.NewScaleMatrix(x, y).Multiply(matrix)

View file

@ -27,13 +27,13 @@ func div(interpreter *Interpreter) {
func idiv(interpreter *Interpreter) {
int2 := interpreter.PopInt()
int1 := interpreter.PopInt()
interpreter.Push(float(int1 / int2))
interpreter.Push(float64(int1 / int2))
}
//int int mod remainder -> Return remainder after dividing int by int
func mod(interpreter *Interpreter) {
int2 := interpreter.PopInt()
int1 := interpreter.PopInt()
interpreter.Push(float(int1 % int2))
interpreter.Push(float64(int1 % int2))
}
//num1 num2 mul product -> Return num1 times num2
@ -51,7 +51,7 @@ func sub(interpreter *Interpreter) {
//num1 abs num2 -> Return absolute value of num1
func abs(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(math.Fabs(float64(f))))
interpreter.Push(math.Fabs(f))
}
//num1 neg num2 -> Return negative of num1
func neg(interpreter *Interpreter) {
@ -61,63 +61,63 @@ func neg(interpreter *Interpreter) {
//num1 ceiling num2 -> Return ceiling of num1
func ceiling(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(int(f + 1)))
interpreter.Push(float64(int(f + 1)))
}
//num1 floor num2 -> Return floor of num1
func floor(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(math.Floor(float64(f))))
interpreter.Push(math.Floor(f))
}
//num1 round num2 -> Round num1 to nearest integer
func round(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(int(f + 0.5)))
interpreter.Push(float64(int(f + 0.5)))
}
//num1 truncate num2 -> Remove fractional part of num1
func truncate(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(int(f)))
interpreter.Push(float64(int(f)))
}
//num sqrt real -> Return square root of num
func sqrt(interpreter *Interpreter) {
f := interpreter.PopFloat()
interpreter.Push(float(math.Sqrt(float64(f))))
interpreter.Push(float64(math.Sqrt(f)))
}
//num den atan angle -> Return arctangent of num/den in degrees
func atan(interpreter *Interpreter) {
den := interpreter.PopFloat()
num := interpreter.PopFloat()
interpreter.Push(float(math.Atan2(float64(num), float64(den))) * (180.0 / math.Pi))
interpreter.Push(math.Atan2(num, den) * (180.0 / math.Pi))
}
//angle cos real -> Return cosine of angle degrees
func cos(interpreter *Interpreter) {
a := interpreter.PopFloat() * math.Pi / 180
interpreter.Push(float(math.Cos(float64(a ))))
interpreter.Push(math.Cos(a))
}
//angle sin real -> Return sine of angle degrees
func sin(interpreter *Interpreter) {
a := interpreter.PopFloat() * math.Pi / 180
interpreter.Push(float(math.Sin(float64(a))))
interpreter.Push(math.Sin(a))
}
//base exponent exp real -> Raise base to exponent power
func exp(interpreter *Interpreter) {
exponent := interpreter.PopFloat()
base := interpreter.PopFloat()
interpreter.Push(float(math.Pow(float64(base), float64(exponent))))
interpreter.Push(math.Pow(base, exponent))
}
//num ln real -> Return natural logarithm (base e)
func ln(interpreter *Interpreter) {
num := interpreter.PopFloat()
interpreter.Push(float(math.Log(float64(num))))
interpreter.Push(math.Log(num))
}
//num log real -> Return common logarithm (base 10)
func log10(interpreter *Interpreter) {
num := interpreter.PopFloat()
interpreter.Push(float(math.Log10(float64(num))))
interpreter.Push(math.Log10(num))
}
// rand int Generate pseudo-random integer
func randInt(interpreter *Interpreter) {
interpreter.Push(float(rand.Int()))
interpreter.Push(float64(rand.Int()))
}
var randGenerator *rand.Rand
@ -127,7 +127,7 @@ func srand(interpreter *Interpreter) {
}
// rrand int -> Return random number seed
func rrand(interpreter *Interpreter) {
interpreter.Push(float(randGenerator.Int()))
interpreter.Push(float64(randGenerator.Int()))
}
func initMathOperators(interpreter *Interpreter) {

View file

@ -71,7 +71,7 @@ func counttomark(interpreter *Interpreter) {
for _, ok := value.(Mark); !ok; i++ {
value = interpreter.Get(i)
}
interpreter.Push(float(i))
interpreter.Push(float64(i))
}
func initStackOperator(interpreter *Interpreter) {