2323# include " pform.h"
2424# include " parse_misc.h"
2525# include " parse_api.h"
26+ # include " PClass.h"
2627# include " PEvent.h"
2728# include " PUdp.h"
2829# include " PGenerate.h"
@@ -267,12 +268,30 @@ void pform_pop_scope()
267268 lexical_scope = lexical_scope->parent_scope ();
268269}
269270
271+ PClass* pform_push_class_scope (const struct vlltype &loc, perm_string name)
272+ {
273+ PClass*class_scope = new PClass (name, lexical_scope);
274+ FILE_NAME (class_scope, loc);
275+
276+ lexical_scope = class_scope;
277+ return class_scope;
278+ }
279+
270280PTask* pform_push_task_scope (const struct vlltype &loc, char *name, bool is_auto)
271281{
272282 perm_string task_name = lex_strings.make (name);
273283
274284 PTask*task = new PTask (task_name, lexical_scope, is_auto);
275285 FILE_NAME (task, loc);
286+
287+ LexicalScope*scope = lexical_scope;
288+ PScopeExtra*scopex = dynamic_cast <PScopeExtra*> (scope);
289+ while (scope && !scopex) {
290+ scope = scope->parent_scope ();
291+ scopex = dynamic_cast <PScopeExtra*> (scope);
292+ }
293+ assert (scopex);
294+
276295 if (pform_cur_generate) {
277296 // Check if the task is already in the dictionary.
278297 if (pform_cur_generate->tasks .find (task->pscope_name ()) !=
@@ -286,15 +305,15 @@ PTask* pform_push_task_scope(const struct vlltype&loc, char*name, bool is_auto)
286305 pform_cur_generate->tasks [task->pscope_name ()] = task;
287306 } else {
288307 // Check if the task is already in the dictionary.
289- if (pform_cur_module->tasks .find (task->pscope_name ()) !=
290- pform_cur_module->tasks .end ()) {
308+ if (scopex->tasks .find (task->pscope_name ()) != scopex->tasks .end ()) {
291309 cerr << task->get_fileline () << " : error: duplicate "
292310 " definition for task '" << name << " ' in '"
293- << pform_cur_module-> mod_name () << " '." << endl;
311+ << scopex-> pscope_name () << " '." << endl;
294312 error_count += 1 ;
295313 }
296- pform_cur_module ->tasks [task->pscope_name ()] = task;
314+ scopex ->tasks [task->pscope_name ()] = task;
297315 }
316+
298317 lexical_scope = task;
299318
300319 return task;
@@ -307,6 +326,15 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, char*name,
307326
308327 PFunction*func = new PFunction (func_name, lexical_scope, is_auto);
309328 FILE_NAME (func, loc);
329+
330+ LexicalScope*scope = lexical_scope;
331+ PScopeExtra*scopex = dynamic_cast <PScopeExtra*> (scope);
332+ while (scope && !scopex) {
333+ scope = scope->parent_scope ();
334+ scopex = dynamic_cast <PScopeExtra*> (scope);
335+ }
336+ assert (scopex);
337+
310338 if (pform_cur_generate) {
311339 // Check if the function is already in the dictionary.
312340 if (pform_cur_generate->funcs .find (func->pscope_name ()) !=
@@ -320,14 +348,13 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, char*name,
320348 pform_cur_generate->funcs [func->pscope_name ()] = func;
321349 } else {
322350 // Check if the function is already in the dictionary.
323- if (pform_cur_module->funcs .find (func->pscope_name ()) !=
324- pform_cur_module->funcs .end ()) {
351+ if (scopex->funcs .find (func->pscope_name ()) != scopex->funcs .end ()) {
325352 cerr << func->get_fileline () << " : error: duplicate "
326353 " definition for function '" << name << " ' in '"
327- << pform_cur_module-> mod_name () << " '." << endl;
354+ << scopex-> pscope_name () << " '." << endl;
328355 error_count += 1 ;
329356 }
330- pform_cur_module ->funcs [func->pscope_name ()] = func;
357+ scopex ->funcs [func->pscope_name ()] = func;
331358 }
332359 lexical_scope = func;
333360
@@ -2640,7 +2667,7 @@ void pform_set_data_type(const struct vlltype&li, data_type_t*data_type, list<pe
26402667 return ;
26412668 }
26422669
2643- if (class_type_t *class_type = dynamic_cast <class_type_t *> (data_type)) {
2670+ if (/* class_type_t*class_type =*/ dynamic_cast <class_type_t *> (data_type)) {
26442671 VLerror (li, " sorry: Class types not supported." );
26452672 return ;
26462673 }
0 commit comments