~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to sql/sp_pcontext.h

  • Committer: msvensson at pilot
  • Date: 2007-04-24 09:11:45 UTC
  • mfrom: (2469.1.106)
  • Revision ID: sp1r-msvensson@pilot.blaudden-20070424091145-10463
Merge pilot.blaudden:/home/msvensson/mysql/my51-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
  sp_cond_type_t *val;
89
89
} sp_cond_t;
90
90
 
 
91
/**
 
92
  The scope of a label in Stored Procedures,
 
93
  for name resolution of labels in a parsing context.
 
94
*/
 
95
enum label_scope_type
 
96
{
 
97
  /**
 
98
    The labels declared in a parent context are in scope.
 
99
  */
 
100
  LABEL_DEFAULT_SCOPE,
 
101
  /**
 
102
    The labels declared in a parent context are not in scope.
 
103
  */
 
104
  LABEL_HANDLER_SCOPE
 
105
};
91
106
 
92
 
/*
93
 
  The parse-time context, used to keep track on declared variables/parameters,
 
107
/**
 
108
  The parse-time context, used to keep track of declared variables/parameters,
94
109
  conditions, handlers, cursors and labels, during parsing.
95
110
  sp_contexts are organized as a tree, with one object for each begin-end
96
 
  block, plus a root-context for the parameters.
 
111
  block, one object for each exception handler,
 
112
  plus a root-context for the parameters.
97
113
  This is used during parsing for looking up defined names (e.g. declared
98
114
  variables and visible labels), for error checking, and to calculate offsets
99
115
  to be used at runtime. (During execution variable values, active handlers
100
116
  and cursors, etc, are referred to by an index in a stack.)
 
117
  Parsing contexts for exception handlers limit the visibility of labels.
101
118
  The pcontext tree is also kept during execution and is used for error
102
119
  checking (e.g. correct number of parameters), and in the future, used by
103
120
  the debugger.
105
122
 
106
123
class sp_pcontext : public Sql_alloc
107
124
{
108
 
  sp_pcontext(const sp_pcontext &); /* Prevent use of these */
109
 
  void operator=(sp_pcontext &);
110
 
 
111
 
 public:
112
 
 
113
 
  sp_pcontext(sp_pcontext *prev);
 
125
public:
 
126
 
 
127
  /**
 
128
    Constructor.
 
129
    Builds a parsing context root node.
 
130
  */
 
131
  sp_pcontext();
114
132
 
115
133
  // Free memory
116
134
  void
117
135
  destroy();
118
136
 
 
137
  /**
 
138
    Create and push a new context in the tree.
 
139
    @param label_scope label scope for the new parsing context
 
140
    @return the node created
 
141
  */
119
142
  sp_pcontext *
120
 
  push_context();
 
143
  push_context(label_scope_type label_scope);
121
144
 
122
 
  // Returns the previous context, not the one we pop
 
145
  /**
 
146
    Pop a node from the parsing context tree.
 
147
    @return the parent node
 
148
  */
123
149
  sp_pcontext *
124
150
  pop_context();
125
151
 
363
389
 
364
390
protected:
365
391
 
 
392
  /**
 
393
    Constructor for a tree node.
 
394
    @param prev the parent parsing context
 
395
    @param label_scope label_scope for this parsing context
 
396
  */
 
397
  sp_pcontext(sp_pcontext *prev, label_scope_type label_scope);
 
398
 
366
399
  /*
367
400
    m_max_var_index -- number of variables (including all types of arguments)
368
401
    in this context including all children contexts.
416
449
 
417
450
  List<sp_pcontext> m_children; // Children contexts, used for destruction
418
451
 
 
452
  /**
 
453
    Scope of labels for this parsing context.
 
454
  */
 
455
  label_scope_type m_label_scope;
 
456
 
 
457
private:
 
458
  sp_pcontext(const sp_pcontext &); /* Prevent use of these */
 
459
  void operator=(sp_pcontext &);
419
460
}; // class sp_pcontext : public Sql_alloc
420
461
 
421
462