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(struct yvm_Func **fptr)

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

Parameters:

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.

yvm_Yvm yvm_screate(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:

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.

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, size_t *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, size_t 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.