]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/identifier.cc
release: 0.0.49
[lilypond.git] / lily / identifier.cc
index e4712f8a5a9e8b630a98bf52c952679c085c0112..72224f92f91c7cfb342767476f22dce220bf9f6b 100644 (file)
@@ -9,9 +9,23 @@
 #include <assert.h>
 
 #include "identifier.hh"
-#include "lexer.hh"
+#include "my-lily-lexer.hh"
 #include "debug.hh"
+#include "input-register.hh"
+#include "input-score.hh" 
+#include "symtable.hh"
+#include "input-staff.hh"
+#include "input-music.hh"
+#include "lookup.hh"
+#include "script-def.hh"
+#include "request.hh"
+#include "input-register.hh"
 
+Identifier::~Identifier()
+{
+    if (!accessed_b_ && !init_b_)
+       warning("Variable not used");
+}
 void
 Identifier::error(String expect)
 {
@@ -20,10 +34,19 @@ Identifier::error(String expect)
     ::error(e);
 }
 
+Identifier::Identifier(String n, int code)
+    :  name_str_(n) 
+{
+    token_code_i_ = code; 
+    data = 0;
+    accessed_b_ = 0;
+    init_b_ = 0;
+}
+
 void
 Identifier::print()const
 {
-    mtor << "identifier \'" << name << "\'=";
+    mtor << "identifier \'" << name_str_ << "\'=";
     do_print();
 }
 
@@ -42,6 +65,9 @@ DEFAULT_PRINT(Staff_id, Input_staff, staff);
 DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
 DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
 DEFAULT_PRINT(Request_id, Request, request);
+DEFAULT_PRINT(Score_id, Input_score, score);
+DEFAULT_PRINT(Input_regs_id, Input_register, iregs);
+
 void
 Real_id::do_print() const
 {
@@ -49,3 +75,35 @@ Real_id::do_print() const
     mtor << *((Real_id*)this)->real(false)<< "\n";
 }
 
+#define implement_id_class(Idclass, Class, accessor)   \
+char const * Idclass::classname() const\
+{\
+    return #Class;\
+}\
+Class*\
+Idclass::accessor(bool copy) {\
+       if (copy){ \
+           accessed_b_ = true;\
+           return new Class(* (Class*) data);\
+        }else\
+           return (Class*) data;\
+    }\
+Idclass::~Idclass() { delete accessor(false); }\
+Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\
+
+
+implement_id_class(Real_id, Real, real);
+implement_id_class(Script_id, Script_def, script);
+implement_id_class(Lookup_id, Lookup, lookup);
+implement_id_class(Symtables_id, Symtables, symtables);
+implement_id_class(Staff_id, Input_staff, staff);
+implement_id_class(M_chord_id, Music_general_chord, mchord);
+implement_id_class(M_voice_id, Music_voice, mvoice);
+implement_id_class(Score_id, Input_score, score);
+implement_id_class(Request_id, Request, request);
+implement_id_class(Input_regs_id, Input_register, iregs);
+
+Identifier::Identifier(Identifier const&)
+{
+    assert(false);
+}