1 // -*- c++ -*-
2 // Package : omniidl
3 // idlvalidate.cc Created on: 1999/10/26
4 // Author : Duncan Grisby (dpg1)
5 //
6 // Copyright (C) 2006 Apasphere Ltd
7 // Copyright (C) 1999 AT&T Laboratories Cambridge
8 //
9 // This file is part of omniidl.
10 //
11 // omniidl is free software; you can redistribute it and/or modify it
12 // under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see http://www.gnu.org/licenses/
23 //
24 // Description:
25 //
26 // Visitor object to validate the tree
27
28 #include <idlvalidate.h>
29 #include <idlerr.h>
30 #include <idlast.h>
31 #include <idlconfig.h>
32
33 #include <string.h>
34
35 void
36 AstValidateVisitor::
visitAST(AST * a)37 visitAST(AST* a)
38 {
39 for (Decl* d = a->declarations(); d; d = d->next())
40 d->accept(*this);
41 }
42
43 void
44 AstValidateVisitor::
visitModule(Module * m)45 visitModule(Module* m)
46 {
47 for (Decl* d = m->definitions(); d; d = d->next())
48 d->accept(*this);
49 }
50
51 void
52 AstValidateVisitor::
visitInterface(Interface * i)53 visitInterface(Interface* i)
54 {
55 for (Decl* d = i->contents(); d; d = d->next())
56 d->accept(*this);
57 }
58
59 void
60 AstValidateVisitor::
visitForward(Forward * f)61 visitForward(Forward* f)
62 {
63 if (Config::forwardWarning) {
64 if (f->isFirst() && !f->definition() &&
65 strcmp(f->scopedName()->scopeList()->identifier(), "CORBA")) {
66
67 char* ssn = f->scopedName()->toString();
68 IdlWarning(f->file(), f->line(),
69 "Forward declared interface '%s' was never fully defined",
70 ssn);
71 delete [] ssn;
72 }
73 }
74 }
75
76 void
77 AstValidateVisitor::
visitValueForward(ValueForward * f)78 visitValueForward(ValueForward* f)
79 {
80 if (Config::forwardWarning) {
81 if (f->isFirst() && !f->definition()) {
82 char* ssn = f->scopedName()->toString();
83 IdlWarning(f->file(), f->line(),
84 "Forward declared valuetype '%s' was never fully defined",
85 ssn);
86 delete [] ssn;
87 }
88 }
89 }
90
91 void
92 AstValidateVisitor::
visitStructForward(StructForward * f)93 visitStructForward(StructForward* f)
94 {
95 if (f->isFirst() && !f->definition()) {
96 char* ssn = f->scopedName()->toString();
97 IdlError(f->file(), f->line(),
98 "Forward declared struct '%s' was never fully defined", ssn);
99 delete [] ssn;
100 }
101 }
102
103 void
104 AstValidateVisitor::
visitUnionForward(UnionForward * f)105 visitUnionForward(UnionForward* f)
106 {
107 if (f->isFirst() && !f->definition()) {
108 char* ssn = f->scopedName()->toString();
109 IdlError(f->file(), f->line(),
110 "Forward declared union '%s' was never fully defined", ssn);
111 delete [] ssn;
112 }
113 }
114