The Croc Programming Language

Macros

#define croc_ex_import(t, name)   (croc_ex_importNS((t), (name)), croc_pop((t), 1))
 
#define croc_ex_importStk(t, name)   (croc_ex_importNSStk((t), (name)), croc_pop((t), 1))
 
#define croc_ex_importFromString(t, name, src, srcName)   (croc_ex_importFromStringNS((t), (name), (src), (srcName)), croc_pop((t), 1))
 
#define croc_ex_importFromStringNS(t, name, src, srcName)   (croc_pushString((t), (src)), croc_ex_importFromStringNSStk((t), (name), (srcName)))
 
#define croc_ex_importFromStringStk(t, name, srcName)   (croc_ex_importFromStringNSStk((t), (name), (src), (srcName)), croc_pop((t), 1))
 

Functions

word_t croc_ex_importNS (CrocThread *t, const char *name)
 
word_t croc_ex_importNSStk (CrocThread *t, word_t name)
 
word_t croc_ex_importFromStringNSStk (CrocThread *t, const char *name, const char *srcName)
 

Detailed Description

Importing modules.

Macro Definition Documentation

#define croc_ex_import (   t,
  name 
)    (croc_ex_importNS((t), (name)), croc_pop((t), 1))

Imports a module, just like an import statement in Croc.

Parameters
tis the thread. This will be evaluated by this macro more than once.
nameis the name of the module to import.
#define croc_ex_importStk (   t,
  name 
)    (croc_ex_importNSStk((t), (name)), croc_pop((t), 1))

Like croc_ex_import, but uses a stack slot for the name.

Parameters
tis the thread. This will be evaluated by this macro more than once.
nameshould be a stack index of a string containing the name of the module to import.
#define croc_ex_importFromString (   t,
  name,
  src,
  srcName 
)    (croc_ex_importFromStringNS((t), (name), (src), (srcName)), croc_pop((t), 1))

Imports a module from a string.

Parameters
tis the thread. This will be evaluated by this macro more than once.
nameis the module name that it will be imported as.
srcis the source code as a string.
srcNameis the name of the source that will be used in error messages.
#define croc_ex_importFromStringNS (   t,
  name,
  src,
  srcName 
)    (croc_pushString((t), (src)), croc_ex_importFromStringNSStk((t), (name), (srcName)))

Like croc_ex_importFromString, but leaves the namespace of the imported module on the stack.

#define croc_ex_importFromStringStk (   t,
  name,
  srcName 
)    (croc_ex_importFromStringNSStk((t), (name), (src), (srcName)), croc_pop((t), 1))

Like croc_ex_importFromString, but expects the source on top of the stack instead of as a parameter.

Function Documentation

word_t croc_ex_importNS ( CrocThread t,
const char *  name 
)

Like croc_ex_import, but leaves the namespace of the imported module on the stack.

Returns
the stack index of the pushed namespace.
word_t croc_ex_importNSStk ( CrocThread t,
word_t  name 
)

Like croc_ex_importStk, but leaves the namespace of the imported module on the stack.

Returns
the stack index of the pushed namespace.
word_t croc_ex_importFromStringNSStk ( CrocThread t,
const char *  name,
const char *  srcName 
)

Like croc_ex_importFromStringStk, but leaves the namespace of the imported module on the stack.

Returns
the stack index of the pushed namespace.