our
$VERSION
= 0.005_100;
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_hashref
$rperl_source_subgroup
;
my
string
$self_class
=
ref
$self
;
my
string
$semicolon
=
q{}
;
if
(
$self_class
eq
'SubExpressionOrVarMod_168'
) {
$self
=
$self
->{children}->[0];
$self_class
=
ref
$self
;
}
elsif
(
$self_class
eq
'Statement_176'
) {
$semicolon
=
$self
->{children}->[1];
$self
=
$self
->{children}->[0];
$self_class
=
ref
$self
;
}
if
(
$self_class
eq
'VariableModification_206'
) {
my
object
$variable
=
$self
->{children}->[0];
my
string
$assign
=
$self
->{children}->[1];
my
object
$subexpression_or_stdin
=
$self
->{children}->[2];
$rperl_source_subgroup
=
$variable
->ast_to_rperl__generate(
$modes
);
RPerl::Generator::source_group_append(
$rperl_source_group
,
$rperl_source_subgroup
);
$rperl_source_group
->{PMC} .=
q{ }
.
$assign
.
q{ }
;
$rperl_source_subgroup
=
$subexpression_or_stdin
->ast_to_rperl__generate(
$modes
);
RPerl::Generator::source_group_append(
$rperl_source_group
,
$rperl_source_subgroup
);
}
elsif
(
$self_class
eq
'VariableModification_207'
) {
my
object
$variable
=
$self
->{children}->[0];
my
string
$assign_by
=
$self
->{children}->[1];
my
object
$subexpression
=
$self
->{children}->[2];
$rperl_source_subgroup
=
$variable
->ast_to_rperl__generate(
$modes
);
RPerl::Generator::source_group_append(
$rperl_source_group
,
$rperl_source_subgroup
);
$rperl_source_group
->{PMC} .=
q{ }
.
$assign_by
.
q{ }
;
$rperl_source_subgroup
=
$subexpression
->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 SubExpressionOrVarMod_168, Statement_176, VariableModification_206, or VariableModification_207 expected, dying'
) .
"\n"
;
}
$rperl_source_group
->{PMC} .=
$semicolon
.
"\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::S::VM __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_hashref
$cpp_source_subgroup
;
my
string
$self_class
=
ref
$self
;
my
string
$semicolon
=
undef
;
if
(
$self_class
eq
'SubExpressionOrVarMod_168'
) {
$self
=
$self
->{children}->[0];
$self_class
=
ref
$self
;
}
elsif
(
$self_class
eq
'Statement_176'
) {
$semicolon
=
$self
->{children}->[1];
$self
=
$self
->{children}->[0];
$self_class
=
ref
$self
;
}
if
(
$self_class
eq
'VariableModification_206'
) {
my
object
$variable
=
$self
->{children}->[0];
my
string
$assign
=
$self
->{children}->[1];
my
object
$subexpression_or_stdin
=
$self
->{children}->[2];
my
boolean
$rhs_is_constructor_call
= 0;
my
boolean
$lhs_is_variable_retrieval
= 0;
if
(
((
ref
$subexpression_or_stdin
) eq
'SubExpressionOrInput_164'
) and
(
exists
$subexpression_or_stdin
->{children}) and
(
defined
$subexpression_or_stdin
->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]) and
((
ref
$subexpression_or_stdin
->{children}->[0]) eq
'SubExpression_155'
) and
(
exists
$subexpression_or_stdin
->{children}->[0]->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]->{children}->[0]) and
((
ref
$subexpression_or_stdin
->{children}->[0]->{children}->[0]) eq
'Expression_154'
)
) {
$rhs_is_constructor_call
= 1;
}
if
(
$rhs_is_constructor_call
and
((
ref
$variable
) eq
'Variable_198'
) and
(
exists
$variable
->{children}) and
(
defined
$variable
->{children}) and
(
defined
$variable
->{children}->[1]) and
((
ref
$variable
->{children}->[1]) eq
'_STAR_LIST'
) and
(
exists
$variable
->{children}->[1]->{children}) and
(
defined
$variable
->{children}->[1]->{children})
) {
foreach
my
object
$lhs_object
(@{
$variable
->{children}->[1]->{children}}) {
if
(
((
ref
$lhs_object
) eq
'VariableRetrieval_199'
) or
((
ref
$lhs_object
) eq
'VariableRetrieval_200'
) or
((
ref
$lhs_object
) eq
'VariableRetrieval_201'
)
) {
$lhs_is_variable_retrieval
= 1;
}
}
}
my
boolean
$rhs_is_undef
= 0;
my
boolean
$lhs_is_array_retrieval_minus_one
= 0;
if
(not (
$rhs_is_constructor_call
or
$lhs_is_variable_retrieval
)) {
if
(
((
ref
$subexpression_or_stdin
) eq
'SubExpressionOrInput_164'
) and
(
exists
$subexpression_or_stdin
->{children}) and
(
defined
$subexpression_or_stdin
->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]) and
((
ref
$subexpression_or_stdin
->{children}->[0]) eq
'SubExpression_156'
)
) {
$rhs_is_undef
= 1;
}
if
(
$rhs_is_undef
and
((
ref
$variable
) eq
'Variable_198'
) and
(
exists
$variable
->{children}) and
(
defined
$variable
->{children}) and
(
defined
$variable
->{children}->[1]) and
((
ref
$variable
->{children}->[1]) eq
'_STAR_LIST'
) and
(
exists
$variable
->{children}->[1]->{children}) and
(
defined
$variable
->{children}->[1]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]) and
((
ref
$variable
->{children}->[1]->{children}->[-1]) eq
'VariableRetrieval_199'
) and
(
exists
$variable
->{children}->[1]->{children}->[-1]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]) and
((
ref
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]) eq
'SubExpression_155'
) and
(
exists
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]) and
((
ref
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]) eq
'Expression_149'
) and
(
exists
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]) and
((
ref
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]) eq
'Operator_113'
) and
(
exists
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[1]) and
(
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[1] eq
'- '
) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]) and
((
ref
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]) eq
'SubExpression_157'
) and
(
exists
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]) and
((
ref
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]) eq
'Literal_255'
) and
(
exists
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}) and
(
defined
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[0]) and
(
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[2]->{children}->[0]->{children}->[0] eq
'1'
)
) {
$lhs_is_array_retrieval_minus_one
= 1;
}
}
if
(
$rhs_is_constructor_call
and
$lhs_is_variable_retrieval
) {
$cpp_source_subgroup
=
$variable
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
my
string
$lhs
=
$cpp_source_subgroup
->{CPP};
my
string
$lhs_underscores
=
$lhs
;
$lhs_underscores
=~ s/->/__/g;
$lhs_underscores
=~ s/\[(.*)\]/__$1/g;
my
string
$rhs_class_underscores
;
if
(
(
exists
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]) and
(
((
ref
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]) eq
'WordScoped_238'
) or
((
ref
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]) eq
'WordScoped_239'
)
) and
(
exists
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]->{children}) and
(
defined
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0])
) {
$rhs_class_underscores
=
$subexpression_or_stdin
->{children}->[0]->{children}->[0]->{children}->[0]->{children}->[0];
$rhs_class_underscores
=~ s/:/_/g;
}
else
{
die
'ERROR ECOGEASCP089, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Object constructor move semantics detected, but RHS class name not found where expected, dying'
.
"\n"
;
}
$cpp_source_group
->{CPP} .=
$rhs_class_underscores
.
'_ptr '
.
$lhs_underscores
.
'{new '
.
$rhs_class_underscores
.
'()}; '
;
$cpp_source_group
->{CPP} .=
$lhs
.
' = std::move('
.
$lhs_underscores
.
')'
;
}
elsif
(
$rhs_is_undef
and
$lhs_is_array_retrieval_minus_one
) {
my
unknown
$size
=
$variable
->{children}->[1]->{children}->[-1]->{children}->[1]->{children}->[0]->{children}->[0]->{children}->[0];
delete
$variable
->{children}->[1]->{children}->[-1];
$cpp_source_subgroup
=
$variable
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
$cpp_source_group
->{CPP} .=
'.resize('
;
$cpp_source_subgroup
=
$size
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
$cpp_source_group
->{CPP} .=
')'
;
}
else
{
$cpp_source_subgroup
=
$variable
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
$cpp_source_group
->{CPP} .=
q{ }
.
$assign
.
q{ }
;
$cpp_source_subgroup
=
$subexpression_or_stdin
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
}
}
elsif
(
$self_class
eq
'VariableModification_207'
) {
my
object
$variable
=
$self
->{children}->[0];
my
string
$assign_by
=
$self
->{children}->[1];
my
object
$subexpression
=
$self
->{children}->[2];
$cpp_source_subgroup
=
$variable
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
$cpp_source_group
->{CPP} .=
q{ }
.
$assign_by
.
q{ }
;
$cpp_source_subgroup
=
$subexpression
->ast_to_cpp__generate__CPPOPS_CPPTYPES(
$modes
);
RPerl::Generator::source_group_append(
$cpp_source_group
,
$cpp_source_subgroup
);
}
else
{
die
RPerl::Parser::rperl_rule__replace(
'ERROR ECOGEASCP000, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule '
.
$self_class
.
' found where SubExpressionOrVarMod_168, Statement_176, VariableModification_206, or VariableModification_207 expected, dying'
) .
"\n"
;
}
if
(
defined
$semicolon
) {
$cpp_source_group
->{CPP} .=
$semicolon
.
"\n"
;
}
return
$cpp_source_group
;
}
1;