Exemplo n.º 1
0
 private void CheckArraySizeType(InstanceCreationExpression node)
 {
     if (node.IsArrayCreation)
     {
         var integerType = _parent._symbolTable.ResolveType(MiniJavaInfo.IntType).Type;
         if (!node.ArraySize.Type.IsAssignableTo(integerType))
         {
             ReportError(ErrorTypes.TypeError, "Array size must be numeric.", node);
         }
     }
 }
Exemplo n.º 2
0
 public override void Visit(InstanceCreationExpression node)
 {
     if (node.IsArrayCreation)
     {
         CheckArraySizeType(node);
     }
 }
Exemplo n.º 3
0
 public override void Visit(InstanceCreationExpression node)
 {
     // Instance creation expressions are checked here instead of
     // the type checking phase because they might create an array
     // of a type not previously used, so this array type needs to
     // be added to the symbol table. This method does not detect
     // errors.
     if (node.CreatedTypeName != MiniJavaInfo.VoidType)
     {
         var scalarTypeSymbol = _globalScope.ResolveType(node.CreatedTypeName);
         if (scalarTypeSymbol != null && node.IsArrayCreation &&
             _globalScope.ResolveArrayType(node.CreatedTypeName) == null)
         {
             DefineArrayType((ScalarType)scalarTypeSymbol.Type);
         }
     }
     HandleExpressionOrStatementNode(node);
 }