Added container accessor to Castle.Core
[castle.git] / AspectSharp / AspectSharp.Lang / Steps / Semantic / SemanticAnalizerBase.cs
blobf6f3730c73b96f1a99fccf28fcffebe0d99ae75f
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.Collections;
20 using AspectSharp.Lang.AST;
22 /// <summary>
23 /// Summary description for SemanticAnalizerBase.
24 /// TODO: Rewrite using the DepthFirstVisitor
25 /// </summary>
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 );
34 else
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 )
51 if (value == null)
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 );