OrcCompiler

## OrcCompiler OrcCompiler — Compile Orc programs |

## Synopsis

    enum                OrcCompileResult;
    struct              OrcCompiler;
    struct              OrcConstant;
    #define             ORC_COMPILER_ERROR                  (compiler,
                                                             ...)
    #define             ORC_COMPILE_RESULT_IS_FATAL         (x)
    #define             ORC_COMPILE_RESULT_IS_SUCCESSFUL    (x)
    #define             ORC_ASM_CODE                        (compiler,
                                                             ...)
    #define             ORC_ENABLE_ASM_CODE
    void                orc_compiler_append_code            (OrcCompiler *p,
                                                             const char *fmt);
    int                 orc_compiler_label_new              (OrcCompiler *compiler);

## Description

OrcCompiler is the object used to convert Orc programs contained in an OrcProgram object into assembly code and object code.

The OrcCompileResult enum is used to indicate whether or not a compilation attempt was successful or not. The macros `ORC_COMPILE_RESULT_IS_SUCCESSFUL()` and `ORC_COMPILE_RESULT_IS_FATAL()` should be used instead of checking values directly.

When a program is compiled, the compiler calls the functions contained in various OrcRule structures. These functions generate assembly and object instructions by calling `ORC_ASM_CODE()` or functions that use `ORC_ASM_CODE()` internally.

## Details

### enum OrcCompileResult

    typedef enum {
      ORC_COMPILE_RESULT_OK = 0,

      ORC_COMPILE_RESULT_UNKNOWN_COMPILE = 0x100,
      ORC_COMPILE_RESULT_MISSING_RULE = 0x101,

      ORC_COMPILE_RESULT_UNKNOWN_PARSE = 0x200,
      ORC_COMPILE_RESULT_PARSE = 0x201,
      ORC_COMPILE_RESULT_VARIABLE = 0x202

    } OrcCompileResult;

### struct OrcCompiler

    struct OrcCompiler {
    };

The OrcCompiler structure has no public members

### struct OrcConstant

    struct OrcConstant {
    };

The OrcConstant structure has no public members

### ORC_COMPILER_ERROR()

    #define             ORC_COMPILER_ERROR(compiler, ...)

### ORC_COMPILE_RESULT_IS_FATAL()

    #define ORC_COMPILE_RESULT_IS_FATAL(x) ((x) >= 0x200)

### ORC_COMPILE_RESULT_IS_SUCCESSFUL()

    #define ORC_COMPILE_RESULT_IS_SUCCESSFUL(x) ((x) < 0x100)

### ORC_ASM_CODE()

    #define ORC_ASM_CODE(compiler,...) orc_compiler_append_code(compiler, __VA_ARGS__)

### ORC_ENABLE_ASM_CODE

    #define ORC_ENABLE_ASM_CODE

### orc_compiler_append_code ()

    void                orc_compiler_append_code            (OrcCompiler *p,
                                                             const char *fmt);

Generates a string using `sprintf()` on the given format and arguments, and appends that string to the generated assembly code for the compiler.

This function is used by the `ORC_ASM_CODE()` macro.

This function is useful in a function implementing an OrcRule or implementing a target.

`p` : | an OrcCompiler object
`fmt` : | a printf-style format string

### orc_compiler_label_new ()

    int                 orc_compiler_label_new              (OrcCompiler *compiler);