Ejemplo n.º 1
0
void ASTFunctionTable::insert(ASTFunction& function)
{
   for ( std::size_t index = 2; index < mFunctions.size(); index++ )
   {
      ASTFunction* pfunction = mFunctions[index];

      if ( pfunction->getName() == function.getName()
        && pfunction->getSignature().exactMatch(function.getSignature()) ) // for now do not allow derived types
      {
         mFunctions[index] = &function;
         return;
      }
   }

   mFunctions.push_back(&function);
}
Ejemplo n.º 2
0
void OOCheckVisitor::visit(ASTFunction& ast)
{
   mpFunction = &ast;

   ScopedScope scope(mScopeStack);

   ast.getArgumentNodes().accept(*this);

   if ( ast.hasAnnotations() )
   {
      if ( ast.getAnnotations().contains(UTEXT("override")) )
      {
         // check if the base class still has this function
      }
   }

   if ( ast.isConstructor() )
   {
      // abstract classes can not have native constructors
      /*
      if ( ast.getModifiers().isNative() && mpClass->getModifiers().isAbstract() )
      {
         mContext.getLog().error("Abstract class " + mpClass->getFullName() + " can not have native constructors.");
      }
      */
   }
   else
   {
      if ( mpClass->hasBaseClass() )
      {
         ASTClass& baseclass = mpClass->getBaseClass();
         ASTFunction* pbasefunc = baseclass.findExactMatch(ast.getName(), ast.getSignature());
         if ( pbasefunc != NULL )
         {
            ast.setBaseFunction(*pbasefunc);
         }
      }
   }

   if ( ast.hasBody() )
   {
      mHasNativeCall = false;

      ast.getBody().accept(*this);

      if ( mHasNativeCall )
      {
         ast.getModifiers().setNative(true);
      }
   }
}