public void ResolveArgAndBounds(MmdGenericTypeVarScope genericTypeVarScope) { if (IsAssignment()) { MmdGenericTypeVar gtv = genericTypeVarScope.Get(arg); if (gtv != null) { gtv.ResolveArgAndBounds(genericTypeVarScope); if (gtv.IsAssignment()) { arg = gtv.arg; } else if (gtv.IsBound()) { arg = null; extendsAttribute = gtv.extendsAttribute; // superAttribute = gtv.superAttribute; } } } else if (IsBound()) { MmdGenericTypeVar extendsGtv = genericTypeVarScope.Get(extendsAttribute); if (extendsGtv != null) { extendsGtv.ResolveArgAndBounds(genericTypeVarScope); extendsAttribute = extendsGtv.arg != null ? extendsGtv.arg : extendsGtv.extendsAttribute; } // TODO superAttribute } else { throw new MetaMetadataException( "wrong meta-metadata generic type var type! must either be an assignment or a bound."); } }
public MetaMetadata ResolveMmdName(String mmdName, NameType[] nameType) { if (mmdName == null) { return(null); } Object resultObj = null; MetaMetadata result = null; MetaMetadataField field = mmStack.Peek(); if (nameType != null && nameType.Length > 0) { nameType[0] = NameType.NONE; } // step 1: try to resolve the name as a concrete meta-metadata name, using the mmdScope. if (field is MetaMetadataNestedField) { MetaMetadataNestedField nested = (MetaMetadataNestedField)field; nested.Scope.TryGetValue(mmdName, out resultObj); result = (MetaMetadata)resultObj; if (result != null) { if (nameType != null && nameType.Length > 0) { nameType[0] = NameType.MMD; } } } // step 2: if step 1 failed, try to use it as a generic type var name if (result == null && mmdName.ToUpper().Equals(mmdName)) { List <Object> gtvScopes = scopeStack.Peek().GetAll(GENERIC_TYPE_VAR_SCOPE); foreach (MmdGenericTypeVarScope gtvScope_object in gtvScopes) { if (!(gtvScope_object is MmdGenericTypeVarScope)) { throw new MetaMetadataException("Object is not instance of MmdGenericTypeVarScope"); } MmdGenericTypeVarScope gtvScope = gtvScope_object; MmdGenericTypeVar gtv = gtvScope.Get(mmdName); if (gtv != null) { if (gtv.Arg != null) { result = ResolveMmdName(gtv.Arg); } else if (gtv.ExtendsAttribute != null) { result = ResolveMmdName(gtv.ExtendsAttribute); } // TODO superAttribute? } } if (result != null) { if (nameType != null && nameType.Length > 0) { nameType[0] = NameType.GENERIC; } } } return(result); }