cppInstanceIdentifier.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Filename: cppInstanceIdentifier.h
  2. // Created by: drose (21Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef CPPINSTANCEIDENTIFIER_H
  6. #define CPPINSTANCEIDENTIFIER_H
  7. #include <dtoolbase.h>
  8. #include <vector>
  9. #include <string>
  10. using namespace std;
  11. class CPPIdentifier;
  12. class CPPParameterList;
  13. class CPPType;
  14. class CPPExpression;
  15. class CPPScope;
  16. class CPPPreprocessor;
  17. enum CPPInstanceIdentifierType {
  18. IIT_pointer,
  19. IIT_reference,
  20. IIT_scoped_pointer,
  21. IIT_array,
  22. IIT_const,
  23. IIT_paren,
  24. IIT_func,
  25. };
  26. ///////////////////////////////////////////////////////////////////
  27. // Class : CPPInstanceIdentifier
  28. // Description : This class is used in parser.y to build up a variable
  29. // instance definition. An instance is something like
  30. // 'int *&a'; the InstanceIdentifier stores everything
  31. // to the right of the typename. Later this can be
  32. // passed to make_instance() to construct a CPPInstance.
  33. ////////////////////////////////////////////////////////////////////
  34. class CPPInstanceIdentifier {
  35. public:
  36. CPPInstanceIdentifier(CPPIdentifier *ident);
  37. CPPType *unroll_type(CPPType *start_type);
  38. void add_modifier(CPPInstanceIdentifierType type);
  39. void add_func_modifier(CPPParameterList *params, int flags);
  40. void add_scoped_pointer_modifier(CPPIdentifier *scoping);
  41. void add_array_modifier(CPPExpression *expr);
  42. CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
  43. CPPPreprocessor *error_sink = NULL) const;
  44. CPPIdentifier *_ident;
  45. class Modifier {
  46. public:
  47. Modifier(CPPInstanceIdentifierType type);
  48. static Modifier func_type(CPPParameterList *params, int flags);
  49. static Modifier array_type(CPPExpression *expr);
  50. static Modifier scoped_pointer_type(CPPIdentifier *scoping);
  51. CPPInstanceIdentifierType _type;
  52. CPPParameterList *_func_params;
  53. int _func_flags;
  54. CPPIdentifier *_scoping;
  55. CPPExpression *_expr;
  56. };
  57. typedef vector<Modifier> Modifiers;
  58. Modifiers _modifiers;
  59. private:
  60. CPPType *
  61. r_unroll_type(CPPType *start_type, Modifiers::const_iterator mi);
  62. };
  63. #endif