Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDL4 map support to TAO #1842

Merged
merged 108 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
c9384eb
Added a test for maps
tmayoff May 21, 2022
3c34706
Fixed test.idl
tmayoff May 23, 2022
6e4f5bb
Added AST for map
tmayoff May 23, 2022
1ff3a93
Updated flex and bison
tmayoff May 23, 2022
067a851
Merge branch 'DOCGroup:master' into maps
tmayoff May 23, 2022
f99f460
More ast
tmayoff May 23, 2022
6e51d10
Merge branch 'maps' of github.com:tmayoff/ACE_TAO into maps
tmayoff May 23, 2022
2686e77
Added functions for ast_visitor
tmayoff May 23, 2022
fc6f206
Removed blank lines
tmayoff May 23, 2022
8a7f735
ifr_visitor
tmayoff May 25, 2022
9c69228
Adding bounds to bison
tmayoff May 26, 2022
8a9729e
Simplified bison
tmayoff May 26, 2022
f154d18
removed whitespace
tmayoff May 26, 2022
78a6345
trailing whitespace
tmayoff May 26, 2022
d6d2bab
cleaned up
tmayoff Jun 2, 2022
06a0959
fixes based on the code review
tmayoff Jun 3, 2022
ed7e91b
Removed MPC submodule
tmayoff Jun 3, 2022
17a670a
key_type + value_type code, and cleanup
tmayoff Jun 4, 2022
42c8ff7
Updated bison, pushing null scope
tmayoff Jun 4, 2022
00099e6
Updated idl for null scope
tmayoff Jun 4, 2022
aa6f53e
removed whitespace
tmayoff Jun 4, 2022
3cbb2c8
fixed whitespace
tmayoff Jun 4, 2022
b4e0d4b
Fixed typo
tmayoff Jun 4, 2022
e677ed0
added map_head rules to parser, for proper null scope
tmayoff Jun 8, 2022
fd1f1ba
Added maps in the idl_features
tmayoff Jun 11, 2022
cbe7b95
Merge branch 'DOCGroup:master' into maps
tmayoff Jun 14, 2022
7b4251e
maps almost being generated via code, still very messy
tmayoff Jun 17, 2022
67ec6ba
Removed whitespaces
tmayoff Jun 17, 2022
facd12c
Fixed fuzz
tmayoff Jun 17, 2022
ad0d7dc
Cleaned up some be_map functions
tmayoff Jun 18, 2022
52939b7
updated include
tmayoff Jun 18, 2022
fb88c10
remove whitespace
tmayoff Jun 18, 2022
7a016b6
Fixed fuzzing
tmayoff Jun 18, 2022
8a730f9
Cleaned up CDR progress
tmayoff Jun 19, 2022
db2924b
Updated test, and stubbed stream operators
tmayoff Jun 20, 2022
26b45ba
Merge branch 'DOCGroup:master' into maps
tmayoff Jun 20, 2022
ba4c116
Fixed fuzzing
tmayoff Jun 23, 2022
30848dd
code generation working properly
tmayoff Jun 24, 2022
2b7f3b4
more cleanup of stubbed code
tmayoff Jun 24, 2022
db20a3a
Fixed static analysis
tmayoff Jun 24, 2022
53a9c6a
Merge branch 'master' into maps
tmayoff Jun 24, 2022
0a2d7a4
removed whitespace
tmayoff Jun 24, 2022
243b738
generating typedefs + maps with maps as values
tmayoff Jun 24, 2022
e5df304
Finished test
tmayoff Jun 24, 2022
95b7517
whitespace
tmayoff Jun 24, 2022
53d65da
whitespace
tmayoff Jun 24, 2022
94eecfc
generating <map> include conditionally
tmayoff Jun 24, 2022
11077a8
Should silence the codacy check
tmayoff Jun 24, 2022
4cff930
used the wrong vars for the check
tmayoff Jun 24, 2022
3af0ed4
Merge branch 'master' into maps
tmayoff Jun 24, 2022
922bc3f
cleaned up some warnings
tmayoff Jun 24, 2022
51b71fd
No more generated warnings and fixed the last codacy warning
tmayoff Jun 25, 2022
51ad46b
added ast_map.h to ast.h
tmayoff Jun 26, 2022
3b736f5
Cleaned up the maps test
tmayoff Jun 27, 2022
cbedd95
Fixed double free error
tmayoff Jun 27, 2022
af034d4
Cleaned up some final comments and stubbed code and fixed formatting
tmayoff Jun 29, 2022
f8e8e5d
cleaned up default destructors + using is_empty
tmayoff Jul 6, 2022
1cb036a
Fixed TAO_IDL_IDL_VERSION macro
tmayoff Jul 7, 2022
508cb95
Fixed formatting
tmayoff Jul 7, 2022
d1bf737
Removed comments
tmayoff Jul 7, 2022
90f9feb
Fixed error messaging in ifr_adding_visitor
tmayoff Jul 12, 2022
b6de86b
Formatted
tmayoff Jul 22, 2022
23700ef
fixed some things, switched to std::strcmp
tmayoff Jul 22, 2022
f55d0fb
Started on some more testing
tmayoff Jul 22, 2022
e06ccf4
Fixed issue with names
tmayoff Aug 4, 2022
0c31804
typos
tmayoff Aug 6, 2022
3eac499
Created recursive example that fails
tmayoff Aug 6, 2022
38dfb73
Updated comments / author notes
tmayoff Aug 12, 2022
da15886
cleaned test file
tmayoff Aug 12, 2022
025d75a
cleaned up old comments
tmayoff Aug 12, 2022
9caa9c9
fixed whitespace
tmayoff Aug 12, 2022
73e4e12
comment
tmayoff Aug 13, 2022
4dfa447
regenerated after changes
tmayoff Aug 13, 2022
d947751
Fixed recursion check
tmayoff Aug 13, 2022
f223c82
Fixed recursive type test
tmayoff Aug 13, 2022
f4789ac
Switched to std::snprintf
tmayoff Aug 13, 2022
42df71b
another switch
tmayoff Aug 13, 2022
4a3d7ed
Typo
tmayoff Aug 20, 2022
8954164
Merge branch 'master' into maps
tmayoff Sep 6, 2022
9b3324c
Update TAO/TAO_IDL/include/idl_global.h
tmayoff Sep 30, 2022
2d311a5
Update TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h
tmayoff Sep 30, 2022
cfc7584
Update TAO/TAO_IDL/include/ast_visitor_reifying.h
tmayoff Sep 30, 2022
45dbc23
Update TAO/TAO_IDL/include/ast_generator.h
tmayoff Sep 30, 2022
36a3d4e
Merge branch 'master' into maps
jwillemsen Oct 5, 2022
37b7fba
Merge branch 'master' into maps
jwillemsen Oct 13, 2022
300a3a1
Added tests/IDLv4 to github actions
tmayoff Oct 13, 2022
be18a08
Merge branch 'maps' of https://github.com/tmayoff/ACE_TAO into maps
tmayoff Oct 13, 2022
f3aff9b
added shell to CI
tmayoff Oct 13, 2022
6ceaada
cleaned up some generated code
tmayoff Oct 13, 2022
4d1b3d3
fixed comments, removed unused
tmayoff Oct 18, 2022
bdc650d
Almost working stream operators
tmayoff Oct 22, 2022
6f8fce1
removed support for bounded maps
tmayoff Oct 22, 2022
c9d754c
fixed cdr op
tmayoff Oct 22, 2022
e271555
remove bounded maps
tmayoff Oct 22, 2022
7ccbd1c
proper map key/val type code gen
tmayoff Oct 22, 2022
735ad05
fixed warnings
tmayoff Oct 22, 2022
8a1a7ba
added map to node_type_to_string
tmayoff Oct 22, 2022
17cee1b
whitespace
tmayoff Oct 22, 2022
c41ff8c
Merge branch 'master' into maps
tmayoff Oct 22, 2022
73bdce4
switched typedef to using
tmayoff Oct 22, 2022
00c4af2
Merge branch 'maps' of https://github.com/tmayoff/ACE_TAO into maps
tmayoff Oct 22, 2022
197dc29
Merge branch 'master' into maps
jwillemsen Jan 31, 2023
69a160c
C++ sometimes struggles with structs as map keys
tmayoff Mar 21, 2023
a0a132a
Merge branch 'master' into maps
tmayoff Mar 21, 2023
061d692
Merge branch 'master' into maps
tmayoff Apr 24, 2023
43d328e
Merge branch 'master' into maps
tmayoff Aug 8, 2023
2564f45
Update TAO/TAO_IDL/be/be_visitor_map/map_cs.cpp
tmayoff Aug 18, 2023
bbf82d1
Update TAO/orbsvcs/IFR_Service/ifr_adding_visitor.cpp
tmayoff Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions TAO/TAO_IDL/ast/ast_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "ast_enum_val.h"
#include "ast_array.h"
#include "ast_sequence.h"
#include "ast_map.h"
#include "ast_string.h"
#include "ast_structure_fwd.h"
#include "ast_typedef.h"
Expand Down Expand Up @@ -867,6 +868,27 @@ AST_Generator::create_sequence (AST_Expression *ms,
return retval;
}

AST_Map *
AST_Generator::create_map (AST_Expression *ms,
AST_Type *key_bt,
AST_Type *val_bt,
UTL_ScopedName *n,
bool is_local,
bool is_abstract)
{
AST_Map *retval = nullptr;
ACE_NEW_RETURN (retval,
AST_Map (ms,
key_bt,
val_bt,
n,
is_local,
is_abstract),
nullptr);

return retval;
}

AST_String *
AST_Generator::create_string (AST_Expression *ms)
{
Expand Down
349 changes: 349 additions & 0 deletions TAO/TAO_IDL/ast/ast_map.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
/*

COPYRIGHT

Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
States of America. All Rights Reserved.

This product is protected by copyright and distributed under the following
license restricting its use.

The Interface Definition Language Compiler Front End (CFE) is made
available for your use provided that you include this license and copyright
notice on all media and documentation and the software program in which
this product is incorporated in whole or part. You may copy and extend
functionality (but may not remove functionality) of the Interface
Definition Language CFE without charge, but you are not authorized to
license or distribute it to anyone else except as part of a product or
program developed by you or with the express written consent of Sun
Microsystems, Inc. ("Sun").

The names of Sun Microsystems, Inc. and any of its subsidiaries or
affiliates may not be used in advertising or publicity pertaining to
distribution of Interface Definition Language CFE as permitted herein.

This license is effective until terminated by Sun for failure to comply
with this license. Upon termination, you shall destroy or return all code
and documentation for the Interface Definition Language CFE.

INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
DEALING, USAGE OR TRADE PRACTICE.

INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.

SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.

IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Use, duplication, or disclosure by the government is subject to
restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
52.227-19.

Sun, Sun Microsystems and the Sun logo are trademarks or registered
trademarks of Sun Microsystems, Inc.

SunSoft, Inc.
2550 Garcia Avenue
Mountain View, California 94043

NOTE:

SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
trademarks or registered trademarks of Sun Microsystems, Inc.

*/

// AST_Map nodes represent IDL map declarations.
// AST_Map is a subclass of AST_ConcreteType.
// AST_Map nodes have a maximum size (an AST_Expression which
// must evaluate to a positive integer) and a base type (a subclass
// of AST_Type).

#include "ast_map.h"
#include "ast_typedef.h"
#include "ast_expression.h"
#include "ast_param_holder.h"
#include "ast_visitor.h"
#include "ast_annotation_appl.h"

#include "utl_identifier.h"
#include "utl_err.h"

#include "global_extern.h"
#include "fe_extern.h"

#include "ace/Log_Msg.h"
#include "ace/OS_Memory.h"
#include "ace/OS_NS_string.h"

AST_Decl::NodeType const
AST_Map::NT = AST_Decl::NT_map;

AST_Map::AST_Map (AST_Expression *ms,
AST_Type *key_bt,
AST_Type *val_bt,
UTL_ScopedName *n,
bool local,
bool abstract)
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
: COMMON_Base (key_bt->is_local () || val_bt->is_local() || local,
abstract),
AST_Decl (AST_Decl::NT_map,
n,
true),
AST_Type (AST_Decl::NT_map,
n),
AST_ConcreteType (AST_Decl::NT_map,
n),
pd_max_size (ms),
key_pd_type (key_bt),
value_pd_type (val_bt),
unbounded_ (true),
owns_base_type_ (false)
{
FE_Utils::tmpl_mod_ref_check (this, key_bt);

AST_Decl::NodeType bnt = key_bt->node_type ();

if (bnt == AST_Decl::NT_param_holder)
{
AST_Param_Holder *ph = dynamic_cast<AST_Param_Holder*> (key_bt);
tmayoff marked this conversation as resolved.
Show resolved Hide resolved

if (ph->info ()->type_ == AST_Decl::NT_const)
{
idl_global->err ()->not_a_type (key_bt);
key_bt->destroy ();
delete key_bt;
key_bt = nullptr;
throw Bailout ();
}
}
tmayoff marked this conversation as resolved.
Show resolved Hide resolved

// Check if we are bounded or unbounded. An expression value of 0 means
// unbounded. If our bound is a template parameter, skip the
// check altogether, this node will trigger no code generation.
if (ms->param_holder () == nullptr)
{
this->unbounded_ = (ms->ev ()->u.ulval == 0);
}

// A map data type is always VARIABLE.
this->size_type (AST_Type::VARIABLE);

AST_Decl::NodeType nt = key_bt->node_type ();

this->owns_base_type_ =
nt == AST_Decl::NT_array
|| nt == AST_Decl::NT_map
|| nt == AST_Decl::NT_param_holder;
}

AST_Map::~AST_Map ()
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
{
}

// Public operations.

bool
AST_Map::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
{
if (list.size () == 0) // only structs, unions and valuetypes can be recursive
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
return false;

list.enqueue_tail(this);

AST_Type *type = dynamic_cast<AST_Type*> (this->key_type ());

if (type == nullptr)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("AST_Map::in_recursion - ")
ACE_TEXT ("bad base type\n")),
false);
}

AST_Decl::NodeType nt = type->node_type ();

if (nt == AST_Decl::NT_typedef)
{
AST_Typedef *td = dynamic_cast<AST_Typedef*> (type);
type = td->primitive_base_type ();
nt = type->node_type ();
}

if (nt != AST_Decl::NT_struct
&& nt != AST_Decl::NT_union
&& nt != AST_Decl::NT_valuetype
&& nt != AST_Decl::NT_map)
{
return false;
}

bool recursion_found = false;
AST_Type** recursable_type = nullptr;
list.get (recursable_type, 0);
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
if (!ACE_OS::strcmp (type->full_name (),
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
(*recursable_type)->full_name ()))
{
// They match.
recursion_found = true;
idl_global->recursive_type_seen_ = true;
}
else
{
// Check the element type.
recursion_found = type->in_recursion (list);
}

return recursion_found;
}

// Redefinition of inherited virtual operations.

// Dump this AST_Map node to the ostream o.
void
AST_Map::dump (ACE_OSTREAM_TYPE &o)
{
this->dump_i (o, "map <");
AST_Annotation_Appls::iterator i,
finished = key_type_annotations ().end ();
for (i = key_type_annotations ().begin (); i != finished; ++i)
{
AST_Annotation_Appl *a = i->get ();
a->dump (o);
dump_i (o, " ");
}
this->key_pd_type->dump (o);
this->dump_i (o, ", ");

finished = value_type_annotations ().end ();
for (i = value_type_annotations ().begin (); i != finished; ++i)
{
AST_Annotation_Appl *a = i->get ();
a->dump (o);
dump_i (o, " ");
}
this->value_pd_type->dump (o);
this->dump_i (o, ", ");
this->pd_max_size->dump (o);
this->dump_i (o, ">");
}

int
AST_Map::ast_accept (ast_visitor *visitor)
{
return visitor->visit_map (this);
}

// Data accessors.

AST_Expression *
AST_Map::max_size ()
{
return this->pd_max_size;
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
}

AST_Type *
AST_Map::key_type () const
{
return this->key_pd_type;
}

AST_Type *
AST_Map::value_type () const
{
return this->value_pd_type;
}

AST_Type *
AST_Map::primitive_key_type () const
{
AST_Type *type_node = key_type ();
if (type_node && type_node->node_type () == AST_Decl::NT_typedef)
{
AST_Typedef *const typedef_node = dynamic_cast<AST_Typedef *> (type_node);
if (!typedef_node) return nullptr;
type_node = typedef_node->primitive_base_type ();
}
return type_node;
}

AST_Type *
AST_Map::primitive_value_type () const
{
AST_Type *type_node = value_type();
if (type_node && type_node->node_type() == AST_Decl::NT_typedef)
{
AST_Typedef * const typedef_node = dynamic_cast<AST_Typedef*>(type_node);
if (!typedef_node) return nullptr;
type_node = typedef_node->primitive_base_type();
}
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
return type_node;
}

bool
AST_Map::unbounded () const
{
return this->unbounded_;
}

bool
AST_Map::legal_for_primary_key () const
{
return this->key_type ()->legal_for_primary_key ();
}

bool
AST_Map::is_defined ()
{
return this->key_pd_type->is_defined () && this->value_pd_type->is_defined();
}

void
AST_Map::destroy ()
{
if (this->owns_base_type_)
{
this->key_pd_type->destroy ();
delete this->key_pd_type;
this->key_pd_type = nullptr;
}

this->pd_max_size->destroy ();
delete this->pd_max_size;
this->pd_max_size = nullptr;

this->AST_ConcreteType::destroy ();
}

AST_Annotation_Appls &
AST_Map::key_type_annotations ()
{
return value_type_annotations_;
}

void
AST_Map::key_type_annotations (const AST_Annotation_Appls &annotations)
{
key_type_annotations_ = annotations;
}

AST_Annotation_Appls &
AST_Map::value_type_annotations ()
{
return value_type_annotations_;
}

void
AST_Map::value_type_annotations (const AST_Annotation_Appls &annotations)
{
value_type_annotations_ = annotations;
}
tmayoff marked this conversation as resolved.
Show resolved Hide resolved
Loading