remove error type

This commit is contained in:
prod2 2022-01-27 06:09:59 +01:00
parent 6cc2406d5f
commit 01de21e32e
1 changed files with 0 additions and 16 deletions

View File

@ -4,10 +4,7 @@ type
NdType* = enum
ndNil, ndBool, ndFloat, ndString,
ndFunct,
ndError,
const errorTypes = {ndError}
type
NdValue* = object
case ndType*: NdType:
@ -22,8 +19,6 @@ type
of ndFunct:
placeholder*: string
entryII*: int # entry instruction index
of errorTypes:
message*: string
NatReturn* = object
ok*: bool
@ -43,12 +38,6 @@ proc `$`*(val: NdValue): string =
return val.stringValue
of ndFunct:
return &"Function object: {val.entryII}"
of errorTypes:
let ename = $val.ndType
return &"{ename[2..^1]}: {val.message}"
proc isError*(val: NdValue): bool =
val.ndType in errorTypes
proc isFalsey*(val: NdValue): bool =
val.ndType in {ndNil} or (val.ndType == ndBool and not val.boolValue)
@ -71,8 +60,6 @@ proc equal*(val, right: NdValue): bool =
val.stringValue == right.stringValue
of ndFunct:
val.entryII == right.entryII
of errorTypes:
false # error comparison is undefined
# NIM VALUE TO KON VALUE WRAPPERS
@ -91,9 +78,6 @@ proc newNdFunction*(ii: int): NdValue =
proc toNdValue*: NdValue =
NdValue(ndType: ndNil)
proc ndError*(msg: string): NdValue =
NdValue(ndType: ndError, message: msg)
# NatReturn misc
proc natError*(msg: string): NatReturn {.inline.} =