# src/m_token.c File Reference

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <malloc.h>`
`#include <string.h>`
`#include <inttypes.h>`
`#include <stdint.h>`
`#include "m_token.h"`
`#include "m_ms.h"`

## Defines

#define | MY_LL "ll"

## Functions

libmangle_gc_context_t * | libmangle_generate_gc (void)
void | libmangle_release_gc (libmangle_gc_context_t *gc)
uMToken * | gen_tok (libmangle_gc_context_t *gc, enum eMToken kind, enum eMSToken subkind, size_t addend)
void | libmangle_dump_tok (FILE *fp, uMToken *p)
uMToken * | chain_tok (uMToken *l, uMToken *add)
uMToken * | gen_value (libmangle_gc_context_t *gc, enum eMSToken skind, uint64_t val, int is_signed, int size)
uMToken * | gen_name (libmangle_gc_context_t *gc, enum eMSToken skind, const char *name)
uMToken * | gen_dim (libmangle_gc_context_t *gc, enum eMSToken skind, uint64_t val, const char *non_tt_param, int fSigned, int fNegate)
uMToken * | gen_unary (libmangle_gc_context_t *gc, enum eMSToken skind, uMToken *un)
uMToken * | gen_binary (libmangle_gc_context_t *gc, enum eMSToken skind, uMToken *l, uMToken *r)
char * | libmangle_sprint_decl (uMToken *r)
void | libmangle_print_decl (FILE *fp, uMToken *r)

## Define Documentation

#define MY_LL "ll"

## Function Documentation

uMToken* chain_tok | ( | uMToken * | l,
|  | uMToken * | add |
| ) |  |  |

Chains uMTokens together.

Parameters:

  `[in]` | l | uMtoken chain to link up with.
  `[in]` | add | uMtoken to add to chain.

Returns:
  l unchanged

uMToken* gen_binary | ( | libmangle_gc_context_t * | gc,
|  | enum eMSToken | skind,
|  | uMToken * | l,
|  | uMToken * | r |
| ) |  |  |

Generates a binary node token.

Parameters:

  `[in]` | gc | Pointer to garbage collection context.
  `[in]` | skind | Token subKind.
  `[in]` | l | Left node element.
  `[in]` | r | Right node element.

Returns:
  Pointer to binary token.

See also:
  sMToken_binary

uMToken* gen_dim | ( | libmangle_gc_context_t * | gc,
|  | enum eMSToken | skind,
|  | uint64_t | val,
|  | const char * | non_tt_param,
|  | int | fSigned,
|  | int | fNegate |
| ) |  |  |

Constructs a "dim" kind token.

Parameters:

  `[in]` | gc | Pointer to garbage collection context.
  `[in]` | skind | Token subkind.
  `[in]` | val | Token numerical value.
  `[in]` | non_tt_param | pointer to decoded C++ template name.
  `[in]` | fSigned | Signedness of the numerical value.
  `[in]` | fNegate | 1 for "val" is negative digit.

Returns:
  Pointer to dim token.

See also:
  sMToken_dim

uMToken* gen_name | ( | libmangle_gc_context_t * | gc,
|  | enum eMSToken | skind,
|  | const char * | name |
| ) |  |  |

Constructs a "name" kind token.

Parameters:

  `[in]` | gc | Pointer to garbage collection context.
  `[in]` | skind | Token subkind.
  `[in]` | name | Pointer to name string.

Returns:
  Pointer to name token.

See also:
  sMToken_name

uMToken* gen_tok | ( | libmangle_gc_context_t * | gc,
|  | enum eMToken | kind,
|  | enum eMSToken | subkind,
|  | size_t | addend |
| ) |  |  |

uMToken* gen_unary | ( | libmangle_gc_context_t * | gc,
|  | enum eMSToken | skind,
|  | uMToken * | un |
| ) |  |  |

Constructs a "unary" kind token.

Parameters:

  `[in]` | gc | Pointer to garbage collection context.
  `[in]` | skind | Token subkind.
  `[in]` | un | Pointer to leaf element.

Returns:
  Pointer to a unary token.

See also:
  sMToken_unary

uMToken* gen_value | ( | libmangle_gc_context_t * | gc,
|  | enum eMSToken | skind,
|  | uint64_t | val,
|  | int | is_signed,
|  | int | size |
| ) |  |  |

Constructs a "value" kind token.

Parameters:

  `[in]` | gc | Pointer to garbage collection context.
  `[in]` | skind | Token subkind.
  `[in]` | val | Sets the value on token,
  `[in]` | is_signed | Signed bit of val.
  `[in]` | size | Width of val.

Returns:
  Pointer to value token.

See also:
  sMToken_value

void libmangle_dump_tok | ( | FILE * | fp,
|  | uMToken * | p |
| ) |  |  |

Dumps uMToken to a file descriptor for debugging.

Parameters:

  `[in]` | fp | File descriptor to print the token to.
  `[in]` | p | uMToken chain to print.

libmangle_gc_context_t* libmangle_generate_gc | ( | void |  | ) |

Constructs a garbage collection context token.

Returns:
  Pointer to context.

See also:
  libmangle_release_gc()

void libmangle_print_decl | ( | FILE * | fp,
|  | uMToken * | p |
| ) |  |  |

Prints C++ name to file descriptor.

Parameters:

  `[in]` | fp | Output file descriptor.
  `[in]` | p | Token containing information about the C++ name.

See also:
  libmangle_decode_ms_name()

void libmangle_release_gc | ( | libmangle_gc_context_t * | gc | ) |

Releases memory tracked by context.

Parameters:

  `[in]` | gc | Garbage collection context to work on.

See also:
  libmangle_generate_gc()

char* libmangle_sprint_decl | ( | uMToken * | r | ) |

Get pointer to decoded C++ name string. Use free() to release returned string.

Parameters:

  `[in]` | r | C++ name token.

Returns:
  pointer to decoded C++ name string.

See also:
  libmangle_decode_ms_name()