ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

slang_print.c
Go to the documentation of this file.
00001 
00007 #include "main/imports.h"
00008 #include "slang_compile.h"
00009 #include "slang_print.h"
00010 
00011 
00012 static void
00013 spaces(int n)
00014 {
00015    while (n--)
00016       printf(" ");
00017 }
00018 
00019 
00020 static void
00021 print_type(const slang_fully_specified_type *t)
00022 {
00023    switch (t->qualifier) {
00024    case SLANG_QUAL_NONE:
00025       /*printf("");*/
00026       break;
00027    case SLANG_QUAL_CONST:
00028       printf("const ");
00029       break;
00030    case SLANG_QUAL_ATTRIBUTE:
00031       printf("attrib ");
00032       break;
00033    case SLANG_QUAL_VARYING:
00034       printf("varying ");
00035       break;
00036    case SLANG_QUAL_UNIFORM:
00037       printf("uniform ");
00038       break;
00039    case SLANG_QUAL_OUT:
00040       printf("output ");
00041       break;
00042    case SLANG_QUAL_INOUT:
00043       printf("inout ");
00044       break;
00045    case SLANG_QUAL_FIXEDOUTPUT:
00046       printf("fixedoutput");
00047       break;
00048    case SLANG_QUAL_FIXEDINPUT:
00049       printf("fixedinput");
00050       break;
00051    default:
00052       printf("unknown qualifer!");
00053    }
00054 
00055    switch (t->specifier.type) {
00056    case SLANG_SPEC_VOID:
00057       printf("void");
00058       break;
00059    case SLANG_SPEC_BOOL:
00060       printf("bool");
00061       break;
00062    case SLANG_SPEC_BVEC2:
00063       printf("bvec2");
00064       break;
00065    case SLANG_SPEC_BVEC3:
00066       printf("bvec3");
00067       break;
00068    case SLANG_SPEC_BVEC4:
00069       printf("bvec4");
00070       break;
00071    case SLANG_SPEC_INT:
00072       printf("int");
00073       break;
00074    case SLANG_SPEC_IVEC2:
00075       printf("ivec2");
00076       break;
00077    case SLANG_SPEC_IVEC3:
00078       printf("ivec3");
00079       break;
00080    case SLANG_SPEC_IVEC4:
00081       printf("ivec4");
00082       break;
00083    case SLANG_SPEC_FLOAT:
00084       printf("float");
00085       break;
00086    case SLANG_SPEC_VEC2:
00087       printf("vec2");
00088       break;
00089    case SLANG_SPEC_VEC3:
00090       printf("vec3");
00091       break;
00092    case SLANG_SPEC_VEC4:
00093       printf("vec4");
00094       break;
00095    case SLANG_SPEC_MAT2:
00096       printf("mat2");
00097       break;
00098    case SLANG_SPEC_MAT3:
00099       printf("mat3");
00100       break;
00101    case SLANG_SPEC_MAT4:
00102       printf("mat4");
00103       break;
00104    case SLANG_SPEC_MAT23:
00105       printf("mat2x3");
00106       break;
00107    case SLANG_SPEC_MAT32:
00108       printf("mat3x2");
00109       break;
00110    case SLANG_SPEC_MAT24:
00111       printf("mat2x4");
00112       break;
00113    case SLANG_SPEC_MAT42:
00114       printf("mat4x2");
00115       break;
00116    case SLANG_SPEC_MAT34:
00117       printf("mat3x4");
00118       break;
00119    case SLANG_SPEC_MAT43:
00120       printf("mat4x3");
00121       break;
00122    case SLANG_SPEC_SAMPLER1D:
00123       printf("sampler1D");
00124       break;
00125    case SLANG_SPEC_SAMPLER2D:
00126       printf("sampler2D");
00127       break;
00128    case SLANG_SPEC_SAMPLER3D:
00129       printf("sampler3D");
00130       break;
00131    case SLANG_SPEC_SAMPLERCUBE:
00132       printf("samplerCube");
00133       break;
00134    case SLANG_SPEC_SAMPLER1DSHADOW:
00135       printf("sampler1DShadow");
00136       break;
00137    case SLANG_SPEC_SAMPLER2DSHADOW:
00138       printf("sampler2DShadow");
00139       break;
00140    case SLANG_SPEC_STRUCT:
00141       printf("struct");
00142       break;
00143    case SLANG_SPEC_ARRAY:
00144       printf("array");
00145       break;
00146    default:
00147       printf("unknown type");
00148    }
00149    /*printf("\n");*/
00150 }
00151 
00152 
00153 static void
00154 print_variable(const slang_variable *v, int indent)
00155 {
00156    spaces(indent);
00157    printf("VAR ");
00158    print_type(&v->type);
00159    printf(" %s (at %p)", (char *) v->a_name, (void *) v);
00160    if (v->initializer) {
00161       printf(" :=\n");
00162       slang_print_tree(v->initializer, indent + 3);
00163    }
00164    else {
00165       printf(";\n");
00166    }
00167 }
00168 
00169 
00170 static void
00171 print_binary(const slang_operation *op, const char *oper, int indent)
00172 {
00173    assert(op->num_children == 2);
00174 #if 0
00175    printf("binary at %p locals=%p outer=%p\n",
00176           (void *) op,
00177           (void *) op->locals,
00178           (void *) op->locals->outer_scope);
00179 #endif
00180    slang_print_tree(&op->children[0], indent + 3);
00181    spaces(indent);
00182    printf("%s at %p locals=%p outer=%p\n",
00183           oper, (void *) op, (void *) op->locals,
00184           (void *) op->locals->outer_scope);
00185    slang_print_tree(&op->children[1], indent + 3);
00186 }
00187 
00188 
00189 static void
00190 print_generic2(const slang_operation *op, const char *oper,
00191                const char *s, int indent)
00192 {
00193    GLuint i;
00194    if (oper) {
00195       spaces(indent);
00196       printf("%s %s at %p locals=%p outer=%p\n",
00197              oper, s, (void *) op, (void *) op->locals, 
00198              (void *) op->locals->outer_scope);
00199    }
00200    for (i = 0; i < op->num_children; i++) {
00201       spaces(indent);
00202       printf("//child %u of %u:\n", i, op->num_children);
00203       slang_print_tree(&op->children[i], indent);
00204    }
00205 }
00206 
00207 static void
00208 print_generic(const slang_operation *op, const char *oper, int indent)
00209 {
00210    print_generic2(op, oper, "", indent);
00211 }
00212 
00213 
00214 static const slang_variable_scope *
00215 find_scope(const slang_variable_scope *s, slang_atom name)
00216 {
00217    GLuint i;
00218    for (i = 0; i < s->num_variables; i++) {
00219       if (s->variables[i]->a_name == name)
00220          return s;
00221    }
00222    if (s->outer_scope)
00223       return find_scope(s->outer_scope, name);
00224    else
00225       return NULL;
00226 }
00227 
00228 static const slang_variable *
00229 find_var(const slang_variable_scope *s, slang_atom name)
00230 {
00231    GLuint i;
00232    for (i = 0; i < s->num_variables; i++) {
00233       if (s->variables[i]->a_name == name)
00234          return s->variables[i];
00235    }
00236    if (s->outer_scope)
00237       return find_var(s->outer_scope, name);
00238    else
00239       return NULL;
00240 }
00241 
00242 
00243 void
00244 slang_print_tree(const slang_operation *op, int indent)
00245 {
00246    GLuint i;
00247 
00248    switch (op->type) {
00249 
00250    case SLANG_OPER_NONE:
00251       spaces(indent);
00252       printf("SLANG_OPER_NONE\n");
00253       break;
00254 
00255    case SLANG_OPER_BLOCK_NO_NEW_SCOPE:
00256       spaces(indent);
00257       printf("{ locals=%p  outer=%p\n", (void*)op->locals, (void*)op->locals->outer_scope);
00258       print_generic(op, NULL, indent+3);
00259       spaces(indent);
00260       printf("}\n");
00261       break;
00262 
00263    case SLANG_OPER_BLOCK_NEW_SCOPE:
00264       spaces(indent);
00265       printf("{{ // new scope  locals=%p outer=%p: ",
00266              (void *) op->locals,
00267              (void *) op->locals->outer_scope);
00268       for (i = 0; i < op->locals->num_variables; i++) {
00269          printf("%s ", (char *) op->locals->variables[i]->a_name);
00270       }
00271       printf("\n");
00272       print_generic(op, NULL, indent+3);
00273       spaces(indent);
00274       printf("}}\n");
00275       break;
00276 
00277    case SLANG_OPER_VARIABLE_DECL:
00278       assert(op->num_children == 0 || op->num_children == 1);
00279       {
00280          slang_variable *v;
00281          v = _slang_variable_locate(op->locals, op->a_id, GL_TRUE);
00282          if (v) {
00283             const slang_variable_scope *scope;
00284             spaces(indent);
00285             printf("DECL (locals=%p outer=%p) ", (void*)op->locals, (void*) op->locals->outer_scope);
00286             print_type(&v->type);
00287             printf(" %s (%p)", (char *) op->a_id,
00288                    (void *) find_var(op->locals, op->a_id));
00289 
00290             scope = find_scope(op->locals, op->a_id);
00291             printf(" (in scope %p) ", (void *) scope);
00292             assert(scope);
00293             if (op->num_children == 1) {
00294                printf(" :=\n");
00295                slang_print_tree(&op->children[0], indent + 3);
00296             }
00297             else if (v->initializer) {
00298                printf(" := INITIALIZER\n");
00299                slang_print_tree(v->initializer, indent + 3);
00300             }
00301             else {
00302                printf(";\n");
00303             }
00304             /*
00305             spaces(indent);
00306             printf("TYPE: ");
00307             print_type(&v->type);
00308             spaces(indent);
00309             printf("ADDR: %d  size: %d\n", v->address, v->size);
00310             */
00311          }
00312          else {
00313             spaces(indent);
00314             printf("DECL %s (anonymous variable!!!!)\n", (char *) op->a_id);
00315          }
00316       }
00317       break;
00318 
00319    case SLANG_OPER_ASM:
00320       spaces(indent);
00321       printf("ASM: %s at %p locals=%p outer=%p\n",
00322              (char *) op->a_id,
00323              (void *) op,
00324              (void *) op->locals,
00325              (void *) op->locals->outer_scope);
00326       print_generic(op, "ASM", indent+3);
00327       break;
00328 
00329    case SLANG_OPER_BREAK:
00330       spaces(indent);
00331       printf("BREAK\n");
00332       break;
00333 
00334    case SLANG_OPER_CONTINUE:
00335       spaces(indent);
00336       printf("CONTINUE\n");
00337       break;
00338 
00339    case SLANG_OPER_DISCARD:
00340       spaces(indent);
00341       printf("DISCARD\n");
00342       break;
00343 
00344    case SLANG_OPER_RETURN:
00345       spaces(indent);
00346       printf("RETURN\n");
00347       if (op->num_children > 0)
00348          slang_print_tree(&op->children[0], indent + 3);
00349       break;
00350 
00351    case SLANG_OPER_LABEL:
00352       spaces(indent);
00353       printf("LABEL %s\n", (char *) op->a_id);
00354       break;
00355 
00356    case SLANG_OPER_EXPRESSION:
00357       spaces(indent);
00358       printf("EXPR:  locals=%p outer=%p\n",
00359              (void *) op->locals,
00360              (void *) op->locals->outer_scope);
00361       /*print_generic(op, "SLANG_OPER_EXPRESSION", indent);*/
00362       slang_print_tree(&op->children[0], indent + 3);
00363       break;
00364 
00365    case SLANG_OPER_IF:
00366       spaces(indent);
00367       printf("IF\n");
00368       slang_print_tree(&op->children[0], indent + 3);
00369       spaces(indent);
00370       printf("THEN\n");
00371       slang_print_tree(&op->children[1], indent + 3);
00372       spaces(indent);
00373       printf("ELSE\n");
00374       slang_print_tree(&op->children[2], indent + 3);
00375       spaces(indent);
00376       printf("ENDIF\n");
00377       break;
00378 
00379    case SLANG_OPER_WHILE:
00380       assert(op->num_children == 2);
00381       spaces(indent);
00382       printf("WHILE LOOP: locals = %p\n", (void *) op->locals);
00383       indent += 3;
00384       spaces(indent);
00385       printf("WHILE cond:\n");
00386       slang_print_tree(&op->children[0], indent + 3);
00387       spaces(indent);
00388       printf("WHILE body:\n");
00389       slang_print_tree(&op->children[1], indent + 3);
00390       indent -= 3;
00391       spaces(indent);
00392       printf("END WHILE LOOP\n");
00393       break;
00394 
00395    case SLANG_OPER_DO:
00396       spaces(indent);
00397       printf("DO LOOP: locals = %p\n", (void *) op->locals);
00398       indent += 3;
00399       spaces(indent);
00400       printf("DO body:\n");
00401       slang_print_tree(&op->children[0], indent + 3);
00402       spaces(indent);
00403       printf("DO cond:\n");
00404       slang_print_tree(&op->children[1], indent + 3);
00405       indent -= 3;
00406       spaces(indent);
00407       printf("END DO LOOP\n");
00408       break;
00409 
00410    case SLANG_OPER_FOR:
00411       spaces(indent);
00412       printf("FOR LOOP: locals = %p\n", (void *) op->locals);
00413       indent += 3;
00414       spaces(indent);
00415       printf("FOR init:\n");
00416       slang_print_tree(&op->children[0], indent + 3);
00417       spaces(indent);
00418       printf("FOR condition:\n");
00419       slang_print_tree(&op->children[1], indent + 3);
00420       spaces(indent);
00421       printf("FOR step:\n");
00422       slang_print_tree(&op->children[2], indent + 3);
00423       spaces(indent);
00424       printf("FOR body:\n");
00425       slang_print_tree(&op->children[3], indent + 3);
00426       indent -= 3;
00427       spaces(indent);
00428       printf("ENDFOR\n");
00429       /*
00430       print_generic(op, "FOR", indent + 3);
00431       */
00432       break;
00433 
00434    case SLANG_OPER_VOID:
00435       spaces(indent);
00436       printf("(oper-void)\n");
00437       break;
00438 
00439    case SLANG_OPER_LITERAL_BOOL:
00440       spaces(indent);
00441       printf("LITERAL (");
00442       for (i = 0; i < op->literal_size; i++)
00443          printf("%s ", op->literal[0] ? "TRUE" : "FALSE");
00444       printf(")\n");
00445 
00446       break;
00447 
00448    case SLANG_OPER_LITERAL_INT:
00449       spaces(indent);
00450       printf("LITERAL (");
00451       for (i = 0; i < op->literal_size; i++)
00452          printf("%d ", (int) op->literal[i]);
00453       printf(")\n");
00454       break;
00455 
00456    case SLANG_OPER_LITERAL_FLOAT:
00457       spaces(indent);
00458       printf("LITERAL (");
00459       for (i = 0; i < op->literal_size; i++)
00460          printf("%f ", op->literal[i]);
00461       printf(")\n");
00462       break;
00463 
00464    case SLANG_OPER_IDENTIFIER:
00465       {
00466          const slang_variable_scope *scope;
00467          spaces(indent);
00468          if (op->var && op->var->a_name) {
00469             scope = find_scope(op->locals, op->var->a_name);
00470             printf("VAR %s  (in scope %p)\n", (char *) op->var->a_name,
00471                    (void *) scope);
00472             assert(scope);
00473          }
00474          else {
00475             scope = find_scope(op->locals, op->a_id);
00476             printf("VAR' %s  (in scope %p) locals=%p outer=%p\n",
00477                    (char *) op->a_id,
00478                    (void *) scope,
00479                    (void *) op->locals,
00480                    (void *) op->locals->outer_scope);
00481             assert(scope);
00482          }
00483       }
00484       break;
00485 
00486    case SLANG_OPER_SEQUENCE:
00487       print_generic(op, "COMMA-SEQ", indent+3);
00488       break;
00489 
00490    case SLANG_OPER_ASSIGN:
00491       spaces(indent);
00492       printf("ASSIGNMENT  locals=%p outer=%p\n",
00493              (void *) op->locals,
00494              (void *) op->locals->outer_scope);
00495       print_binary(op, ":=", indent);
00496       break;
00497 
00498    case SLANG_OPER_ADDASSIGN:
00499       spaces(indent);
00500       printf("ASSIGN\n");
00501       print_binary(op, "+=", indent);
00502       break;
00503 
00504    case SLANG_OPER_SUBASSIGN:
00505       spaces(indent);
00506       printf("ASSIGN\n");
00507       print_binary(op, "-=", indent);
00508       break;
00509 
00510    case SLANG_OPER_MULASSIGN:
00511       spaces(indent);
00512       printf("ASSIGN\n");
00513       print_binary(op, "*=", indent);
00514       break;
00515 
00516    case SLANG_OPER_DIVASSIGN:
00517       spaces(indent);
00518       printf("ASSIGN\n");
00519       print_binary(op, "/=", indent);
00520       break;
00521 
00522     /*SLANG_OPER_MODASSIGN,*/
00523     /*SLANG_OPER_LSHASSIGN,*/
00524     /*SLANG_OPER_RSHASSIGN,*/
00525     /*SLANG_OPER_ORASSIGN,*/
00526     /*SLANG_OPER_XORASSIGN,*/
00527     /*SLANG_OPER_ANDASSIGN,*/
00528    case SLANG_OPER_SELECT:
00529       spaces(indent);
00530       printf("SLANG_OPER_SELECT n=%d\n", op->num_children);
00531       assert(op->num_children == 3);
00532       slang_print_tree(&op->children[0], indent+3);
00533       spaces(indent);
00534       printf("?\n");
00535       slang_print_tree(&op->children[1], indent+3);
00536       spaces(indent);
00537       printf(":\n");
00538       slang_print_tree(&op->children[2], indent+3);
00539       break;
00540 
00541    case SLANG_OPER_LOGICALOR:
00542       print_binary(op, "||", indent);
00543       break;
00544 
00545    case SLANG_OPER_LOGICALXOR:
00546       print_binary(op, "^^", indent);
00547       break;
00548 
00549    case SLANG_OPER_LOGICALAND:
00550       print_binary(op, "&&", indent);
00551       break;
00552 
00553    /*SLANG_OPER_BITOR*/
00554    /*SLANG_OPER_BITXOR*/
00555    /*SLANG_OPER_BITAND*/
00556    case SLANG_OPER_EQUAL:
00557       print_binary(op, "==", indent);
00558       break;
00559 
00560    case SLANG_OPER_NOTEQUAL:
00561       print_binary(op, "!=", indent);
00562       break;
00563 
00564    case SLANG_OPER_LESS:
00565       print_binary(op, "<", indent);
00566       break;
00567 
00568    case SLANG_OPER_GREATER:
00569       print_binary(op, ">", indent);
00570       break;
00571 
00572    case SLANG_OPER_LESSEQUAL:
00573       print_binary(op, "<=", indent);
00574       break;
00575 
00576    case SLANG_OPER_GREATEREQUAL:
00577       print_binary(op, ">=", indent);
00578       break;
00579 
00580    /*SLANG_OPER_LSHIFT*/
00581    /*SLANG_OPER_RSHIFT*/
00582    case SLANG_OPER_ADD:
00583       print_binary(op, "+", indent);
00584       break;
00585 
00586    case SLANG_OPER_SUBTRACT:
00587       print_binary(op, "-", indent);
00588       break;
00589 
00590    case SLANG_OPER_MULTIPLY:
00591       print_binary(op, "*", indent);
00592       break;
00593 
00594    case SLANG_OPER_DIVIDE:
00595       print_binary(op, "/", indent);
00596       break;
00597 
00598    /*SLANG_OPER_MODULUS*/
00599    case SLANG_OPER_PREINCREMENT:
00600       spaces(indent);
00601       printf("PRE++\n");
00602       slang_print_tree(&op->children[0], indent+3);
00603       break;
00604 
00605    case SLANG_OPER_PREDECREMENT:
00606       spaces(indent);
00607       printf("PRE--\n");
00608       slang_print_tree(&op->children[0], indent+3);
00609       break;
00610 
00611    case SLANG_OPER_PLUS:
00612       spaces(indent);
00613       printf("SLANG_OPER_PLUS\n");
00614       break;
00615 
00616    case SLANG_OPER_MINUS:
00617       spaces(indent);
00618       printf("SLANG_OPER_MINUS\n");
00619       break;
00620 
00621    /*SLANG_OPER_COMPLEMENT*/
00622    case SLANG_OPER_NOT:
00623       spaces(indent);
00624       printf("NOT\n");
00625       slang_print_tree(&op->children[0], indent+3);
00626       break;
00627 
00628    case SLANG_OPER_SUBSCRIPT:
00629       spaces(indent);
00630       printf("SLANG_OPER_SUBSCRIPT locals=%p outer=%p\n",
00631              (void *) op->locals,
00632              (void *) op->locals->outer_scope);
00633       print_generic(op, NULL, indent+3);
00634       break;
00635 
00636    case SLANG_OPER_CALL:
00637 #if 0
00638          slang_function *fun
00639             = _slang_function_locate(A->space.funcs, oper->a_id,
00640                                      oper->children,
00641                                      oper->num_children, &A->space, A->atoms);
00642 #endif
00643       spaces(indent);
00644       printf("CALL %s(\n", (char *) op->a_id);
00645       for (i = 0; i < op->num_children; i++) {
00646          slang_print_tree(&op->children[i], indent+3);
00647          if (i + 1 < op->num_children) {
00648             spaces(indent + 3);
00649             printf(",\n");
00650          }
00651       }
00652       spaces(indent);
00653       printf(")\n");
00654       break;
00655 
00656    case SLANG_OPER_METHOD:
00657       spaces(indent);
00658       printf("METHOD CALL %s.%s\n", (char *) op->a_obj, (char *) op->a_id);
00659       break;
00660 
00661    case SLANG_OPER_FIELD:
00662       spaces(indent);
00663       printf("FIELD %s of\n", (char*) op->a_id);
00664       slang_print_tree(&op->children[0], indent+3);
00665       break;
00666 
00667    case SLANG_OPER_POSTINCREMENT:
00668       spaces(indent);
00669       printf("POST++\n");
00670       slang_print_tree(&op->children[0], indent+3);
00671       break;
00672 
00673    case SLANG_OPER_POSTDECREMENT:
00674       spaces(indent);
00675       printf("POST--\n");
00676       slang_print_tree(&op->children[0], indent+3);
00677       break;
00678 
00679    default:
00680       printf("unknown op->type %d\n", (int) op->type);
00681    }
00682 
00683 }
00684 
00685 
00686 
00687 void
00688 slang_print_function(const slang_function *f, GLboolean body)
00689 {
00690    GLuint i;
00691 
00692 #if 0
00693    if (_mesa_strcmp((char *) f->header.a_name, "main") != 0)
00694      return;
00695 #endif
00696 
00697    printf("FUNCTION %s ( scope=%p\n",
00698           (char *) f->header.a_name, (void *) f->parameters);
00699 
00700    for (i = 0; i < f->param_count; i++) {
00701       print_variable(f->parameters->variables[i], 3);
00702    }
00703 
00704    printf(") param scope = %p\n", (void *) f->parameters);
00705 
00706    if (body && f->body)
00707       slang_print_tree(f->body, 0);
00708 }
00709 
00710 
00711 
00712 
00713 
00714 const char *
00715 slang_type_qual_string(slang_type_qualifier q)
00716 {
00717    switch (q) {
00718    case SLANG_QUAL_NONE:
00719       return "none";
00720    case SLANG_QUAL_CONST:
00721       return "const";
00722    case SLANG_QUAL_ATTRIBUTE:
00723       return "attribute";
00724    case SLANG_QUAL_VARYING:
00725       return "varying";
00726    case SLANG_QUAL_UNIFORM:
00727       return "uniform";
00728    case SLANG_QUAL_OUT:
00729       return "out";
00730    case SLANG_QUAL_INOUT:
00731       return "inout";
00732    case SLANG_QUAL_FIXEDOUTPUT:
00733       return "fixedoutput";
00734    case SLANG_QUAL_FIXEDINPUT:
00735       return "fixedinputk";
00736    default:
00737       return "qual?";
00738    }
00739 }
00740 
00741 
00742 static const char *
00743 slang_type_string(slang_type_specifier_type t)
00744 {
00745    switch (t) {
00746    case SLANG_SPEC_VOID:
00747       return "void";
00748    case SLANG_SPEC_BOOL:
00749       return "bool";
00750    case SLANG_SPEC_BVEC2:
00751       return "bvec2";
00752    case SLANG_SPEC_BVEC3:
00753       return "bvec3";
00754    case SLANG_SPEC_BVEC4:
00755       return "bvec4";
00756    case SLANG_SPEC_INT:
00757       return "int";
00758    case SLANG_SPEC_IVEC2:
00759       return "ivec2";
00760    case SLANG_SPEC_IVEC3:
00761       return "ivec3";
00762    case SLANG_SPEC_IVEC4:
00763       return "ivec4";
00764    case SLANG_SPEC_FLOAT:
00765       return "float";
00766    case SLANG_SPEC_VEC2:
00767       return "vec2";
00768    case SLANG_SPEC_VEC3:
00769       return "vec3";
00770    case SLANG_SPEC_VEC4:
00771       return "vec4";
00772    case SLANG_SPEC_MAT2:
00773       return "mat2";
00774    case SLANG_SPEC_MAT3:
00775       return "mat3";
00776    case SLANG_SPEC_MAT4:
00777       return "mat4";
00778    case SLANG_SPEC_SAMPLER1D:
00779       return "sampler1D";
00780    case SLANG_SPEC_SAMPLER2D:
00781       return "sampler2D";
00782    case SLANG_SPEC_SAMPLER3D:
00783       return "sampler3D";
00784    case SLANG_SPEC_SAMPLERCUBE:
00785       return "samplerCube";
00786    case SLANG_SPEC_SAMPLER1DSHADOW:
00787       return "sampler1DShadow";
00788    case SLANG_SPEC_SAMPLER2DSHADOW:
00789       return "sampler2DShadow";
00790    case SLANG_SPEC_SAMPLER2DRECT:
00791       return "sampler2DRect";
00792    case SLANG_SPEC_SAMPLER2DRECTSHADOW:
00793       return "sampler2DRectShadow";
00794    case SLANG_SPEC_STRUCT:
00795       return "struct";
00796    case SLANG_SPEC_ARRAY:
00797       return "array";
00798    default:
00799       return "type?";
00800    }
00801 }
00802 
00803 
00804 static const char *
00805 slang_fq_type_string(const slang_fully_specified_type *t)
00806 {
00807    static char str[1000];
00808    sprintf(str, "%s %s", slang_type_qual_string(t->qualifier),
00809       slang_type_string(t->specifier.type));
00810    return str;
00811 }
00812 
00813 
00814 void
00815 slang_print_type(const slang_fully_specified_type *t)
00816 {
00817    printf("%s %s", slang_type_qual_string(t->qualifier),
00818       slang_type_string(t->specifier.type));
00819 }
00820 
00821 
00822 #if 0
00823 static char *
00824 slang_var_string(const slang_variable *v)
00825 {
00826    static char str[1000];
00827    sprintf(str, "%s : %s",
00828            (char *) v->a_name,
00829            slang_fq_type_string(&v->type));
00830    return str;
00831 }
00832 #endif
00833 
00834 
00835 void
00836 slang_print_variable(const slang_variable *v)
00837 {
00838    printf("Name: %s\n", (char *) v->a_name);
00839    printf("Type: %s\n", slang_fq_type_string(&v->type));
00840 }
00841 
00842 
00843 void
00844 _slang_print_var_scope(const slang_variable_scope *vars, int indent)
00845 {
00846    GLuint i;
00847 
00848    spaces(indent);
00849    printf("Var scope %p  %d vars:\n", (void *) vars, vars->num_variables);
00850    for (i = 0; i < vars->num_variables; i++) {
00851       spaces(indent + 3);
00852       printf("%s (at %p)\n", (char *) vars->variables[i]->a_name, (void*) (vars->variables + i));
00853    }
00854    spaces(indent + 3);
00855    printf("outer_scope = %p\n", (void*) vars->outer_scope);
00856 
00857    if (vars->outer_scope) {
00858       /*spaces(indent + 3);*/
00859       _slang_print_var_scope(vars->outer_scope, indent + 3);
00860    }
00861 }
00862 
00863 
00864 
00865 int
00866 slang_checksum_tree(const slang_operation *op)
00867 {
00868    int s = op->num_children;
00869    GLuint i;
00870 
00871    for (i = 0; i < op->num_children; i++) {
00872       s += slang_checksum_tree(&op->children[i]);
00873    }
00874    return s;
00875 }

Generated on Sat May 26 2012 04:19:27 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.