Common Data Structures

DType

Defined in dtype.h.

typedef enum _dType DType
enum _dType

An enum for the data types in Decision.

The values go up in powers of 2. This is so that we can combine data types to make vague data types, e.g. a number is TYPE_INTEGER | TYPE_FLOAT.

Note that there are several macros for common vague data types, e.g. TYPE_NUMBER, TYPE_BITWISE, TYPE_VAR_ANY, …

Values:

TYPE_NONE = 0
TYPE_EXECUTION = 1
TYPE_INT = 2
TYPE_FLOAT = 4
TYPE_STRING = 8
TYPE_BOOL = 16
TYPE_NAME = 32

LexData

Defined in dlex.h.

typedef union _lexData LexData
union _lexData
#include <dlex.h>

A union for storing the variable data types in Decision.

This is usually used in conjunction with DType to determine which element to get data from.

Public Members

dint integerValue
dfloat floatValue
bool booleanValue
char *stringValue

Graph Structures

The graph of a sheet is the set of nodes, and the wires connecting those nodes.

SocketMeta

Defined in dgraph.h.

typedef struct _socketMeta SocketMeta
struct _socketMeta

Defines the metadata of a socket, i.e. it’s type, name, description, etc.

Public Members

const char *name

The name of the socket.

const char *description

The socket description. Can be NULL.

DType type

The data type of the socket. Can be vague.

LexData defaultValue

The default value of the socket. Although it is not used by the compiler, it can be used by other programs to place a value in the socket by default.

NodeDefinition

Defined in dgraph.h.

typedef struct _nodeDefinition NodeDefinition
struct _nodeDefinition

Defined a node in Decision, i.e. it’s name, what sockets it has, etc.

Public Members

const char *name

The name of the node.

const char *description

The node description. Can be NULL.

const SocketMeta *sockets

An array of the node’s sockets.

size_t numSockets

The number of sockets the node has.

size_t startOutputIndex

Any socket before this index is an input socket, the rest are output sockets. This is also equivalent to the number of input sockets the node has.

bool infiniteInputs

Can the node has infinite inputs?

NodeSocket

Defined in dgraph.h.

typedef struct _nodeSocket NodeSocket
struct _nodeSocket

A struct for indexing a node’s socket.

Public Members

size_t nodeIndex

The node index in the graph.

size_t socketIndex

The socket index in the node.

Wire

Defined in dgraph.h.

typedef struct _wire Wire
struct _wire

A struct for connecting two sockets together, effectively an edge of a graph.

Public Members

NodeSocket socketFrom

The output socket.

NodeSocket socketTo

The input socket.

Node

Defined in dgraph.h.

typedef struct _node Node
struct _node

A struct for storing node data.

Public Members

const NodeDefinition *definition

The definition of the node. This is where you would get details like the node’s name.

size_t lineNum

What line is the node on in the original source code?

int *_stackPositions

Used by Code Generation.

DType *reducedTypes

Needs to be malloc’d, and have as many elements as sockets. Can be NULL if the types are the same as in *definition.

LexData *literalValues

Needs to be malloc’d, and have startOutputIndex elements. Can be NULL if the default values are the same as in *definition.

size_t startOutputIndex

This will by default be the same value as in the definition, but in the event that the definition allows for infinite inputs, this value will change to signify where the start of the outputs actually is.

NameDefinition nameDefinition

If the node is the getter or setter of a variable, then this points to the variable. If the node is a Define or Return node, this points to the function. Otherwise, it points to the name definition of the node.

Graph

Defined in dgraph.h.

typedef struct _graph Graph
struct _graph

A collection of nodes and wires. Essentially a representation of the code that the user wrote.

Public Members

Node *nodes

The array of nodes.

size_t numNodes

The number of nodes in the nodes array.

Wire *wires

This list will be stored in lexicographical order, so binary search can be performed on it.

size_t numWires

The number of wires in the wires array.

Sheet Structures

Sheets contain graphs, as well as extra properties like variables, functions, and the compiled bytecode.

SheetVariable

Defined in dsheet.h.

typedef struct _sheetVariable SheetVariable
struct _sheetVariable

A struct for storing variable data.

Public Members

const NodeDefinition getterDefinition

The definition of the variable’s getter node. This is determined automatically when a variable is added to a sheet.

const SocketMeta variableMeta

The variable metadata, i.e. it’s name, it’s type, etc.

struct _sheet *sheet

The sheet the variable belongs to.

SheetFunction

Defined in dsheet.h.

typedef struct _sheetFunction SheetFunction
struct _sheetFunction

A struct for storing function data.

Note that if you want to know if the function is a subroutine, you can use d_is_subroutine.

Public Members

const NodeDefinition functionDefinition

The definition of the function, i.e. it’s name, it’s sockets, etc.

const NodeDefinition defineDefinition

The definition of the function’s Define node. This is determined automatically when adding a function to a sheet.

const NodeDefinition returnDefinition

The definition of the function’s Return node. This is determined automatically when adding a function to a sheet.

size_t defineNodeIndex

Used in Semantic Analysis.

size_t numDefineNodes

Used in Semantic Analysis.

size_t lastReturnNodeIndex

Used in Semantic Analysis.

size_t numReturnNodes

Used in Semantic Analysis.

struct _sheet *sheet

The sheet the function belongs to.

Sheet

Defined in dsheet.h.

typedef struct _sheet Sheet
struct _sheet

A struct for storing sheet data.

Public Members

Graph graph

Can be empty if the sheet came from a Decision object file.

DebugInfo _debugInfo

If the sheet is compiled in debug mode, this will contain debugging information.

LinkMetaList _link

What can be linked in this sheet?

const char *filePath

Essentially the name of the sheet.

const char *includePath

i.e. what was the argument of the Include property that included this sheet. Default value is NULL.

struct _sheet **includes

The list of included sheets.

size_t numIncludes

The number of included sheets.

SheetVariable *variables

The list of variables defined in this sheet.

size_t numVariables

The number of variables in this sheet.

SheetFunction *functions

The list of functions defined in this sheet.

size_t numFunctions

The number of functions in this sheet.

CFunction *cFunctions

The list of C functions defined in this sheet.

size_t numCFunctions

The number of C functions in this sheet.

size_t _main

Points to the index of the first instruction of Start, not the RET instruction one before.

char *_text

The compiled bytecode.

size_t _textSize

The number of bytes the compiled bytecode has.

char *_data

The compiled data section.

size_t _dataSize

The number of bytes the data section has.

InstructionToLink *_insLinkList

A list of which instructions should link to which items.

size_t _insLinkListSize

The number of instructions to link.

size_t numStarts

Used by Semantic Analysis.

int startNodeIndex

If this value is -1, then no Start node exists.

bool hasErrors

If true, the sheet cannot be run.

bool allowFree

Allow sheets that include this sheet to free it?

bool _isCompiled

Has the sheet been compiled?

bool _isLinked

Has the sheet been linked?