Пример #1
0
        override public object Clone()
        {
            ArrayTypeReference clone = new ArrayTypeReference();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._isPointer = _isPointer;
            if (null != _elementType)
            {
                clone._elementType = _elementType.Clone() as TypeReference;
                clone._elementType.InitializeParent(clone);
            }
            if (null != _rank)
            {
                clone._rank = _rank.Clone() as IntegerLiteralExpression;
                clone._rank.InitializeParent(clone);
            }
            return(clone);
        }
Пример #2
0
 B.TypeReference ConvertTypeReference(TypeReference t)
 {
     if (t == null || t.IsNull)
     {
         return(null);
     }
     B.TypeReference r;
     if (t.GenericTypes.Count > 0)
     {
         r = new B.GenericTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type));
         foreach (TypeReference ta in t.GenericTypes)
         {
             ((B.GenericTypeReference)r).GenericArguments.Add(ConvertTypeReference(ta));
         }
     }
     else
     {
         r = new B.SimpleTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type));
     }
     if (t.IsArrayType)
     {
         for (int i = t.RankSpecifier.Length - 1; i >= 0; --i)
         {
             r = new B.ArrayTypeReference(GetLexicalInfo(t), r, new B.IntegerLiteralExpression(t.RankSpecifier[i] + 1));
         }
     }
     if (t.PointerNestingLevel != 0)
     {
         AddError(t, "Pointers are not supported by boo.");
     }
     return(r);
 }
Пример #3
0
	protected ArrayTypeReference  array_type_reference() //throws RecognitionException, TokenStreamException
{
		ArrayTypeReference atr;
		
		IToken  lparen = null;
		IToken  rparen = null;
		
				TypeReference tr = null;
				atr = null;
				IntegerLiteralExpression rank = null;
			
		
		try {      // for error handling
			lparen = LT(1);
			match(LPAREN);
			if (0==inputState.guessing)
			{
				
						atr = new ArrayTypeReference(ToLexicalInfo(lparen));
					
			}
			{
				tr=type_reference();
				if (0==inputState.guessing)
				{
					atr.ElementType = tr;
				}
				{
					switch ( LA(1) )
					{
					case COMMA:
					{
						match(COMMA);
						rank=integer_literal();
						if (0==inputState.guessing)
						{
							atr.Rank = rank;
						}
						break;
					}
					case RPAREN:
					{
						break;
					}
					default:
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					 }
				}
			}
			rparen = LT(1);
			match(RPAREN);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "array_type_reference");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return atr;
	}
Пример #4
0
 public override void OnArrayTypeReference(ArrayTypeReference node)
 {
 }
Пример #5
0
 public static IReturnType CreateReturnType(AST.TypeReference reference, IClass callingClass,
                                            IMethodOrProperty callingMember, int caretLine, int caretColumn,
                                            IProjectContent projectContent)
 {
     System.Diagnostics.Debug.Assert(projectContent != null);
     if (reference == null)
     {
         return(GetDefaultReturnType(projectContent));
     }
     if (reference is AST.ArrayTypeReference)
     {
         AST.ArrayTypeReference arr = (AST.ArrayTypeReference)reference;
         return(new ArrayReturnType(projectContent,
                                    CreateReturnType(arr.ElementType, callingClass, callingMember,
                                                     caretLine, caretColumn, projectContent),
                                    (arr.Rank != null) ? (int)arr.Rank.Value : 1));
     }
     else if (reference is AST.SimpleTypeReference)
     {
         string      name = ((AST.SimpleTypeReference)reference).Name;
         IReturnType rt;
         int         typeParameterCount = (reference is AST.GenericTypeReference) ? ((AST.GenericTypeReference)reference).GenericArguments.Count : 0;
         if (name == "duck")
         {
             rt = new BooResolver.DuckClass(new DefaultCompilationUnit(projectContent)).DefaultReturnType;
         }
         else if (BooAmbience.ReverseTypeConversionTable.ContainsKey(name))
         {
             rt = new GetClassReturnType(projectContent, BooAmbience.ReverseTypeConversionTable[name], typeParameterCount);
         }
         else if (callingClass == null)
         {
             rt = new GetClassReturnType(projectContent, name, typeParameterCount);
         }
         else
         {
             rt = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn,
                                            name, typeParameterCount);
         }
         if (typeParameterCount > 0)
         {
             AST.TypeReferenceCollection arguments = ((AST.GenericTypeReference)reference).GenericArguments;
             // GenericTypeReference derives from SimpleTypeReference
             IReturnType[] typeArguments = new IReturnType[arguments.Count];
             for (int i = 0; i < typeArguments.Length; i++)
             {
                 typeArguments[i] = CreateReturnType(arguments[i], callingClass, callingMember, caretLine, caretColumn,
                                                     projectContent);
             }
             rt = new ConstructedReturnType(rt, typeArguments);
         }
         return(rt);
     }
     else if (reference is AST.CallableTypeReference)
     {
         AST.CallableTypeReference ctr  = (AST.CallableTypeReference)reference;
         AnonymousMethodReturnType amrt = new AnonymousMethodReturnType(new DefaultCompilationUnit(projectContent));
         if (ctr.ReturnType != null)
         {
             amrt.MethodReturnType = CreateReturnType(ctr.ReturnType, callingClass, callingMember, caretLine, caretColumn, projectContent);
         }
         amrt.MethodParameters = new List <IParameter>();
         AddParameters(ctr.Parameters, amrt.MethodParameters, callingMember, callingClass ?? new DefaultClass(new DefaultCompilationUnit(projectContent), "__Dummy"));
         return(amrt);
     }
     else
     {
         throw new NotSupportedException("unknown reference type: " + reference.ToString());
     }
 }
Пример #6
0
 public override void OnArrayTypeReference(ArrayTypeReference node)
 {
     NameResolutionService.ResolveArrayTypeReference(node);
 }
Пример #7
0
		override public object Clone()
		{
		
			ArrayTypeReference clone = new ArrayTypeReference();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._isPointer = _isPointer;
			if (null != _elementType)
			{
				clone._elementType = _elementType.Clone() as TypeReference;
				clone._elementType.InitializeParent(clone);
			}
			if (null != _rank)
			{
				clone._rank = _rank.Clone() as IntegerLiteralExpression;
				clone._rank.InitializeParent(clone);
			}
			return clone;


		}
Пример #8
0
		B.TypeReference ConvertTypeReference(TypeReference t)
		{
			if (t == null || t.IsNull)
				return null;
			B.TypeReference r;
			if (t.GenericTypes.Count > 0) {
				r = new B.GenericTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type));
				foreach (TypeReference ta in t.GenericTypes) {
					((B.GenericTypeReference)r).GenericArguments.Add(ConvertTypeReference(ta));
				}
			} else {
				r = new B.SimpleTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type));
			}
			if (t.IsArrayType) {
				for (int i = t.RankSpecifier.Length - 1; i >= 0; --i) {
					r = new B.ArrayTypeReference(GetLexicalInfo(t), r, new B.IntegerLiteralExpression(t.RankSpecifier[i] + 1));
				}
			}
			if (t.PointerNestingLevel != 0) {
				AddError(t, "Pointers are not supported by boo.");
			}
			return r;
		}
 public override bool Replace(Node existing, Node newNode)
 {
     if (base.Replace(existing, newNode))
     {
         return true;
     }
     if (_items != null)
     {
         Expression item = existing as Expression;
         if (null != item)
         {
             Expression newItem = (Expression)newNode;
             if (_items.Replace(item, newItem))
             {
                 return true;
             }
         }
     }
     if (_type == existing)
     {
         this.Type = (ArrayTypeReference)newNode;
         return true;
     }
     return false;
 }
Пример #10
0
 public override void OnArrayTypeReference(ArrayTypeReference t)
 {
     Write("(");
     Visit(t.ElementType);
     if (null != t.Rank && t.Rank.Value > 1)
     {
         Write(", ");
         t.Rank.Accept(this);
     }
     Write(")");
 }
 public override string ArrayTypeReferenceTypeName(ArrayTypeReference arrayReference)
 {
     return arrayReference.get_ElementType().ToString();
 }
Пример #12
0
        public TypeReference CreateTypeReference(IType tag)
        {
            TypeReference typeReference = null;

            if (tag.IsArray)
            {
                IArrayType arrayType = (IArrayType) tag;
                IType elementType = arrayType.ElementType;
                //typeReference = new ArrayTypeReference();
                //((ArrayTypeReference)typeReference).ElementType = CreateTypeReference(elementType);
                // FIXME: This is what it *should* be, but it causes major breakage. ??
                typeReference = new ArrayTypeReference(CreateTypeReference(elementType), CreateIntegerLiteral(arrayType.Rank));
            }
            else
            {
                typeReference = new SimpleTypeReference(tag.FullName);
            }

            typeReference.Entity = tag;
            return typeReference;
        }
Пример #13
0
        public TypeReference type_reference()
        {
            TypeReference reference = null;
            IToken token = null;
            int num = 1;
            try
            {
                switch (this.LA(1))
                {
                    case 0x3b:
                        reference = this.simple_type_reference();
                        break;

                    case 0x13:
                        reference = this.anonymous_function_type();
                        break;

                    default:
                        throw new NoViableAltException(this.LT(1), this.getFilename());
                }
                if ((this.LA(1) == 0x44) && ((this.LA(2) == 0x43) || (this.LA(2) == 0x45)))
                {
                    token = this.LT(1);
                    this.match(0x44);
                    while (this.LA(1) == 0x43)
                    {
                        this.match(0x43);
                        if (base.inputState.guessing == 0)
                        {
                            num++;
                        }
                    }
                    this.match(0x45);
                    if (base.inputState.guessing == 0)
                    {
                        reference = new ArrayTypeReference(reference.get_LexicalInfo(), reference, new IntegerLiteralExpression(ToLexicalInfo(token), (long) num));
                    }
                    return reference;
                }
                if (!tokenSet_35_.member(this.LA(1)) || !tokenSet_25_.member(this.LA(2)))
                {
                    throw new NoViableAltException(this.LT(1), this.getFilename());
                }
                return reference;
            }
            catch (RecognitionException exception)
            {
                if (base.inputState.guessing != 0)
                {
                    throw;
                }
                this.reportError(exception);
                this.recover(exception, tokenSet_35_);
                return reference;
            }
            return reference;
        }
Пример #14
0
        public void ResolveArrayTypeReference(ArrayTypeReference node)
        {
            if (null != node.Entity) return;

            ResolveTypeReference(node.ElementType);

            IType elementType = TypeSystemServices.GetType(node.ElementType);
            if (TypeSystemServices.IsError(elementType))
            {
                node.Entity = TypeSystemServices.ErrorEntity;
            }
            else
            {
                int rank = null == node.Rank ? 1 : (int)node.Rank.Value;
                node.Entity = _context.TypeSystemServices.GetArrayType(elementType, rank);
            }
        }