Beispiel #1
0
        private string GetTypeOf(TypeAST currentType, TypeAST otherType)
        {
            if (currentType == null)
            {
                return(otherType.ToString());
            }

            return(ComputeType(currentType.ToString(), otherType.ToString()));
        }
Beispiel #2
0
        public override void Visit(ReturnAST returnStatement)
        {
            if (_returnType.ToString() == Enum.GetName(typeof(Keyword), Keyword.VOID).ToLower() &&
                returnStatement.ReturnExpr != null)
            {
                throw new Exception("Return statement must not be followed by expression because the function has no return type");
            }

            var returnExprType = _exprTypeVisitor.GetAstNodeType(_currentFileName,
                                                                 _currentScopeId, _currentNodePosition,
                                                                 returnStatement.ReturnExpr);

            var subsetOfRetType = _returnType.GetType().IsAssignableFrom(returnExprType.GetType());

            if (!IsSameTypeOrNullPtr(_returnType, returnExprType) && !subsetOfRetType)
            {
                throw new Exception(string.Format("Return type must be of type '{0}', found type '{1}'",
                                                  _returnType, returnExprType.ToString()));
            }
        }
Beispiel #3
0
 public override string ToString()
 {
     return(string.Format("[] {0}", TypeOfContainedValues.ToString()));
 }
Beispiel #4
0
 public override string ToString()
 {
     return(string.Concat("^", Type.ToString()));
 }
Beispiel #5
0
 public override string ToString()
 {
     return(string.Format("FunctionPrototype : Name {0}, Args : {1}, Return type : {2}",
                          Name, Args == null ? "()" : string.Join("\n\t", Args),
                          ReturnType == null ? "?" : ReturnType.ToString()));
 }