/[ascend]/trunk/base/generic/compiler/visitlink.c
ViewVC logotype

Annotation of /trunk/base/generic/compiler/visitlink.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 188 - (hide annotations) (download) (as text)
Mon Jan 16 07:47:02 2006 UTC (18 years, 6 months ago) by johnpye
File MIME type: text/x-csrc
File size: 5151 byte(s)
Adding some missing 'EXT' code, adding 'error_reporter_here' functionality.
1 aw0a 1 /*
2     * Ascend Name Tree Visit Implementation
3     * by Benjamin Andrew Allan
4     * 09/19/97
5     * Version: $Revision: 1.3 $
6     * Version control file: $RCSfile: visitlink.c,v $
7     * Date last modified: $Date: 1997/12/20 17:51:57 $
8     * Last modified by: $Author: ballan $
9     *
10     * This file is part of the Ascend Language Interpreter.
11     *
12     * Copyright (C) 1997 Carnegie Mellon University
13     *
14     * The Ascend Language Interpreter is free software; you can redistribute
15     * it and/or modify it under the terms of the GNU General Public License as
16     * published by the Free Software Foundation; either version 2 of the
17     * License, or (at your option) any later version.
18     *
19     * The Ascend Language Interpreter is distributed in hope that it will be
20     * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22     * General Public License for more details.
23     *
24     * You should have received a copy of the GNU General Public License
25     * along with the program; if not, write to the Free Software Foundation,
26     * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
27     * COPYING.
28     *
29     */
30    
31     #include <stdarg.h>
32     #include "utilities/ascConfig.h"
33     #include "utilities/ascPanic.h"
34     #include "utilities/ascMalloc.h"
35     #include "general/list.h"
36     #include "general/dstring.h"
37     #include "compiler/compiler.h"
38     #include "compiler/symtab.h"
39     #include "compiler/fractions.h"
40     #include "compiler/dimen.h"
41     #include "compiler/functype.h"
42     #include "compiler/types.h"
43     #include "compiler/child.h"
44     #include "compiler/type_desc.h"
45     #include "compiler/instance_enum.h"
46     #include "compiler/instance_name.h"
47     #include "compiler/instquery.h"
48     #include "compiler/instance_io.h"
49     #include "compiler/instmacro.h"
50     #include "compiler/parentchild.h"
51     #include "compiler/when_util.h"
52     #include "compiler/instance_types.h"
53     #include "compiler/visitlink.h"
54    
55     #ifndef lint
56     static CONST char NameVisitModuleID[] = "$Id: visitlink.c,v 1.3 1997/12/20 17:51:57 ballan Exp $";
57     #endif
58    
59     static
60     void SlowVisitTreeTwo(struct Instance *inst,
61     VisitNameTwoProc proc,
62     int depth, int leaf, int anon_flags,
63     struct gl_list_t *path,
64     VOIDPTR userdata)
65     {
66     unsigned long nc,c;
67     unsigned nullchildren=0;
68     struct Instance *child;
69     AssertMemory(inst);
70     if (!depth) {
71     (*proc)(inst,path,userdata);
72     }
73     if (leaf || NotAtom(inst) ) {
74     nc = NumberChildren(inst);
75     for(c = 1; c <= nc; c++) {
76     child = InstanceChild(inst,c);
77     if (child != NULL) {
78     if ( anon_flags || !InstanceUniversal(child) ) {
79     gl_append_ptr(path,(VOIDPTR)c);
80     gl_append_ptr(path,(VOIDPTR)inst);
81     SlowVisitTreeTwo(child,proc,depth,leaf,anon_flags,path,userdata);
82     gl_delete(path,gl_length(path),0);
83     gl_delete(path,gl_length(path),0);
84     }
85     } else {
86     nullchildren++;
87     }
88     }
89     if (nullchildren) {
90 johnpye 188 FPRINTF(ASCERR,"Found %u NULL children of '",nullchildren);
91 aw0a 1 WriteInstanceName(ASCERR,inst,NULL);
92 johnpye 188 FPRINTF(ASCERR,"'.\n");
93 aw0a 1 }
94     }
95     if (depth) {
96     (*proc)(inst,path,userdata);
97     }
98     }
99    
100     static
101     void SilentVisitTreeTwo(struct Instance *inst,
102     VisitNameTwoProc proc,
103     int depth, int leaf, int anon_flags,
104     struct gl_list_t *path,
105     VOIDPTR userdata)
106     {
107     unsigned long nc,c;
108     struct Instance *child;
109     AssertMemory(inst);
110     if (!depth) {
111     (*proc)(inst,path,userdata);
112     }
113     if (leaf || NotAtom(inst) ) {
114     nc = NumberChildren(inst);
115     for(c = 1; c <= nc; c++) {
116     child = InstanceChild(inst,c);
117     if (child != NULL && (GetAnonFlags(child) & anon_flags) == 0) {
118     gl_append_ptr(path,(VOIDPTR)c);
119     gl_append_ptr(path,(VOIDPTR)inst);
120     SilentVisitTreeTwo(child,proc,depth,leaf,anon_flags,path,userdata);
121     gl_delete(path,gl_length(path),0);
122     gl_delete(path,gl_length(path),0);
123     }
124     }
125     }
126     if (depth) {
127     (*proc)(inst,path,userdata);
128     }
129     }
130    
131    
132     #define IVIT_MIN_LEN 20
133     void SlowVisitNameTreeTwo(struct Instance *inst,
134     VisitNameTwoProc proc,
135     int depth, int leaf, int anon_flags,
136     VOIDPTR userdata)
137     {
138     struct gl_list_t *path;
139     AssertMemory(inst);
140     if (inst!=NULL) {
141     path = gl_create(IVIT_MIN_LEN*2);
142     if (path==NULL) {
143     Asc_Panic(2,"SlowVisitNameTreeTwo","insufficient memory");
144     }
145     SlowVisitTreeTwo(inst,proc,depth,leaf,anon_flags,path,userdata);
146     gl_destroy(path);
147     } else {
148     FPRINTF(ASCERR,"SlowVisitNameTreeTwo called with NULL.");
149     }
150     }
151     void SilentVisitNameTreeTwo(struct Instance *inst,
152     VisitNameTwoProc proc,
153     int depth, int leaf, int anon_flags,
154     VOIDPTR userdata)
155     {
156     struct gl_list_t *path;
157     AssertMemory(inst);
158     path = gl_create(IVIT_MIN_LEN*2);
159     if (path==NULL) {
160     Asc_Panic(2,"SilentVisitNameTreeTwo","insufficient memory");
161     }
162     SilentVisitTreeTwo(inst,proc,depth,leaf,anon_flags,path,userdata);
163     gl_destroy(path);
164     }
165     #undef IVIT_MIN_LEN

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