• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/include/ucode/program.h

  1 /*
  2  * Copyright (C) 2022 Jo-Philipp Wich <jo@mein.io>
  3  *
  4  * Permission to use, copy, modify, and/or distribute this software for any
  5  * purpose with or without fee is hereby granted, provided that the above
  6  * copyright notice and this permission notice appear in all copies.
  7  *
  8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 15  */
 16 
 17 #ifndef UCODE_PROGRAM_H
 18 #define UCODE_PROGRAM_H
 19 
 20 #include "types.h"
 21 
 22 
 23 uc_program_t *uc_program_new(void);
 24 
 25 static inline uc_program_t *
 26 uc_program_get(uc_program_t *prog) {
 27         return (uc_program_t *)ucv_get(prog ? &prog->header : NULL);
 28 }
 29 
 30 static inline void
 31 uc_program_put(uc_program_t *prog) {
 32         ucv_put(prog ? &prog->header : NULL);
 33 }
 34 
 35 #define uc_program_function_foreach(prog, fn)                   \
 36         uc_function_t *fn;                                                                      \
 37         for (fn = (uc_function_t *)prog->functions.prev;        \
 38              fn != (uc_function_t *)&prog->functions;           \
 39              fn = (uc_function_t *)fn->progref.prev)
 40 
 41 #define uc_program_function_foreach_safe(prog, fn)              \
 42         uc_function_t *fn, *fn##_tmp;                                           \
 43         for (fn = (uc_function_t *)prog->functions.prev,        \
 44              fn##_tmp = (uc_function_t *)fn->progref.prev;      \
 45              fn != (uc_function_t *)&prog->functions;           \
 46              fn = fn##_tmp,                                                             \
 47              fn##_tmp = (uc_function_t *)fn##_tmp->progref.prev)
 48 
 49 #define uc_program_function_last(prog) (uc_function_t *)prog->functions.next
 50 
 51 __hidden uc_function_t *uc_program_function_new(uc_program_t *, const char *, uc_source_t *, size_t);
 52 __hidden size_t uc_program_function_id(uc_program_t *, uc_function_t *);
 53 __hidden uc_function_t *uc_program_function_load(uc_program_t *, size_t);
 54 __hidden uc_source_t *uc_program_function_source(uc_function_t *);
 55 __hidden size_t uc_program_function_srcpos(uc_function_t *, size_t);
 56 __hidden void uc_program_function_free(uc_function_t *);
 57 
 58 __hidden uc_value_t *uc_program_get_constant(uc_program_t *, size_t);
 59 __hidden ssize_t uc_program_add_constant(uc_program_t *, uc_value_t *);
 60 
 61 void uc_program_write(uc_program_t *, FILE *, bool);
 62 uc_program_t *uc_program_load(uc_source_t *, char **);
 63 
 64 uc_function_t *uc_program_entry(uc_program_t *);
 65 
 66 #endif /* UCODE_PROGRAM_H */
 67 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt