2 identifier.cc -- implement identifier and derived classes
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "identifier.hh"
12 #include "my-lily-lexer.hh"
14 #include "input-register.hh"
15 #include "input-score.hh"
16 #include "symtable.hh"
17 #include "input-staff.hh"
18 #include "input-music.hh"
20 #include "script-def.hh"
22 #include "input-register.hh"
24 Identifier::~Identifier()
26 if (!accessed_b_ && !init_b_)
27 warning("Variable not used");
30 Identifier::error(String expect)
32 String e("Wrong identifier type: ");
33 e += String(classname()) + "(expected " + expect + ")";
37 Identifier::Identifier(String n, int code)
47 Identifier::print()const
49 mtor << "identifier \'" << name_str_ << "\'=";
54 #define DEFAULT_PRINT(Class, Content_type, accessor) \
56 Class::do_print() const { \
57 ((Class*)this)->accessor(false)->print(); \
61 DEFAULT_PRINT(Script_id, Script_def, script);
62 DEFAULT_PRINT(Lookup_id, Lookup, lookup);
63 DEFAULT_PRINT(Symtables_id, Symtables, symtables);
64 DEFAULT_PRINT(Staff_id, Input_staff, staff);
65 DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
66 DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
67 DEFAULT_PRINT(Request_id, Request, request);
68 DEFAULT_PRINT(Score_id, Input_score, score);
69 DEFAULT_PRINT(Input_regs_id, Input_register, iregs);
72 Real_id::do_print() const
75 mtor << *((Real_id*)this)->real(false)<< "\n";
78 #define implement_id_class(Idclass, Class, accessor) \
79 char const * Idclass::classname() const\
84 Idclass::accessor(bool copy) {\
87 return new Class(* (Class*) data);\
89 return (Class*) data;\
91 Idclass::~Idclass() { delete accessor(false); }\
92 Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\
95 implement_id_class(Real_id, Real, real);
96 implement_id_class(Script_id, Script_def, script);
97 implement_id_class(Lookup_id, Lookup, lookup);
98 implement_id_class(Symtables_id, Symtables, symtables);
99 implement_id_class(Staff_id, Input_staff, staff);
100 implement_id_class(M_chord_id, Music_general_chord, mchord);
101 implement_id_class(M_voice_id, Music_voice, mvoice);
102 implement_id_class(Score_id, Input_score, score);
103 implement_id_class(Request_id, Request, request);
104 implement_id_class(Input_regs_id, Input_register, iregs);
106 Identifier::Identifier(Identifier const&)