Fixed merge conflicts

This commit is contained in:
nocturn9x 2020-10-22 15:51:39 +02:00
commit 46827695d5
4 changed files with 38 additions and 23 deletions

View File

@ -15,9 +15,9 @@
import tables
import strutils
import meta/valueobject
import meta/valuearray
import meta/tokenobject
import types/objecttype
import types/japlvalue
const FRAMES_MAX* = 400 # TODO: Inspect why the VM crashes if this exceeds 400

View File

@ -12,14 +12,39 @@
# See the License for the specific language governing permissions and
# limitations under the License.
## Base structure for objects in JAPL, all
## Base structure for values and objects in JAPL, all
## types inherit from this simple structure
import tables
import ../meta/chunk
type
Chunk* = ref object
## A piece of bytecode.
## Consts represents (TODO newdoc)
## Code represents (TODO newdoc)
## Lines represents (TODO newdoc)
consts*: ValueArray
code*: seq[uint8]
lines*: seq[int]
ValueType* {.pure.} = enum
# All possible value types (this is the VM's notion of 'type', not the end user's)
Integer, Double, Bool, Nil, Object, Nan, Inf, Minf
Value* = object
## Represents an internal JAPL type
case kind*: ValueType
of ValueType.Integer:
intValue*: int
of ValueType.Double:
floatValue*: float
of ValueType.Bool:
boolValue*: bool
of ValueType.Nil, ValueType.Inf, ValueType.Nan, ValueType.Minf:
discard
of ValueType.Object:
obj*: ptr Obj
ObjectType* {.pure.} = enum
## All the possible object types
String, Exception, Function,

View File

@ -15,6 +15,10 @@
## The module dedicated to the Chunk type
## A chunk is a piece of bytecode.
<<<<<<< HEAD:meta/chunk.nim
=======
import japlvalue
>>>>>>> 7649cf6e3bdf4ce47c9c63bbdbe3e99a53274a8d:meta/opcode.nim
type
OpCode* {.pure.} = enum
@ -61,6 +65,7 @@ type
Bnot
<<<<<<< HEAD:meta/chunk.nim
Chunk* = ref object
## A piece of bytecode.
## Consts is the chunk's constant table
@ -70,6 +75,8 @@ type
code*: seq[uint8]
lines*: seq[int] # TODO: Run-length encoding?
=======
>>>>>>> 7649cf6e3bdf4ce47c9c63bbdbe3e99a53274a8d:meta/opcode.nim
const simpleInstructions* = {OpCode.Return, OpCode.Add, OpCode.Multiply,
OpCode.Divide, OpCode.Subtract,
@ -123,4 +130,4 @@ proc writeConstant*(self: Chunk, constant: Value): array[3, uint8] =
## TODO newdoc
let index = self.addConstant(constant)
result = cast[array[3, uint8]](index)

View File

@ -19,29 +19,12 @@
## allocated on the heap, while the simpler ones live on the stack
# import ../types/functiontype
import ../types/objecttype
import japlvalue
import ../types/stringtype
import strformat
type
ValueType* {.pure.} = enum
# All possible value types (this is the VM's notion of 'type', not the end user's)
Integer, Double, Bool, Nil, Object, Nan, Inf, Minf
Value* = object
## Represents an internal JAPL type
case kind*: ValueType
of ValueType.Integer:
intValue*: int
of ValueType.Double:
floatValue*: float
of ValueType.Bool:
boolValue*: bool
of ValueType.Nil, ValueType.Inf, ValueType.Nan, ValueType.Minf:
discard
of ValueType.Object:
obj*: ptr Obj
ValueArray* = ref object
values*: seq[Value]