API

group yvm

Public function definitions and types for Yvm.

Typedefs

typedef struct yvm_yvm *yvm_Yvm

The public type for a Yvm code container.

Functions

yvm_Yvm yvm_create(y_str name, struct yvm_Func **fptr)

Creates a container for Yvm code that must be freed with yvm_free();.

Parameters:
  • name – The name of the first function.

  • fptr – A pointer to a yvm_Func pointer that, if non-NULL, will be used to return a pointer to the first function created.

Returns:

A container for Yvm code, or NULL on error.

Pre:

name.a must not be NULL.

yvm_Yvm yvm_screate(y_str name, struct yvm_Func **fptr)

Creates a container for Yvm code that must be freed with y_stackallocator_free() because this uses the stack allocator.

Parameters:
  • name – The name of the first function.

  • fptr – A pointer to a yvm_Func pointer that, if non-NULL, will be used to return a pointer to the first function created.

Returns:

A container for Yvm code, or NULL on error.

Pre:

name.a must not be NULL.

void yvm_free(void *yvmcode)

Frees the Yvm code container.

Parameters:

yvmcode – The Yvm code container.

Pre:

yvmcode must not be NULL.

y_Status yvm_name(yvm_Yvm y, y_str *str, const char *prefix, y_usize *idx)

Generates a name that has not been used before.

Parameters:
  • y – The Yao code container.

  • str – The string to initialize.

  • prefix – The prefix to put on the generated name. Can be “”.

  • idx – A pointer to the current generated index.

Returns:

An error code, if any.

Pre:

y must not be NULL.

Pre:

str must not be NULL.

Pre:

prefix must not be NULL.

Pre:

idx must not be NULL.

y_Status yvm_str(yvm_Yvm y, y_str *str, const char *string, y_usize size)

Stores a string in the program’s setpool and returns a y_str that points to it.

If the string already exists, then the y_str is pointed to that instead.

Parameters:
  • y – The program.

  • str – The y_str to store the result in.

  • string – The string to store.

  • size – The size of the string.

Returns:

An error code, if any.

Pre:

y must not be NULL.

Pre:

str must not be NULL.

Pre:

string must not be NULL.

Pre:

size must be equal to strlen(string) + 1.