73 |
73 |
74 /* Now we try to find the variable instance declaration, to determine its type... */ |
74 /* Now we try to find the variable instance declaration, to determine its type... */ |
75 symbol_c *var_decl = search_var_instance_decl.get_decl(var_name_part); |
75 symbol_c *var_decl = search_var_instance_decl.get_decl(var_name_part); |
76 if (NULL == var_decl) { |
76 if (NULL == var_decl) { |
77 /* variable instance declaration not found! */ |
77 /* variable instance declaration not found! */ |
78 return NULL; |
78 return NULL; |
79 } |
79 } |
80 |
80 |
81 /* if it is a struct or function block, we must search the type |
81 /* if it is a struct or function block, we must search the type |
82 * of the struct or function block member. |
82 * of the struct or function block member. |
83 * This is done by this class visiting the var_decl. |
83 * This is done by this class visiting the var_decl. |
85 * decompose_var_instance_name->get_next() when and if required... |
85 * decompose_var_instance_name->get_next() when and if required... |
86 */ |
86 */ |
87 symbol_c *res = (symbol_c *)var_decl->accept(*this); |
87 symbol_c *res = (symbol_c *)var_decl->accept(*this); |
88 if (NULL == res) ERROR; |
88 if (NULL == res) ERROR; |
89 |
89 |
|
90 /* make sure that we have decomposed all strcuture elements of the variable name */ |
|
91 symbol_c *var_name = decompose_var_instance_name->next_part(); |
|
92 if (NULL != var_name) ERROR; |
|
93 |
|
94 return res; |
|
95 } |
|
96 |
|
97 unsigned int get_vartype(symbol_c *variable_name) { |
|
98 this->current_structelement_name = NULL; |
|
99 this->decompose_var_instance_name = new decompose_var_instance_name_c(variable_name); |
|
100 if (NULL == decompose_var_instance_name) ERROR; |
|
101 |
|
102 /* find the part of the variable name that will appear in the |
|
103 * variable declaration, for e.g., in window.point.x, this would be |
|
104 * window! |
|
105 */ |
|
106 symbol_c *var_name_part = decompose_var_instance_name->next_part(); |
|
107 if (NULL == var_name_part) ERROR; |
|
108 |
|
109 /* Now we try to find the variable instance declaration, to determine its type... */ |
|
110 symbol_c *var_decl = search_var_instance_decl.get_decl(var_name_part); |
|
111 if (NULL == var_decl) { |
|
112 /* variable instance declaration not found! */ |
|
113 return 0; |
|
114 } |
|
115 |
|
116 /* if it is a struct or function block, we must search the type |
|
117 * of the struct or function block member. |
|
118 * This is done by this class visiting the var_decl. |
|
119 * This class, while visiting, will recursively call |
|
120 * decompose_var_instance_name->get_next() when and if required... |
|
121 */ |
|
122 unsigned int res = search_var_instance_decl.get_vartype(); |
|
123 |
90 /* make sure that we have decomposed all strcuture elements of the variable name */ |
124 /* make sure that we have decomposed all strcuture elements of the variable name */ |
91 symbol_c *var_name = decompose_var_instance_name->next_part(); |
125 symbol_c *var_name = decompose_var_instance_name->next_part(); |
92 if (NULL != var_name) ERROR; |
126 if (NULL != var_name) ERROR; |
93 |
127 |
94 return res; |
128 return res; |