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_label.c
Go to the documentation of this file.
00001 
00002 
00010 #include "slang_label.h"
00011 #include "slang_mem.h"
00012 
00013 
00014 
00015 slang_label *
00016 _slang_label_new(const char *name)
00017 {
00018    slang_label *l = (slang_label *) _slang_alloc(sizeof(slang_label));
00019    if (l) {
00020       l->Name = _slang_strdup(name);
00021       l->Location = -1;
00022    }
00023    return l;
00024 }
00025 
00029 slang_label *
00030 _slang_label_new_unique(const char *name)
00031 {
00032    static int id = 1;
00033    slang_label *l = (slang_label *) _slang_alloc(sizeof(slang_label));
00034    if (l) {
00035       l->Name = (char *) _slang_alloc(_mesa_strlen(name) + 10);
00036       if (!l->Name) {
00037          _mesa_free(l);
00038          return NULL;
00039       }
00040       _mesa_sprintf(l->Name, "%s_%d", name, id);
00041       id++;
00042       l->Location = -1;
00043    }
00044    return l;
00045 }
00046 
00047 void
00048 _slang_label_delete(slang_label *l)
00049 {
00050    if (l->Name) {
00051       _slang_free(l->Name);
00052       l->Name = NULL;
00053    }
00054    if (l->References) {
00055       _slang_free(l->References);
00056       l->References = NULL;
00057    }
00058    _slang_free(l);
00059 }
00060 
00061 
00062 void
00063 _slang_label_add_reference(slang_label *l, GLuint inst)
00064 {
00065    const GLuint oldSize = l->NumReferences * sizeof(GLuint);
00066    assert(l->Location < 0);
00067    l->References = _slang_realloc(l->References,
00068                                   oldSize, oldSize + sizeof(GLuint));
00069    if (l->References) {
00070       l->References[l->NumReferences] = inst;
00071       l->NumReferences++;
00072    }
00073 }
00074 
00075 
00076 GLint
00077 _slang_label_get_location(const slang_label *l)
00078 {
00079    return l->Location;
00080 }
00081 
00082 
00083 void
00084 _slang_label_set_location(slang_label *l, GLint location,
00085                           struct gl_program *prog)
00086 {
00087    GLuint i;
00088 
00089    assert(l->Location < 0);
00090    assert(location >= 0);
00091 
00092    l->Location = location;
00093 
00094    /* for the instructions that were waiting to learn the label's location: */
00095    for (i = 0; i < l->NumReferences; i++) {
00096       const GLuint j = l->References[i];
00097       prog->Instructions[j].BranchTarget = location;
00098    }
00099 
00100    if (l->References) {
00101       _slang_free(l->References);
00102       l->References = NULL;
00103    }
00104 }

Generated on Thu May 24 2012 04:20:52 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.