Exemplo n.º 1
0
        override public object Clone()
        {
            CallableTypeReference clone = (CallableTypeReference)FormatterServices.GetUninitializedObject(typeof(CallableTypeReference));

            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 != _parameters)
            {
                clone._parameters = _parameters.Clone() as ParameterDeclarationCollection;
                clone._parameters.InitializeParent(clone);
            }
            if (null != _returnType)
            {
                clone._returnType = _returnType.Clone() as TypeReference;
                clone._returnType.InitializeParent(clone);
            }
            return(clone);
        }
Exemplo n.º 2
0
	    private CallableSignature CallableSignatureFor(CallableTypeReference node)
	    {
	        var parameters = new IParameter[node.Parameters.Count];
	        for (int i=0; i<parameters.Length; ++i)
	            parameters[i] = new InternalParameter(node.Parameters[i], i);
			
	        var returnType = node.ReturnType != null
                   ? GetType(node.ReturnType)
                   : TypeSystemServices.VoidType;

	        return new CallableSignature(parameters, returnType, node.Parameters.HasParamArray);
	    }
Exemplo n.º 3
0
        public override void LeaveCallableTypeReference(CallableTypeReference node)
        {
            IParameter[] parameters = new IParameter[node.Parameters.Count];
            for (int i=0; i<parameters.Length; ++i)
            {
                parameters[i] = new InternalParameter(node.Parameters[i], i);
            }

            IType returnType = null;
            if (null != node.ReturnType)
            {
                returnType = GetType(node.ReturnType);
            }
            else
            {
                returnType = TypeSystemServices.VoidType;
            }

            node.Entity = TypeSystemServices.GetConcreteCallableType(node, new CallableSignature(parameters, returnType));
        }
Exemplo n.º 4
0
	protected CallableTypeReference  callable_type_reference() //throws RecognitionException, TokenStreamException
{
		CallableTypeReference ctr;
		
		IToken  c = null;
		
				ctr = null;
				TypeReference tr = null;
				ParameterDeclarationCollection parameters = null;
			
		
		try {      // for error handling
			c = LT(1);
			match(CALLABLE);
			match(LPAREN);
			if (0==inputState.guessing)
			{
				
						ctr = new CallableTypeReference(ToLexicalInfo(c));
						parameters = ctr.Parameters;
					
			}
			callable_parameter_declaration_list(parameters);
			match(RPAREN);
			{
				if ((LA(1)==AS) && (tokenSet_46_.member(LA(2))))
				{
					match(AS);
					tr=type_reference();
					if (0==inputState.guessing)
					{
						
								ctr.ReturnType = tr; 
								
					}
				}
				else if ((tokenSet_44_.member(LA(1))) && (tokenSet_15_.member(LA(2)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "callable_type_reference");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return ctr;
	}
Exemplo n.º 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());
     }
 }
Exemplo n.º 6
0
 public override void LeaveCallableTypeReference(CallableTypeReference node)
 {
     node.Entity = TypeSystemServices.GetConcreteCallableType(node, CallableSignatureFor(node));
 }
Exemplo n.º 7
0
		public override void OnCallableTypeReference(CallableTypeReference node)
		{
			MakeTypeResult(ConvertType(node));
		}
Exemplo n.º 8
0
		override public object Clone()
		{
		
			CallableTypeReference clone = new CallableTypeReference();
			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 != _parameters)
			{
				clone._parameters = _parameters.Clone() as ParameterDeclarationCollection;
				clone._parameters.InitializeParent(clone);
			}
			if (null != _returnType)
			{
				clone._returnType = _returnType.Clone() as TypeReference;
				clone._returnType.InitializeParent(clone);
			}
			return clone;


		}
Exemplo n.º 9
0
 public override void OnCallableTypeReference(CallableTypeReference node)
 {
     Write("callable(");
     WriteCommaSeparatedList(node.Parameters);
     Write(")");
     WriteTypeReference(node.ReturnType);
 }
Exemplo n.º 10
0
 public TypeReference anonymous_function_type()
 {
     TypeReference reference = null;
     IToken token = null;
     try
     {
         CallableTypeReference reference2;
         ParameterDeclarationCollection declarations;
         token = this.LT(1);
         this.match(0x13);
         if (base.inputState.guessing == 0)
         {
             reference = reference2 = new CallableTypeReference(ToLexicalInfo(token));
             declarations = reference2.get_Parameters();
         }
         this.function_type_parameters(declarations);
         if ((this.LA(1) == 0x42) && ((this.LA(2) == 0x13) || (this.LA(2) == 0x3b)))
         {
             this.match(0x42);
             TypeReference reference3 = this.type_reference();
             if (base.inputState.guessing == 0)
             {
                 reference2.set_ReturnType(reference3);
             }
             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;
 }