Mercurial > emacs
comparison lisp/cedet/semantic/analyze/fcn.el @ 104490:7811201f57f2
* cedet/semantic/analyze/fcn.el (semantic-analyze-dereference-metatype-1)
(semantic-analyze-type): Require semantic/scope.
(semantic-analyze-select-best-tag): Require semantic/db-typecache.
(semantic-analyze-dereference-metatype): Move up to avoid compiler warning.
* cedet/semantic/analyze.el (semantic-adebug-analyze): Require data-debug.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 13 Sep 2009 16:12:23 +0000 |
parents | 08a15f853c45 |
children | bbd7017a25d9 |
comparison
equal
deleted
inserted
replaced
104489:25e047f7f6a2 | 104490:7811201f57f2 |
---|---|
26 ;;; Code: | 26 ;;; Code: |
27 | 27 |
28 (require 'mode-local) | 28 (require 'mode-local) |
29 (require 'semantic) | 29 (require 'semantic) |
30 (require 'semantic/tag) | 30 (require 'semantic/tag) |
31 | |
32 (eval-when-compile (require 'semantic/find)) | |
33 | |
34 (declare-function semanticdb-typecache-merge-streams "semantic/db-typecache") | |
35 (declare-function semantic-scope-find name "semantic/scope") | |
36 (declare-function semantic-scope-set-typecache "semantic/scope") | |
37 (declare-function semantic-scope-tag-get-scope "semantic/scope") | |
31 | 38 |
32 ;;; Small Mode Specific Options | 39 ;;; Small Mode Specific Options |
33 ;; | 40 ;; |
34 ;; These queries allow a major mode to help the analyzer make decisions. | 41 ;; These queries allow a major mode to help the analyzer make decisions. |
35 ;; | 42 ;; |
103 ;; This step will eliminate a vast majority of the types, | 110 ;; This step will eliminate a vast majority of the types, |
104 ;; in addition to merging namespaces together. | 111 ;; in addition to merging namespaces together. |
105 ;; | 112 ;; |
106 ;; 2) | 113 ;; 2) |
107 ;; It will also remove prototypes. | 114 ;; It will also remove prototypes. |
115 (require 'semantic/db-typecache) | |
108 (setq sequence (semanticdb-typecache-merge-streams sequence nil)) | 116 (setq sequence (semanticdb-typecache-merge-streams sequence nil)) |
109 | 117 |
110 (if (< (length sequence) 2) | 118 (if (< (length sequence) 2) |
111 ;; If the remaining sequence after the merge is 1 tag or less, | 119 ;; If the remaining sequence after the merge is 1 tag or less, |
112 ;; just return it and skip the rest of this mumbo-jumbo. | 120 ;; just return it and skip the rest of this mumbo-jumbo. |
148 (semantic-find-tags-for-completion | 156 (semantic-find-tags-for-completion |
149 prefix (current-buffer)))) | 157 prefix (current-buffer)))) |
150 | 158 |
151 ;;; Finding Datatypes | 159 ;;; Finding Datatypes |
152 ;; | 160 ;; |
161 | |
162 (define-overloadable-function semantic-analyze-dereference-metatype (type scope &optional type-declaration) | |
163 ;; todo - move into typecahe!! | |
164 "Return a concrete type tag based on input TYPE tag. | |
165 A concrete type is an actual declaration of a memory description, | |
166 such as a structure, or class. A meta type is an alias, | |
167 or a typedef in C or C++. If TYPE is concrete, it | |
168 is returned. If it is a meta type, it will return the concrete | |
169 type defined by TYPE. | |
170 The default behavior always returns TYPE. | |
171 Override functions need not return a real semantic tag. | |
172 Just a name, or short tag will be ok. It will be expanded here. | |
173 SCOPE is the scope object with additional items in which to search for names." | |
174 (catch 'default-behavior | |
175 (let* ((ans-tuple (:override | |
176 ;; Nothing fancy, just return type by default. | |
177 (throw 'default-behavior (list type type-declaration)))) | |
178 (ans-type (car ans-tuple)) | |
179 (ans-type-declaration (cadr ans-tuple))) | |
180 (list (semantic-analyze-dereference-metatype-1 ans-type scope) ans-type-declaration)))) | |
181 | |
153 ;; Finding a data type by name within a project. | 182 ;; Finding a data type by name within a project. |
154 ;; | 183 ;; |
155 (defun semantic-analyze-type-to-name (type) | 184 (defun semantic-analyze-type-to-name (type) |
156 "Get the name of TAG's type. | 185 "Get the name of TAG's type. |
157 The TYPE field in a tag can be nil (return nil) | 186 The TYPE field in a tag can be nil (return nil) |
182 within that types field. Also handles anonymous types. | 211 within that types field. Also handles anonymous types. |
183 Optional SCOPE represents a calculated scope in which the | 212 Optional SCOPE represents a calculated scope in which the |
184 types might be found. This can be nil. | 213 types might be found. This can be nil. |
185 If NOMETADEREF, then do not dereference metatypes. This is | 214 If NOMETADEREF, then do not dereference metatypes. This is |
186 used by the analyzer debugger." | 215 used by the analyzer debugger." |
216 (require 'semantic/scope) | |
187 (let ((name nil) | 217 (let ((name nil) |
188 (typetag nil) | 218 (typetag nil) |
189 ) | 219 ) |
190 | 220 |
191 ;; Is it an anonymous type? | 221 ;; Is it an anonymous type? |
255 (semantic-tag-name lasttype)) | 285 (semantic-tag-name lasttype)) |
256 (throw 'metatype-recursion nil)) | 286 (throw 'metatype-recursion nil)) |
257 )) | 287 )) |
258 lasttype)) | 288 lasttype)) |
259 | 289 |
260 (define-overloadable-function semantic-analyze-dereference-metatype (type scope &optional type-declaration) | |
261 ;; todo - move into typecahe!! | |
262 "Return a concrete type tag based on input TYPE tag. | |
263 A concrete type is an actual declaration of a memory description, | |
264 such as a structure, or class. A meta type is an alias, | |
265 or a typedef in C or C++. If TYPE is concrete, it | |
266 is returned. If it is a meta type, it will return the concrete | |
267 type defined by TYPE. | |
268 The default behavior always returns TYPE. | |
269 Override functions need not return a real semantic tag. | |
270 Just a name, or short tag will be ok. It will be expanded here. | |
271 SCOPE is the scope object with additional items in which to search for names." | |
272 (catch 'default-behavior | |
273 (let* ((ans-tuple (:override | |
274 ;; Nothing fancy, just return type by default. | |
275 (throw 'default-behavior (list type type-declaration)))) | |
276 (ans-type (car ans-tuple)) | |
277 (ans-type-declaration (cadr ans-tuple))) | |
278 (list (semantic-analyze-dereference-metatype-1 ans-type scope) ans-type-declaration)))) | |
279 | |
280 ;; @ TODO - the typecache can also return a stack of scope names. | 290 ;; @ TODO - the typecache can also return a stack of scope names. |
281 | 291 |
282 (defun semantic-analyze-dereference-metatype-1 (ans scope) | 292 (defun semantic-analyze-dereference-metatype-1 (ans scope) |
283 "Do extra work after dereferencing a metatype. | 293 "Do extra work after dereferencing a metatype. |
284 ANS is the answer from the the language specific query. | 294 ANS is the answer from the the language specific query. |
285 SCOPE is the current scope." | 295 SCOPE is the current scope." |
296 (require 'semantic/scope) | |
286 ;; If ANS is a string, or if ANS is a short tag, we | 297 ;; If ANS is a string, or if ANS is a short tag, we |
287 ;; need to do some more work to look it up. | 298 ;; need to do some more work to look it up. |
288 (if (stringp ans) | 299 (if (stringp ans) |
289 ;; The metatype is just a string... look it up. | 300 ;; The metatype is just a string... look it up. |
290 (or (and scope (car-safe | 301 (or (and scope (car-safe |