1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace AspectSharp
.Lang
.Steps
.Semantic
18 using System
.Collections
;
20 using AspectSharp
.Lang
.AST
;
23 /// Summary description for SemanticAnalizerBase.
24 /// TODO: Rewrite using the DepthFirstVisitor
26 public abstract class SemanticAnalizerBase
: AbstractStep
28 protected void AssertUnique(IDictionary values
, NodeBase node
, object value, String message
)
30 if (values
.Contains(value))
32 RaiseErrorEvent( node
.LexicalInfo
, message
);
36 values
.Add(value, String
.Empty
);
40 protected void AssertEntriesAreValid(IDictionary types
)
42 foreach(DictionaryEntry entry
in types
)
44 DefinitionBase type
= entry
.Value
as DefinitionBase
;
45 AssertNotEmpty( type
, entry
.Key
as String
, "A key must be specified to identify the type in the map" );
49 protected void AssertNotNull( NodeBase node
, object value, String message
)
53 RaiseErrorEvent( node
.LexicalInfo
, message
);
57 protected void AssertNotEmpty( NodeBase node
, String
value, String message
)
59 AssertNotNull(node
, value, message
);
60 if (String
.Empty
.Equals(value))
62 RaiseErrorEvent( node
.LexicalInfo
, message
);
66 protected void AssertKeyExists( IDictionary names
, NodeBase node
, object key
, String message
)
68 if (!names
.Contains(key
))
70 RaiseErrorEvent( node
.LexicalInfo
, message
);