The root of the entire intermediate representation is the variable
global_namespace
. This is the namespace specified with ::
in C++ source code. All other namespaces, types, variables, functions,
and so forth can be found starting with this namespace.
Korean Translation
Àüü Áß°£Ç¥ÇöÀÇ ±Ù¿øÀº º¯¼ö global_namespace
ÀÌ´Ù. ÀÌ°ÍÀº C++ ¼Ò½ºÄڵ忡¼ ::
°ú ÇÔ²² ³ªÅ¸³»¾îÁö´Â ³×ÀÓ½ºÆäÀ̽º´Ù. ¸ðµç ´Ù¸¥ ³×ÀÓ½ºÆäÀ̽ºµ,ŸÀÔ,º¯¼ö,ÇÔ¼öµîÀº ÀÌ ³×ÀÓ½ºÆäÀ̽º¿Í °°ÀÌ ½ÃÀ۵Ǵ °ÍÀ» ¾Ë ¼ö ÀÖ´Ù.
Besides namespaces, the other high-level scoping construct in C++ is the
class. (Throughout this manual the term class is used to mean the
types referred to in the ANSI/ISO C++ Standard as classes; these include
types defined with the class
, struct
, and union
keywords.)
Korean Translation
³×ÀÓ½ºÆäÀ̽º¿Ü¿¡ C++¿¡¼ ´Ù¸¥ °í±Þ·¹º§ÀÇ scopingÀ¸·Î´Â Ŭ·¡½º°¡ ÀÖ´Ù.
¸ðµç ´Ù¸¥ ³×ÀÓ½ºÆäÀ̽ºµé,ŸÀÔ(Çü,º¯¼ö,ÇÔ¼öµîÀº
A namespace is represented by a NAMESPACE_DECL
node.
Korean Translation
³×ÀÓ½ºÆäÀ̽º´Â NAMESPACE_DECL
³ëµå¿¡ ÀÇÇØ Ç¥ÇöµÈ´Ù.
However, except for the fact that it is distinguished as the root of the
representation, the global namespace is no different from any other
namespace. Thus, in what follows, we describe namespaces generally,
rather than the global namespace in particular.
Korean Translation
±×·¯³ª, Ç¥ÇöÀÇ ±Ù¿øÀ¸·Î¼ ±¸ºÐµÇ´Â »ç½Ç¿Ü¿£ global namespace´Â ´Ù¸¥ ¾î¶² ³×ÀÓ½ºÆäÀ̽º¿Í º°¹Ý Â÷ÀÌ°¡ ¾ø´Ù. ±×·¯¹Ç·Î Ưº°È÷ global_namespaceº¸´Ù´Â ÀϹÝÀûÀ¸·Î ³×ÀÓ½ºÆäÀ̽º¸¦ ¼³¸íÇÑ´Ù.
The ::std
namespace, however, is special, unless
flag_honor_std
is set. This variable is set by the use
`-fhonor-std' (or an option that implies it, like
`-fnew-abi'), when invoking G++. When flag_honor_std
is
set, the std
namespace is just like any other namespace. When
flag_honor_std
is not set, however, the ::std
namespace is
treated as a synonym for the global namespace, thereby allowing users to
write code that will work with compilers that put the standard library
in the ::std
namespace, even though the library supplied with G++
does not do so, as of GCC 2.95. The std
namespace is represented
by the variable std_node
. Although std_node
is a
NAMESPACE_DECL
, it does not have all the fields required of a
real namespace, and the macros and functions described here do not work,
in general. It is safest simply to ignore std_node
should you
encounter it while examining the internal representation. In
particular, you will encounter std_node
while looking at the
members of the global namespace. Just skip it without attempting to
examine its members.
Korean Translation
::std
³×ÀÓ½ºÆäÀ̽º´Â '-fhonor-sed'°¡ ¼¼ÆõÇÁö ¾Ê¾Ò´Ù¸é Ưº°ÇÑ ³×ÀÓ½ºÆäÀ̽º´Ù. ÀÌ º¯¼ö´Â G++¿¡¼ '-flag_honor-std'¸¦ ÀÌ¿ëÇÏ¿© ¼¼ÆõȴÙ. 'flag-honor'
°¡ ¼ÂµÇ¾úÀ»¶§ ::std
³×ÀÓ½ºÆäÀ̽º´Â ´Ù¸¥ ÀÏ¹Ý ³×ÀÓ½ºÆäÀ̽º¿Í °°´Ù. ¼¼ÆõÇÁö ¾Ê¾ÒÀ» °æ¿ì ::std
³×ÀÓ½ºÆäÀ̽º´Â global_namespace¿¡ ´ëÇÑ µ¿ÀǾî·Î¼ 󸮵ȴÙ. ±×¸®ÇÏ¿© »ç¿ëÀÚ°¡ ÄÄÆÄÀÏ·¯¿Í ÀÛ¾÷ÇÒ ¼ö ÀÖ´Â ÄÚµåÀÛ¼ºÀ» Çã¿ëÇϱâ À§ÇØ ::std
³×ÀÓ½ºÆäÀ̽º¿¡ standard library¸¦ ³Ö´Â´Ù(½ÉÁö¾î G++¿¡¼ Á¦°øµÇ´Â ¶óÀ̺귯¸®°¡ ±×·¸°Ô µ¿ÀÛÇÏÁö¾Ê´õ¶óµµ). std ³×ÀÓ½ºÆäÀ̽º´Â º¯¼ö std_node¿¡ ÀÇÇØ Ç¥ÇöµÈ´Ù. ºñ·Ï std_node°¡ ÇϳªÀÇ NAMESPACE_DECL
ÀÌÁö¸¸ ±×°ÍÀº ½ÇÁ¦ ³×ÀÓ½ºÆäÀ̽º¿¡°Ô ÇÊ¿äÇÑ ÇʵåµéÀ» °¡Áö°í ÀÖÁö ¾Ê°í ¿©±â¼ ¾ð±ÞµÈ ÇÔ¼ö³ª ¸ÅÅ©·ÎµéÀº ÀϹÝÀûÀ¸·Î »ç¿ëµÇÁö ¾Ê´Â´Ù. ³»ºÎÇ¥ÇöÀ» Á¶»çÇÒ ¶§ std_node¸¦ Á¢ÇÏ°Ô µÇ¸é °£´ÜÈ÷ ¹«½ÃÇÏ´Â °ÍÀÌ °¡Àå ¾ÈÀüÇÒ °ÍÀÌ´Ù. Ưº°È÷ global_namespaceÀÇ ¸â¹öµéÀ» Á¶»çÇÏ¸é¼ std_node¸¦ ¸¸³¯ ¼ö ÀÖÀ» °ÍÀÌ´Ù. ±×·² °æ¿ì ±×°ÍÀÇ ¸â¹öµéÀ» Á¶»çÇϱ⸦ ½ÃµµÇÏÁö¸»°í ±×³É Áö³ªÃÄ ¹ö¸°´Ù.½
The following macros and functions can be used on a NAMESPACE_DECL
:
ÀÌ ¸ÅÅ©·Î¿Í ÇÔ¼öµéÀº NAMESPACE_DECL
¿¡¼ »ç¿ëµÉ ¼ö ÀÖ´Ù.
DECL_NAME
IDENTIFIER_NODE
corresponding to
the unqualified name of the name of the namespace (see section Identifiers).
The name of the global namespace is `::', even though in C++ the
global namespace is unnamed. However, you should use comparison with
global_namespace
, rather than DECL_NAME
to determine
whether or not a namespaces is the global one. An unnamed namespace
will have a DECL_NAME
equal to anonymous_namespace_name
.
Within a single translation unit, all unnamed namespaces will have the
same name.
ÀÌ ¸ÅÅ©·Î´Â ³×ÀÓ½ºÆäÀ̽ºÀÇ À̸§À¸·Î¼ ºÎÀûÀýÇÑ À̸§¿¡ »óÀÀÇÏ´Â IDENTIFIER_NODE
¸¦ ¾ò´Âµ¥ »ç¿ëµÈ´Ù. ºñ·Ï C++¿¡¼± Àü¿ª ³×ÀÓ½ºÆäÀ̽º¶õ À̸§ÀÌ ¾øÁö¸¸ ¿©±â¼ Àü¿ª ³×ÀÓ½ºÆäÀ̽º´Â '::'ÀÌ´Ù. ³×ÀÓ½ºÆäÀ̽º°¡ Àü¿ªÀÎÁöÀÇ ¿©ºÎ¸¦ °áÁ¤Çϱâ À§Çؼ± DECL_NAME
º¸´Ù´Â global_namespace
¿Í ºñ±³Çؾ߸¸ ÇÑ´Ù. À̸§¾ø´Â ³×ÀÓ½ºÆäÀ̽º´Â anonymous_namespace_name
¿Í °°Àº DECL_NAME
¸¦ °¡Áú °ÍÀÌ´Ù. ´ÜÀÏ Çؼ®´ÜÀ§¿¡¼ ¸ðµç À̸§¾ø´Â ³×ÀÓ½ºÆäÀ̽ºµéÀº °°Àº À̸§À» °¡Áú °ÍÀÌ´Ù.
DECL_CONTEXT
DECL_CONTEXT
for
the global_namespace
is NULL_TREE
.
ÀÌ ¸ÅÅ©·Î´Â enclosing(?) ³×ÀÓ½ºÆäÀ̽º¸¦ ¸®ÅÏÇÑ´Ù.
DECL_NAMESPACE_ALIAS
DECL_NAMESPACE_ALIAS
is the namespace for which this one is an
alias.
Do not attempt to use cp_namespace_decls
for a namespace which is
an alias. Instead, follow DECL_NAMESPACE_ALIAS
links until you
reach an ordinary, non-alias, namespace, and call
cp_namespace_decls
there.
ÀÌ ¼±¾ðÀÌ ³×ÀÓ½ºÆäÀ̽º ¾Ë¸®¾î½º¿¡ ´ëÇÑ °ÍÀ̶ó¸é DECL_NAMESPACE_ALIASE
´Â ±× ³×ÀÓ½ºÆäÀ̽º¿¡ ´ëÇÑ ¾Ë¸®¾î½º´Ù. ³×ÀÓ½ºÆäÀ̽ºÀÇ ¾Ë¸®¾î½º¿¡ ´ëÇØ cp_namespace_decls
¸¦ »ç¿ëÇؼ´Â ¾ÊµÈ´Ù. ´ë½Å º¸ÅÖÀÇ ¾Ë¸®¾î½º µÇÁö¾ÊÀº ³×ÀÓ½ºÆäÀ̽º¸¦ ¸¸³¯¶§±îÁö DECL_NAMESPACE_ALIAS
¸µÅ©¸¦ µû¶ó°£ ÈÄ °Å±â¼ cp_namespace
¸¦ È£ÃâÇؾßÇÑ´Ù.
DECL_NAMESPACE_STD_P
::std
namespace.
³×ÀÓ½ºÆäÀ̽º°¡ Ưº°ÇÑ ::std
ÀÏ °æ¿ì Âü °ªÀ» °¡Áö´Â ¸ÅÅ©·Î.
cp_namespace_decls
NULL_TREE
. The declarations are connected through their
TREE_CHAIN
fields.
Although most entries on this list will be declarations,
TREE_LIST
nodes may also appear. In this case, the
TREE_VALUE
will be an OVERLOAD
. The value of the
TREE_PURPOSE
is unspecified; back-ends should ignore this value.
As with the other kinds of declarations returned by
cp_namespace_decls
, the TREE_CHAIN
will point to the next
declaration in this list.
For more information on the kinds of declarations that can occur on this
list, See section Declarations. Some declarations will not appear on this
list. In particular, no FIELD_DECL
, LABEL_DECL
, or
PARM_DECL
nodes will appear here.
This function cannot be used with namespaces that have
DECL_NAMESPACE_ALIAS
set.
NULL_TREE
¸¦ ¸®ÅÏÇÒ °ÍÀÌ´Ù. ±× ¼±¾ðµéÀº ±×µéÀÇ TREE_CHAIN
Çʵ带 ÅëÇÏ¿© ¿¬°áµÈ´Ù. ºñ·Ï ÀÌ ¸®½ºÆ®¿¡ ´ëºÎºÐ ¿£Æ®¸®µéÀÌ ¼±¾ðºÎºÐÀÌÁö¸¸ TREE_LIST
¶ÇÇÑ ³ªÅ¸³¯ Áöµµ ¸ð¸¥´Ù. ÀÌ °æ¿ì TREE_VALUE
´Â OVERLOAD
°¡ µÉ °ÍÀÌ´Ù. TREE_PURPOSE
ÀÇ °ªÀº Á¤ÇØÁöÁö ¾Ê´Â´Ù. cp_namespace_decls
¿¡ ÀÇÇØ ¸®ÅϵǴ ¼±¾ðµéÀÇ ´Ù¸¥ Á¾·ù·Î¼ TREE_CHAIN
Àº ÀÌ ¸®½ºÆ®¾È¿¡¼ ´ÙÀ½ ¼±¾ðºÎºÐÀ» °¡¸®Å³ °ÍÀÌ´Ù. ÀÌ ¸®½ºÆ®¿¡¼ ÀϾ ¼ö ÀÖ´Â ¼±¾ðµéÀÇ ´Ù¸¥ Á¾·ùµé¿¡ ´ëÇØ ´õ ¾Ë°íÀÚ ÇÑ´Ù¸é Declarations ºÎºÐÀ» ÂüÁ¶Ç϶ó. ¾î¶² ¼±¾ðµéÀº ÀÌ ¸®½ºÆ®¿¡¼ ³ªÅ¸³ªÁö ¾ÊÀ» °ÍÀÌ´Ù. Ưº°È÷ FIELD_DECL,LABEL_DECL,PARM_DECL
µîÀº ¿©±â¼ ³ªÅ¸³ªÁö ¾Ê´Â´Ù. ÀÌ ÇÔ¼ö´Â DECL_NAMESPACE_ALIAS
°ªÀ» °¡Áö´Â ³×ÀÓ½ºÆäÀ̽ºµé°ú ÇÔ²² »ç¿ëµÇ¾î Áú ¼ö ¾ø´Ù. ÷
A class type is represented by either a RECORD_TYPE
or a
UNION_TYPE
. A class declared with the union
tag is
represented by a UNION_TYPE
, while classes declared with either
the struct
or the class
tag are represented by
RECORD_TYPE
s. You can use the CLASSTYPE_DECLARED_CLASS
macro to discern whether or not a particular type is a class
as
opposed to a struct
. This macro will be true only for classes
declared with the class
tag.
Ŭ·¡½º ŸÀÔÀº RECORD_TYPE
ȤÀº UNION_TYPE
À¸·Î Ç¥ÇöµÈ´Ù. union
ÅÂÅ©¿Í ÇÔ²² ¼±¾ðµÈ Ŭ·¡½º´Â UNION_TYPE
¿¡ ÀÇÇØ Ç¥ÇöµÈ´Ù. ¹Ý¸é¿¡ struct
¶Ç´Â class
ű׷Π¼±¾ðµÈ Ŭ·¡½º´Â RECORD_TYPE
¿¡ ÀÇÇØ Ç¥ÇöµÈ´Ù. ƯÁ¤ÇÑ Å¸ÀÔ¿¡ ´ëÇØ class
ȤÀº ÀÌ¿Í ±¸º°µÇ´Â struct
ÀÎÁö¸¦ ¾Ë±âÀ§ÇØ CLASSTYPE_DECLARED_CLASS
¸ÅÅ©·Î¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌ ¸ÅÅ©·Î´Â class
ÅÂÅ©·Î ¼±¾ðµÈ Ŭ·¡½ºµé¿¡ ´ëÇØ Âü°ªÀ» °¡Áø´Ù.
Almost all non-function members are available on the TYPE_FIELDS
list. Given one member, the next can be found by following the
TREE_CHAIN
. You should not depend in any way on the order in
which fields appear on this list. All nodes on this list will be
`DECL' nodes. A FIELD_DECL
is used to represent a non-static
data member, a VAR_DECL
is used to represent a static data
member, and a TYPE_DECL
is used to represent a type. Note that
the CONST_DECL
for an enumeration constant will appear on this
list, if the enumeration type was declared in the class. (Of course,
the TYPE_DECL
for the enumeration type will appear here as well.)
There are no entries for base classes on this list. In particular,
there is no FIELD_DECL
for the "base-class portion" of an
object.
°ÅÀÇ ¸ðµç ºñÇÔ¼öÇü ¸â¹öµéÀº TYPE_FIELDS
¸®½ºÆ®¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ´Ù. ÁÖ¾îÁø ÇϳªÀÇ ¸â¹ö¿¡ ´ëÇØ ´ÙÀ½ ¸â¹ö´Â TREE_CHAIN
Çʵ带 ÀÌ¿ëÇÏ¿© ãÀ» ¼ö ÀÖ´Ù. ¾î¶² °æ¿ì¿¡µµ ÀÌ ¸®½ºÆ®¿¡ ³ªÅ¸³ ÇʵåµéÀÇ ¿ì¼±¼øÀ§¿¡ ÀÇÁ¸Çؼ´Â ¾ÊµÈ´Ù. ÀÌ ¸®½ºÆ®ÀÇ ¸ðµç ³ëµåµéÀº 'DECL' ³ëµå ÀÏ°ÍÀÌ´Ù. FIELD_DECL
Àº ºñÁ¤Àû µ¥ÀÌŸ ¸â¹ö¸¦ Ç¥ÇöÇϱâ À§ÇØ ±×¸®°í, VAR_DECL
Àº Á¤Àû µ¥ÀÌŸ ¸â¹ö¸¦ Ç¥ÇöÇϱâ À§ÇØ »ç¿ëµÈ´Ù. ¶ÇÇÑ TYPE_DECL
Àº ŸÀÔÀ» ³ªÅ¸³»±â À§ÇØ »ç¿ëµÈ´Ù.
The TYPE_VFIELD
is a compiler-generated field used to point to
virtual function tables. It may or may not appear on the
TYPE_FIELDS
list. However, back-ends should handle the
TYPE_VFIELD
just like all the entries on the TYPE_FIELDS
list.
The function members are available on the TYPE_METHODS
list.
Again, subsequent members are found by following the TREE_CHAIN
field. If a function is overloaded, each of the overloaded functions
appears; no OVERLOAD
nodes appear on the TYPE_METHODS
list. Implicitly declared functions (including default constructors,
copy constructors, assignment operators, and destructors) will appear on
this list as well.
Every class has an associated binfo, which can be obtained with
TYPE_BINFO
. Binfos are used to represent base-classes. The
binfo given by TYPE_BINFO
is the degenerate case, whereby every
class is considered to be its own base-class. The base classes for a
particular binfo can be obtained with BINFO_BASETYPES
. These
base-classes are themselves binfos. The class type associated with a
binfo is given by BINFO_TYPE
. It is always the case that
BINFO_TYPE (TYPE_BINFO (x))
is the same type as x
, up to
qualifiers. However, it is not always the case that TYPE_BINFO
(BINFO_TYPE (y))
is always the same binfo as y
. The reason is
that if y
is a binfo representing a base-class B
of a
derived class D
, then BINFO_TYPE (y)
will be B
, and
TYPE_INFO (BINFO_TYPE (y))
will be B
as its own
base-class, rather than as a base-class of D
.
The BINFO_BASETYPES
is a TREE_VEC
(see section Containers).
Base types appear in left-to-right order in this vector. You can tell
whether or public
, protected
, or private
inheritance was used by using the TREE_VIA_PUBLIC
,
TREE_VIA_PROTECTED
, and TREE_VIA_PRIVATE
macros. Each of
these macros takes a BINFO
and is true if and only if the
indicated kind of inheritance was used. If TREE_VIA_VIRTUAL
holds of a binfo, then its BINFO_TYPE
was inherited from
virtually.
FIXME: Talk about TYPE_NONCOPIED_PARTS
.
The following macros can be used on a tree node representing a class-type.
LOCAL_CLASS_P
TYPE_POLYMORPHIC_P
TYPE_HAS_DEFAULT_CONSTRUCTOR
CLASSTYPE_HAS_MUTABLE
TYPE_HAS_MUTABLE_P
CLASSTYPE_NON_POD_P
TYPE_HAS_NEW_OPERATOR
operator new
.
TYPE_HAS_ARRAY_NEW_OPERATOR
operator new[]
is defined.
TYPE_OVERLOADS_CALL_EXPR
operator()
is overloaded.
TYPE_OVERLOADS_ARRAY_REF
operator[]
TYPE_OVERLOADS_ARROW
operator->
is
overloaded.
Go to the first, previous, next, last section, table of contents.