Sync with 5.4.2
[deliverable/titan.core.git] / compiler2 / ttcn3 / Templatestuff.cc
index 94af53796a164a156c1ef16512274fc1989f8ee5..8ad7c948978613df41eb847fbe7f6b20e6bf6916 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2000-2014 Ericsson Telecom AB
+// Copyright (c) 2000-2015 Ericsson Telecom AB
 // All rights reserved. This program and the accompanying materials
 // are made available under the terms of the Eclipse Public License v1.0
 // which accompanies this distribution, and is available at
@@ -196,6 +196,12 @@ namespace Ttcn {
   // =================================
   // ===== IndexedTemplate
   // =================================
+  
+  IndexedTemplate::IndexedTemplate(const IndexedTemplate& p)
+  {
+    index = p.index->clone();
+    temp = p.temp->clone();
+  }
 
   IndexedTemplate::IndexedTemplate(FieldOrArrayRef *p_i, Template *p_t)
   {
@@ -212,7 +218,7 @@ namespace Ttcn {
 
   IndexedTemplate *IndexedTemplate::clone() const
   {
-    FATAL_ERROR("IndexedTemplate::clone");
+    return new IndexedTemplate(*this);
   }
 
   void IndexedTemplate::set_fullname(const string& p_fullname)
@@ -245,6 +251,14 @@ namespace Ttcn {
   // =================================
   // ===== IndexedTemplates
   // =================================
+  
+  IndexedTemplates::IndexedTemplates(const IndexedTemplates& p)
+  : Node(p)
+  {
+    for (size_t i = 0; i < p.its_v.size(); i++) {
+      its_v.add(p.its_v[i]->clone());
+    }
+  }
 
   IndexedTemplates::~IndexedTemplates()
   {
@@ -254,7 +268,7 @@ namespace Ttcn {
 
   IndexedTemplates *IndexedTemplates::clone() const
   {
-    FATAL_ERROR("IndexedTemplates::clone");
+    return new IndexedTemplates(*this);
   }
 
   void IndexedTemplates::set_fullname(const string& p_fullname)
@@ -296,6 +310,12 @@ namespace Ttcn {
     name = p_n;
     temp = p_t;
   }
+  
+  NamedTemplate::NamedTemplate(const NamedTemplate& p)
+  {
+    name = p.name->clone();
+    temp = p.temp->clone();
+  }
 
   NamedTemplate::~NamedTemplate()
   {
@@ -305,7 +325,7 @@ namespace Ttcn {
 
   NamedTemplate *NamedTemplate::clone() const
   {
-    FATAL_ERROR("NamedTemplate::clone");
+    return new NamedTemplate(*this);
   }
 
   void NamedTemplate::set_fullname(const string& p_fullname)
@@ -319,6 +339,24 @@ namespace Ttcn {
     Node::set_my_scope(p_scope);
     temp->set_my_scope(p_scope);
   }
+  
+  void NamedTemplate::set_name_to_lowercase()
+  {
+    string new_name = name->get_name();
+    if (isupper(new_name[0])) {
+      new_name[0] = tolower(new_name[0]);
+      if (new_name[new_name.size() - 1] == '_') {
+        // an underscore is inserted at the end of the alternative name if it's
+        // a basic type's name (since it would conflict with the class generated
+        // for that type)
+        // remove the underscore, it won't conflict with anything if its name
+        // starts with a lowercase letter
+        new_name.replace(new_name.size() - 1, 1, "");
+      }
+      delete name;
+      name = new Identifier(Identifier::ID_NAME, new_name);
+    }
+  }
 
   Template* NamedTemplate::extract_template()
   {
@@ -336,6 +374,18 @@ namespace Ttcn {
   // =================================
   // ===== NamedTemplates
   // =================================
+  
+  NamedTemplates::NamedTemplates(const NamedTemplates& p)
+  : Node(p), checked(p.checked)
+  {
+    for (size_t i = 0; i < p.nts_v.size(); i++) {
+      NamedTemplate* nt = p.nts_v[i]->clone();
+      nts_v.add(nt);
+      if (checked) {
+        nts_m.add(p.nts_m.get_nth_key(i), nt);
+      }
+    }
+  }
 
   NamedTemplates::~NamedTemplates()
   {
@@ -346,7 +396,7 @@ namespace Ttcn {
 
   NamedTemplates *NamedTemplates::clone() const
   {
-    FATAL_ERROR("NamedTemplates::clone");
+    return new NamedTemplates(*this);
   }
 
   void NamedTemplates::set_fullname(const string& p_fullname)
This page took 0.029042 seconds and 5 git commands to generate.