print_binary(const slang_operation *op, const char *oper, int indent)
{
assert(op->num_children == 2);
+ printf("binary at %p locals=%p outer=%p\n",
+ (void *) op,
+ (void *) op->locals,
+ (void *) op->locals->outer_scope);
slang_print_tree(&op->children[0], indent + 3);
spaces(indent);
- printf("%s\n", oper);
+ printf("%s at %p locals=%p outer=%p\n",
+ oper, (void *) op, (void *) op->locals,
+ (void *) op->locals->outer_scope);
slang_print_tree(&op->children[1], indent + 3);
}
print_generic2(const slang_operation *op, const char *oper,
const char *s, int indent)
{
- int i;
+ GLuint i;
if (oper) {
spaces(indent);
- printf("[%p locals %p] %s %s\n", (void*) op, (void*) op->locals, oper, s);
+ printf("%s %s at %p locals=%p outer=%p\n",
+ oper, s, (void *) op, (void *) op->locals,
+ (void *) op->locals->outer_scope);
}
for (i = 0; i < op->num_children; i++) {
spaces(indent);
- printf("//child %d:\n", i);
+ printf("//child %u of %u:\n", i, op->num_children);
slang_print_tree(&op->children[i], indent);
}
}
case SLANG_OPER_BLOCK_NO_NEW_SCOPE:
spaces(indent);
- printf("{ locals %p outer %p\n", (void*)op->locals, (void*)op->locals->outer_scope);
+ printf("{ locals=%p outer=%p\n", (void*)op->locals, (void*)op->locals->outer_scope);
print_generic(op, NULL, indent+3);
spaces(indent);
printf("}\n");
case SLANG_OPER_BLOCK_NEW_SCOPE:
spaces(indent);
- printf("{{ // new scope locals %p\n", (void*)op->locals);
+ printf("{{ // new scope locals=%p: ", (void*)op->locals);
+ {
+ int i;
+ for (i = 0; i < op->locals->num_variables; i++) {
+ printf("%s ", (char *) op->locals->variables[i]->a_name);
+ }
+ printf("\n");
+ }
print_generic(op, NULL, indent+3);
spaces(indent);
printf("}}\n");
slang_variable *v;
v = _slang_locate_variable(op->locals, op->a_id, GL_TRUE);
if (v) {
+ const slang_variable_scope *scope;
spaces(indent);
printf("DECL (locals=%p outer=%p) ", (void*)op->locals, (void*) op->locals->outer_scope);
print_type(&v->type);
printf(" %s (%p)", (char *) op->a_id,
(void *) find_var(op->locals, op->a_id));
- printf(" (in scope %p) ",
- (void *) find_scope(op->locals, op->a_id));
+ scope = find_scope(op->locals, op->a_id);
+ printf(" (in scope %p) ", (void *) scope);
+ assert(scope);
if (op->num_children == 1) {
printf(" :=\n");
slang_print_tree(&op->children[0], indent + 3);
case SLANG_OPER_ASM:
spaces(indent);
- printf("ASM: %s\n", (char*) op->a_id);
- print_generic(op, NULL, indent+3);
+ printf("ASM: %s at %p locals=%p outer=%p\n",
+ (char *) op->a_id,
+ (void *) op,
+ (void *) op->locals,
+ (void *) op->locals->outer_scope);
+ print_generic(op, "ASM", indent+3);
break;
case SLANG_OPER_BREAK:
case SLANG_OPER_EXPRESSION:
spaces(indent);
- printf("EXPR: locals %p\n", (void*) op->locals);
+ printf("EXPR: locals=%p outer=%p\n",
+ (void *) op->locals,
+ (void *) op->locals->outer_scope);
/*print_generic(op, "SLANG_OPER_EXPRESSION", indent);*/
slang_print_tree(&op->children[0], indent + 3);
break;
break;
case SLANG_OPER_IDENTIFIER:
- spaces(indent);
- if (op->var && op->var->a_name)
- printf("VAR %s (in scope %p)\n", (char *) op->var->a_name,
- (void *) find_scope(op->locals, op->a_id));
- else
- printf("VAR' %s (in scope %p)\n", (char *) op->a_id,
- (void *) find_scope(op->locals, op->a_id));
+ {
+ const slang_variable_scope *scope;
+ spaces(indent);
+ if (op->var && op->var->a_name) {
+ scope = find_scope(op->locals, op->var->a_name);
+ printf("VAR %s (in scope %p)\n", (char *) op->var->a_name,
+ (void *) scope);
+ assert(scope);
+ }
+ else {
+ scope = find_scope(op->locals, op->a_id);
+ printf("VAR' %s (in scope %p) locals=%p outer=%p\n",
+ (char *) op->a_id,
+ (void *) scope,
+ (void *) op->locals,
+ (void *) op->locals->outer_scope);
+ assert(scope);
+ }
+ }
break;
case SLANG_OPER_SEQUENCE:
case SLANG_OPER_ASSIGN:
spaces(indent);
- printf("ASSIGNMENT locals %p\n", (void*)op->locals);
+ printf("ASSIGNMENT locals=%p outer=%p\n",
+ (void *) op->locals,
+ (void *) op->locals->outer_scope);
print_binary(op, ":=", indent);
break;
case SLANG_OPER_SUBSCRIPT:
spaces(indent);
- printf("SLANG_OPER_SUBSCRIPT\n");
+ printf("SLANG_OPER_SUBSCRIPT locals=%p outer=%p\n",
+ (void *) op->locals,
+ (void *) op->locals->outer_scope);
print_generic(op, NULL, indent+3);
break;
print_variable(f->parameters->variables[i], 3);
}
- printf(")\n");
+ printf(") param scope = %p\n", (void *) f->parameters);
+
if (body && f->body)
slang_print_tree(f->body, 0);
}
slang_checksum_tree(const slang_operation *op)
{
int s = op->num_children;
- int i;
+ GLuint i;
for (i = 0; i < op->num_children; i++) {
s += slang_checksum_tree(&op->children[i]);