/[ascend]/trunk/ascend/compiler/instance_io.c
ViewVC logotype

Diff of /trunk/ascend/compiler/instance_io.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2687 by jpye, Wed Dec 12 12:39:25 2012 UTC revision 2688 by jpye, Mon Mar 4 08:11:49 2013 UTC
# Line 121  struct gl_list_t *ShortestPath(CONST str Line 121  struct gl_list_t *ShortestPath(CONST str
121    unsigned long c,len;    unsigned long c,len;
122    unsigned mybest= UINT_MAX;    unsigned mybest= UINT_MAX;
123    if(height>=best) return NULL;    if(height>=best) return NULL;
124    if(i==ref) {    if(i==ref){
125      shortest = gl_create(1L);      shortest = gl_create(1L);
126      gl_append_ptr(shortest,(VOIDPTR)ref);      gl_append_ptr(shortest,(VOIDPTR)ref);
127      return shortest;      return shortest;
# Line 133  struct gl_list_t *ShortestPath(CONST str Line 133  struct gl_list_t *ShortestPath(CONST str
133      if (shortest==NULL){      if (shortest==NULL){
134        shortest=path;        shortest=path;
135        mybest = height+gl_length(path);        mybest = height+gl_length(path);
136      } else{      }else{
137        if (gl_length(path)<gl_length(shortest)){        if(gl_length(path)<gl_length(shortest)){
138          gl_destroy(shortest);          gl_destroy(shortest);
139          shortest = path;          shortest = path;
140          mybest = height+gl_length(path);          mybest = height+gl_length(path);
141        } else {        }else{
142              gl_destroy(path);              gl_destroy(path);
143            }            }
144      }      }
145        }        }
146      }      }
147      if (shortest){      if(shortest){
148        gl_append_ptr(shortest,NULL);        gl_append_ptr(shortest,NULL);
149        for(c=gl_length(shortest);c>1;c--) {        for(c=gl_length(shortest);c>1;c--) {
150      gl_store(shortest,c,gl_fetch(shortest,c-1));      gl_store(shortest,c,gl_fetch(shortest,c-1));
151        }        }
152        gl_store(shortest,1,(char *)i);        gl_store(shortest,1,(VOIDPTR)i);
153        assert((ref!=NULL)||(gl_length(shortest)==InstanceShortDepth(i)));        assert((ref!=NULL)||(gl_length(shortest)==InstanceShortDepth(i)));
154      }      }
155    }else{    }else{
# Line 164  struct gl_list_t *ShortestPath(CONST str Line 164  struct gl_list_t *ShortestPath(CONST str
164    return shortest;    return shortest;
165  }  }
166    
167  int WritePath(FILE *f, CONST struct gl_list_t *path)  
168  {  int WritePath(FILE *f, CONST struct gl_list_t *path){
169    CONST struct Instance *parent,*child;    CONST struct Instance *parent,*child;
170    struct InstanceName name;    struct InstanceName name;
171    unsigned long c;    unsigned long c;
172    int count = 0;    int count = 0;
173    
174    if (path!=NULL){    if(path!=NULL){
175      parent = gl_fetch(path,gl_length(path));      parent = gl_fetch(path,gl_length(path));
176      for(c=gl_length(path)-1;c>=1;c--){      for(c=gl_length(path)-1;c>=1;c--){
177        child = gl_fetch(path,c);        child = gl_fetch(path,c);
178        name = ParentsName(parent,child);        name = ParentsName(parent,child);
179        switch (InstanceNameType(name)){        switch (InstanceNameType(name)){
180        case StrName:        case StrName:
181      if (c<(gl_length(path)-1)) PUTC('.',f);      if(c<(gl_length(path)-1)) PUTC('.',f);
182      FPRINTF(f,SCP(InstanceNameStr(name)));      FPRINTF(f,SCP(InstanceNameStr(name)));
183      count += SCLEN(InstanceNameStr(name));      count += SCLEN(InstanceNameStr(name));
184      break;      break;
# Line 191  int WritePath(FILE *f, CONST struct gl_l Line 191  int WritePath(FILE *f, CONST struct gl_l
191        }        }
192        parent = child;        parent = child;
193      }      }
194    }    }else{
   else{  
195      FPRINTF(ASCERR,"Cannot print name.\n");      FPRINTF(ASCERR,"Cannot print name.\n");
196      FPRINTF(f,"?????");      FPRINTF(f,"?????");
197    }    }
# Line 233  static void WritePathDS(Asc_DString *dsP Line 232  static void WritePathDS(Asc_DString *dsP
232    }    }
233  }  }
234    
235  char *WritePathString(CONST struct gl_list_t *path)  
236  {  char *WritePathString(CONST struct gl_list_t *path){
237    char *result;    char *result;
238    Asc_DString ds, *dsPtr;    Asc_DString ds, *dsPtr;
239    dsPtr = &ds;    dsPtr = &ds;

Legend:
Removed from v.2687  
changed lines
  Added in v.2688

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22