return pc;
}
+static bool
+find_lexical_block (tree lhs, tree block, int *indexp)
+{
+ tree t;
+
+ /* Search locally */
+ if (BLOCK_VARS (block))
+ for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
+ if (lhs == t)
+ return true;
+
+ if(BLOCK_CHAIN (block))
+ {
+ for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN(block))
+ {
+ (*indexp)++;
+ bool found = false;
+ found = find_lexical_block (lhs, t, indexp);
+ if (found)
+ return true;
+ }
+ }
+ return false;
+}
+
/**
* Return the scope of the variable that an assignment statement
* assigns to (i.e., the left-hand side), which will be on of the
* \return For a direct assignment to a variable, the scope of that
* variable, otherwise AOP_MEMORY_SCOPE.
*/
-enum aop_scope
+int
aop_capture_lhs_var_scope (struct aop_joinpoint *jp)
{
tree lhs;
+ tree function_block;
+ int var_index = 0;
lhs = get_lhs_var (jp);
+
if (lhs != NULL_TREE)
{
if (DECL_FILE_SCOPE_P (lhs))
}
else if (TREE_CODE (DECL_CONTEXT (lhs)) == FUNCTION_DECL)
{
- return AOP_FUNCTION_SCOPE;
+ function_block = DECL_INITIAL (current_function_decl);
+ bool retval = false;
+ retval = find_lexical_block (lhs, function_block, &var_index);
+
+ aop_assert (retval == true);
+ return var_index;
}
else
{
* values to indicate the scope of the variable assigned in a
* specified assignment statement.
*/
-enum aop_scope {
- /**
- * The variable is accessible by name from anywhere in the program.
- */
- AOP_GLOBAL_SCOPE,
-
- /**
- * The variable is only accessible by name from the current file.
- */
- AOP_FILE_SCOPE,
+/**
+ * The variable is accessible by name from anywhere in the program.
+ */
+#define AOP_GLOBAL_SCOPE -1
+
+/**
+ * The variable is only accessible by name from the current file.
+ */
+#define AOP_FILE_SCOPE -2
- /**
- * The variable is only accessible by name from the current function
- * or method.
- */
- AOP_FUNCTION_SCOPE,
+/**
+ * Used for an assignment that does not assign to a variable. For
+ * example, the assignment may be to a field in a struct or a
+ * dereferenced pointer.
+ */
+#define AOP_MEMORY_SCOPE -3
- /**
- * Used for an assignment that does not assign to a variable. For
- * example, the assignment may be to a field in a struct or a
- * dereferenced pointer.
- */
- AOP_MEMORY_SCOPE,
-};
-extern enum aop_scope aop_capture_lhs_var_scope (struct aop_joinpoint *jp);
+extern int aop_capture_lhs_var_scope (struct aop_joinpoint *jp);
#endif