scope.cpp 566 B

123456789101112131415161718192021222324252627282930313233
  1. #include "std.h"
  2. #include "block.h"
  3. #include "val.h"
  4. //******************** Scope **********************
  5. Scope::~Scope(){
  6. }
  7. Val *Scope::find( string id ){
  8. return 0;
  9. }
  10. Val *Scope::findTypeIdent( string id ){
  11. int i=id.find('.');
  12. if( i==string::npos ){
  13. globalIdent="";
  14. Val *v=find( id );
  15. if( !v ) v=findGlobal( id );
  16. if( v && globalIdent.size() ) id=globalIdent;
  17. return v;
  18. }
  19. Scope *sc=mainFun;
  20. while( (i=id.find('.'))!=string::npos ){
  21. Val *v=sc->find(id.substr(0,i));
  22. if( !v ) return 0;
  23. id=id.substr(i+1);
  24. sc=v;
  25. }
  26. return sc->find(id);
  27. }