idlast.h

来自「编译工具」· C头文件 代码 · 共 1,254 行 · 第 1/3 页

H
1,254
字号
// -*- c++ -*-//                          Package   : omniidl// idlast.h                 Created on: 1999/10/07//			    Author    : Duncan Grisby (dpg1)////    Copyright (C) 1999 AT&T Laboratories Cambridge////  This file is part of omniidl.////  omniidl is free software; you can redistribute it and/or modify it//  under the terms of the GNU General Public License as published by//  the Free Software Foundation; either version 2 of the License, or//  (at your option) any later version.////  This program is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU//  General Public License for more details.////  You should have received a copy of the GNU General Public License//  along with this program; if not, write to the Free Software//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA//  02111-1307, USA.//// Description://   //   Definitions for abstract syntax tree classes// $Id: idlast.h,v 1.10.2.6 2001/08/29 11:55:23 dpg1 Exp $// $Log: idlast.h,v $// Revision 1.10.2.6  2001/08/29 11:55:23  dpg1// Enumerator nodes record their value.//// Revision 1.10.2.5  2001/03/13 10:32:11  dpg1// Fixed point support.//// Revision 1.10.2.4  2000/11/01 12:45:56  dpg1// Update to CORBA 2.4 specification.//// Revision 1.10.2.3  2000/10/27 16:31:08  dpg1// Clean up of omniidl dependencies and types, from omni3_develop.//// Revision 1.10.2.2  2000/10/10 10:18:50  dpg1// Update omniidl front-end from omni3_develop.//// Revision 1.8.2.6  2000/08/29 10:20:26  dpg1// Operations and attributes now have repository ids.//// Revision 1.8.2.5  2000/08/04 11:39:03  dpg1// Updates for AIX with xlC//// Revision 1.8.2.4  2000/06/08 14:36:19  dpg1// Comments and pragmas are now objects rather than plain strings, so// they can have file,line associated with them.//// Revision 1.8.2.3  2000/06/05 18:13:27  dpg1// Comments can be attached to subsequent declarations (with -K). Better// idea of most recent decl in operation declarations//// Revision 1.8.2.2  2000/03/07 10:36:38  dpg1// More sensible idea of the "most recent" declaration.//// Revision 1.8.2.1  2000/03/06 15:03:48  dpg1// Minor bug fixes to omniidl. New -nf and -k flags.//// Revision 1.8  2000/02/04 12:17:09  dpg1// Support for VMS.//// Revision 1.7  1999/11/17 17:17:00  dpg1// Changes to remove static initialisation of objects.//// Revision 1.6  1999/11/02 17:07:27  dpg1// Changes to compile on Solaris.//// Revision 1.5  1999/11/01 20:19:56  dpg1// Support for union switch types declared inside the switch statement.//// Revision 1.4  1999/11/01 10:05:01  dpg1// New file attribute to AST.//// Revision 1.3  1999/10/29 15:43:02  dpg1// Code to detect recursive structs and unions.//// Revision 1.2  1999/10/29 10:00:43  dpg1// Added code to find a value for the default case in a union.//// Revision 1.1  1999/10/27 14:05:59  dpg1// *** empty log message ***//#ifndef _idlast_h_#define _idlast_h_#include <idlutil.h>#include <idltype.h>#include <idlexpr.h>#include <idlscope.h>#include <idlvisitor.h>#include <stdio.h>extern "C" int yyparse();class Decl;// Pragma class stores a list of pragmas:class Pragma {public:  Pragma(const char* pragmaText, const char* file, int line)    : pragmaText_(idl_strdup(pragmaText)),      file_(idl_strdup(file)), line_(line), next_(0) {}  ~Pragma() {    delete [] pragmaText_;    delete [] file_;    if (next_) delete next_;  }  const char* pragmaText() const { return pragmaText_; }  const char* file()       const { return file_; }  int         line()       const { return line_; }  Pragma*     next()       const { return next_; }  static void add(const char* pragmaText, const char* file, int line);private:  char*   pragmaText_;  char*   file_;  int     line_;  Pragma* next_;  friend class AST;  friend class Decl;};// Comment class stores a list of comment strings:class Comment {public:  Comment(const char* commentText, const char* file, int line)    : commentText_(idl_strdup(commentText)),      file_(idl_strdup(file)), line_(line), next_(0) {    mostRecent_ = this;  }  ~Comment() {    delete [] commentText_;    delete [] file_;    if (next_) delete next_;  }  const char* commentText() const { return commentText_; }  const char* file()        const { return file_; }  int         line()        const { return line_; }  Comment*    next()        const { return next_; }  static void add   (const char* commentText, const char* file, int line);  static void append(const char* commentText);  static void clear() { mostRecent_ = 0; }  static Comment* grabSaved();  // Return any saved comments, and clear the saved comment listprivate:  char*           commentText_;  char*           file_;  int             line_;  Comment*        next_;  static Comment* mostRecent_;  static Comment* saved_;  friend class AST;  friend class Decl;};// AST class represents the whole IDL definitionclass AST {public:  AST();  ~AST();  static AST*        tree();  static IDL_Boolean process(FILE* f, const char* name);  static void        clear();  Decl*       declarations()              { return declarations_; }  const char* file()                      { return file_; }  Pragma*     pragmas()                   { return pragmas_; }  Comment*    comments()                  { return comments_; }  void        accept(AstVisitor& visitor) { visitor.visitAST(this); }  void        setFile(const char* f);  void        addPragma(const char* pragmaText, const char* file, int line);  void        addComment(const char* commentText, const char* file, int line);private:  void        setDeclarations(Decl* d);  Decl*       declarations_;  char*       file_;  static AST* tree_;  Pragma*     pragmas_;  Pragma*     lastPragma_;  Comment*    comments_;  Comment*    lastComment_;  friend int  yyparse();};// Base declaration abstract classclass Decl {public:  // Declaration kinds  enum Kind {    D_MODULE, D_INTERFACE, D_FORWARD, D_CONST, D_DECLARATOR,    D_TYPEDEF, D_MEMBER, D_STRUCT, D_STRUCTFORWARD, D_EXCEPTION,    D_CASELABEL, D_UNIONCASE, D_UNION, D_UNIONFORWARD,    D_ENUMERATOR, D_ENUM, D_ATTRIBUTE, D_PARAMETER, D_OPERATION,    D_NATIVE, D_STATEMEMBER, D_FACTORY, D_VALUEFORWARD, D_VALUEBOX,    D_VALUEABS, D_VALUE  };  Decl(Kind kind, const char* file, int line, IDL_Boolean mainFile);  virtual ~Decl();  // Declaration kind  Kind                kind()         const { return kind_; }  virtual const char* kindAsString() const = 0;  // Query interface  const char*       file()       const { return file_; }  int               line()       const { return line_; }  IDL_Boolean       mainFile()   const { return mainFile_; }  const Scope*      inScope()    const { return inScope_; }  const Pragma*     pragmas()    const { return pragmas_; }  const Comment*    comments()   const { return comments_; }  // Linked list  Decl* next() { return next_; }  void append(Decl* d) {    if (d) {      last_->next_ = d;      last_        = d;    }  }  // Find a decl given a name. Does not mark the name used.  static Decl* scopedNameToDecl(const char* file, int line,				const ScopedName* sn);  static Decl* mostRecent() { return mostRecent_; }  static void  clear()      { mostRecent_ = 0; }  // Visitor pattern accept(). The visitor is responsible for  // recursively visiting children if it needs to  virtual void accept(AstVisitor& visitor) = 0;  void addPragma(const char* pragmaText, const char* file, int line);  void addComment(const char* commentText, const char* file, int line);private:  Kind              kind_;  char*             file_;  int               line_;  IDL_Boolean       mainFile_;  const Scope*      inScope_;  Pragma*           pragmas_;  Pragma*           lastPragma_;  Comment*          comments_;  Comment*          lastComment_;protected:  static Decl*      mostRecent_;  Decl* next_;  Decl* last_;};// Mixin class for Decls with a RepoIdclass DeclRepoId {public:  DeclRepoId(const char* identifier);  ~DeclRepoId();  // eidentifier() returns the identifier with _ escapes intact  const char*       identifier()  const { return identifier_; }  const char*       eidentifier() const { return eidentifier_; }  const ScopedName* scopedName()  const { return scopedName_; }  const char*       repoId()      const { return repoId_; }  const char*       prefix()      const { return prefix_; }  void setRepoId(const char* repoId, const char* file, int line);  void setVersion(IDL_Short maj, IDL_Short min,		  const char* file, int line);  // Static set functions taking a Decl as an argument  static void setRepoId(Decl* d, const char* repoId,			const char* file, int line);  static void setVersion(Decl* d, IDL_Short maj, IDL_Short min,			 const char* file, int line);  IDL_Boolean repoIdSet() const { return set_; }  const char* rifile()    const { return rifile_; }  int         riline()    const { return riline_; }  IDL_Short   rimaj()     const { return maj_; }  IDL_Short   rimin()     const { return min_; }private:  void genRepoId();  char*          identifier_;  char*          eidentifier_;  ScopedName*    scopedName_;  char*          repoId_;  char*          prefix_; // Prefix in force at time of declaration  IDL_Boolean    set_;    // True if repoId or version has been manually set  char*          rifile_; // File where repoId or version was set  int            riline_; // Line where repoId or version was set  IDL_Short      maj_;  IDL_Short      min_;};// Moduleclass Module : public Decl, public DeclRepoId {public:  Module(const char* file, int line, IDL_Boolean mainFile,	 const char* identifier);  virtual ~Module();  const char* kindAsString() const { return "module"; }  // Query interface  Decl* definitions() const { return definitions_; }    void accept(AstVisitor& visitor) { visitor.visitModule(this); }  void finishConstruction(Decl* defs);private:  Decl*  definitions_;};// List of inherited interfacesclass InheritSpec {public:  InheritSpec(const ScopedName* sn, const char* file, int line);  ~InheritSpec() { if (next_) delete next_; }  // The ScopedName used in an inheritance specification may be a  // typedef. In that case, decl() returns the Typedef declarator  // object and interface() returns the actual Interface object.  // Otherwise, both functions return the same Interface pointer.  Interface*   interface() const { return interface_; }  Decl*        decl()      const { return decl_; }  const Scope* scope()     const { return scope_; }  InheritSpec* next()      const { return next_; }  void append(InheritSpec* is, const char* file, int line);private:  Interface*   interface_;  Decl*        decl_;  const Scope* scope_;protected:  InheritSpec* next_;};// Interfaceclass Interface : public Decl, public DeclRepoId {public:  Interface(const char* file, int line, IDL_Boolean mainFile,	    const char* identifier, IDL_Boolean abstract,	    IDL_Boolean local, InheritSpec* inherits);  virtual ~Interface();  const char* kindAsString() const { return "interface"; }  // Queries  IDL_Boolean    abstract() const { return abstract_; }  IDL_Boolean    local()    const { return local_;    }  InheritSpec*   inherits() const { return inherits_; }  Decl*          contents() const { return contents_; }  Scope*         scope()    const { return scope_;    }  IdlType*       thisType() const { return thisType_; }  void accept(AstVisitor& visitor) { visitor.visitInterface(this); }  void finishConstruction(Decl* decls);private:  IDL_Boolean    abstract_;  IDL_Boolean    local_;  InheritSpec*   inherits_;  Decl*          contents_;  Scope*         scope_;  IdlType*       thisType_;};// Forward-declared interfaceclass Forward : public Decl, public DeclRepoId {public:  Forward(const char* file, int line, IDL_Boolean mainFile,	  const char* identifier, IDL_Boolean abstract, IDL_Boolean local);  virtual ~Forward();

⌨️ 快捷键说明

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