start removing newNumber and number types from the code.

This commit is contained in:
2024-07-11 03:55:19 +01:00
parent 70f2c47e4f
commit bfdb7b6e6a
10 changed files with 150 additions and 128 deletions

9
server_test/app.ar Normal file
View File

@@ -0,0 +1,9 @@
import "http.ar" as http
let server = http.server()
let home(req,res) = do
res.send("hello world")
server.get("/",home)
server.run()

View File

@@ -0,0 +1,4 @@
{
"name": "server-test",
"version": "1.0.0"
}

View File

@@ -0,0 +1 @@
[{"Name":"http.ar","Version":"1.1.6","URL":"https://isotope.wbell.dev/isotope-download?name=http.ar\u0026version=1.1.6","Remote":"isotope.wbell.dev"}]

View File

@@ -6,8 +6,6 @@ import (
"fmt" "fmt"
) )
var one = newNumber().SetInt64(1)
func ArByte(Byte byte) ArObject { func ArByte(Byte byte) ArObject {
obj := ArObject{ obj := ArObject{
obj: anymap{ obj: anymap{
@@ -30,7 +28,7 @@ func ArByte(Byte byte) ArObject {
obj.obj["number"] = builtinFunc{ obj.obj["number"] = builtinFunc{
"number", "number",
func(a ...any) (any, ArErr) { func(a ...any) (any, ArErr) {
return newNumber().SetInt64(int64(Byte)), ArErr{} return Number(int64(Byte)), ArErr{}
}, },
} }
obj.obj["from"] = builtinFunc{ obj.obj["from"] = builtinFunc{
@@ -114,16 +112,17 @@ func ArBuffer(buf []byte) ArObject {
case []any: case []any:
outputbuf := []byte{} outputbuf := []byte{}
for _, v := range x { for _, v := range x {
switch y := v.(type) { V := ArValidToAny(v)
case number: switch y := V.(type) {
if y.Denom().Cmp(one.Denom()) != 0 { case int64:
if y > 255 || y < 0 {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "ValueError",
message: "Cannot convert non-integer to byte", message: "expected number between 0 and 255, got " + fmt.Sprint(y),
EXISTS: true, EXISTS: true,
} }
} }
outputbuf = append(outputbuf, byte(y.Num().Int64())) outputbuf = append(outputbuf, byte(y))
default: default:
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
@@ -171,15 +170,14 @@ func ArBuffer(buf []byte) ArObject {
EXISTS: true, EXISTS: true,
} }
} }
nNum := nVal.(number) n, err := numberToInt64(nVal.(ArObject))
if nNum.Denom().Cmp(one.Denom()) != 0 { if err != nil {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
message: "expected integer, got " + fmt.Sprint(nNum), message: err.Error(),
EXISTS: true, EXISTS: true,
} }
} }
n := nNum.Num().Int64()
var result [][]byte var result [][]byte
start := 0 start := 0
var i int64 var i int64
@@ -253,39 +251,37 @@ func ArBuffer(buf []byte) ArObject {
EXISTS: true, EXISTS: true,
} }
} }
startVal := ArValidToAny(a[0]) if typeof(a[0]) != "number" || typeof(a[1]) != "number" {
if typeof(startVal) != "number" {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
message: "expected number, got " + typeof(startVal), message: "expected number, got " + typeof(a[0]) + " and " + typeof(a[1]),
EXISTS: true, EXISTS: true,
} }
} }
start := startVal.(number) start, err := numberToInt64(ArValidToAny(a[0]).(ArObject))
if start.Denom().Cmp(one.Denom()) != 0 { if err != nil {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
message: "expected integer, got " + fmt.Sprint(start), message: err.Error(),
EXISTS: true, EXISTS: true,
} }
} }
endVal := ArValidToAny(a[1]) end, err := numberToInt64(ArValidToAny(a[1]).(ArObject))
if typeof(endVal) != "number" { if err != nil {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
message: "expected number, got " + typeof(endVal), message: err.Error(),
EXISTS: true, EXISTS: true,
} }
} }
end := endVal.(number) if start < 0 || end < 0 || start > int64(len(buf)) || end > int64(len(buf)) {
if end.Denom().Cmp(one.Denom()) != 0 {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Index Error",
message: "expected integer, got " + fmt.Sprint(end), message: "index out of range",
EXISTS: true, EXISTS: true,
} }
} }
return ArBuffer(buf[floor(start).Num().Int64():floor(end).Num().Int64()]), ArErr{} return ArBuffer(buf[start:end]), ArErr{}
}, },
} }
obj.obj["to"] = builtinFunc{ obj.obj["to"] = builtinFunc{
@@ -342,15 +338,15 @@ func ArBuffer(buf []byte) ArObject {
} }
a[0] = ArValidToAny(a[0]) a[0] = ArValidToAny(a[0])
switch x := a[0].(type) { switch x := a[0].(type) {
case number: case int64:
if x.Denom().Cmp(one.Denom()) != 0 { if x > 255 || x < 0 {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "ValueError",
message: "Cannot convert non-integer to byte", message: "expected number between 0 and 255, got " + fmt.Sprint(x),
EXISTS: true, EXISTS: true,
} }
} }
buf = append(buf, byte(x.Num().Int64())) buf = append(buf, byte(x))
case string: case string:
buf = append(buf, []byte(x)...) buf = append(buf, []byte(x)...)
case []byte: case []byte:
@@ -358,15 +354,15 @@ func ArBuffer(buf []byte) ArObject {
case []any: case []any:
for _, v := range x { for _, v := range x {
switch y := v.(type) { switch y := v.(type) {
case number: case int64:
if y.Denom().Cmp(one.Denom()) != 0 { if y > 255 || y < 0 {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "ValueError",
message: "Cannot convert non-integer to byte", message: "expected number between 0 and 255, got " + fmt.Sprint(y),
EXISTS: true, EXISTS: true,
} }
} }
buf = append(buf, byte(y.Num().Int64())) buf = append(buf, byte(y))
default: default:
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
@@ -405,25 +401,24 @@ func ArBuffer(buf []byte) ArObject {
EXISTS: true, EXISTS: true,
} }
} }
pos := poss.(number) posNum, err := numberToInt64(poss.(ArObject))
if pos.Denom().Cmp(one.Denom()) != 0 { if err != nil {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
message: "position must be an integer", message: err.Error(),
EXISTS: true, EXISTS: true,
} }
} }
posNum := pos.Num().Int64()
switch x := values.(type) { switch x := values.(type) {
case number: case int64:
if x.Denom().Cmp(one.Denom()) != 0 { if x > 255 || x < 0 {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "ValueError",
message: "Cannot convert non-integer to byte", message: "expected number between 0 and 255, got " + fmt.Sprint(x),
EXISTS: true, EXISTS: true,
} }
} }
buf = append(buf[:posNum], append([]byte{byte(x.Num().Int64())}, buf[posNum:]...)...) buf = append(buf[:posNum], append([]byte{byte(x)}, buf[posNum:]...)...)
case string: case string:
buf = append(buf[:posNum], append([]byte(x), buf[posNum:]...)...) buf = append(buf[:posNum], append([]byte(x), buf[posNum:]...)...)
case []byte: case []byte:
@@ -431,15 +426,15 @@ func ArBuffer(buf []byte) ArObject {
case []any: case []any:
for _, v := range x { for _, v := range x {
switch y := v.(type) { switch y := v.(type) {
case number: case int64:
if y.Denom().Cmp(one.Denom()) != 0 { if y > 255 || y < 0 {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "ValueError",
message: "Cannot convert non-integer to byte", message: "expected number between 0 and 255, got " + fmt.Sprint(y),
EXISTS: true, EXISTS: true,
} }
} }
buf = append(buf[:posNum], append([]byte{byte(y.Num().Int64())}, buf[posNum:]...)...) buf = append(buf[:posNum], append([]byte{byte(y)}, buf[posNum:]...)...)
default: default:
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
@@ -474,7 +469,7 @@ func ArBuffer(buf []byte) ArObject {
if typeof(a[0]) == "string" { if typeof(a[0]) == "string" {
var name = ArValidToAny(a[0]).(string) var name = ArValidToAny(a[0]).(string)
if name == "length" { if name == "length" {
return newNumber().SetInt64(int64(len(buf))), ArErr{} return Number(len(buf)), ArErr{}
} }
} }
} }
@@ -523,15 +518,21 @@ func ArBuffer(buf []byte) ArObject {
EXISTS: true, EXISTS: true,
} }
} }
pos := poss.(number) posNum, err := numberToInt64(poss.(ArObject))
if pos.Denom().Cmp(one.Denom()) != 0 { if err != nil {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
message: "position must be an integer", message: err.Error(),
EXISTS: true,
}
}
if posNum < 0 || posNum >= int64(len(buf)) {
return nil, ArErr{
TYPE: "Index Error",
message: "index out of range",
EXISTS: true, EXISTS: true,
} }
} }
posNum := pos.Num().Int64()
buf = append(buf[:posNum], buf[posNum+1:]...) buf = append(buf[:posNum], buf[posNum+1:]...)
obj.obj["__value__"] = buf obj.obj["__value__"] = buf
return obj, ArErr{} return obj, ArErr{}

View File

@@ -19,7 +19,7 @@ func ArgonString(args ...any) (any, ArErr) {
func ArgonNumber(args ...any) (any, ArErr) { func ArgonNumber(args ...any) (any, ArErr) {
if len(args) == 0 { if len(args) == 0 {
return newNumber(), ArErr{} return _zero_Number, ArErr{}
} }
args[0] = ArValidToAny(args[0]) args[0] = ArValidToAny(args[0])
switch x := args[0].(type) { switch x := args[0].(type) {
@@ -27,17 +27,17 @@ func ArgonNumber(args ...any) (any, ArErr) {
if !isNumber(UNPARSEcode{code: x}) { if !isNumber(UNPARSEcode{code: x}) {
return nil, ArErr{TYPE: "Conversion Error", message: "Cannot convert " + anyToArgon(x, true, true, 3, 0, false, 0) + " to a number", EXISTS: true} return nil, ArErr{TYPE: "Conversion Error", message: "Cannot convert " + anyToArgon(x, true, true, 3, 0, false, 0) + " to a number", EXISTS: true}
} }
N, _ := newNumber().SetString(x) N := Number(x)
return N, ArErr{} return N, ArErr{}
case number: case int64, *big.Int, *big.Rat:
return x, ArErr{} return Number(x), ArErr{}
case bool: case bool:
if x { if x {
return newNumber().SetInt64(1), ArErr{} return _one_Number, ArErr{}
} }
return newNumber(), ArErr{} return _zero_Number, ArErr{}
case nil: case nil:
return newNumber(), ArErr{} return _zero_Number, ArErr{}
} }
return nil, ArErr{TYPE: "Number Error", message: "Cannot convert " + typeof(args[0]) + " to a number", EXISTS: true} return nil, ArErr{TYPE: "Number Error", message: "Cannot convert " + typeof(args[0]) + " to a number", EXISTS: true}

View File

@@ -66,7 +66,7 @@ func makeGlobal() ArObject {
a[0] = ArValidToAny(a[0]) a[0] = ArValidToAny(a[0])
switch x := a[0].(type) { switch x := a[0].(type) {
case number: case number:
if x.Denom().Cmp(one.Denom()) != 0 { if x.Denom().Cmp(_one_Rat.Denom()) != 0 {
return nil, ArErr{TYPE: "Type Error", message: "Cannot convert non-integer to hex", EXISTS: true} return nil, ArErr{TYPE: "Type Error", message: "Cannot convert non-integer to hex", EXISTS: true}
} }
n := x.Num().Int64() n := x.Num().Int64()

View File

@@ -19,8 +19,16 @@ var ArColour = Map(
} }
var c *color.Color var c *color.Color
var s string var s string
if x, ok := a[0].(number); ok { if x, ok := a[0].(ArObject); ok {
c = color.Set(color.Attribute(x.Num().Int64())) colour_int64, err := numberToInt64(x)
if err != nil {
return nil, ArErr{
TYPE: "Type Error",
message: err.Error(),
EXISTS: true,
}
}
c = color.New(color.Attribute(colour_int64))
} else { } else {
return nil, ArErr{ return nil, ArErr{
TYPE: "Type Error", TYPE: "Type Error",
@@ -45,52 +53,52 @@ var ArColour = Map(
}}, }},
"bg": Map( "bg": Map(
anymap{ anymap{
"black": newNumber().SetInt64(int64(color.BgBlack)), "black": Number(int64(color.BgBlack)),
"red": newNumber().SetInt64(int64(color.BgRed)), "red": Number(int64(color.BgRed)),
"green": newNumber().SetInt64(int64(color.BgGreen)), "green": Number(int64(color.BgGreen)),
"yellow": newNumber().SetInt64(int64(color.BgYellow)), "yellow": Number(int64(color.BgYellow)),
"blue": newNumber().SetInt64(int64(color.BgBlue)), "blue": Number(int64(color.BgBlue)),
"magenta": newNumber().SetInt64(int64(color.BgMagenta)), "magenta": Number(int64(color.BgMagenta)),
"cyan": newNumber().SetInt64(int64(color.BgCyan)), "cyan": Number(int64(color.BgCyan)),
"white": newNumber().SetInt64(int64(color.BgWhite)), "white": Number(int64(color.BgWhite)),
"hiBlack": newNumber().SetInt64(int64(color.BgHiBlack)), "hiBlack": Number(int64(color.BgHiBlack)),
"hiRed": newNumber().SetInt64(int64(color.BgHiRed)), "hiRed": Number(int64(color.BgHiRed)),
"hiGreen": newNumber().SetInt64(int64(color.BgHiGreen)), "hiGreen": Number(int64(color.BgHiGreen)),
"hiYellow": newNumber().SetInt64(int64(color.BgHiYellow)), "hiYellow": Number(int64(color.BgHiYellow)),
"hiBlue": newNumber().SetInt64(int64(color.BgHiBlue)), "hiBlue": Number(int64(color.BgHiBlue)),
"hiMagenta": newNumber().SetInt64(int64(color.BgHiMagenta)), "hiMagenta": Number(int64(color.BgHiMagenta)),
"hiCyan": newNumber().SetInt64(int64(color.BgHiCyan)), "hiCyan": Number(int64(color.BgHiCyan)),
"hiWhite": newNumber().SetInt64(int64(color.BgHiWhite)), "hiWhite": Number(int64(color.BgHiWhite)),
}, },
), ),
"fg": Map( "fg": Map(
anymap{ anymap{
"black": newNumber().SetInt64(int64(color.FgBlack)), "black": Number(int64(color.FgBlack)),
"red": newNumber().SetInt64(int64(color.FgRed)), "red": Number(int64(color.FgRed)),
"green": newNumber().SetInt64(int64(color.FgGreen)), "green": Number(int64(color.FgGreen)),
"yellow": newNumber().SetInt64(int64(color.FgYellow)), "yellow": Number(int64(color.FgYellow)),
"blue": newNumber().SetInt64(int64(color.FgBlue)), "blue": Number(int64(color.FgBlue)),
"magenta": newNumber().SetInt64(int64(color.FgMagenta)), "magenta": Number(int64(color.FgMagenta)),
"cyan": newNumber().SetInt64(int64(color.FgCyan)), "cyan": Number(int64(color.FgCyan)),
"white": newNumber().SetInt64(int64(color.FgWhite)), "white": Number(int64(color.FgWhite)),
"hiBlack": newNumber().SetInt64(int64(color.FgHiBlack)), "hiBlack": Number(int64(color.FgHiBlack)),
"hiRed": newNumber().SetInt64(int64(color.FgHiRed)), "hiRed": Number(int64(color.FgHiRed)),
"hiGreen": newNumber().SetInt64(int64(color.FgHiGreen)), "hiGreen": Number(int64(color.FgHiGreen)),
"hiYellow": newNumber().SetInt64(int64(color.FgHiYellow)), "hiYellow": Number(int64(color.FgHiYellow)),
"hiBlue": newNumber().SetInt64(int64(color.FgHiBlue)), "hiBlue": Number(int64(color.FgHiBlue)),
"hiMagenta": newNumber().SetInt64(int64(color.FgHiMagenta)), "hiMagenta": Number(int64(color.FgHiMagenta)),
"hiCyan": newNumber().SetInt64(int64(color.FgHiCyan)), "hiCyan": Number(int64(color.FgHiCyan)),
"hiWhite": newNumber().SetInt64(int64(color.FgHiWhite)), "hiWhite": Number(int64(color.FgHiWhite)),
}, },
), ),
"reset": newNumber().SetInt64(int64(color.Reset)), "reset": Number(int64(color.Reset)),
"bold": newNumber().SetInt64(int64(color.Bold)), "bold": Number(int64(color.Bold)),
"faint": newNumber().SetInt64(int64(color.Faint)), "faint": Number(int64(color.Faint)),
"italic": newNumber().SetInt64(int64(color.Italic)), "italic": Number(int64(color.Italic)),
"underline": newNumber().SetInt64(int64(color.Underline)), "underline": Number(int64(color.Underline)),
"blinkSlow": newNumber().SetInt64(int64(color.BlinkSlow)), "blinkSlow": Number(int64(color.BlinkSlow)),
"blinkRapid": newNumber().SetInt64(int64(color.BlinkRapid)), "blinkRapid": Number(int64(color.BlinkRapid)),
"reverseVideo": newNumber().SetInt64(int64(color.ReverseVideo)), "reverseVideo": Number(int64(color.ReverseVideo)),
"concealed": newNumber().SetInt64(int64(color.Concealed)), "concealed": Number(int64(color.Concealed)),
"crossedOut": newNumber().SetInt64(int64(color.CrossedOut)), "crossedOut": Number(int64(color.CrossedOut)),
}) })

View File

@@ -577,7 +577,7 @@ func _BigInt_logic(val ArObject, CurrentNumber *big.Int) {
if ReceivingNumber.Cmp(_zero_Rat) == 0 { if ReceivingNumber.Cmp(_zero_Rat) == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
x := newNumber().Set(ReceivingNumber) x := new(big.Rat).Set(ReceivingNumber)
output := new(big.Rat).SetInt(CurrentNumber) output := new(big.Rat).SetInt(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -613,8 +613,8 @@ func _BigInt_logic(val ArObject, CurrentNumber *big.Int) {
if CurrentNumber.Cmp(_zero) == 0 { if CurrentNumber.Cmp(_zero) == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
currentNumber_RAT := newNumber().SetInt(CurrentNumber) currentNumber_RAT := new(big.Rat).SetInt(CurrentNumber)
x := newNumber().Set(currentNumber_RAT) x := new(big.Rat).Set(currentNumber_RAT)
output := new(big.Rat).Set(ReceivingNumber) output := new(big.Rat).Set(ReceivingNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -650,7 +650,7 @@ func _BigInt_logic(val ArObject, CurrentNumber *big.Int) {
if ReceivingNumber.Cmp(_zero_Rat) == 0 { if ReceivingNumber.Cmp(_zero_Rat) == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
x := newNumber().Set(ReceivingNumber) x := new(big.Rat).Set(ReceivingNumber)
output := new(big.Rat).SetInt(CurrentNumber) output := new(big.Rat).SetInt(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -685,8 +685,8 @@ func _BigInt_logic(val ArObject, CurrentNumber *big.Int) {
if CurrentNumber.Cmp(_zero) == 0 { if CurrentNumber.Cmp(_zero) == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
currentNumber_RAT := newNumber().SetInt(CurrentNumber) currentNumber_RAT := new(big.Rat).SetInt(CurrentNumber)
x := newNumber().Set(currentNumber_RAT) x := new(big.Rat).Set(currentNumber_RAT)
output := new(big.Rat).Set(ReceivingNumber) output := new(big.Rat).Set(ReceivingNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1046,7 +1046,7 @@ func _BigRat_logic(val ArObject, CurrentNumber *big.Rat) {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
ReceivingNumber_RAT := new(big.Rat).SetInt(ReceivingNumber) ReceivingNumber_RAT := new(big.Rat).SetInt(ReceivingNumber)
x := newNumber().Set(ReceivingNumber_RAT) x := new(big.Rat).Set(ReceivingNumber_RAT)
output := new(big.Rat).Set(CurrentNumber) output := new(big.Rat).Set(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1058,7 +1058,7 @@ func _BigRat_logic(val ArObject, CurrentNumber *big.Rat) {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
ReceivingNumber_RAT := new(big.Rat).SetInt64(ReceivingNumber) ReceivingNumber_RAT := new(big.Rat).SetInt64(ReceivingNumber)
x := newNumber().Set(ReceivingNumber_RAT) x := new(big.Rat).Set(ReceivingNumber_RAT)
output := new(big.Rat).Set(CurrentNumber) output := new(big.Rat).Set(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1069,7 +1069,7 @@ func _BigRat_logic(val ArObject, CurrentNumber *big.Rat) {
if ReceivingNumber.Cmp(_zero_Rat) == 0 { if ReceivingNumber.Cmp(_zero_Rat) == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
x := newNumber().Set(ReceivingNumber) x := new(big.Rat).Set(ReceivingNumber)
output := new(big.Rat).Set(CurrentNumber) output := new(big.Rat).Set(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1096,7 +1096,7 @@ func _BigRat_logic(val ArObject, CurrentNumber *big.Rat) {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
ReceivingNumber_RAT := new(big.Rat).SetInt(ReceivingNumber) ReceivingNumber_RAT := new(big.Rat).SetInt(ReceivingNumber)
x := newNumber().Set(ReceivingNumber_RAT) x := new(big.Rat).Set(ReceivingNumber_RAT)
output := new(big.Rat).Set(CurrentNumber) output := new(big.Rat).Set(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1108,7 +1108,7 @@ func _BigRat_logic(val ArObject, CurrentNumber *big.Rat) {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
ReceivingNumber_RAT := new(big.Rat).SetInt64(ReceivingNumber) ReceivingNumber_RAT := new(big.Rat).SetInt64(ReceivingNumber)
x := newNumber().Set(ReceivingNumber_RAT) x := new(big.Rat).Set(ReceivingNumber_RAT)
output := new(big.Rat).Set(CurrentNumber) output := new(big.Rat).Set(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1119,7 +1119,7 @@ func _BigRat_logic(val ArObject, CurrentNumber *big.Rat) {
if CurrentNumber.Cmp(_zero_Rat) == 0 { if CurrentNumber.Cmp(_zero_Rat) == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
x := newNumber().Set(ReceivingNumber) x := new(big.Rat).Set(ReceivingNumber)
output := new(big.Rat).Set(CurrentNumber) output := new(big.Rat).Set(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1596,7 +1596,7 @@ func _int64_logic(val ArObject, CurrentNumber int64) {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
CurrentNumber_Rat := new(big.Rat).SetInt64(CurrentNumber) CurrentNumber_Rat := new(big.Rat).SetInt64(CurrentNumber)
x := newNumber().Set(ReceivingNumber) x := new(big.Rat).Set(ReceivingNumber)
output := new(big.Rat).Set(CurrentNumber_Rat) output := new(big.Rat).Set(CurrentNumber_Rat)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)
@@ -1632,7 +1632,7 @@ func _int64_logic(val ArObject, CurrentNumber int64) {
if CurrentNumber == 0 { if CurrentNumber == 0 {
return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true} return nil, ArErr{"Runtime Error", "division by zero", 0, "", "", true}
} }
x := newNumber().Set(ReceivingNumber) x := new(big.Rat).Set(ReceivingNumber)
output := new(big.Rat).SetInt64(CurrentNumber) output := new(big.Rat).SetInt64(CurrentNumber)
x.Quo(output, x) x.Quo(output, x)
x = floor(x) x = floor(x)

View File

@@ -226,15 +226,16 @@ func ArSocketServer(args ...any) (any, ArErr) {
} }
} }
networktype := ArValidToAny(args[0]).(string) networktype := ArValidToAny(args[0]).(string)
port := args[1].(number) port_num := args[1].(ArObject)
if port.Denom().Int64() != 1 { port, err := numberToInt64(port_num)
if err != nil {
return ArObject{}, ArErr{ return ArObject{}, ArErr{
TYPE: "Socket Error", TYPE: "Socket Error",
message: "Socket port must be an integer", message: err.Error(),
EXISTS: true, EXISTS: true,
} }
} }
ln, err := net.Listen(networktype, ":"+fmt.Sprint(port.Num().Int64())) ln, err := net.Listen(networktype, ":"+fmt.Sprint(port))
if err != nil { if err != nil {
return ArObject{}, ArErr{ return ArObject{}, ArErr{
TYPE: "Socket Error", TYPE: "Socket Error",

View File

@@ -8,8 +8,6 @@ func typeof(val any) string {
return "boolean" return "boolean"
case string: case string:
return "string" return "string"
case number:
return "number"
case []any: case []any:
return "array" return "array"
case anymap: case anymap: