raising the head after a three-weeks refactoring
[m6w6/ext-psi] / src / types / impl_var.h
index e35a8b71486861212a9beeb54cd10fb90ddf43a4..4576cb9f896c41ec986bc1e87c423bef57409064 100644 (file)
 #ifndef PSI_TYPES_IMPL_VAR_H
 #define PSI_TYPES_IMPL_VAR_H
 
-typedef struct impl_var {
+struct psi_token;
+struct psi_impl;
+struct psi_impl_arg;
+
+struct psi_impl_var {
        struct psi_token *token;
-       char *name;
-       struct impl_arg *arg;
+       char *name, *fqn;
+       struct psi_impl_arg *arg;
        unsigned reference:1;
-} impl_var;
+};
+
+struct psi_impl_var *psi_impl_var_init(const char *name, bool is_reference);
+struct psi_impl_var *psi_impl_var_copy(struct psi_impl_var *var);
+void psi_impl_var_free(struct psi_impl_var **var_ptr);
+
+#include <string.h>
 
-impl_var *init_impl_var(const char *name, int is_reference);
-impl_var *copy_impl_var(impl_var *var);
-void free_impl_var(impl_var *var);
+static inline char *psi_impl_var_name_prepend(char *current, const char *prepend) {
+       size_t c_len = strlen(current);
+       size_t p_len = strlen(prepend);
 
-struct impl_args;
+       current = realloc(current, p_len
+                       + c_len // includes '$'
+                       + 1 // connecting dot
+                       + 1 // terminating 0
+       );
+       if (current) {
+               if (c_len > 1) {
+                       memmove(current + p_len + 1 + 1, current + 1, c_len - 1 + 1);
+                       current[p_len + 1] = '.';
+               } else {
+                       /* just '$' */
+                       current[p_len + 1] = '\0';
+               }
+               memcpy(current + 1, prepend, p_len);
+       }
+       return current;
+}
 
-struct impl_arg *locate_impl_var_arg(impl_var *var, struct impl_args *args);
+bool psi_impl_var_validate(struct psi_data *data, struct psi_impl_var *ivar, struct psi_impl *impl,
+               struct psi_let_exp *current_let_exp, struct psi_set_exp *current_set_exp);
 
 #endif