Esempio n. 1
0
void DSubUD::ResolveLabel( ProgNodeP p)
{
    if( p == NULL) return;

// if( p->getNextSibling() != NULL)
// 	std::cout << "Resolve("<< p->getLine()<<"): " << p << " keepRight: " << p->KeepRight()<< ": "<< p->getText() <<"  r: "<< p->GetNextSibling()->getText() << std::endl;
// else
// 	std::cout << "Resolve("<< p->getLine()<<"): " << p << " keepRight: " << p->KeepRight()<< ": "<< p->getText() <<"  r: NULL"<< std::endl;

    if( p->getType() == GDLTreeParser::ON_IOERROR ||
            p->getType() == GDLTreeParser::GOTO)
    {
        int ix = labelList.Find( p->getText());
        if( ix == -1)
            throw GDLException( p, ObjectName()+": Undefined label "+p->getText()+
                                " referenced in GOTO statement.",false,false);

        p->SetGotoIx( ix);
    }
    else if( p->getType() == GDLTreeParser::LABEL)
    {
        labelList.SetLabelNode( p);
    }

    if( !p->KeepDown())
        ResolveLabel( p->getFirstChild());
    if( !p->KeepRight())
        ResolveLabel( p->getNextSibling());
//   else
// 	ResolveLabel( p->getNextSibling());
}
int GDLInterpreter::GetProIx( ProgNodeP f)
{
  string subName = f->getText();
  int proIx=ProIx(subName);
  if( proIx == -1)
    {
      // trigger reading/compiling of source file
      /*bool found=*/ SearchCompilePro(subName, true);
	  
      proIx=ProIx(subName);
      if( proIx == -1)
	{
	  throw GDLException(f,"Procedure not found: "+subName,true,false);
	}
    }
  return proIx;
}
int GDLInterpreter::GetFunIx( ProgNodeP f)
{
  string subName = f->getText();
  int funIx=FunIx(subName);
  if( funIx == -1)
    {
      // trigger reading/compiling of source file
      /*bool found=*/ SearchCompilePro(subName, false);
            
      funIx=FunIx(subName);
      if( funIx == -1)
	{
	  throw GDLException(f, "Function not found: "+subName, true, false);
	}
    }
  return funIx;
}