本文整理汇总了C#中TrivialHashtable类的典型用法代码示例。如果您正苦于以下问题:C# TrivialHashtable类的具体用法?C# TrivialHashtable怎么用?C# TrivialHashtable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrivialHashtable类属于命名空间,在下文中一共展示了TrivialHashtable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Duplicator
/// <param name="module">The module into which the duplicate IR will be grafted.</param>
/// <param name="type">The type into which the duplicate Member will be grafted. Ignored if entire type, or larger unit is duplicated.</param>
public Duplicator(Module/*!*/ module, TypeNode type) {
this.TargetModule = module;
this.TargetType = this.OriginalTargetType = type;
this.DuplicateFor = new TrivialHashtable();
this.TypesToBeDuplicated = new TrivialHashtable();
//^ base();
}
示例2: GetClosestMatch
public virtual AttributeNode GetClosestMatch(AttributeNode/*!*/ nd1, AttributeList/*!*/ list1, AttributeList list2, int list1pos, ref int list2start,
TrivialHashtable/*!*/ matchedNodes, out Differences closestDifferences, out int list2pos) {
closestDifferences = null; list2pos = -1;
if (list2 == null) return null;
if (nd1 == null || list1 == null || matchedNodes == null || list1pos < 0 || list1pos >= list1.Count || list2start < 0 || list2start >= list2.Count) {
Debug.Assert(false); return null;
}
AttributeNode closest = null;
Differences winnerSoFar = null;
for (int j = list2start, m = list2.Count; j < m; j++){
AttributeNode nd2 = list2[j];
if (list2start == j) list2start++;
if (nd2 == null) continue;
if (matchedNodes[nd2.UniqueKey] != null) continue;
Differences diff = this.GetDifferences(nd1, nd2);
if (diff == null){Debug.Assert(false); continue;}
if (diff.Similarity <= 0.5){
//Not a good enough match
if (list2start == j+1) list2start--; //The next call to GetClosestMatch will start looking at list2start, so this node will be considered then
continue; //ignore it for the rest of this call
}
if (winnerSoFar != null && winnerSoFar.Similarity >= diff.Similarity) continue;
winnerSoFar = closestDifferences = diff;
closest = nd2;
list2pos = j;
if (diff.NumberOfDifferences == 0) return closest; //Perfect match, no need to look for other matches
}
if (closest != null){
//^ assert winnerSoFar != null;
//closest is closer to nd1 than any other node in list2, but this is no good if some other node in list1 has a better claim on closest
for (int i = list1pos+1, n = list1.Count; i < n; i++){
AttributeNode nd1alt = list1[i];
if (nd1alt == null) continue;
if (matchedNodes[nd1alt.UniqueKey] != null) continue;
Differences diff = this.GetDifferences(nd1alt, closest);
if (diff == null){Debug.Assert(false); continue;}
if (diff.Similarity <= winnerSoFar.Similarity) continue;
//nd1alt has a better claim on closest. See if it wants closest.
Differences diff2;
int j, k = list2start;
AttributeNode nd2alt = this.GetClosestMatch(nd1alt, list1, list2, i, ref k, matchedNodes, out diff2, out j);
if (nd2alt != closest){
Debug.Assert(nd2alt != null && diff2 != null && diff2.Similarity >= diff.Similarity);
continue; //nd1alt prefers nd2alt to closest, so closest is still available
}
//nd1alt wants closest, take it out of the running
matchedNodes[closest.UniqueKey] = nd1alt;
//Now that closest is out of the running, try again
k = list2start;
AttributeNode newClosest = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out winnerSoFar, out list2pos);
//put closest back in the running so that the next call to this routine will pick it up
matchedNodes[closest.UniqueKey] = closest;
closest = newClosest;
break;
}
}
closestDifferences = winnerSoFar;
return closest;
}
示例3: VisitBlock
/// <summary>
/// Walks the statement list of the given block gathering information from declarations for use by forward references. Does not recurse into nested blocks.
/// </summary>
/// <param name="block">The block whose declarations are to be processed</param>
/// <param name="scope">Maps identifiers to Metadata nodes (e.g. Fields).</param>
/// <param name="targetFor">Maps labels (Identifiers) to the corresponding labeled blocks (single statements are promoted to blocks for this purpose).</param>
/// <param name="labelList">A list of all the labels encountered by Declarer.</param>
public virtual void VisitBlock(Block block, Class scope, TrivialHashtable targetFor, IdentifierList labelList){
if (block == null) return;
this.scope = scope;
this.targetFor = targetFor;
this.labelList = labelList;
StatementList statements = block.Statements;
if (statements == null) return;
for (int i = 0, n = statements.Count; i < n; i++)
statements[i] = (Statement)this.Visit(statements[i]);
}
示例4: Normalizer
public Normalizer(TypeSystem typeSystem){
this.typeSystem = typeSystem;
this.exitTargets = new StatementList();
this.continueTargets = new StatementList();
this.currentTryStatements = new Stack();
this.exceptionBlockFor = new TrivialHashtable();
this.visitedCompleteTypes = new TrivialHashtable();
this.EndIfLabel = new TrivialHashtable();
this.foreachLength = 7;
this.WrapToBlockExpression = true;
this.useGenerics = TargetPlatform.UseGenerics;
}
示例5: Checker
public Checker(ErrorHandler errorHandler, TypeSystem typeSystem, TrivialHashtable scopeFor, TrivialHashtable ambiguousTypes, TrivialHashtable referencedLabels)
: base(errorHandler) {
this.typeSystem = typeSystem;
this.Errors = errorHandler == null ? null : errorHandler.Errors;
this.scopeFor = scopeFor;
this.ambiguousTypes = ambiguousTypes;
this.referencedLabels = referencedLabels;
this.MayNotReferenceThisFromFieldInitializer = true;
this.allowedExceptions = new TypeNodeList();
this.useGenerics = TargetPlatform.UseGenerics;
this.AllowPropertiesIndexersAsRef = true;
}
示例6: VisitLabeledStatement
public override Statement VisitLabeledStatement(LabeledStatement lStatement){
if (lStatement == null) return null;
this.labelList.Add(lStatement.Label);
lStatement.Scope = this.scope as BlockScope;
if (this.localLabels == null) this.localLabels = new TrivialHashtable();
if (this.localLabels[lStatement.Label.UniqueIdKey] == null){
this.localLabels[lStatement.Label.UniqueIdKey] = lStatement;
this.targetFor[lStatement.Label.UniqueIdKey] = lStatement;
}else
this.HandleError(lStatement.Label, Error.LabelIdentiferAlreadyInUse, lStatement.Label.ToString());
lStatement.Statement = (Statement)this.Visit(lStatement.Statement);
return lStatement;
}
示例7: Looker
public Looker(Scope scope, ErrorHandler errorHandler, TrivialHashtable scopeFor, TypeSystem typeSystem, TrivialHashtable ambiguousTypes, TrivialHashtable referencedLabels)
: base(errorHandler){
//TODO: verify that crucial system types have either been imported or defined by the Parser
this.scope = scope;
this.AddToAllScopes(this.scope);
this.scopeFor = scopeFor;
this.ambiguousTypes = ambiguousTypes;
this.referencedLabels = referencedLabels;
this.alreadyReported = new TrivialHashtable();
this.hasExplicitBaseClass = new TrivialHashtable();
this.typesToKeepUninstantiated = new TrivialHashtable();
this.UsedNamespaces = new UsedNamespaceList();
this.targetFor = new TrivialHashtable();
this.labelList = new IdentifierList();
this.AbstractSealedUsedAsType = Error.NotAType;
Debug.Assert(typeSystem != null);
this.typeSystem = typeSystem;
this.useGenerics = TargetPlatform.UseGenerics;
this.inMethodParameter = false;
this.inEventContext = false;
}
示例8: Translate
/// <summary>
/// Walks the supplied System.CodeDom.CodeCompileUnit and produces a corresponding CompilationUnit.
/// Enters declarations into the supplied Module and errors into the supplied ErrorNodeList.
/// Calls back to the supplied compiler to resolve assembly references and to create appropriate documents for code snippets.
/// </summary>
/// <param name="compiler">Called upon to resolve assembly references and to create Documents for snippets.</param>
/// <param name="compilationUnit">The root of the CodeDOM tree to be translated into an IR CompileUnit.</param>
/// <param name="targetModule">The module or assembly to which the compilation unit will be compiled.</param>
/// <param name="errorNodes">Errors in the CodeDOM tree that are found during translation are added to this list.</param>
/// <returns></returns>
public CompilationUnit Translate(Compiler compiler, CodeCompileUnit compilationUnit, Module targetModule, ErrorNodeList errorNodes){
Debug.Assert(compiler != null);
Debug.Assert(compilationUnit != null);
Debug.Assert(targetModule != null);
Debug.Assert(errorNodes != null);
this.compiler = compiler;
this.errorNodes = errorNodes;
this.targetModule = targetModule;
CodeSnippetCompileUnit cscu = compilationUnit as CodeSnippetCompileUnit;
CompilationUnit cunit = cscu != null ? new CompilationUnitSnippet() : new CompilationUnit();
this.Translate(compilationUnit.AssemblyCustomAttributes, targetModule.Attributes);
StringCollection references = compilationUnit.ReferencedAssemblies;
if (references != null && references.Count > 0){
AssemblyReferenceList arefs = targetModule.AssemblyReferences;
TrivialHashtable alreadyReferencedAssemblies = new TrivialHashtable();
for (int i = 0, n = arefs.Count; i < n; i++)
alreadyReferencedAssemblies[arefs[i].Assembly.UniqueKey] = this;
foreach (string rAssemblyName in references)
compiler.AddAssemblyReferenceToModule(null, targetModule, rAssemblyName, null, errorNodes, alreadyReferencedAssemblies, false);
}
Namespace defaultNamespace = new Namespace(Identifier.Empty, Identifier.Empty, null, null, new NamespaceList(), null);
NamespaceList nspaceList = defaultNamespace.NestedNamespaces;
CodeNamespaceCollection nspaces = compilationUnit.Namespaces;
if (nspaces != null)
foreach (CodeNamespace cns in nspaces)
nspaceList.Add(this.Translate(cns));
if (cscu == null) return cunit;
Document doc = null;
if (cscu.LinePragma == null)
doc = compiler.CreateDocument(targetModule.Name, 1, cscu.Value);
else{
doc = compiler.CreateDocument(cscu.LinePragma.FileName, cscu.LinePragma.LineNumber, cscu.Value);
cunit.Name = Identifier.For(cscu.LinePragma.FileName);
}
cunit.SourceContext = new SourceContext(doc);
defaultNamespace.SourceContext = cunit.SourceContext;
return cunit;
}
示例9: InferMethodTemplateArguments
/// <summary>
/// We pass the argument expression in case we are dealing with an implicit delegate construction
/// </summary>
/// <param name="argExpr">This is the actual argument expression</param>
public virtual bool InferMethodTemplateArguments(TypeNode argType, MemberBinding argExpr, TypeNode parType, TrivialHashtable inferredTypeFor){
if (argType == null || parType == null) return false;
if (inferredTypeFor == null){Debug.Assert(false); return false;}
TypeNode modifiedArgType = argType;
TypeNode modifiedParType = parType;
argType = TypeNode.StripModifiers(argType);
parType = TypeNode.StripModifiers(parType);
if (parType is MethodTypeParameter || parType is MethodClassParameter){
TypeNode prevInference = inferredTypeFor[parType.UniqueKey] as TypeNode;
if (prevInference != null) {
if (!prevInference.IsStructurallyEquivalentTo(modifiedArgType)) {
if (!TypeNode.StripModifiers(prevInference).IsStructurallyEquivalentTo(argType)) return false;
if (!this.typeSystem.ImplicitCoercionFromTo(argType, prevInference)) return false;
}
} else
inferredTypeFor[parType.UniqueKey] = modifiedArgType;
return true;
}
ArrayType pArrT = parType as ArrayType;
ArrayType aArrT = argType as ArrayType;
if (pArrT != null){
if (aArrT == null || aArrT.Rank != pArrT.Rank) return false; //TODO: param arrays
return this.InferMethodTemplateArguments(aArrT.ElementType, null, pArrT.ElementType, inferredTypeFor);
}
Reference pRefT = parType as Reference;
Reference aRefT = argType as Reference;
if (pRefT != null) {
if (aRefT == null) return false;
return this.InferMethodTemplateArguments(aRefT.ElementType, null, pRefT.ElementType, inferredTypeFor);
}
if (parType.IsStructural && argType.IsStructural){
TypeNodeList parElemTypes = parType.StructuralElementTypes;
TypeNodeList argElemTypes = argType.StructuralElementTypes;
int n = parElemTypes == null ? 0 : parElemTypes.Count;
int m = argElemTypes == null ? 0 : argElemTypes.Count;
if (parType.Template != null && argType.Template != null && parType.Template == argType.Template) {
for (int i = 0; i < n; i++) {
TypeNode peType = parElemTypes[i]; if (peType == null) return false;
TypeNode aeType = argElemTypes[i]; if (aeType == null) return false;
if (!this.InferMethodTemplateArguments(aeType, null, peType, inferredTypeFor)) return false;
}
if (parType.DeclaringType == null) return true;
if (argType == parType) return true;
if (argType.DeclaringType != null && parType.DeclaringType != null && this.InferMethodTemplateArguments(argType.DeclaringType, null, parType.DeclaringType, inferredTypeFor)) {
if (argType.Template != null) argType = argType.Template;
if (parType.Template != null) parType = parType.Template;
return argType.Name != null && parType.Name != null && argType.Name.UniqueIdKey == parType.Name.UniqueIdKey;
}
return true;
} else {
for (int i = 0, c = argType.Interfaces == null ? 0 : argType.Interfaces.Count; i < c; i++) {
Interface aintf = argType.Interfaces[i];
if (aintf == null) return false;
if (this.InferMethodTemplateArguments(aintf, null, parType, inferredTypeFor)) return true;
}
Class cl = argType as Class;
if (cl != null)
return this.InferMethodTemplateArguments(cl.BaseClass, null, parType, inferredTypeFor);
}
}
if (argType == parType) return true;
if (argType.DeclaringType != null && parType.DeclaringType != null && this.InferMethodTemplateArguments(argType.DeclaringType, null, parType.DeclaringType, inferredTypeFor))
return argType.Name != null && parType.Name != null && argType.Name.UniqueIdKey == parType.Name.UniqueIdKey;
if (argExpr != null && argType == SystemTypes.Delegate) {
DelegateNode parDelegate = parType as DelegateNode;
Method meth = argExpr.BoundMember as Method;
if (meth != null && parDelegate != null) {
// match up parameters and results
int numArgs1 = meth.Parameters == null ? 0 : meth.Parameters.Count;
int numArgs2 = parDelegate.Parameters == null ? 0 : parDelegate.Parameters.Count;
if (numArgs1 == numArgs2) {
for (int j = 0; j < numArgs1; j++) {
if (!InferMethodTemplateArguments(meth.Parameters[j].Type, null, parDelegate.Parameters[j].Type, inferredTypeFor)) return false;
}
// do result type
return InferMethodTemplateArguments(meth.ReturnType, null, parDelegate.ReturnType, inferredTypeFor);
}
}
}
return this.typeSystem.ImplicitCoercionFromTo(argType, parType);
}
示例10: VisitAttributeNode
public virtual AttributeNode VisitAttributeNode(AttributeNode attribute, Node target) {
if (attribute == null || target == null) return null;
attribute.Constructor = this.VisitAttributeConstructor(attribute, target);
ExpressionList expressions = attribute.Expressions = this.VisitExpressionList(attribute.Expressions);
MemberBinding mb = attribute.Constructor as MemberBinding;
if (mb == null || mb.BoundMember == null) {
Debug.Assert(attribute.Constructor == null);
return null;
}
//Check arguments for validity
TypeNode attributeType = mb.BoundMember.DeclaringType;
if (attributeType == null) return null;
InstanceInitializer ctor = (InstanceInitializer)mb.BoundMember;
ParameterList pars = ctor.Parameters;
ExpressionList positionalArgs = new ExpressionList();
TrivialHashtable alreadySeenNames = new TrivialHashtable();
for (int i = 0, n = expressions == null ? 0 : expressions.Count; i < n; i++) {
Expression e = expressions[i];
this.TypeInVariableContext(e as Literal);
NamedArgument narg = e as NamedArgument;
if (narg == null) { positionalArgs.Add(e); expressions[i] = null; continue; }
if (narg.Name == null) { expressions[i] = null; continue; }
if (alreadySeenNames[narg.Name.UniqueIdKey] != null) {
this.HandleError(narg.Name, Error.DuplicateNamedAttributeArgument, narg.Name.ToString());
expressions[i] = null; continue;
}
alreadySeenNames[narg.Name.UniqueIdKey] = narg.Name;
Member mem = null;
TypeNode aType = attributeType;
while (aType != null) {
MemberList members = this.GetTypeView(aType).GetMembersNamed(narg.Name);
for (int j = 0, m = members == null ? 0 : members.Count; j < m; j++) {
mem = members[j];
if (mem == null) continue;
switch (mem.NodeType) {
case NodeType.Field:
if (!mem.IsPublic) goto error;
Field f = (Field)mem;
if (f.IsInitOnly || f.IsLiteral || f.IsStatic) goto error;
if (!this.IsValidTypeForCustomAttributeParameter(f.Type)) {
this.HandleError(narg, Error.BadNamedAttributeArgumentType, this.GetMemberSignature(f));
this.HandleRelatedError(f);
return null;
}
this.CheckForObsolesence(narg, f);
narg.IsCustomAttributeProperty = false;
e = this.typeSystem.ImplicitCoercion(narg.Value, narg.Type = f.Type, this.TypeViewer);
if (!this.IsValidTypeForCustomAttributeArgument(e, narg.Value)) return null;
if (e is BinaryExpression && e.NodeType == NodeType.Box) {
narg.ValueIsBoxed = true;
e = ((BinaryExpression)e).Operand1;
}
narg.Value = e;
goto doneWithArg;
case NodeType.Property:
if (!mem.IsPublic) goto error;
Property p = (Property)mem;
if (!this.IsValidTypeForCustomAttributeParameter(p.Type)) {
this.HandleError(narg, Error.BadNamedAttributeArgumentType, this.GetMemberSignature(p));
this.HandleRelatedError(p);
return null;
}
if (p.Setter == null || p.Getter == null || p.IsStatic || !p.Setter.IsPublic || !p.Getter.IsPublic) goto error;
this.CheckForObsolesence(narg, p);
narg.IsCustomAttributeProperty = true;
e = this.typeSystem.ImplicitCoercion(narg.Value, narg.Type = p.Type, this.TypeViewer);
if (!this.IsValidTypeForCustomAttributeArgument(e, narg.Value)) return null;
if (e is BinaryExpression && e.NodeType == NodeType.Box) {
narg.ValueIsBoxed = true;
e = ((BinaryExpression)e).Operand1;
}
narg.Value = e;
goto doneWithArg;
}
}
aType = aType.BaseType;
}
error:
if (mem != null) {
this.HandleError(narg, Error.BadNamedAttributeArgument, narg.Name.ToString());
this.HandleRelatedError(mem);
} else
this.HandleError(narg, Error.NoSuchMember, this.GetTypeName(attributeType), narg.Name.ToString());
doneWithArg: ;
}
ExpressionList exprs = positionalArgs.Clone();
this.CoerceArguments(pars, ref positionalArgs, true, ctor.CallingConvention);
attribute.Expressions = positionalArgs;
for (int i = 0, n = positionalArgs == null ? 0 : positionalArgs.Count; i < n; i++) {
Expression e = positionalArgs[i];
if (e == null) continue;
if (!this.IsValidTypeForCustomAttributeArgument(e, exprs[i])) return null;
if (e is BinaryExpression && e.NodeType == NodeType.Box) e = ((BinaryExpression)e).Operand1;
positionalArgs[i] = e;
}
for (int i = 0, n = expressions == null ? 0 : expressions.Count; i < n; i++) {
Expression e = expressions[i];
if (e == null) continue;
positionalArgs.Add(e);
}
//.........这里部分代码省略.........
示例11: VisitTypeNode
public override TypeNode VisitTypeNode(TypeNode typeNode) {
if (typeNode == null) return null;
TypeNode savedCurrentType = this.currentType;
if (typeNode.IsNormalized) {
this.currentType = this.typeSystem.currentType = typeNode;
this.VisitMemberList(typeNode.Members);
this.currentType = this.typeSystem.currentType = savedCurrentType;
return typeNode;
}
if (typeNode.Template == this.currentType && typeNode.IsNotFullySpecialized) return typeNode;
if (typeNode.PartiallyDefines != null) {
if (this.visitedCompleteTypes == null) this.visitedCompleteTypes = new TrivialHashtable();
if (this.visitedCompleteTypes[typeNode.PartiallyDefines.UniqueKey] == null) {
this.VisitTypeNode(typeNode.PartiallyDefines);
this.visitedCompleteTypes[typeNode.PartiallyDefines.UniqueKey] = typeNode;
}
return typeNode;
}
typeNode.Attributes = this.VisitAttributeList(typeNode.Attributes);
//Flatten interface list
InterfaceList interfaces = this.GetTypeView(typeNode).Interfaces;
for (int i = 0, n = interfaces == null ? 0 : interfaces.Count; i < n; i++) {
Interface iface = interfaces[i];
if (iface == null || iface is TypeParameter) continue;
if (this.GetTypeView(iface).IsAssignableTo(typeNode)) {
this.HandleError(typeNode.Name, Error.CycleInInterfaceInheritance, this.GetTypeName(iface), this.GetTypeName(typeNode));
if (iface != typeNode) this.HandleRelatedError(iface);
for (int j = i; j < n-1; j++)
interfaces[j] = interfaces[j+1];
interfaces.Count = n-1;
continue;
}
if (typeNode.NodeType == NodeType.Interface) {
if (this.IsLessAccessible(iface, typeNode)) {
this.HandleError(typeNode.Name, Error.BaseInterfaceLessAccessible, this.GetTypeName(iface), this.GetTypeName(typeNode));
this.HandleRelatedError(iface);
}
}
InterfaceList inheritedInterfaces = this.GetTypeView(iface).Interfaces;
int m = inheritedInterfaces == null ? 0 : inheritedInterfaces.Count;
for (int j = 0; j < m; j++) {
Interface iiface = inheritedInterfaces[j];
if (iiface == null) continue;
bool mustAddInterface = true;
for (int k = 0; k < n; k++) {
if (interfaces[k] == iiface) {
mustAddInterface = false;
break;
}
}
if (mustAddInterface) {
interfaces.Add(iiface);
n++;
}
}
}
typeNode.Attributes = this.VisitAttributeList(typeNode.Attributes, typeNode);
this.currentType = this.typeSystem.currentType = typeNode;
this.CheckHidingAndOverriding(typeNode);
#region Deal with modelfields that are inherited from implemented interfaces.
if (typeNode is Class) {
StringCollection implementedModelfields = new StringCollection(); //contains the names of modelfields implemented so far
foreach (Interface implInterface in typeNode.Interfaces) {
if (implInterface == null) continue; //Why is Interfaces initialized to a List with a single null element? Means this check is essential.
if (implInterface.Contract != null)
{
foreach (ModelfieldContract mfCToImplement in implInterface.Contract.ModelfieldContracts)
{
#region implement mfCToImplement in typeNode
String fieldnameToImplement = mfCToImplement.Modelfield.Name.Name;
if (implementedModelfields.Contains(fieldnameToImplement))
{
this.HandleError(typeNode, Error.GenericError, "Class " + typeNode.Name.Name + " cannot implement two interfaces that both define a model field " + fieldnameToImplement);
continue; //ignore this contract
//Disallowed to prevent the unexpected modification of a modelfield in one interface by changing a modelfield in another interface.
}
else
{
implementedModelfields.Add(fieldnameToImplement);
ModelfieldContract mfCThatImplements = null; //represents the contract that will implement mfCToImplement
Member implementingMember = null;
#region if typeNode or a superclass already defines a member named fieldNameToImplement, store it in implementingMember.
for (TypeNode classWithField = typeNode; classWithField != null && implementingMember == null; classWithField = classWithField.BaseType)
{
MemberList members = this.GetTypeView(classWithField).GetMembersNamed(mfCToImplement.Modelfield.Name);
foreach (Member m in members)
{
if (m.Name.Name == fieldnameToImplement)
{
implementingMember = m;
break; //implementing member found; stop looking
}
}
}
#endregion
#region if there is an implentingMember: if it is a modelfield in typeNode, then store its contract in mfCThatImplements, else complain
if (implementingMember != null && implementingMember.DeclaringType != typeNode)
{
this.HandleError(typeNode, Error.GenericError, "Class " + typeNode.Name.Name + " does not define a model field " + fieldnameToImplement + " that implements " + mfCToImplement.Modelfield.FullName + " and hides " + implementingMember.FullName);
this.HandleRelatedError(mfCToImplement.Modelfield);
//.........这里部分代码省略.........
示例12: VisitProperty
public override Property VisitProperty(Property property) {
property = base.VisitProperty(property);
if (property == null) return null;
property.Attributes = this.VisitAttributeList(property.Attributes, property);
if (property.Name != null && property.Name.UniqueIdKey == StandardIds.Item.UniqueIdKey &&
property.Parameters != null && property.Parameters.Count > 0) {
if (this.indexerNames == null) this.indexerNames = new TrivialHashtable();
Identifier previousName = (Identifier)this.indexerNames[this.currentType.UniqueKey];
if (previousName == null)
this.indexerNames[this.currentType.UniqueKey] = StandardIds.Item;
else if (previousName.UniqueIdKey != property.Name.UniqueIdKey) {
this.HandleError(property.Name, Error.InconsistantIndexerNames);
Identifier id = new Identifier(previousName.ToString());
id.SourceContext = property.Name.SourceContext;
property.Name = id;
}
}
if (property.Type == SystemTypes.Void)
this.HandleError(property.Name, Error.PropertyCantHaveVoidType, this.GetMemberSignature(property));
else if (this.IsLessAccessible(property.Type, property)) {
Error e = Error.PropertyTypeLessAccessibleThanProperty;
if (property.Parameters != null && property.Parameters.Count > 0)
e = Error.PropertyTypeLessAccessibleThanIndexedProperty;
this.HandleError(property.Name, e, this.GetTypeName(property.Type), this.GetMemberSignature(property));
this.HandleRelatedError(property.Type);
}
this.CheckParameterTypeAccessibility(property.Parameters, property);
if (property.Getter == null && property.Setter == null) {
this.HandleError(property.Name, Error.PropertyWithNoAccessors, this.GetMemberSignature(property));
return null;
}
TypeNodeList implementedTypes = property.ImplementedTypes;
for (int i = 0, n = implementedTypes == null ? 0 : implementedTypes.Count; i < n; i++) {
TypeNode t = implementedTypes[i];
if (t == null) continue;
MemberList tmems = this.GetTypeView(t).GetMembersNamed(property.Name);
Property p = null;
for (int j = 0, m = tmems == null ? 0 : tmems.Count; j < m; j++) {
p = tmems[j] as Property;
if (p == null) continue;
if (p.Type != property.Type) { p = null; continue; }
if (!p.ParametersMatch(property.Parameters)) { p = null; continue; }
break;
}
if (p == null) {
this.HandleError(property.Name, Error.InterfaceMemberNotFound, this.GetMemberSignature(property), this.GetTypeName(t));
this.HandleRelatedError(t);
} else {
if (p.Getter == null) {
if (property.Getter != null) {
this.HandleError(property.Getter.Name, Error.ExplicitPropertyAddingAccessor, this.GetMethodSignature(property.Getter), this.GetMemberSignature(p));
this.HandleRelatedError(p);
}
} else {
if (property.Getter == null) {
this.HandleError(property.Name, Error.ExplicitPropertyMissingAccessor, this.GetMemberSignature(property), this.GetMethodSignature(p.Getter));
this.HandleRelatedError(p.Getter);
}
}
if (p.Setter == null) {
if (property.Setter != null) {
this.HandleError(property.Setter.Name, Error.ExplicitPropertyAddingAccessor, this.GetMethodSignature(property.Setter), this.GetMemberSignature(p));
this.HandleRelatedError(p);
}
} else {
if (property.Setter == null) {
this.HandleError(property.Name, Error.ExplicitPropertyMissingAccessor, this.GetMemberSignature(property), this.GetMethodSignature(p.Setter));
this.HandleRelatedError(p.Setter);
}
}
}
}
return property;
}
示例13: VisitAttributeList
public virtual AttributeList VisitAttributeList(AttributeList attributes, Node target) {
if (attributes == null) return null;
TypeNode targetType = target as TypeNode;
TrivialHashtable alreadyPresent = null;
for (int i = 0, n = attributes.Count; i < n; i++) {
AttributeNode attr = attributes[i];
if (attr == null) continue;
if (!attr.AllowMultiple) {
TypeNode attrType = attr.Type;
if (attrType == null) continue;
if (alreadyPresent == null)
alreadyPresent = new TrivialHashtable();
else if (alreadyPresent[attrType.UniqueKey] != null) {
if (attr.Constructor.SourceContext.Document != null) {
Error e = Error.None;
AttributeTargets attrTarget = attr.Target;
for (int j = 0; j < i; j++) {
AttributeNode a = attributes[j];
if (a == null) a = alreadyPresent[attrType.UniqueKey] as AttributeNode;
if (a == null) continue;
if (a.Type == attr.Type && a.Target == attrTarget) {
e = Error.DuplicateAttribute;
break;
}
}
if (e != Error.None)
this.HandleError(attr.Constructor, e, attr.Constructor.SourceContext.SourceText);
}
attributes[i] = null;
continue;
}
alreadyPresent[attrType.UniqueKey] = attr;
}
attributes[i] = this.VisitAttributeNode(attributes[i], target);
}
return attributes;
}
示例14: MemberReferenceFinder
public MemberReferenceFinder(TrivialHashtable membersToFind, bool omitMethodBodies){
if (membersToFind == null){Debug.Assert(false); membersToFind = new TrivialHashtable();}
this.MembersToFind = membersToFind;
this.AllReferencesAreConfinedToMethodBodies = true;
this.insideMethodBody = false;
this.omitMethodBodies = omitMethodBodies;
}
示例15: VisitNamespace
public override Namespace VisitNamespace(Namespace nspace) {
nspace = base.VisitNamespace(nspace);
if (nspace == null) return null;
TypeNodeList types = nspace.Types;
UsedNamespaceList usedNspaces = nspace.UsedNamespaces;
if (usedNspaces != null) {
TrivialHashtable alreadyUsedNamespaces = new TrivialHashtable();
for (int i = 0, n = usedNspaces.Count; i < n; i++) {
UsedNamespace uns = usedNspaces[i];
if (uns == null || uns.Namespace == null) continue;
if (alreadyUsedNamespaces[uns.Namespace.UniqueIdKey] != null)
this.HandleError(uns.Namespace, Error.DuplicateUsedNamespace, uns.Namespace.ToString());
alreadyUsedNamespaces[uns.Namespace.UniqueIdKey] = uns;
this.VisitUsedNamespace(usedNspaces[i]);
}
}
AliasDefinitionList aliasDefinitions = nspace.AliasDefinitions;
if (aliasDefinitions != null) {
TrivialHashtable alreadyUsedAliases = new TrivialHashtable();
for (int i = 0, n = aliasDefinitions == null ? 0 : aliasDefinitions.Count; i < n; i++) {
AliasDefinition aliasDef = aliasDefinitions[i];
if (aliasDef == null) continue;
AliasDefinition dup = (AliasDefinition)alreadyUsedAliases[aliasDef.Alias.UniqueIdKey];
if (dup == null)
alreadyUsedAliases[aliasDef.Alias.UniqueIdKey] = aliasDef;
else {
this.HandleError(aliasDef.Alias, Error.DuplicateAliasDefinition, nspace.Name.ToString(), aliasDef.Alias.ToString());
this.HandleError(dup.Alias, Error.RelatedErrorLocation);
continue;
}
if (aliasDef.ConflictingType != null) {
string nsName = nspace.Name == null || nspace.Name == Identifier.Empty ? "<global namespace>" : nspace.Name.ToString();
this.HandleError(aliasDef.Alias, Error.ConflictBetweenAliasAndType, nsName, aliasDef.Alias.ToString());
this.HandleRelatedError(aliasDef.ConflictingType);
}
}
}
return nspace;
}