our
$VERSION
= 0.011_000;
our
hashref
$properties
= {};
sub
ast_to_rperl__generate {
{
my
string_hashref::method
$RETURN_TYPE
};
(
my
object
$self
,
my
string_hashref
$modes
) =
@ARG
;
my
string_hashref
$rperl_source_group
= {
PMC
=>
q{}
};
my
string
$self_class
=
ref
$self
;
if
( (
$self_class
eq
'SubExpression_158'
) or (
$self_class
eq
'VariableOrLiteral_248'
) or (
$self_class
eq
'VarOrLitOrOpStrOrWord_250'
) ) {
$self
=
$self
->{children}->[0];
}
$self_class
=
ref
$self
;
if
(
$self_class
eq
'Variable_198'
) {
my
string
$symbol_or_self
=
$self
->{children}->[0]->{children}->[0];
$rperl_source_group
->{PMC} .=
$symbol_or_self
;
foreach
my
object
$variable_retrieval
( @{
$self
->{children}->[1]->{children} } ) {
my
string_hashref
$rperl_source_subgroup
=
$variable_retrieval
->ast_to_rperl__generate(
$modes
);
RPerl::Generator::source_group_append(
$rperl_source_group
,
$rperl_source_subgroup
);
}
}
else
{
die
RPerl::Parser::rperl_rule__replace(
'ERROR ECOGEASRP000, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule '
. (
$self_class
)
.
' found where SubExpression_158, VariableOrLiteral_248, VarOrLitOrOpStrOrWord_250, or Variable_198 expected, dying'
)
.
"\n"
;
}
return
$rperl_source_group
;
}
sub
ast_to_cpp__generate__CPPOPS_PERLTYPES {
{
my
string_hashref::method
$RETURN_TYPE
};
(
my
object
$self
,
my
string_hashref
$modes
) =
@ARG
;
my
string_hashref
$cpp_source_group
= {
CPP
=>
q{// <<< RP::O::E::SE::V __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>}
.
"\n"
};
return
$cpp_source_group
;
}
sub
ast_to_cpp__generate__CPPOPS_CPPTYPES {
{
my
string_hashref::method
$RETURN_TYPE
};
(
my
object
$self
,
my
string_hashref
$modes
) =
@ARG
;
my
string_hashref
$cpp_source_group
= {
CPP
=>
q{}
};
my
string
$self_class
=
ref
$self
;
if
( (
$self_class
eq
'SubExpression_158'
) or (
$self_class
eq
'VariableOrLiteral_248'
) or (
$self_class
eq
'VarOrLitOrOpStrOrWord_250'
) ) {
$self
=
$self
->{children}->[0];
}
$self_class
=
ref
$self
;
if
(
$self_class
eq
'Variable_198'
) {
my
string
$symbol_or_self
=
$self
->{children}->[0]->{children}->[0];
my
string_arrayref
$types
= [];
substr
$symbol_or_self
, 0, 1,
q{}
;
if
(
$symbol_or_self
eq
'self'
) {
$symbol_or_self
=
'this'
;
$types
->[0] =
$modes
->{_symbol_table}->{_namespace};
}
else
{
$types
->[0] =
$modes
->{_symbol_table}->{
$modes
->{_symbol_table}->{_namespace} }->{
$modes
->{_symbol_table}->{_subroutine} }->{
$symbol_or_self
}->{type};
}
$cpp_source_group
->{CPP} =
$symbol_or_self
;
my
integer
$i_max
= (
scalar
@{
$self
->{children}->[1]->{children} } ) - 1;
for
my
integer
$i
( 0 ..
$i_max
) {
my
object
$variable_retrieval
=
$self
->{children}->[1]->{children}->[
$i
];
my
string_hashref
$cpp_source_subgroup
=
$variable_retrieval
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$symbol_or_self
,
$types
->[
$i
],
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
if
(
$i
<
$i_max
) {
if
(
$types
->[
$i
] =~ /_arrayref$/ ) {
$types
->[
$i
+ 1 ] =
substr
$types
->[
$i
], 0, ( (
length
$types
->[
$i
] ) - 9 );
}
elsif
(
$types
->[
$i
] =~ /_hashref$/ ) {
$types
->[
$i
+ 1 ] =
substr
$types
->[
$i
], 0, ( (
length
$types
->[
$i
] ) - 8 );
}
elsif
(
$types
->[
$i
] =~ /sse_number_pair$/xms ) {
$types
->[
$i
+ 1 ] =
'number'
;
}
elsif
(
exists
$rperlnamespaces_generated::RPERL
->{
$types
->[
$i
] .
'::'
} ) {
die
'ERROR ECOGEASCP030, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not retrieve data subcomponent from scalar type '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
else
{
if
( (
ref
$variable_retrieval
) eq
'VariableRetrieval_200'
) {
my
object
$subexpression
=
$variable_retrieval
->{children}->[1];
if
(( (
ref
$subexpression
) eq
'SubExpression_157'
)
or ( (
ref
$subexpression
) eq
'VariableOrLiteral_249'
)
or ( (
ref
$subexpression
) eq
'VarOrLitOrOpStrOrWord_251'
)
)
{
my
string
$number_or_string_literal
=
$subexpression
->{children}->[0]->{children}->[0];
$number_or_string_literal
=
eval
"return $number_or_string_literal"
;
if
((
substr
$types
->[
$i
], -2, 2) ne
'::'
) {
$types
->[
$i
] .=
'::'
; }
if
(
exists
$modes
->{_symbol_table}->{
$types
->[
$i
] }->{_properties}->{
$number_or_string_literal
} ) {
$types
->[
$i
+ 1 ] =
$modes
->{_symbol_table}->{
$types
->[
$i
] }->{_properties}->{
$number_or_string_literal
}->{type};
}
else
{
my
$parent_package_names
= RPerl::CompileUnit::Module::Class::parent_and_grandparent_package_names(
substr
$types
->[
$i
], 0, -2);
my
boolean
$property_found
= 0;
foreach
my
$parent_package_name
(@{
$parent_package_names
}) {
if
(
exists
$modes
->{_symbol_table}->{
$parent_package_name
.
q{::}
}->{_properties}->{
$number_or_string_literal
}) {
$types
->[
$i
+ 1 ] =
$modes
->{_symbol_table}->{
$parent_package_name
.
q{::}
}->{_properties}->{
$number_or_string_literal
}->{type};
$property_found
= 1;
last
;
}
}
if
(not
$property_found
) {
if
((not
exists
$modes
->{dependencies}) or
(not
defined
$modes
->{dependencies}) or
(
$modes
->{dependencies} ne
'ON'
)) {
die
'ERROR ECOGEASCP031 #0, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, dependencies disabled, can not verify validity of OO property '
.
$number_or_string_literal
.
' in user-defined class '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
else
{
die
'ERROR ECOGEASCP032 #0, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not retrieve invalid OO property '
.
$number_or_string_literal
.
' in user-defined class '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
}
}
}
else
{
my
string
$subexpression_generated
= (
$subexpression
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
))->{CPP};
die
'ERROR ECOGEASCP033, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not determine OO property name (and thus type) from non-literal subexpression...'
.
"\n"
.
$subexpression_generated
.
"\n"
.
'...in user-defined class '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
}
elsif
( (
ref
$variable_retrieval
) eq
'VariableRetrieval_201'
) {
if
((
substr
$types
->[
$i
], -2, 2) ne
'::'
) {
$types
->[
$i
] .=
'::'
; }
my
string
$word
=
$variable_retrieval
->{children}->[1];
if
(
exists
$modes
->{_symbol_table}->{
$types
->[
$i
] }->{_properties}->{
$word
} ) {
$types
->[
$i
+ 1 ] =
$modes
->{_symbol_table}->{
$types
->[
$i
] }->{_properties}->{
$word
}->{type};
}
else
{
my
$parent_package_names
= RPerl::CompileUnit::Module::Class::parent_and_grandparent_package_names(
substr
$types
->[
$i
], 0, -2);
my
boolean
$property_found
= 0;
foreach
my
$parent_package_name
(@{
$parent_package_names
}) {
if
(
exists
$modes
->{_symbol_table}->{
$parent_package_name
.
q{::}
}->{_properties}->{
$word
}) {
$types
->[
$i
+ 1 ] =
$modes
->{_symbol_table}->{
$parent_package_name
.
q{::}
}->{_properties}->{
$word
}->{type};
$property_found
= 1;
last
;
}
}
if
(not
$property_found
) {
if
((not
exists
$modes
->{dependencies}) or
(not
defined
$modes
->{dependencies}) or
(
$modes
->{dependencies} ne
'ON'
)) {
die
'ERROR ECOGEASCP031 #1, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, dependencies disabled, can not verify validity of OO property '
.
$word
.
' in user-defined class '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
else
{
die
'ERROR ECOGEASCP031 #2, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not retrieve invalid OO property '
.
$word
.
' in user-defined class '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
}
}
}
else
{
die
'ERROR ECOGEASCP034, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Variable retrieval, can not use arrayref retrieval on object of user-defined class '
.
$types
->[
$i
] .
', dying'
.
"\n"
;
}
}
}
}
}
else
{
die
RPerl::Parser::rperl_rule__replace(
'ERROR ECOGEASCP000, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
. (
$self_class
)
.
' found where SubExpression_158, VariableOrLiteral_248, VarOrLitOrOpStrOrWord_250, or Variable_198 expected, dying'
)
.
"\n"
;
}
return
$cpp_source_group
;
}
1;