Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 589fce1fde
Fetching contributors…

Cannot retrieve contributors at this time

204 lines (109 sloc) 3.357 kb

Synopsis

This document describes NAM, aka CgOp, the Niecza Abstract Machine. It is a language used to connect the portable parts of Niecza to the unportable, and as such requires a fairly strong definition. Unfortunately this document is rather incomplete.

General model

NAM code consists of one or more units. Each unit contains a set of fixups (details TBD) which allow compiled code to find metaobject data, and a set of compilable function bodies. One unit shall contain a body named MAIN, which is run to start execution.

A body contains some basic metadata such as the number of lexical slots required, and also a tree of operations. This tree is structured much like a Lisp program and obeys similar evaluation rules. One difference is that NAM nodes have two kinds of children, scalar children and node children, which are treated separately.

NAM code must be statically typable but this may not always be enforced. Different data objects have logical types, which can map many-to-one onto lower-level types, especially in type-poor environments such as Parrot and JavaScript.

Runtime data objects, by static type

int

A native integer, suitable for loop variables and similar purposes.

num

A native float, suitable for the Perl 6 Num class.

bool

A native bool, as returned by comparison operators.

str

A reference to a native immutable string.

strbuf

A reference to a native mutable string.

var

A Perl 6 variable, with identity, potentially mutable and tied.

obj

A reference to a Perl 6 object; not a variable and cannot be assigned to.

varhash

A hash table mapping strings to Perl 6 variables.

fvarlist

An array of Perl 6 variables fixed in length at creation.

vvarlist

An array of Perl 6 variables supporting O(1) deque operations.

stab

The nexus of HOW, WHAT, WHO, and REPR. Details subject to flux.

treader

A reference to a native text input object.

twriter

A reference to a native text output object.

lad

A node in the LTM Automaton Descriptor metaobject tree.

cc

A reference to a compiled character class.

cursor

A reference to a low-level cursor. Currently a subtype of obj.

frame

A reference to a call frame. Currently a subtype of obj.

Operations

Aritmetic and logical operations

Sequence control

prog

span

ehspan

sink

labelhere

cgoto

goto

ncgoto

ternary

whileloop

take

cotake

Data control

letn

fetch

assign

newscalar

newrwscalar

newblankrwscalar

newrwlistvar

null

sink

cast

Object model

getslot

setslot

how

obj_is_defined

obj_llhow

obj_isa

obj_does

subcall

methodcall

I/O

say

slurp

treader_stdin

Native operations (CLR)

These are for user code only. Core library code should define custom system primitives instead.

getfield

setfield

rawsget

rawsset

rawscall

rawcall

setindex

getindex

rawnew

rawnewarr

rawnewzarr

labelid

Jump to Line
Something went wrong with that request. Please try again.