remove error type
This commit is contained in:
parent
6cc2406d5f
commit
01de21e32e
16
value.nim
16
value.nim
|
@ -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.} =
|
||||
|
|
Loading…
Reference in New Issue