Constants¶
The yace constants consists of:
Constant Values:
Symbolic Constants:
Enum Types:
Their ir representation follows below.
- class yace.ir.constants.Dec(*, key: str = 'dec', ant: dict | None = <factory>, lit: int)¶
Representation of a an integer literal in decimal
- key: str¶
- lit: int¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class yace.ir.constants.Define(*, sym: str, key: str = 'define', ant: dict | None = <factory>, val: ~yace.ir.constants.String | ~yace.ir.constants.Hex | ~yace.ir.constants.Dec)¶
C MACROS, one of biggest headaches when it comes to FFI interfaces, especially for interpreted languages such as Python, since MACRO-expressions have no symbols to “call” as these are all pre-preprocossed and gone thus, no longer available.
Thus, yace only support the definition of MACRO values, such as:
#define SOME_GLOBALLY_CONSTANT 0xACDC
Definitions such as these to translate fairly when into equivalent globally available and constant constructs in other languages
- key: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class yace.ir.constants.Enum(*, doc: ~yace.ir.base.Docstring, sym: str, key: str = 'enum', ant: dict | None = <factory>, members: ~typing.List[~yace.ir.constants.EnumValue])¶
Representation of enumeration values, note that literals on the
yace.ir.constants.EnumValue
are optional, anyace.ir.constants.Enum
with non literalyace.ir.constants.EnumValue
looks like:enum example { FOO, BAR, BAZ, };
Whereas, an
yace.ir.constants.Enum
with literalyace.ir.constants.EnumValue
looks like:enum example { FOO = 0xACDC, BAR = 0x1337, BAZ = 0xBEEF, };
for the
yace.ir.constants.EnumValue`
.- is_valid_members()¶
Checks whether the
yace.ir.constants.Enum
is valid
- key: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class yace.ir.constants.EnumValue(*, doc: ~yace.ir.base.Docstring, sym: str, key: str = 'enum_value', ant: dict | None = <factory>, val: ~yace.ir.constants.Hex | ~yace.ir.constants.Dec)¶
Representation of values in
yace.ir.constants.Enum
.By default, the C emitter produces:
SYMBOL = lit.val
for the
yace.ir.constants.EnumValue
.- key: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class yace.ir.constants.Hex(*, key: str = 'hex', ant: dict | None = <factory>, lit: int)¶
Representation of a hexadecimal constant
The emitted C code should be hexadecimal notation of literal integer values, such as those used by
yace.ir.constants.Define
andyace.ir.enumtypes.Enum
:#define FOO 0xACDC
- key: str¶
- lit: int¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class yace.ir.constants.String(*, key: str = 'str', ant: dict | None = <factory>, lit: str)¶
Representation of a literal string e.g. in C:
"this is a string-literal"
- key: str¶
- lit: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].