1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-15 05:04:49 +00:00
janet/dsts/example.dsts

70 lines
1.9 KiB
Plaintext
Raw Normal View History

2017-11-01 21:53:43 +00:00
# A .dsts file will contain VM, assembly for a dst function. This includes
# associated constants and what not. The assembler should be able to
# simply construct a FuncDef from this file. This file is also parsed
# in the same markup as dst itself (extended S expressions)
{
arity 3
source "source file path"
varargs false
# Name for reference by nested funcdefs
name outerfunc
# Contains the bytecode for this function. This can be assembly
# instructions or integers. Assembly will be converted to integer bytecodes immediately.
bytecode [
(load-constant 0 bork)
(load-constant 1 bip)
(add 0 0 1)
(add-immediate 0 0 127)
(push3 0 0 0)
(push3 0 0 0)
(push3 0 0 0)
(syscall 1 0)
(return 0)
2017-11-01 21:53:43 +00:00
]
# A source map is optional. The sourcemap corresponds with the byte code.
# Each number is a 64 bit integer, the concatenation of two 32 bit integers.
# These integers represent source character index for each instruction.
2017-11-01 21:53:43 +00:00
# This format may change.
# map [
# 1
# 2
# 3
# 10
# 15
# 39
# 90
# 134
# ...
# ]
#
# The number of slots available for the function.
# Slots can be named as well for convenience.
2017-11-01 21:53:43 +00:00
slots [
x
y
z
]
# Captured outer environments that are referenced
environments [ ]
2017-11-01 21:53:43 +00:00
# Constants are an array or tuple. For named constants, use a tuple that begins with let
# For a literal tuple, use (quote tuple), or 'tuple. Without names, constants must be indexed
# from their number
# Literal FuncEnvs and Functions may be possible later
2017-11-01 21:53:43 +00:00
constants [
:hello
(def bork 123)
(def bip 456)
2017-11-01 21:53:43 +00:00
'(1 2 3)
(def atuple (1 2 3))
2017-11-01 21:53:43 +00:00
(567)
]
# Arbitrary meta data can be added to the source
my-meta-2 @{
1 2 3 4
}
my-meta {
1 2 3 4 5 6 7 8 9 0 11 12 13 14
}
2017-11-01 21:53:43 +00:00
}