idlscope.cc

来自「编译工具」· CC 代码 · 共 1,370 行 · 第 1/3 页

CC
1,370
字号
	break;      }    case Entry::E_DECL:      {	IdlError(file, line,		 "Declaration of module '%s' clashes with declaration "		 "of %s '%s'", identifier, clash->decl()->kindAsString(),		 clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_CALLABLE:    case Entry::E_INHERITED:    case Entry::E_INSTANCE:    case Entry::E_USE:      {	assert(0); // Should never reach here      }    case Entry::E_PARENT:      {	IdlError(file, line,		 "Declaration of module '%s' clashes with name of "		 "enclosing module '%s'", identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "(module '%s' declared here)", clash->identifier());	break;      }    }  }  Entry* e = new Entry(this, Entry::E_MODULE, identifier, scope,		       decl, 0, 0, file, line);  appendEntry(e);}voidScope::addDecl(const char* identifier, Scope* scope, Decl* decl, IdlType* idltype,	const char* file, int line){  if (*identifier == '_')    ++identifier;  else    keywordClash(identifier, file, line);  Entry* clash = iFind(identifier);  if (clash) {    switch (clash->kind()) {    case Entry::E_MODULE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with declaration "		 "of module '%s'", decl->kindAsString(),		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "(module '%s' declared here)", clash->identifier());	break;      }    case Entry::E_DECL:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with earlier declaration "		 "of %s '%s'", decl->kindAsString(), identifier,		 clash->decl()->kindAsString(), clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_CALLABLE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with %s '%s'",		 decl->kindAsString(), identifier,		 clash->decl()->kindAsString(), clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_INHERITED:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with inherited %s '%s'",		 decl->kindAsString(), identifier,		 clash->decl()->kindAsString(), clash->identifier());	char* inhfrom =	  clash->inh_from()->container()->scopedName()->toString();	IdlErrorCont(clash->inh_from()->file(), clash->inh_from()->line(),		     "('%s' declared in %s here)",		     clash->identifier(), inhfrom);	delete [] inhfrom;	break;      }    case Entry::E_INSTANCE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with instance '%s'",		 decl->kindAsString(), identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "('%s' declared here)", clash->identifier());	break;      }    case Entry::E_USE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with use of "		 "identifier '%s'", decl->kindAsString(),		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "('%s' used here)", clash->identifier());	break;      }    case Entry::E_PARENT:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with name of "		 "enclosing scope '%s'", decl->kindAsString(),		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "('%s' declared here)",		     clash->identifier());	break;      }    }  }  Entry* e = new Entry(this, Entry::E_DECL, identifier, scope,		       decl, idltype, 0, file, line);  appendEntry(e);}voidScope::addCallable(const char* identifier, Scope* scope, Decl* decl,	    const char* file, int line){  if (*identifier == '_')    ++identifier;  else    keywordClash(identifier, file, line);  Entry* clash = iFind(identifier);  if (clash) {    switch (clash->kind()) {    case Entry::E_MODULE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with declaration "		 "of module '%s'", decl->kindAsString(),		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "(module '%s' declared here)", clash->identifier());	break;      }    case Entry::E_DECL:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with earlier declaration "		 "of %s '%s'", decl->kindAsString(), identifier,		 clash->decl()->kindAsString(), clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_CALLABLE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with %s '%s'",		 decl->kindAsString(), identifier,		 clash->decl()->kindAsString(), clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_INHERITED:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with inherited %s '%s'",		 decl->kindAsString(), identifier,		 clash->decl()->kindAsString(), clash->identifier());	char* inhfrom =	  clash->inh_from()->container()->scopedName()->toString();	IdlErrorCont(clash->inh_from()->file(), clash->inh_from()->line(),		     "('%s' declared in %s here)",		     clash->identifier(), inhfrom);	delete [] inhfrom;	break;      }    case Entry::E_INSTANCE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with instance '%s'",		 decl->kindAsString(), identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "('%s' declared here)", clash->identifier());	break;      }    case Entry::E_USE:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with use of "		 "identifier '%s'", decl->kindAsString(),		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "('%s' used here)", clash->identifier());	break;      }    case Entry::E_PARENT:      {	IdlError(file, line,		 "Declaration of %s '%s' clashes with name of "		 "enclosing scope '%s'", decl->kindAsString(),		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "('%s' declared here)",		     clash->identifier());	break;      }    }  }  Entry* e = new Entry(this, Entry::E_CALLABLE, identifier, scope,		       decl, 0, 0, file, line);  appendEntry(e);}voidScope::addInherited(const char* id, Scope* scope, Decl* decl,	     Scope::Entry* inh_from, const char* file, int line){  if (*id == '_') ++id;  Entry* clash = iFind(id);  if (clash) {    switch (clash->kind()) {    case Entry::E_MODULE:    case Entry::E_DECL:    case Entry::E_CALLABLE:    case Entry::E_INSTANCE:    case Entry::E_USE:      {	assert(0); // Should never reach here      }    case Entry::E_INHERITED:      {	if (inh_from != clash->inh_from()) {	  IdlError(file, line, "In definition of '%s': clash between "		   "inherited identifiers '%s' and '%s'",		   identifier(), id, clash->identifier());	  char* inhfrom =	    inh_from->container()->scopedName()->toString();	  IdlErrorCont(inh_from->file(), inh_from->line(),		       "(%s '%s' declared in %s here)",		       decl->kindAsString(), id, inhfrom);	  delete [] inhfrom;	  inhfrom = clash->inh_from()->container()->scopedName()->toString();	  IdlErrorCont(clash->inh_from()->file(), clash->inh_from()->line(),		       "(%s '%s' declared in %s here)",		       clash->decl()->kindAsString(),		       clash->identifier(), inhfrom);	  delete [] inhfrom;	}	break;      }    case Entry::E_PARENT:      {	// It's not clear whether this is OK, but the spec doesn't say	// it's definitely illegal//  	IdlWarning(file, line,//  		   "Inherited %s '%s' clashes with interface name '%s'",//  		   decl->kindAsString(), id, clash->identifier());//  	IdlWarningCont(decl->file(), decl->line(),//  		       "(%s '%s' declared here)", decl->kindAsString(), id);	break;      }    }  }  Entry* e = new Entry(this, Entry::E_INHERITED, id, scope,		       decl, 0, inh_from, file, line);  appendEntry(e);}voidScope::addInstance(const char* identifier, Decl* decl, IdlType* idltype,	    const char* file, int line){  if (*identifier == '_')    ++identifier;  else    keywordClash(identifier, file, line);  Entry* clash = iFind(identifier);  if (clash) {    switch (clash->kind()) {    case Entry::E_MODULE:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with declaration "		 "of module '%s'", identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "(module '%s' declared here)", clash->identifier());	break;      }    case Entry::E_DECL:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with declaration "		 "of %s '%s'", identifier, clash->decl()->kindAsString(),		 clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_CALLABLE:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with %s '%s'",		 identifier, clash->decl()->kindAsString(),		 clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "(%s '%s' declared here)",		     clash->decl()->kindAsString(), clash->identifier());	break;      }    case Entry::E_INHERITED:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with inherited %s '%s'",		 identifier, clash->decl()->kindAsString(),		 clash->identifier());	char* inhfrom =	  clash->inh_from()->container()->scopedName()->toString();	IdlErrorCont(clash->inh_from()->file(), clash->inh_from()->line(),		     "('%s' declared in %s here)",		     clash->identifier(), inhfrom);	delete [] inhfrom;	break;      }    case Entry::E_INSTANCE:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with instance '%s'",		 identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "('%s' declared here)", clash->identifier());	break;      }    case Entry::E_USE:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with use of "		 "identifier '%s'", identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(),		     "('%s' used here)", clash->identifier());	break;      }    case Entry::E_PARENT:      {	IdlError(file, line,		 "Instance identifier '%s' clashes with name of "		 "enclosing scope '%s'", identifier, clash->identifier());	IdlErrorCont(clash->file(), clash->line(), "('%s' declared here)",		     clash->identifier());	break;      }    }  }  Entry* e = new Entry(this, Entry::E_INSTANCE, identifier, 0,		       decl, idltype, 0, file, line);  appendEntry(e);}voidScope::remEntry(Scope::Entry* re){  if (entries_ == re) {    entries_ = re->next();    if (!entries_) last_ = 0;  }  else {    Entry *e;    for (e = entries_; e && (e->next() != re); e = e->next());    assert(e != 0);    e->next_ = re->next();    if (!e->next_) last_ = e;  }  re->next_ = 0;  delete re;}IDL_BooleanScope::keywordClash(const char* identifier, const char* file, int line){  static const char* keywords[] = {    "abstract", "any", "attribute", "boolean", "case", "char", "const",    "context", "custom", "default", "double", "enum", "exception",    "factory", "FALSE", "fixed", "float", "in", "inout", "interface",    "local", "long", "module", "native", "Object", "octet", "oneway",    "out", "private", "public", "raises", "readonly", "sequence",    "short", "string", "struct", "supports", "switch", "TRUE",    "truncatable", "typedef", "union", "unsigned", "ValueBase",    "valuetype", "void", "wchar", "wstring", 0  };  static const char* new_keywords[] = {    "component", "consumes", "emits", "eventtype", "finder", "getraises",    "home", "import", "multiple", "primarykey", "provides", "publishes",    "setraises", "typeid", "typeprefix", "uses", 0  };  const char** k;  for (k = keywords; *k; k++) {    if (Config::caseSensitive) {      if (!strcmp(*k, identifier)) {	IdlError(file, line, "Identifier '%s' is identical to keyword '%s'",		 identifier, *k);	return 1;      }    }    else {      if (!strcasecmp(*k, identifier)) {	IdlError(file, line, "Identifier '%s' clashes with keyword '%s'",		 identifier, *k);	return 1;      }    }  }  for (k = new_keywords; *k; k++) {    if (Config::caseSensitive) {      if (!strcmp(*k, identifier)) {	IdlWarning(file, line, "Identifier '%s' is identical to "		   "CORBA 3 keyword '%s'.", identifier, *k);	return 1;      }    }    else {      if (!strcasecmp(*k, identifier)) {	IdlWarning(file, line, "Identifier '%s' clashes with "		   "CORBA 3 keyword '%s'", identifier, *k);	return 1;      }    }  }  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?