[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/6] * variable.h: Add support of struct value_records and par
From: |
Macpaul Lin |
Subject: |
[PATCH v2 2/6] * variable.h: Add support of struct value_records and parent_records |
Date: |
Mon, 18 Aug 2014 21:27:11 +0800 |
(struct parent_record): add struct parent_record,
for constructing variables dependencies.
(struct value_record): add struct value_record for record
each value is assigned to a variable.
(variable_name_extract): add support to extract variable name
with [$()] prefix.
(alloc_parent_record): a function allocate memory for a parent_record
(do_variable_definition): add a paremeter of parent_records which will keep
related parent_variable occured in conditional_line.
(try_variable_definition): add a paremeter of parent_records to make
parent_record be associaited when the variable is defined.
(dup_parent_record): a function for distinquish variables in the same
conditional line's depth but may have different parents sets.
Signed-off-by: Macpaul Lin <address@hidden>
---
Changes for v2:
- add depth to struct parent_record.
- add (dup_parent_record).
- add depth support for (alloc_parent_record).
variable.h | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/variable.h b/variable.h
index 3e2328a..0dae4a4 100644
--- a/variable.h
+++ b/variable.h
@@ -47,6 +47,25 @@ enum variable_flavor
#define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */
#define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1)
+struct parent_record
+ {
+ struct variable *parent; /* a pointer to a parent which defined
+ a value of a variable */
+ struct parent_record *next; /* a pointer to next parent which defined
+ the same value */
+ unsigned int depth; /* a variable to remember the depth of
+ ifdef/ifeq conditional lines */
+ };
+
+struct value_record
+ {
+ char *value; /* defined value of a variable. */
+ struct parent_record *p_records; /* a list of parents which defined
+ this value */
+ struct value_record *next; /* a pointer to next defined value */
+ };
+
+
struct variable
{
char *name; /* Variable name. */
@@ -78,6 +97,8 @@ struct variable
v_ifset, /* Export it if it has a non-default value. */
v_default /* Decide in target_environment. */
} export ENUM_BITFIELD (2);
+ struct value_record *v_records;
+ /* a list of defined values of this variable */
};
/* Structure that represents a variable set. */
@@ -119,6 +140,7 @@ char *allocated_variable_expand_for_file (const char *line,
struct file *file);
#define allocated_variable_expand(line) \
allocated_variable_expand_for_file (line, (struct file *) 0)
char *expand_argument (const char *str, const char *end);
+char *variable_name_extract (char *p, char **ps);
char *variable_expand_string (char *line, const char *string, long length);
void install_variable_buffer (char **bufp, unsigned int *lenp);
void restore_variable_buffer (char *buf, unsigned int len);
@@ -152,17 +174,23 @@ void print_file_variables (const struct file *file);
void print_target_variables (const struct file *file);
void merge_variable_set_lists (struct variable_set_list **to_list,
struct variable_set_list *from_list);
+struct parent_record *dup_parent_record (struct parent_record **dst_pr,
+ struct parent_record *src_pr);
+struct parent_record *alloc_parent_record (struct variable *parent,
+ unsigned int depth);
struct variable *do_variable_definition (const gmk_floc *flocp,
const char *name, const char *value,
enum variable_origin origin,
enum variable_flavor flavor,
- int target_var);
+ int target_var,
+ struct parent_record *parents);
char *parse_variable_definition (const char *line,
struct variable *v);
struct variable *assign_variable_definition (struct variable *v, const char
*line);
struct variable *try_variable_definition (const gmk_floc *flocp, const char
*line,
enum variable_origin origin,
- int target_var);
+ int target_var,
+ struct parent_record *parents);
void init_hash_global_variable_set (void);
void hash_init_function_table (void);
void define_new_function(const gmk_floc *flocp, const char *name,
--
1.9.1
- [PATCH v2 1/6] * expand.c (variable_name_extract): extract variable name and strip prefix., Macpaul Lin, 2014/08/18
- [PATCH v2 2/6] * variable.h: Add support of struct value_records and parent_records,
Macpaul Lin <=
- [PATCH v2 3/6] * variable.c: Add support for constructing value_records and parent_records, Macpaul Lin, 2014/08/18
- [PATCH v2 4/6] * read.c: Construct the dependency chain between parent and target variable, Macpaul Lin, 2014/08/18
- [PATCH v2 5/6] * load.c: add support of parent_records, Macpaul Lin, 2014/08/18
- [PATCH v2 6/6] * main.c: add --dep parameter for print variable dependency, Macpaul Lin, 2014/08/18
- Re: [PATCH v2 1/6] * expand.c (variable_name_extract): extract variable name and strip prefix., Paul Smith, 2014/08/18