fixed a bug where determinate 1D arrays would not have correct sizeof() -- REALLY hacky fix :(
authorDavid Anderson <dvander@alliedmods.net>
Sat Feb 17 04:37:47 2007 +0000 (2007-02-17)
changeset 510546acad59370
parent 509 9489c25cefea
child 511 c29f8796bcf4
fixed a bug where determinate 1D arrays would not have correct sizeof() -- REALLY hacky fix :(
fixed local arrays asserting on more than two dimensions with the last dimension being indeterminate
sourcepawn/compiler/sc.h
sourcepawn/compiler/sc1.c
sourcepawn/compiler/sc2.c
     1.1 --- a/sourcepawn/compiler/sc.h	Sat Feb 17 04:10:58 2007 +0000
     1.2 +++ b/sourcepawn/compiler/sc.h	Sat Feb 17 04:37:47 2007 +0000
     1.3 @@ -823,6 +823,7 @@
     1.4  SC_VDECL int pc_memflags;     /* special flags for the stack/heap usage */
     1.5  SC_VDECL int pc_functag;      /* global function tag */
     1.6  SC_VDECL int pc_tag_string;   /* global string tag */
     1.7 +SC_VDECL int glbstringread;	  /* last global string read */
     1.8  
     1.9  SC_VDECL constvalue sc_automaton_tab; /* automaton table */
    1.10  SC_VDECL constvalue sc_state_tab;     /* state table */
     2.1 --- a/sourcepawn/compiler/sc1.c	Sat Feb 17 04:10:58 2007 +0000
     2.2 +++ b/sourcepawn/compiler/sc1.c	Sat Feb 17 04:37:47 2007 +0000
     2.3 @@ -170,6 +170,7 @@
     2.4    static HWND hwndFinish = 0;
     2.5  #endif
     2.6  
     2.7 +SC_VDECL int glbstringread = 0;
     2.8  char g_tmpfile[_MAX_PATH] = {0};
     2.9  
    2.10  /*  "main" of the compiler
    2.11 @@ -2044,6 +2045,9 @@
    2.12      } /* if */
    2.13      assert(litidx==0);  /* literal queue should be empty (again) */
    2.14      initials(ident,tag,&size,dim,numdim,enumroot);/* stores values in the literal queue */
    2.15 +    if (tag == pc_tag_string && (numdim == 1) && !dim[numdim-1]) {
    2.16 +      slength = glbstringread;
    2.17 +    }
    2.18      assert(size>=litidx);
    2.19      if (numdim==1)
    2.20        dim[0]=(int)size;
    2.21 @@ -2209,6 +2213,7 @@
    2.22    do {
    2.23      ident=iVARIABLE;
    2.24      size=1;
    2.25 +    slength=0;
    2.26      numdim=0;                           /* no dimensions */
    2.27      tag=pc_addtag(NULL);
    2.28      if (lex(&val,&str)!=tSYMBOL)        /* read in (new) token */
    2.29 @@ -2304,7 +2309,12 @@
    2.30          sc_alignnext=FALSE;
    2.31        } /* if */
    2.32        cur_lit=litidx;           /* save current index in the literal table */
    2.33 +      if (numdim && !dim[numdim-1])
    2.34 +        size = 0;
    2.35        initials(ident,tag,&size,dim,numdim,enumroot);
    2.36 +      if (tag == pc_tag_string && (numdim == 1) && !dim[numdim-1]) {
    2.37 +        slength = glbstringread;
    2.38 +      }
    2.39        if (size==0)
    2.40          return ident;           /* error message already given */
    2.41        if (numdim==1)
     3.1 --- a/sourcepawn/compiler/sc2.c	Sat Feb 17 04:10:58 2007 +0000
     3.2 +++ b/sourcepawn/compiler/sc2.c	Sat Feb 17 04:37:47 2007 +0000
     3.3 @@ -1798,6 +1798,7 @@
     3.4  
     3.5    i=0; /* start at least significant byte */
     3.6    val=0;
     3.7 +  glbstringread=1;
     3.8    while (*lptr!='\"' && *lptr!='\0') {
     3.9      if (*lptr=='\a') {          /* ignore '\a' (which was inserted at a line concatenation) */
    3.10        lptr++;
    3.11 @@ -1807,6 +1808,7 @@
    3.12      if (c>=(ucell)(1 << sCHARBITS))
    3.13        error(43);                /* character constant exceeds range */
    3.14      val |= (c << 8*i);
    3.15 +    glbstringread++;
    3.16      if (i==sizeof(ucell)-(sCHARBITS/8)) {
    3.17        litadd(val);
    3.18        val=0;
    3.19 @@ -2821,10 +2823,14 @@
    3.20      for (level=0; level<numdim; level++) {
    3.21        top=addsym(name,addr,ident,vclass,tag,uDEFINE);
    3.22        top->dim.array.length=dim[level];
    3.23 -      if (tag == pc_tag_string && level == numdim - 1)
    3.24 -        top->dim.array.slength=slength;
    3.25 -	  else
    3.26 +      if (tag == pc_tag_string && level == numdim - 1) {
    3.27 +        if (slength == 0)
    3.28 +          top->dim.array.length=dim[level] * sizeof(cell);
    3.29 +        else
    3.30 +          top->dim.array.slength=slength;
    3.31 +      } else {
    3.32          top->dim.array.slength=0;
    3.33 +      }
    3.34        top->dim.array.level=(short)(numdim-level-1);
    3.35        top->x.tags.index=idxtag[level];
    3.36        top->parent=parent;