// This file is part of PUMA. // Copyright (C) 1999-2003 The PUMA developer team. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this program; if not, write to the Free // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, // MA 02111-1307 USA #ifndef __ext_ac_builder_cc_ah__ #define __ext_ac_builder_cc_ah__ #include "Puma/ExtACBuilderH.ah" #include "Puma/ACTree.h" // ************************** // C and CC-Builder extension // ************************** slice bool ExtACBuilder::is_advice_decl () const { return (nodes () == 1 && get_node ()->NodeName () == Puma::CT_AdviceDecl::NodeId ()); } slice Puma::CTree *ExtACBuilder::advice_decl () { // 3: ADVICE decl_list pointcut // 4: ADVICE : decl pointcut return nodes () == 3 ? new Puma::CT_AdviceDecl (get_node (0), get_node (2), 0, get_node (1)) : new Puma::CT_AdviceDecl (get_node (0), get_node (3), get_node (1), get_node (2)); } slice Puma::CTree *ExtACBuilder::order_list () { // 2 + N: ( pointcut-expr-seq ) return list (new Puma::CT_OrderList); } slice Puma::CTree *ExtACBuilder::order_decl () { // 3: ORDER order_list ; return new Puma::CT_OrderDecl (get_node (0), get_node (1), get_node (2)); } slice Puma::CTree *ExtACBuilder::pointcut_decl () { // 1: POINTCUT decl return new Puma::CT_PointcutDecl (get_node (0), get_node (1)); } slice Puma::CTree *ExtACBuilder::slice_ref () { // 3: SLICE unqual_id ; // 4: SLICE :: unqual_id ; // 4: SLICE nested_name_spec unqual_id ; // 5: SLICE :: nested_name_spec unqual_id ; Puma::CT_QualName *qn = 0; int num = nodes (); if (num == 3) { // 3: SLICE unqual_id ; } else if (num == 4) { if (get_node (1)->NodeName () == Builder::Container::NodeId ()) { // 4: SLICE nested_name_spec unqual_id ; Builder::Container *nns = (Builder::Container*)get_node (1); qn = new Puma::CT_QualName (nns->Sons ()+1); copy_list (qn, nns); qn->AddSon (get_node (2)); delete nns; } else { // 4: SLICE :: unqual_id ; qn = new Puma::CT_RootQualName (2); qn->AddSon (get_node (1)); qn->AddSon (get_node (2)); } } else if (num == 5) { // 5: SLICE :: nested_name_spec unqual_id ; Builder::Container *nns = (Builder::Container*)get_node (2); qn = new Puma::CT_RootQualName (nns->Sons ()+2); qn->AddSon (get_node (1)); copy_list (qn, nns); qn->AddSon (get_node (3)); delete nns; } return new Puma::CT_SliceRef (get_node (0), qn ? (Puma::CTree*)qn : get_node (1), get_node (num-1)); } slice Puma::CTree *ExtACBuilder::class_slice_decl () { // 1: SLICE class_key class_slice_name base_clause? memb_list? ; int n = nodes (); bool has_base = (get_node (3)->NodeName () == Puma::CT_Intro::NodeId ()); bool has_members = (get_node (n - 2)->NodeName () == Puma::CT_MembList::NodeId ()); return new Puma::CT_ClassSliceDecl (get_node (0), get_node (1), get_node (2), has_base ? get_node (3) : (Puma::CTree*)0, has_members ? get_node (nodes () - 2) : (Puma::CTree*)0, get_node (n - 1)); } slice Puma::CTree *ExtACBuilder::class_slice_name () { // 1: identifier // 1: private_name // 2: :: identifier // 2: nested_name_spec identifier // 3: :: nested_name_spec identifier int num = nodes (); if (num == 1) return get_node (0); Puma::CT_QualName *qn = 0; if (num == 2) { if (get_node (0)->NodeName () == Puma::CT_Token::NodeId ()) { // 2: :: identifier qn = new Puma::CT_RootQualName (2); qn->AddSon (get_node (0)); qn->AddSon (get_node (1)); } else { // 2: nested_name_spec identifier Builder::Container *nns = (Builder::Container*)get_node (0); qn = new Puma::CT_QualName (nns->Sons ()+1); copy_list (qn, nns); qn->AddSon (get_node (1)); delete nns; } } else if (num == 3) { // 3: :: nested_name_spec identifier Builder::Container *nns = (Builder::Container*)get_node (1); qn = new Puma::CT_RootQualName (nns->Sons () + 2); qn->AddSon (get_node (0)); copy_list (qn, nns); qn->AddSon (get_node (2)); delete nns; } return qn; } slice Puma::CTree *ExtACBuilder::class_slice_member_list () { Puma::CT_MembList *ml = new Puma::CT_MembList; ml->AddSon (get_node (0)); for (int i = 1; i < nodes () - 1; i++) ml->AddSon (get_node (i)); ml->AddSon (get_node (nodes () - 1)); ml->AddProperties (Puma::CT_List::OPEN_CLOSE); return ml; } slice Puma::CTree *ExtACBuilder::class_slice_member_decl () { // 2: SLICE intro Puma::CT_Intro *i = (Puma::CT_Intro*)get_node (1); i->PrefixSon (get_node (0)); i->AddProperties (Puma::CT_List::OPEN); return i; } slice Puma::CTree *ExtACBuilder::pointcut_expr () { // 1: const_expr return get_node (0); } slice Puma::CTree *ExtACBuilder::intro () { // N: token-seq return list (new Puma::CT_Intro); } // FIXME tagging slice Puma::CTree *ExtACCBuilder::tag_expr () { int num = nodes (); if (get_node (0)->token ()->type () == TOK_AT) { Puma::CTree* result = 0; Puma::CTree* para = (Puma::CT_ExprList*)0; if (num >= 3) { result = get_node (2); if (result->NodeName () == Puma::CT_ExprList::NodeId ()) { para = result; } } return new Puma::CT_TagExpr (get_node (0), get_node (1), para); } else return (Puma::CTree*)0; } slice Puma::CTree *ExtACCBuilder::intro () { // N: token-seq return list (new Puma::CT_Intro); } /*slice Puma::CTypeInfo *ExtACCSemExpr::resolve (Puma::CT_TagExpr *node, Puma::CTree *base) { return resolve ((CTree*)node, base); }*/ // FIXME tagging #endif /* __ext_ac_builder_cc_ah__ */