From 20acfc71606167434a8f95d5d4d97fa126b96351 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Wed, 20 Dec 2023 12:44:56 -0500 Subject: [PATCH 01/18] EidosValue design overhaul, step 1 --- core/chromosome.cpp | 9 +- core/community_eidos.cpp | 2 +- core/genome.cpp | 8 +- core/individual.cpp | 59 +++--- core/interaction_type.cpp | 4 +- core/mutation.cpp | 4 +- core/mutation_type.cpp | 4 +- core/population.cpp | 12 +- core/slim_eidos_block.cpp | 2 +- core/slim_functions.cpp | 30 +-- core/slim_globals.cpp | 2 +- core/slim_globals.h | 2 +- core/spatial_map.cpp | 14 +- core/species_eidos.cpp | 16 +- core/subpopulation.cpp | 34 ++-- eidos/eidos_class_Dictionary.cpp | 24 +-- eidos/eidos_class_TestElement.cpp | 2 +- eidos/eidos_functions.cpp | 84 ++++---- eidos/eidos_functions_distributions.cpp | 38 ++-- eidos/eidos_functions_files.cpp | 4 +- eidos/eidos_functions_math.cpp | 213 ++++++++++---------- eidos/eidos_functions_matrices.cpp | 18 +- eidos/eidos_functions_other.cpp | 4 +- eidos/eidos_functions_stats.cpp | 110 +++++------ eidos/eidos_functions_strings.cpp | 12 +- eidos/eidos_functions_values.cpp | 128 ++++++------ eidos/eidos_interpreter.cpp | 246 ++++++++++++------------ eidos/eidos_value.cpp | 181 ++++------------- eidos/eidos_value.h | 138 ++++++------- 29 files changed, 643 insertions(+), 761 deletions(-) diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 2492954cd..7d6089b78 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -2041,8 +2041,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setAncestralNucleotides(EidosGlobalStrin else { // non-singleton, direct access - const EidosValue_Int_vector *int_vec = sequence_value->IntVector(); - const int64_t *int_data = int_vec->data(); + const int64_t *int_data = sequence_value->IntData(); ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, int_data); } @@ -2052,13 +2051,13 @@ EidosValue_SP Chromosome::ExecuteMethod_setAncestralNucleotides(EidosGlobalStrin if (sequence_value_count != 1) { // A vector of characters has been provided, which must all be "A" / "C" / "G" / "T" - const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_data = sequence_value->StringData(); - ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, *string_vec); + ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, string_data); } else // sequence_value_count == 1 { - const std::string &sequence_string = sequence_value->IsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &sequence_string = sequence_value->StringData()[0]; bool contains_only_nuc = true; // OK, we do a weird thing here. We want to try to construct a NucleotideArray diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index d9b6bfc9c..93e2a2127 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -417,7 +417,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) // variables case gID_tick: { - if (cached_value_tick_ && (((EidosValue_Int_singleton *)cached_value_tick_.get())->IntValue() != tick_)) + if (cached_value_tick_ && (cached_value_tick_->IntData()[0] != tick_)) cached_value_tick_.reset(); if (!cached_value_tick_) cached_value_tick_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tick_)); diff --git a/core/genome.cpp b/core/genome.cpp index 1f6011b8b..ddfaa6f0a 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -570,7 +570,7 @@ void Genome::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Genome *)(p_values[value_index]))->tag_value_ = source_data[value_index]; @@ -767,7 +767,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMutations(EidosObject ** EidosValue_SP result(logical_result); int64_t result_index = 0; - EidosObject * const *mutations_data = mutations_value->ObjectElementVector()->data(); + EidosObject * const *mutations_data = mutations_value->ObjectData(); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) { @@ -1181,7 +1181,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, else { // vector case: replace the appropriate element in char_value - std::vector *char_vec = ((EidosValue_String_vector *)(char_value.get()))->StringVector_Mutable(); + std::string &char_vec = char_value->StringData_Mutable()[0]; GenomeWalker walker(this); walker.MoveToPosition(start); @@ -1198,7 +1198,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, int8_t nuc = mut->nucleotide_; if (nuc != -1) - (*char_vec)[pos - start] = gSLiM_Nucleotides[nuc]; + char_vec[pos - start] = gSLiM_Nucleotides[nuc]; walker.NextMutation(); } diff --git a/core/individual.cpp b/core/individual.cpp index 73a305d82..201fd22c4 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -1245,7 +1245,7 @@ void Individual::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_va } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->tag_value_ = source_data[value_index]; @@ -1266,7 +1266,7 @@ void Individual::SetProperty_Accelerated_tagF(EidosObject **p_values, size_t p_v } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->tagF_value_ = source_data[value_index]; @@ -1277,9 +1277,11 @@ void Individual::SetProperty_Accelerated_tagL0(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1291,7 +1293,6 @@ void Individual::SetProperty_Accelerated_tagL0(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1307,9 +1308,11 @@ void Individual::SetProperty_Accelerated_tagL1(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1321,8 +1324,6 @@ void Individual::SetProperty_Accelerated_tagL1(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1337,9 +1338,11 @@ void Individual::SetProperty_Accelerated_tagL2(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1351,8 +1354,6 @@ void Individual::SetProperty_Accelerated_tagL2(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1367,9 +1368,11 @@ void Individual::SetProperty_Accelerated_tagL3(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1381,8 +1384,6 @@ void Individual::SetProperty_Accelerated_tagL3(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1397,9 +1398,11 @@ void Individual::SetProperty_Accelerated_tagL4(EidosObject **p_values, size_t p_ { s_any_individual_tagL_set_ = true; + const eidos_logical_t *source_data = p_source.LogicalData(); + if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = source_data[0]; for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1411,8 +1414,6 @@ void Individual::SetProperty_Accelerated_tagL4(EidosObject **p_values, size_t p_ } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); - for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); @@ -1478,7 +1479,7 @@ void Individual::SetProperty_Accelerated_fitnessScaling(EidosObject **p_values, } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); needs_raise = _SetFitnessScaling_N(source_data, p_values, p_values_size); } @@ -1498,7 +1499,7 @@ void Individual::SetProperty_Accelerated_x(EidosObject **p_values, size_t p_valu } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_x_ = source_data[value_index]; @@ -1516,7 +1517,7 @@ void Individual::SetProperty_Accelerated_y(EidosObject **p_values, size_t p_valu } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_y_ = source_data[value_index]; @@ -1534,7 +1535,7 @@ void Individual::SetProperty_Accelerated_z(EidosObject **p_values, size_t p_valu } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_z_ = source_data[value_index]; @@ -1573,12 +1574,12 @@ void Individual::SetProperty_Accelerated_color(EidosObject **p_values, size_t p_ } else { - const std::vector *source_data = p_source.StringVector(); + const std::string *source_data = p_source.StringData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { Individual *individual = ((Individual *)(p_values[value_index])); - const std::string &source_value = (*source_data)[value_index]; + const std::string &source_value = source_data[value_index]; if (source_value.empty()) { @@ -1606,7 +1607,7 @@ void Individual::SetProperty_Accelerated_age(EidosObject **p_values, size_t p_va } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->age_ = SLiMCastToAgeTypeOrRaise(source_data[value_index]); @@ -2282,8 +2283,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri } else if (target_size > 1) { - const EidosValue_Object_vector *target_vec = p_target->ObjectElementVector(); - Individual * const *targets = (Individual * const *)(target_vec->data()); + Individual * const *targets = (Individual * const *)(p_target->ObjectData()); dimensionality = targets[0]->subpopulation_->species_.SpatialDimensionality(); @@ -2333,8 +2333,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri else if (target_size > 1) { // Vector target case, one point - const EidosValue_Object_vector *target_vec = p_target->ObjectElementVector(); - Individual * const *targets = (Individual * const *)(target_vec->data()); + Individual * const *targets = (Individual * const *)(p_target->ObjectData()); switch (dimensionality) { @@ -2391,10 +2390,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri else if (value_count == dimensionality * target_size) { // Vector target case, one point per target (so the point vector has to be non-singleton too) - const EidosValue_Object_vector *target_vec = p_target->ObjectElementVector(); - Individual * const *targets = (Individual * const *)(target_vec->data()); - const EidosValue_Float_vector *position_vec = position_value->FloatVector(); - const double *positions = position_vec->data(); + Individual * const *targets = (Individual * const *)(p_target->ObjectData()); + const double *positions = position_value->FloatData(); #ifdef _OPENMP if (((dimensionality == 1) && (target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_2_1D)) || diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 43178040f..1424e7320 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -3698,7 +3698,7 @@ EidosValue_SP InteractionType::ExecuteMethod_clippedIntegral(EidosGlobalStringID } else { - receivers_data = (Individual * const *)receivers_value->ObjectElementVector()->data(); + receivers_data = (Individual * const *)receivers_value->ObjectData(); } InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receivers_data[0]->subpopulation_); @@ -6159,7 +6159,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID else { // non-singleton case - Individual * const *inds = (Individual * const *)individuals_value->ObjectElementVector()->data(); + Individual * const *inds = (Individual * const *)individuals_value->ObjectData(); if (returnIndividuals) { diff --git a/core/mutation.cpp b/core/mutation.cpp index f9f87306c..2d9f049d3 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -669,7 +669,7 @@ void Mutation::SetProperty_Accelerated_subpopID(EidosObject **p_values, size_t p } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Mutation *)(p_values[value_index]))->subpop_index_ = SLiMCastToObjectidTypeOrRaise(source_data[value_index]); @@ -688,7 +688,7 @@ void Mutation::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_valu } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Mutation *)(p_values[value_index]))->tag_value_ = source_data[value_index]; diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index 723f97bed..f75ffc340 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -688,7 +688,7 @@ void MutationType::SetProperty_Accelerated_convertToSubstitution(EidosObject **p } else { - const eidos_logical_t *source_data = p_source.LogicalVector()->data(); + const eidos_logical_t *source_data = p_source.LogicalData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((MutationType *)(p_values[value_index]))->convert_to_substitution_ = source_data[value_index]; @@ -707,7 +707,7 @@ void MutationType::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_ } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((MutationType *)(p_values[value_index]))->tag_value_ = source_data[value_index]; diff --git a/core/population.cpp b/core/population.cpp index 0c25400e3..880a3aa51 100644 --- a/core/population.cpp +++ b/core/population.cpp @@ -826,13 +826,8 @@ slim_popsize_t Population::ApplyMateChoiceCallbacks(slim_popsize_t p_parent1_ind weights_modified = true; } - // We really want to use EidosValue_Float_vector's FloatVector() method to get the values; - // if we have an EidosValue_Float_singleton we have to get its value with FloatAtIndex. - // BCH 1/18/2018: IsSingleton() should be much faster than the dynamic_cast<> used here before - if (!result->IsSingleton()) - memcpy(current_weights, ((EidosValue_Float_vector *)result)->FloatVector()->data(), sizeof(double) * weights_length); - else - current_weights[0] = result->FloatAtIndex(0, nullptr); + // use FloatData() to get the values, copy them with memcpy() + memcpy(current_weights, result->FloatData(), sizeof(double) * weights_length); // remember this callback for error attribution below last_interventionist_mate_choice_callback = mate_choice_callback; @@ -2512,8 +2507,7 @@ bool Population::ApplyRecombinationCallbacks(slim_popsize_t p_parent_index, Geno p_crossovers[0] = (slim_position_t)local_crossovers_ptr->IntAtIndex(0, nullptr); else { - const EidosValue_Int_vector *new_crossover_vector = local_crossovers_ptr->IntVector(); - const int64_t *new_crossover_data = new_crossover_vector->data(); + const int64_t *new_crossover_data = local_crossovers_ptr->IntData(); slim_position_t *p_crossovers_data = p_crossovers.data(); for (int value_index = 0; value_index < count; ++value_index) diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 6c849d5a0..324a29585 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -1731,7 +1731,7 @@ void SLiMTypeInterpreter::_SetTypeForISArgumentOfClass(const EidosASTNode *p_arg // The argument can be numeric, in which case it must have a cached int value that is singleton and within bounds EidosValue *cached_value = p_arg_node->cached_literal_value_.get(); - if (cached_value && (cached_value->Type() == EidosValueType::kValueInt) && (cached_value->IsSingleton())) + if (cached_value && (cached_value->Type() == EidosValueType::kValueInt) && (cached_value->Count() == 1)) { int64_t cached_int = cached_value->IntAtIndex(0, nullptr); diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index 2d5bb27e0..beec1e433 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -610,7 +610,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorIntVector()->data(); + const int64_t *int_data = codons_value->IntData(); if (integer_result) { @@ -639,7 +639,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &aa_string = string_result->StringValue_Mutable(); + std::string &aa_string = string_result->StringData_Mutable()[0]; aa_string.resize(codons_length * 4 - 1); // create space for all the amino acids we will generate, including hyphens @@ -669,7 +669,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &aa_string = string_result->StringValue_Mutable(); + std::string &aa_string = string_result->StringData_Mutable()[0]; aa_string.resize(codons_length); // create space for all the amino acids we will generate @@ -726,7 +726,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vectorIsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &string_ref = sequence_value->StringData()[0]; int64_t length = (int64_t)string_ref.length(); if (length % 3 != 0) @@ -770,15 +770,15 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_vec = sequence_value->StringData(); for (int value_index = 0; value_index < length_3; ++value_index) { int64_t codon_base = (size_t)value_index * 3; - const std::string &nucstring1 = (*string_vec)[codon_base]; - const std::string &nucstring2 = (*string_vec)[codon_base + 1]; - const std::string &nucstring3 = (*string_vec)[codon_base + 2]; + const std::string &nucstring1 = string_vec[codon_base]; + const std::string &nucstring2 = string_vec[codon_base + 1]; + const std::string &nucstring3 = string_vec[codon_base + 2]; if ((nucstring1.length() != 1) || (nucstring2.length() != 1) || (nucstring3.length() != 1)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_nucleotidesToCodons): function nucleotidesToCodons() requires string sequence values to be 'A', 'C', 'G', or 'T'." << EidosTerminate(nullptr); @@ -798,7 +798,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vectorIntVector()->data(); + const int64_t *int_data = sequence_value->IntData(); for (int value_index = 0; value_index < length_3; ++value_index) { @@ -841,7 +841,7 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co else // sequence_type == EidosValueType::kValueString { uint8_t *nuc_lookup = NucleotideArray::NucleotideCharToIntLookup(); - const std::string &string_ref = sequence_value->IsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &string_ref = sequence_value->StringData()[0]; std::size_t length = string_ref.length(); for (std::size_t i = 0; i < length; ++i) @@ -861,7 +861,7 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co // Vector case, optimized for speed if (sequence_type == EidosValueType::kValueInt) { - const int64_t *int_data = sequence_value->IntVector()->data(); + const int64_t *int_data = sequence_value->IntData(); for (int value_index = 0; value_index < sequence_count; ++value_index) { @@ -876,11 +876,11 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co else // sequence_type == EidosValueType::kValueString { uint8_t *nuc_lookup = NucleotideArray::NucleotideCharToIntLookup(); - const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_vec = sequence_value->StringData(); for (int value_index = 0; value_index < sequence_count; ++value_index) { - const std::string &nuc_string = (*string_vec)[value_index]; + const std::string &nuc_string = string_vec[value_index]; if (nuc_string.length() != 1) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_" << function_name << "): function " << function_name << "() requires string sequence values to be 'A', 'C', 'G', or 'T'." << EidosTerminate(nullptr); @@ -1165,7 +1165,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &nuc_string = string_result->StringValue_Mutable(); + std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate @@ -1269,7 +1269,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); - std::string &nuc_string = string_result->StringValue_Mutable(); + std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate diff --git a/core/slim_globals.cpp b/core/slim_globals.cpp index b6484bf76..9bda0d460 100644 --- a/core/slim_globals.cpp +++ b/core/slim_globals.cpp @@ -780,7 +780,7 @@ NucleotideArray::NucleotideArray(std::size_t p_length, const char *p_char_buffer } } -NucleotideArray::NucleotideArray(std::size_t p_length, const std::vector &p_string_vector) : length_(p_length) +NucleotideArray::NucleotideArray(std::size_t p_length, const std::string p_string_vector[]) : length_(p_length) { buffer_ = (uint64_t *)malloc(((length_ + 31) / 32) * sizeof(uint64_t)); if (!buffer_) diff --git a/core/slim_globals.h b/core/slim_globals.h index 3405b2bfa..5e61259a8 100644 --- a/core/slim_globals.h +++ b/core/slim_globals.h @@ -662,7 +662,7 @@ class NucleotideArray // should therefore generally be called from a try/catch block. NucleotideArray(std::size_t p_length, const int64_t *p_int_buffer); NucleotideArray(std::size_t p_length, const char *p_char_buffer); - NucleotideArray(std::size_t p_length, const std::vector &p_string_vector); + NucleotideArray(std::size_t p_length, const std::string p_string_vector[]); std::size_t size() const { return length_; } diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index 755179476..89e95f9b0 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -291,7 +291,7 @@ void SpatialMap::TakeColorsFromEidosValues(EidosValue *p_value_range, EidosValue if (!red_components_ || !green_components_ || !blue_components_) EIDOS_TERMINATION << "ERROR (" << p_code_name << "): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); - const std::string *colors_vec_ptr = p_colors->StringVector()->data(); + const std::string *colors_vec_ptr = p_colors->StringData(); for (int colors_index = 0; colors_index < n_colors_; ++colors_index) Eidos_GetColorComponents(colors_vec_ptr[colors_index], red_components_ + colors_index, green_components_ + colors_index, blue_components_ + colors_index); @@ -338,8 +338,8 @@ void SpatialMap::TakeValuesFromEidosValue(EidosValue *p_values, const std::strin EIDOS_TERMINATION << "ERROR (" << p_code_name << "): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); // Take the values we were passed in - const double *values_float_vec_ptr = (p_values->Type() == EidosValueType::kValueFloat) ? p_values->FloatVector()->data() : nullptr; - const int64_t *values_integer_vec_ptr = (p_values->Type() == EidosValueType::kValueInt) ? p_values->IntVector()->data() : nullptr; + const double *values_float_vec_ptr = (p_values->Type() == EidosValueType::kValueFloat) ? p_values->FloatData() : nullptr; + const int64_t *values_integer_vec_ptr = (p_values->Type() == EidosValueType::kValueInt) ? p_values->IntData() : nullptr; if (spatiality_ == 1) { @@ -2148,9 +2148,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleImprovedNearbyPoint(EidosGlobalStr bool periodic = periodic_a_; // now guaranteed to apply to all dimensions - const EidosValue_Float_vector *point_vec = (point_count == 1) ? nullptr : point_value->FloatVector(); - double point_singleton = (point_count == 1) ? point_value->FloatAtIndex(0, nullptr) : 0.0; - const double *point_buf = (point_count == 1) ? &point_singleton : point_vec->data(); + const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(point_count); @@ -2378,9 +2376,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleNearbyPoint(EidosGlobalStringID p_ bool periodic = periodic_a_; // now guaranteed to apply to all dimensions - const EidosValue_Float_vector *point_vec = (point_count == 1) ? nullptr : point_value->FloatVector(); - double point_singleton = (point_count == 1) ? point_value->FloatAtIndex(0, nullptr) : 0.0; - const double *point_buf = (point_count == 1) ? &point_singleton : point_vec->data(); + const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(point_count); diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index 1ff5809a3..f86015b31 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -82,8 +82,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeAncestralNucleotides(con else { // non-singleton, direct access - const EidosValue_Int_vector *int_vec = sequence_value->IntVector(); - const int64_t *int_data = int_vec->data(); + const int64_t *int_data = sequence_value->IntData(); chromosome_->ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, int_data); } @@ -93,13 +92,13 @@ EidosValue_SP Species::ExecuteContextFunction_initializeAncestralNucleotides(con if (sequence_value_count != 1) { // A vector of characters has been provided, which must all be "A" / "C" / "G" / "T" - const std::vector *string_vec = sequence_value->StringVector(); + const std::string *string_data = sequence_value->StringData(); - chromosome_->ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, *string_vec); + chromosome_->ancestral_seq_buffer_ = new NucleotideArray(sequence_value_count, string_data); } else // sequence_value_count == 1 { - const std::string &sequence_string = sequence_value->IsSingleton() ? ((EidosValue_String_singleton *)sequence_value)->StringValue() : (*sequence_value->StringVector())[0]; + const std::string &sequence_string = sequence_value->StringData()[0]; bool contains_only_nuc = true; // OK, we do a weird thing here. We want to try to construct a NucleotideArray @@ -1623,7 +1622,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_cycle: { - if (cached_value_cycle_ && (((EidosValue_Int_singleton *)cached_value_cycle_.get())->IntValue() != cycle_)) + if (cached_value_cycle_ && (cached_value_cycle_->IntData()[0] != cycle_)) cached_value_cycle_.reset(); if (!cached_value_cycle_) cached_value_cycle_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(cycle_)); @@ -1879,7 +1878,7 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin else { // Non-singleton case: vectorized access to the pedigree IDs - const int64_t *pedigree_id_data = pedigreeIDs_value->IntVector()->data(); + const int64_t *pedigree_id_data = pedigreeIDs_value->IntData(); EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(pedigreeIDs_count); // reserve enough space for all results if (pedigreeIDs_count < 30) // crossover point determined by timing tests on macOS with various subpop sizes; 30 seems good, although it will vary across paltforms etc. @@ -3294,8 +3293,7 @@ EidosValue_SP Species::ExecuteMethod_treeSeqRememberIndividuals(EidosGlobalStrin } else { - const EidosValue_Object_vector *ind_vector = individuals_value->ObjectElementVector(); - EidosObject * const *oe_buffer = ind_vector->data(); + EidosObject * const *oe_buffer = individuals_value->ObjectData(); Individual * const *ind_buffer = (Individual * const *)oe_buffer; AddIndividualsToTable(ind_buffer, ind_count, &tables_, &tabled_individuals_hash_, flag); } diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 839d7dad2..d202b7d16 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -3897,14 +3897,13 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) else { // check that the cache is correct - EidosValue_Object_vector *vec = cached_child_genomes_value_->ObjectElementVector_Mutable(); - const std::vector *vec_direct = vec->ObjectElementVector(); - int vec_size = (int)vec_direct->size(); + const EidosObject * const *vec_direct = cached_child_genomes_value_->ObjectData(); + int vec_size = cached_child_genomes_value_->Count(); if (vec_size == (int)child_genomes_.size()) { for (int i = 0; i < vec_size; ++i) - if ((*vec_direct)[i] != &(child_genomes_[i])) + if (vec_direct[i] != child_genomes_[i]) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): value mismatch in cached_child_genomes_value_." << EidosTerminate(); } else @@ -3928,14 +3927,13 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) else { // check that the cache is correct - EidosValue_Object_vector *vec = cached_parent_genomes_value_->ObjectElementVector_Mutable(); - const std::vector *vec_direct = vec->ObjectElementVector(); - int vec_size = (int)vec_direct->size(); + const EidosObject * const *vec_direct = cached_parent_genomes_value_->ObjectData(); + int vec_size = cached_parent_genomes_value_->Count(); if (vec_size == (int)parent_genomes_.size()) { for (int i = 0; i < vec_size; ++i) - if ((*vec_direct)[i] != &(parent_genomes_[i])) + if (vec_direct[i] != parent_genomes_[i]) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): value mismatch in cached_parent_genomes_value_." << EidosTerminate(); } else @@ -4296,7 +4294,7 @@ void Subpopulation::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Subpopulation *)(p_values[value_index]))->tag_value_ = source_data[value_index]; @@ -4317,7 +4315,7 @@ void Subpopulation::SetProperty_Accelerated_fitnessScaling(EidosObject **p_value } else { - const double *source_data = p_source.FloatVector()->data(); + const double *source_data = p_source.FloatData(); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -5858,9 +5856,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointDeviated(EidosGlobalStringID p_m EidosValue *point_value = p_arguments[1].get(); int point_count = point_value->Count(); - const EidosValue_Float_vector *point_vec = (point_count == 1) ? nullptr : point_value->FloatVector(); - double point_singleton = (point_count == 1) ? point_value->FloatAtIndex(0, nullptr) : 0.0; - const double *point_buf = (point_count == 1) ? &point_singleton : point_vec->data(); + const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; if (point_count % dimensionality != 0) @@ -6220,8 +6216,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointInBounds(EidosGlobalStringID p_m return ((x >= bounds_x0_) && (x <= bounds_x1_)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF; } - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); if (point_count == 1) { @@ -6351,8 +6346,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointReflected(EidosGlobalStringID p_ } // non-singleton general case - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); @@ -6478,8 +6472,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointStopped(EidosGlobalStringID p_me } // non-singleton general case - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); @@ -6583,8 +6576,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointPeriodic(EidosGlobalStringID p_m } // non-singleton general case - const EidosValue_Float_vector *float_vec = point_value->FloatVector(); - const double *point_buf = float_vec->data(); + const double *point_buf = point_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index 93c0fd342..855f44c0b 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -239,15 +239,13 @@ std::string EidosDictionaryUnretained::Serialization_SLiM(void) const // We want to output our keys in the same order as allKeys, so we just use AllKeys() EidosValue_SP all_keys = AllKeys(); - EidosValue_String_vector *string_vec = dynamic_cast(all_keys.get()); + int all_keys_count = all_keys->Count(); + const std::string *all_key_strings = all_keys->StringData(); - if (!string_vec) - EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::Serialization_SLiM): (internal error) allKeys did not return a string vector." << EidosTerminate(nullptr); - - const std::vector *all_key_strings = string_vec->StringVector(); - - for (const std::string &key : *all_key_strings) + for (int key_index = 0; key_index < all_keys_count; ++key_index) { + const std::string key = all_key_strings[key_index]; + // emit the key; note that we now always quote stringkeys, to distinguish them from the integer-key case easily ss << Eidos_string_escaped(key, EidosStringQuoting::kDoubleQuotes) << "="; @@ -446,15 +444,13 @@ nlohmann::json EidosDictionaryUnretained::JSONRepresentation(void) const // We want to output our keys in the same order as allKeys, so we just use AllKeys() EidosValue_SP all_keys = AllKeys(); - EidosValue_String_vector *string_vec = dynamic_cast(all_keys.get()); + int all_keys_count = all_keys->Count(); + const std::string *all_key_strings = all_keys->StringData(); - if (!string_vec) - EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::JSONRepresentation): (internal error) allKeys did not return a string vector." << EidosTerminate(nullptr); - - const std::vector *all_key_strings = string_vec->StringVector(); - - for (const std::string &key : *all_key_strings) + for (int key_index = 0; key_index < all_keys_count; ++key_index) { + const std::string key = all_key_strings[key_index]; + // get the value auto hash_iter = symbols->find(key); diff --git a/eidos/eidos_class_TestElement.cpp b/eidos/eidos_class_TestElement.cpp index 8c2782e78..1b58c0c8d 100644 --- a/eidos/eidos_class_TestElement.cpp +++ b/eidos/eidos_class_TestElement.cpp @@ -116,7 +116,7 @@ void EidosTestElement::SetProperty_Accelerated__yolk(EidosObject **p_elements, s } else { - const int64_t *source_data = p_source.IntVector()->data(); + const int64_t *source_data = p_source.IntData(); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) ((EidosTestElement *)(p_elements[element_index]))->yolk_ = source_data[element_index]; diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 5225ce4ee..400738c11 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -440,8 +440,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa // We have x_count != 1, so we can use the fast vector API; we want identical() to be very fast since it is a common bottleneck if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical_data0 = x_value->LogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) if (logical_data0[value_index] != logical_data1[value_index]) @@ -449,8 +449,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); for (int value_index = 0; value_index < x_count; ++value_index) if (int_data0[value_index] != int_data1[value_index]) @@ -458,8 +458,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data0 = x_value->FloatVector()->data(); - const double *float_data1 = y_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = y_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -473,8 +473,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueString) { - const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); for (int value_index = 0; value_index < x_count; ++value_index) if (string_vec0[value_index] != string_vec1[value_index]) @@ -482,8 +482,8 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *objelement_vec0 = x_value->ObjectElementVector()->data(); - EidosObject * const *objelement_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec0 = x_value->ObjectData(); + EidosObject * const *objelement_vec1 = y_value->ObjectData(); for (int value_index = 0; value_index < x_count; ++value_index) if (objelement_vec0[value_index] != objelement_vec1[value_index]) @@ -596,7 +596,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value_count) // weeds out NULL; otherwise we must have a logical vector { - const eidos_logical_t *arg_data = arg_value->LogicalVector()->data(); + const eidos_logical_t *arg_data = arg_value->LogicalData(); // Unlike the integer and float cases below, memcpy() is much faster for logical values // on OS X 10.12.6, Xcode 8.3; about 1.5 times faster, in fact. So it is a win here. @@ -631,7 +631,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value->Type() == EidosValueType::kValueInt) { // Speed up integer arguments, which are probably common since our result is integer - const int64_t *arg_data = arg_value->IntVector()->data(); + const int64_t *arg_data = arg_value->IntData(); // Annoyingly, memcpy() is actually *slower* here on OS X 10.12.6, Xcode 8.3; a test of the // memcpy() version runs in ~53.3 seconds versus ~48.4 seconds for the loop. So the Clang @@ -672,7 +672,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value->Type() == EidosValueType::kValueFloat) { // Speed up float arguments, which are probably common since our result is float - const double *arg_data = arg_value->FloatVector()->data(); + const double *arg_data = arg_value->FloatData(); // Annoyingly, memcpy() is actually *slower* here on OS X 10.12.6, Xcode 8.3; a test of the // memcpy() version runs in ~53.3 seconds versus ~48.4 seconds for the loop. So the Clang @@ -712,7 +712,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value->Type() == EidosValueType::kValueString) { // Speed up string arguments, which are probably common since our result is string - const std::vector &arg_vec = *arg_value->StringVector(); + const std::string *arg_vec = arg_value->StringData(); for (int value_index = 0; value_index < arg_value_count; ++value_index) result->PushString(arg_vec[value_index]); @@ -747,14 +747,13 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (arg_value_count) { - const EidosValue_Object_vector *object_arg_value = arg_value->ObjectElementVector(); - EidosObject * const *arg_data = object_arg_value->data(); + EidosObject * const *arg_data = arg_value->ObjectData(); // Given the lack of win for memcpy() for integer and float above, I'm not even going to bother checking it for // EidosObject*, since there would also be the complexity of retain/release and DeclareClass() to deal with... // When retain/release of EidosObject is enabled, we go through the accessors so the copied pointers get retained - if (object_arg_value->UsesRetainRelease()) + if (result->UsesRetainRelease()) { for (int value_index = 0; value_index < arg_value_count; ++value_index) result->set_object_element_no_check_no_previous_RR(arg_data[value_index], result_set_index++); @@ -798,7 +797,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec } else if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); bool containsF = false, containsT = false; if (logical_data[0]) @@ -845,7 +844,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueInt) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -885,7 +884,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueFloat) { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -930,7 +929,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueString) { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -938,7 +937,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { for (int value_index = 0; value_index < x_count; ++value_index) { - std::string value = string_vec[value_index]; + const std::string &value = string_vec[value_index]; int scan_index; for (scan_index = 0; scan_index < value_index; ++scan_index) @@ -953,8 +952,13 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec } else { - std::vector dup_vec = string_vec; + std::vector dup_vec; + + // first make a copy of string_vec into dup_vec + for (int value_index = 0; value_index < x_count; ++value_index) + dup_vec.push_back(string_vec[value_index]); + // then sort and unique std::sort(dup_vec.begin(), dup_vec.end()); auto unique_iter = std::unique(dup_vec.begin(), dup_vec.end()); @@ -966,7 +970,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec else if (x_type == EidosValueType::kValueObject) { // We have x_count != 1, so the type of x_value must be EidosValue_Object_vector; we can use the fast API - EidosObject * const *object_data = x_value->ObjectElementVector()->data(); + EidosObject * const *object_data = x_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -1040,7 +1044,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } // Subsetting with a logical vector does not attempt to allocate singleton values, for now; seems unlikely to be a frequently hit case - const eidos_logical_t *logical_index_data = p_indices->LogicalVector()->data(); + const eidos_logical_t *logical_index_data = p_indices->LogicalData(); if (original_value_count == 1) { @@ -1058,7 +1062,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // Here we can special-case each type for speed since we know we're not dealing with singletons if (original_value_type == EidosValueType::kValueLogical) { - const eidos_logical_t *first_child_data = p_original_value->LogicalVector()->data(); + const eidos_logical_t *first_child_data = p_original_value->LogicalData(); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->reserve(indices_count); @@ -1070,7 +1074,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = p_original_value->IntVector()->data(); + const int64_t *first_child_data = p_original_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); @@ -1082,7 +1086,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueFloat) { - const double *first_child_data = p_original_value->FloatVector()->data(); + const double *first_child_data = p_original_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); @@ -1094,7 +1098,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueString) { - const std::vector &first_child_vec = *p_original_value->StringVector(); + const std::string *first_child_vec = p_original_value->StringData(); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); @@ -1106,7 +1110,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } else if (original_value_type == EidosValueType::kValueObject) { - EidosObject * const *first_child_vec = p_original_value->ObjectElementVector()->data(); + EidosObject * const *first_child_vec = p_original_value->ObjectData(); EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); @@ -1163,14 +1167,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa if (original_value_type == EidosValueType::kValueFloat) { // result type is float; optimize for that - const double *first_child_data = p_original_value->FloatVector()->data(); + const double *first_child_data = p_original_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1207,14 +1211,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueInt) { // result type is integer; optimize for that - const int64_t *first_child_data = p_original_value->IntVector()->data(); + const int64_t *first_child_data = p_original_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1251,14 +1255,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueObject) { // result type is object; optimize for that - EidosObject * const *first_child_vec = p_original_value->ObjectElementVector()->data(); + EidosObject * const *first_child_vec = p_original_value->ObjectData(); EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1295,14 +1299,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueLogical) { // result type is logical; optimize for that - const eidos_logical_t *first_child_data = p_original_value->LogicalVector()->data(); + const eidos_logical_t *first_child_data = p_original_value->LogicalData(); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { @@ -1339,14 +1343,14 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueString) { // result type is string; optimize for that - const std::vector &first_child_vec = *p_original_value->StringVector(); + const std::string *first_child_vec = p_original_value->StringData(); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); if (indices_type == EidosValueType::kValueInt) { // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntVector()->data(); + const int64_t *int_index_data = p_indices->IntData(); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_distributions.cpp b/eidos/eidos_functions_distributions.cpp index d3f81e13e..89475272f 100644 --- a/eidos/eidos_functions_distributions.cpp +++ b/eidos/eidos_functions_distributions.cpp @@ -86,7 +86,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Int_singleton *)arg_vec)->IntValue_Mutable() : ((EidosValue_Int_vector *)arg_vec)->data(); + const int64_t *vec_data = arg_vec->IntData(); // Check that vec is sorted for (int vec_index = 0; vec_index < vec_count - 1; ++vec_index) @@ -96,7 +96,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Int_singleton *)arg_x)->IntValue_Mutable() : ((EidosValue_Int_vector *)arg_x)->data(); + const int64_t *x_data = arg_x->IntData(); // Find intervals for integer vec, integer x @@ -143,7 +143,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Float_singleton *)arg_x)->FloatValue_Mutable() : ((EidosValue_Float_vector *)arg_x)->data(); + const double *x_data = arg_x->FloatData(); // Find intervals for integer vec, float x @@ -192,7 +192,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Float_singleton *)arg_vec)->FloatValue_Mutable() : ((EidosValue_Float_vector *)arg_vec)->data(); + const double *vec_data = arg_vec->FloatData(); // Check that vec is sorted for (int vec_index = 0; vec_index < vec_count - 1; ++vec_index) @@ -202,7 +202,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Int_singleton *)arg_x)->IntValue_Mutable() : ((EidosValue_Int_vector *)arg_x)->data(); + const int64_t *x_data = arg_x->IntData(); // Find intervals for float vec, integer x @@ -249,7 +249,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorIsSingleton() ? &((EidosValue_Float_singleton *)arg_x)->FloatValue_Mutable() : ((EidosValue_Float_vector *)arg_x)->data(); + const double *x_data = arg_x->FloatData(); // Find intervals for float vec, float x @@ -412,7 +412,7 @@ EidosValue_SP Eidos_ExecuteFunction_dmvnorm(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dmvnorm): (internal error) an unknown error with code " << gsl_err << " occurred inside the GNU Scientific Library's gsl_linalg_cholesky_decomp1() function." << EidosTerminate(nullptr); } - const double *float_data = arg_x->FloatVector()->data(); + const double *float_data = arg_x->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -486,7 +486,7 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -498,7 +498,7 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -566,7 +566,7 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar } else { - const double *float_data = arg_prob->FloatVector()->data(); + const double *float_data = arg_prob->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_probs); result_SP = EidosValue_SP(float_result); @@ -579,7 +579,7 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar } else { - const double *float_data = arg_prob->FloatVector()->data(); + const double *float_data = arg_prob->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_probs); result_SP = EidosValue_SP(float_result); @@ -636,7 +636,7 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -646,7 +646,7 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_quantiles); result_SP = EidosValue_SP(float_result); @@ -702,7 +702,7 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -712,7 +712,7 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1129,7 +1129,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1139,7 +1139,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1325,7 +1325,7 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); @@ -1337,7 +1337,7 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a } else { - const double *float_data = arg_quantile->FloatVector()->data(); + const double *float_data = arg_quantile->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); diff --git a/eidos/eidos_functions_files.cpp b/eidos/eidos_functions_files.cpp index 3bbe8a3fe..b9f075b2d 100644 --- a/eidos/eidos_functions_files.cpp +++ b/eidos/eidos_functions_files.cpp @@ -397,7 +397,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vector &string_vec = *contents_value->StringVector(); + const std::string *string_vec = contents_value->StringData(); for (int value_index = 0; value_index < contents_count; ++value_index) outstream << string_vec[value_index] << std::endl; @@ -458,7 +458,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vector &string_vec = *contents_value->StringVector(); + const std::string *string_vec = contents_value->StringData(); for (int value_index = 0; value_index < contents_count; ++value_index) { diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 31dd7c5ee..f1d724c70 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -78,7 +78,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -108,7 +108,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -258,7 +258,7 @@ EidosValue_SP Eidos_ExecuteFunction_ceil(const std::vector &p_arg else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -318,7 +318,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t product = 1; EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -345,7 +345,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double product = 1.0; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); @@ -381,7 +381,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t sum = 0; EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -408,7 +408,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double sum = 0.0; EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); @@ -449,7 +449,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -480,7 +480,7 @@ EidosValue_SP Eidos_ExecuteFunction_floor(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -528,8 +528,8 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector { if (x_count == y_count) { - const int64_t *int1_data = x_value->IntVector()->data(); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -547,7 +547,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector else if (x_count == 1) { int64_t int1 = x_value->IntAtIndex(0, nullptr); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); @@ -563,7 +563,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector } else if (y_count == 1) { - const int64_t *int1_data = x_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); int64_t int2 = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -629,8 +629,8 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector { if (x_count == y_count) { - const int64_t *int1_data = x_value->IntVector()->data(); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -648,7 +648,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector else if (x_count == 1) { int64_t int1 = x_value->IntAtIndex(0, nullptr); - const int64_t *int2_data = y_value->IntVector()->data(); + const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); @@ -664,7 +664,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector } else if (y_count == 1) { - const int64_t *int1_data = x_value->IntVector()->data(); + const int64_t *int1_data = x_value->IntData(); int64_t int2 = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -716,7 +716,7 @@ EidosValue_SP Eidos_ExecuteFunction_isFinite(const std::vector &p else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -748,7 +748,7 @@ EidosValue_SP Eidos_ExecuteFunction_isInfinite(const std::vector else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -780,7 +780,7 @@ EidosValue_SP Eidos_ExecuteFunction_isNAN(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -817,7 +817,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -856,7 +856,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -895,7 +895,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -929,7 +929,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t product = 1; double product_d = 1.0; bool fits_in_integer = true; @@ -971,7 +971,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double product = 1; for (int value_index = 0; value_index < x_count; ++value_index) @@ -999,7 +999,7 @@ EidosValue_SP Eidos_ExecuteFunction_round(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -1061,9 +1061,9 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorLogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); bool containsF0 = false, containsT0 = false, containsF1 = false, containsT1 = false; if (logical_data0[0]) @@ -1179,7 +1179,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr); - const int64_t *int_data = y_value->IntVector()->data(); + const int64_t *int_data = y_value->IntData(); for (int value_index = 0; value_index < y_count; ++value_index) if (int0 == int_data[value_index]) @@ -1190,7 +1190,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr); - const double *float_data = y_value->FloatVector()->data(); + const double *float_data = y_value->FloatData(); for (int value_index = 0; value_index < y_count; ++value_index) { @@ -1205,7 +1205,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); - const std::vector &string_vec = *y_value->StringVector(); + const std::string *string_vec = y_value->StringData(); for (int value_index = 0; value_index < y_count; ++value_index) if (string0 == string_vec[value_index]) @@ -1216,7 +1216,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr); - EidosObject * const *object_vec = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec = y_value->ObjectData(); for (int value_index = 0; value_index < y_count; ++value_index) if (obj0 == object_vec[value_index]) @@ -1235,7 +1235,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr); - EidosValue_Int_vector *int_vec = result_SP->IntVector_Mutable(); + EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1248,8 +1248,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr); - EidosValue_Float_vector *float_vec = result_SP->FloatVector_Mutable(); - double *float_data = float_vec->data(); + EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + double *float_data = float_vec->FloatData_Mutable(); for (int value_index = 0; value_index < result_count; ++value_index) { @@ -1265,7 +1265,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); - std::vector &string_vec = *result_SP->StringVector_Mutable(); + EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + std::vector &string_vec = string_vector_obj->StringVectorData(); for (int value_index = 0; value_index < result_count; ++value_index) if (string1 == string_vec[value_index]) @@ -1277,7 +1278,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr); - EidosValue_Object_vector *object_element_vec = result_SP->ObjectElementVector_Mutable(); + EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1293,8 +1294,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vector1, so we can use fast APIs for both if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -1324,8 +1325,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatVector()->data(); - const double *float_data1 = y_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = y_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -1363,8 +1364,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -1394,8 +1395,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementVector()->data(); - EidosObject * const *object_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec0 = x_value->ObjectData(); + EidosObject * const *object_vec1 = y_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -1469,9 +1470,9 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorLogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); bool containsF0 = false, containsT0 = false, containsF1 = false, containsT1 = false; if (logical_data0[0]) @@ -1591,7 +1592,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorIntAtIndex(0, nullptr); - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) if (value == int_data[scan_index]) @@ -1603,7 +1604,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatAtIndex(0, nullptr); - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) { @@ -1619,7 +1620,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorStringRefAtIndex(0, nullptr); - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) if (value == string_vec[scan_index]) @@ -1631,7 +1632,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementAtIndex(0, nullptr); - EidosObject * const *object_vec = x_value->ObjectElementVector()->data(); + EidosObject * const *object_vec = x_value->ObjectData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) if (value == object_vec[scan_index]) @@ -1651,8 +1652,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vector1, so we can use fast APIs for both if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -1681,8 +1682,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatVector()->data(); - const double *float_data1 = y_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = y_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -1717,8 +1718,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -1747,8 +1748,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementVector()->data(); - EidosObject * const *object_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec0 = x_value->ObjectData(); + EidosObject * const *object_vec1 = y_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -1836,9 +1837,9 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorLogicalVector()->data(); - const eidos_logical_t *logical_data1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = y_value->LogicalData(); bool containsF0 = false, containsT0 = false, containsF1 = false, containsT1 = false; if (logical_data0[0]) @@ -1963,7 +1964,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntAtIndex(0, nullptr); - EidosValue_Int_vector *int_vec = result_SP->IntVector_Mutable(); + EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); int value_index; @@ -1979,8 +1980,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatAtIndex(0, nullptr); - EidosValue_Float_vector *float_vec = result_SP->FloatVector_Mutable(); - double *float_data = float_vec->data(); + EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + double *float_data = float_vec->FloatData_Mutable(); int value_index; for (value_index = 0; value_index < result_count; ++value_index) @@ -1999,7 +2000,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorStringRefAtIndex(0, nullptr); - std::vector &string_vec = *result_SP->StringVector_Mutable(); + EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + std::vector &string_vec = string_vector_obj->StringVectorData(); int value_index; for (value_index = 0; value_index < result_count; ++value_index) @@ -2014,7 +2016,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementAtIndex(0, nullptr); - EidosValue_Object_vector *object_element_vec = result_SP->ObjectElementVector_Mutable(); + EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); int value_index; @@ -2036,8 +2038,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntVector()->data(); - const int64_t *int_data1 = y_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = y_value->IntData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -2085,8 +2087,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatVector()->data(); - const double *float_vec1 = y_value->FloatVector()->data(); + const double *float_vec0 = x_value->FloatData(); + const double *float_vec1 = y_value->FloatData(); EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); result_SP = EidosValue_SP(float_result); @@ -2150,8 +2152,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *y_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = y_value->StringData(); EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); @@ -2199,8 +2201,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementVector()->data(); - EidosObject * const *object_vec1 = y_value->ObjectElementVector()->data(); + EidosObject * const *object_vec0 = x_value->ObjectData(); + EidosObject * const *object_vec1 = y_value->ObjectData(); EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); @@ -2299,9 +2301,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p else if (arg_type == EidosValueType::kValueLogical) { // Because EidosValue_Logical works differently than other EidosValue types, this code can handle - // both the singleton and non-singleton cases; LogicalVector() is always available - const eidos_logical_t *logical_vec0 = x_value->LogicalVector()->data(); - const eidos_logical_t *logical_vec1 = y_value->LogicalVector()->data(); + // both the singleton and non-singleton cases + const eidos_logical_t *logical_vec0 = x_value->LogicalData(); + const eidos_logical_t *logical_vec1 = y_value->LogicalData(); bool containsF = false, containsT = false; if (((x_count > 0) && logical_vec0[0]) || ((y_count > 0) && logical_vec1[0])) @@ -2430,7 +2432,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (arg_type == EidosValueType::kValueInt) { int64_t value = y_value->IntAtIndex(0, nullptr); - const int64_t *int_data = result_SP->IntVector()->data(); + const int64_t *int_data = result_SP->IntData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) @@ -2440,12 +2442,16 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } if (scan_index == result_count) - result_SP->IntVector_Mutable()->push_int(value); + { + EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); + + int_vec->push_int(value); + } } else if (arg_type == EidosValueType::kValueFloat) { double value1 = y_value->FloatAtIndex(0, nullptr); - const double *float_data = result_SP->FloatVector()->data(); + const double *float_data = result_SP->FloatData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) @@ -2457,37 +2463,50 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } if (scan_index == result_count) - result_SP->FloatVector_Mutable()->push_float(value1); + { + EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + + float_vec->push_float(value1); + } } else if (arg_type == EidosValueType::kValueString) { const std::string &value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); - const std::vector &string_vec = *result_SP->StringVector(); + const std::string *string_data = result_SP->StringData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) { - if (value == string_vec[scan_index]) + if (value == string_data[scan_index]) break; } if (scan_index == result_count) - result_SP->StringVector_Mutable()->emplace_back(value); + { + EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + std::vector &string_vec = string_vector_obj->StringVectorData(); + + string_vec.emplace_back(value); + } } else if (arg_type == EidosValueType::kValueObject) { EidosObject *value = y_value->ObjectElementAtIndex(0, nullptr); - EidosObject * const *object_vec = result_SP->ObjectElementVector()->data(); + EidosObject * const *object_data = result_SP->ObjectData(); int scan_index; for (scan_index = 0; scan_index < result_count; ++scan_index) { - if (value == object_vec[scan_index]) + if (value == object_data[scan_index]) break; } if (scan_index == result_count) - result_SP->ObjectElementVector_Mutable()->push_object_element_CRR(value); + { + EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + + object_element_vec->push_object_element_CRR(value); + } } } else @@ -2552,7 +2571,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -2588,7 +2607,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu #ifndef _OPENMP { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); int64_t sum = 0; double sum_d = 0; bool fits_in_integer = true; @@ -2624,7 +2643,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu { // In the OpenMP case we want to follow fairly different logic, because dealing with catching the overflow // case across multiple threads seems excessively complex; instead we look for an overflow afterwards - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); double sum_d = 0; EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_INTEGER); @@ -2652,7 +2671,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double sum = 0; EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_FLOAT); @@ -2666,7 +2685,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu else if (x_type == EidosValueType::kValueLogical) { // EidosValue_Logical does not have a singleton subclass, so we can always use the fast API - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); int64_t sum = 0; EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_LOGICAL); @@ -2695,7 +2714,7 @@ EidosValue_SP Eidos_ExecuteFunction_sumExact(const std::vector &p else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); double sum = Eidos_ExactSum(float_data, x_count); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum)); @@ -2745,7 +2764,7 @@ EidosValue_SP Eidos_ExecuteFunction_trunc(const std::vector &p_ar else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index 0c003d060..514d867ec 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -311,7 +311,7 @@ EidosValue_SP Eidos_ExecuteFunction_array(const std::vector &p_ar // construct the array from the data and dimensions result_SP = data_value->CopyValues(); - result_SP->SetDimensions(dim_count, dim_value->IntVector()->data()); + result_SP->SetDimensions(dim_count, dim_value->IntData()); return result_SP; } @@ -659,7 +659,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector if (x_type == EidosValueType::kValueInt) { int64_t x_singleton = x_value->IntAtIndex(0, nullptr); - const int64_t *y_data = y_value->IntVector()->data(); + const int64_t *y_data = y_value->IntData(); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -678,7 +678,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector else // (x_type == EidosValueType::kValueFloat) { double x_singleton = x_value->FloatAtIndex(0, nullptr); - const double *y_data = y_value->FloatVector()->data(); + const double *y_data = y_value->FloatData(); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -691,7 +691,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector // a column vector multiplied by a 1x1 vector if (x_type == EidosValueType::kValueInt) { - const int64_t *x_data = x_value->IntVector()->data(); + const int64_t *x_data = x_value->IntData(); int64_t y_singleton = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -710,7 +710,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector } else // (x_type == EidosValueType::kValueFloat) { - const double *x_data = x_value->FloatVector()->data(); + const double *x_data = x_value->FloatData(); double y_singleton = y_value->FloatAtIndex(0, nullptr); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -724,8 +724,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector // this is the general case; we have non-singleton matrices for both x and y, so we can divide by integer/float and use direct access if (x_type == EidosValueType::kValueInt) { - const int64_t *x_data = x_value->IntVector()->data(); - const int64_t *y_data = y_value->IntVector()->data(); + const int64_t *x_data = x_value->IntData(); + const int64_t *y_data = y_value->IntData(); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -767,8 +767,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector } else // (x_type == EidosValueType::kValueFloat) { - const double *x_data = x_value->FloatVector()->data(); - const double *y_data = y_value->FloatVector()->data(); + const double *x_data = x_value->FloatData(); + const double *y_data = y_value->FloatData(); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 4745c5ff0..9e2385014 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -59,7 +59,7 @@ EidosValue_SP Eidos_ExecuteFunction_assert(const std::vector &p_a // determine whether the assertions vector is all true int assertions_count = assertions_value->Count(); - const eidos_logical_t *logical_data = assertions_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = assertions_value->LogicalData(); bool any_false = false; for (int assertions_index = 0; assertions_index < assertions_count; ++assertions_index) @@ -1468,7 +1468,7 @@ EidosValue_SP Eidos_ExecuteFunction_system(const std::vector &p_a } else { - const std::vector &string_vec = *input_value->StringVector(); + const std::string *string_vec = input_value->StringData(); for (int value_index = 0; value_index < input_count; ++value_index) { diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index 5341a3692..f015ec17f 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -46,7 +46,7 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu EidosValue *y_value = p_arguments[1].get(); int count = x_value->Count(); - if (x_value->IsArray() || y_value->IsArray()) + if (x_value->IsMatrixOrArray() || y_value->IsMatrixOrArray()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cor): function cor() does not currently support matrix/array arguments." << EidosTerminate(nullptr); if (count != y_value->Count()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cor): function cor() requires that x and y be the same size." << EidosTerminate(nullptr); @@ -100,7 +100,7 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu EidosValue *y_value = p_arguments[1].get(); int count = x_value->Count(); - if (x_value->IsArray() || y_value->IsArray()) + if (x_value->IsMatrixOrArray() || y_value->IsMatrixOrArray()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cov): function cov() does not currently support matrix/array arguments." << EidosTerminate(nullptr); if (count != y_value->Count()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cov): function cov() requires that x and y be the same size." << EidosTerminate(nullptr); @@ -186,20 +186,11 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu { EidosValue *arg_value = p_arguments[arg_index].get(); int arg_count = arg_value->Count(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); - if (arg_count == 1) - { - if (arg_value->LogicalAtIndex(0, nullptr) == true) + for (int value_index = 0; value_index < arg_count; ++value_index) + if (logical_data[value_index] == true) return gStaticEidosValue_LogicalT; - } - else - { - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); - - for (int value_index = 0; value_index < arg_count; ++value_index) - if (logical_data[value_index] == true) - return gStaticEidosValue_LogicalT; - } } result_SP = gStaticEidosValue_LogicalF; @@ -221,7 +212,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else if (arg_count > 1) { - const int64_t *int_data = arg_value->IntVector()->data(); + const int64_t *int_data = arg_value->IntData(); int64_t loop_max = INT64_MIN; EIDOS_THREAD_COUNT(gEidos_OMP_threads_MAX_INT); @@ -262,7 +253,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else { - const double *float_data = arg_value->FloatVector()->data(); + const double *float_data = arg_value->FloatData(); double loop_max = -std::numeric_limits::infinity(); bool saw_NAN = false; @@ -307,7 +298,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else { - const std::vector &string_vec = *arg_value->StringVector(); + const std::string *string_vec = arg_value->StringData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -401,20 +392,11 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu { EidosValue *arg_value = p_arguments[arg_index].get(); int arg_count = arg_value->Count(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); - if (arg_count == 1) - { - if (arg_value->LogicalAtIndex(0, nullptr) == false) + for (int value_index = 0; value_index < arg_count; ++value_index) + if (logical_data[value_index] == false) return gStaticEidosValue_LogicalF; - } - else - { - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); - - for (int value_index = 0; value_index < arg_count; ++value_index) - if (logical_data[value_index] == false) - return gStaticEidosValue_LogicalF; - } } result_SP = gStaticEidosValue_LogicalT; @@ -436,7 +418,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else if (arg_count > 1) { - const int64_t *int_data = arg_value->IntVector()->data(); + const int64_t *int_data = arg_value->IntData(); int64_t loop_min = INT64_MAX; EIDOS_THREAD_COUNT(gEidos_OMP_threads_MIN_INT); @@ -477,7 +459,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else { - const double *float_data = arg_value->FloatVector()->data(); + const double *float_data = arg_value->FloatData(); double loop_min = std::numeric_limits::infinity(); bool saw_NAN = false; @@ -522,7 +504,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else { - const std::vector &string_vec = *arg_value->StringVector(); + const std::string *string_vec = arg_value->StringData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -602,7 +584,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg // Then split up by type if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); eidos_logical_t y_singleton_value = y_value->LogicalAtIndex(0, nullptr); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -612,7 +594,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); int64_t y_singleton_value = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); @@ -638,7 +620,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); double y_singleton_value = y_value->FloatAtIndex(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); @@ -658,7 +640,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -672,8 +654,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg // We know the type is not NULL or object, that x_count == y_count, and that they are not singletons; we split up by type and handle fast if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); - const eidos_logical_t *logical1_data = y_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); + const eidos_logical_t *logical1_data = y_value->LogicalData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -682,8 +664,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); - const int64_t * __restrict__ int1_data = y_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); + const int64_t * __restrict__ int1_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -699,8 +681,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); - const double * __restrict__ float1_data = y_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); + const double * __restrict__ float1_data = y_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -720,8 +702,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); - const std::vector &string1_vec = *y_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); + const std::string *string1_vec = y_value->StringData(); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -800,7 +782,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg // Then split up by type if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); eidos_logical_t y_singleton_value = y_value->LogicalAtIndex(0, nullptr); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -810,7 +792,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); int64_t y_singleton_value = y_value->IntAtIndex(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); @@ -826,7 +808,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); double y_singleton_value = y_value->FloatAtIndex(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); @@ -846,7 +828,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -860,8 +842,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg // We know the type is not NULL or object, that x_count == y_count, and that they are not singletons; we split up by type and handle fast if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical0_data = x_value->LogicalVector()->data(); - const eidos_logical_t *logical1_data = y_value->LogicalVector()->data(); + const eidos_logical_t *logical0_data = x_value->LogicalData(); + const eidos_logical_t *logical1_data = y_value->LogicalData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -870,8 +852,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueInt) { - const int64_t * __restrict__ int0_data = x_value->IntVector()->data(); - const int64_t * __restrict__ int1_data = y_value->IntVector()->data(); + const int64_t * __restrict__ int0_data = x_value->IntData(); + const int64_t * __restrict__ int1_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -887,8 +869,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueFloat) { - const double * __restrict__ float0_data = x_value->FloatVector()->data(); - const double * __restrict__ float1_data = y_value->FloatVector()->data(); + const double * __restrict__ float0_data = x_value->FloatData(); + const double * __restrict__ float1_data = y_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -908,8 +890,8 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg } else if (x_type == EidosValueType::kValueString) { - const std::vector &string0_vec = *x_value->StringVector(); - const std::vector &string1_vec = *y_value->StringVector(); + const std::string *string0_vec = x_value->StringData(); + const std::string *string1_vec = y_value->StringData(); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -988,7 +970,7 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) if (std::isnan(float_data[value_index])) @@ -999,9 +981,9 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p std::vector order; if (x_type == EidosValueType::kValueInt) - order = EidosSortIndexes(x_value->IntVector()->data(), x_count, true); + order = EidosSortIndexes(x_value->IntData(), x_count, true); else if (x_type == EidosValueType::kValueFloat) - order = EidosSortIndexes(x_value->FloatVector()->data(), x_count, true); + order = EidosSortIndexes(x_value->FloatData(), x_count, true); // Now loop over the requested probabilities and calculate them for (int probs_index = 0; probs_index < probs_count; ++probs_index) @@ -1087,7 +1069,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar } else { - const int64_t *int_data = arg_value->IntVector()->data(); + const int64_t *int_data = arg_value->IntData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -1135,7 +1117,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar } else { - const double *float_data = arg_value->FloatVector()->data(); + const double *float_data = arg_value->FloatData(); for (int value_index = 0; value_index < arg_count; ++value_index) { @@ -1223,7 +1205,7 @@ EidosValue_SP Eidos_ExecuteFunction_ttest(const std::vector &p_ar if (x_count <= 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ttest): function ttest() requires enough elements in x to compute variance." << EidosTerminate(nullptr); - const double *vec1 = x_value->FloatVector()->data(); + const double *vec1 = x_value->FloatData(); double pvalue = 0.0; if (y_type != EidosValueType::kValueNULL) @@ -1232,7 +1214,7 @@ EidosValue_SP Eidos_ExecuteFunction_ttest(const std::vector &p_ar if (y_count <= 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ttest): function ttest() requires enough elements in y to compute variance." << EidosTerminate(nullptr); - const double *vec2 = y_value->FloatVector()->data(); + const double *vec2 = y_value->FloatData(); // Right now this function only provides a two-sample t-test; we could add an optional mu argument and make y optional in order to allow a one-sample test as well // If we got into that, we'd probably want to provide one-sided t-tests as well, yada yada... @@ -1259,7 +1241,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - if (x_value->IsArray()) + if (x_value->IsMatrixOrArray()) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_var): function var() does not currently support a matrix/array argument." << EidosTerminate(nullptr); if (x_count > 1) diff --git a/eidos/eidos_functions_strings.cpp b/eidos/eidos_functions_strings.cpp index 7c8111bd3..51162cbed 100644 --- a/eidos/eidos_functions_strings.cpp +++ b/eidos/eidos_functions_strings.cpp @@ -234,7 +234,7 @@ EidosValue_SP Eidos_ExecuteFunction_nchar(const std::vector &p_ar } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -278,7 +278,7 @@ EidosValue_SP Eidos_ExecuteFunction_strcontains(const std::vector } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -321,7 +321,7 @@ EidosValue_SP Eidos_ExecuteFunction_strfind(const std::vector &p_ } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -364,7 +364,7 @@ EidosValue_SP Eidos_ExecuteFunction_strprefix(const std::vector & } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -452,7 +452,7 @@ EidosValue_SP Eidos_ExecuteFunction_strsuffix(const std::vector & } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -529,7 +529,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a } else { - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); EidosValue *arg_first = p_arguments[1].get(); int arg_first_count = arg_first->Count(); bool first_singleton = (arg_first_count == 1); diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index c24a5daad..8088d5344 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -144,7 +144,7 @@ EidosValue_SP Eidos_ExecuteFunction_integer(const std::vector &p_ } else { - const int64_t *positions_data = fill2Indices_value->IntVector()->data(); + const int64_t *positions_data = fill2Indices_value->IntData(); for (int positions_index = 0; positions_index < positions_count; ++positions_index) { @@ -347,16 +347,16 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a case EidosValueType::kValueVOID: break; // NOLINT(*-branch-clone) : intentional consecutive branches case EidosValueType::kValueNULL: break; case EidosValueType::kValueLogical: - Eidos_ran_shuffle(main_thread_rng, result->LogicalVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->LogicalData_Mutable(), x_count); break; case EidosValueType::kValueInt: - Eidos_ran_shuffle(main_thread_rng, result->IntVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->IntData_Mutable(), x_count); break; case EidosValueType::kValueFloat: - Eidos_ran_shuffle(main_thread_rng, result->FloatVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->FloatData_Mutable(), x_count); break; case EidosValueType::kValueObject: - Eidos_ran_shuffle(main_thread_rng, result->ObjectElementVector_Mutable()->data(), x_count); + Eidos_ran_shuffle(main_thread_rng, result->ObjectData_Mutable(), x_count); break; default: EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_sample): (internal error) unsupported type in sample()" << EidosTerminate(nullptr); @@ -413,7 +413,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a if (weights_type == EidosValueType::kValueFloat) { - weights_float = weights_value->FloatVector()->data(); + weights_float = weights_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -427,7 +427,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else // EidosValueType::kValueInt : convert the weights to doubles { - const int64_t *weights_int = weights_value->IntVector()->data(); + const int64_t *weights_int = weights_value->IntData(); weights_float_malloced = (double *)malloc(x_count * sizeof(double)); @@ -461,7 +461,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a // now treat each type separately if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(sample_size); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -482,7 +482,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(sample_size); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -503,7 +503,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *object_data = x_value->ObjectElementVector()->data(); + EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); @@ -556,7 +556,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a // handle the weights vector with separate cases for float and integer, so we can access it directly for speed else if (weights_type == EidosValueType::kValueFloat) { - const double *weights_float = weights_value->FloatVector()->data(); + const double *weights_float = weights_value->FloatData(); double weights_sum = 0.0; for (int value_index = 0; value_index < x_count; ++value_index) @@ -651,7 +651,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (weights_type == EidosValueType::kValueInt) { - const int64_t *weights_int = weights_value->IntVector()->data(); + const int64_t *weights_int = weights_value->IntData(); int64_t weights_sum = 0; for (int value_index = 0; value_index < x_count; ++value_index) @@ -778,7 +778,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(sample_size); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -798,7 +798,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(sample_size); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -818,7 +818,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *object_data = x_value->ObjectElementVector()->data(); + EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); @@ -1131,7 +1131,7 @@ EidosValue_SP Eidos_ExecuteFunction_all(const std::vector &p_argu EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_all): function all() requires that all arguments be of type logical." << EidosTerminate(nullptr); int arg_count = arg_value->Count(); - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); for (int value_index = 0; value_index < arg_count; ++value_index) if (!logical_data[value_index]) @@ -1163,7 +1163,7 @@ EidosValue_SP Eidos_ExecuteFunction_any(const std::vector &p_argu EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_any): function any() requires that all arguments be of type logical." << EidosTerminate(nullptr); int arg_count = arg_value->Count(); - const eidos_logical_t *logical_data = arg_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = arg_value->LogicalData(); for (int value_index = 0; value_index < arg_count; ++value_index) if (logical_data[value_index]) @@ -1481,7 +1481,7 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a EidosValue *test_value = p_arguments[0].get(); int test_count = test_value->Count(); - const eidos_logical_t *logical_vec = (*test_value->LogicalVector()).data(); + const eidos_logical_t *logical_vec = test_value->LogicalData(); EidosValue *trueValues_value = p_arguments[1].get(); EidosValueType trueValues_type = trueValues_value->Type(); @@ -1502,8 +1502,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a // Use direct access to make this fast if (trueValues_type == EidosValueType::kValueLogical) { - const eidos_logical_t *true_vec = trueValues_value->LogicalVector()->data(); - const eidos_logical_t *false_vec = falseValues_value->LogicalVector()->data(); + const eidos_logical_t *true_vec = trueValues_value->LogicalData(); + const eidos_logical_t *false_vec = falseValues_value->LogicalData(); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->resize_no_initialize(test_count); @@ -1514,8 +1514,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueInt) { - const int64_t *true_data = trueValues_value->IntVector()->data(); - const int64_t *false_data = falseValues_value->IntVector()->data(); + const int64_t *true_data = trueValues_value->IntData(); + const int64_t *false_data = falseValues_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(test_count); @@ -1526,8 +1526,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueFloat) { - const double *true_data = trueValues_value->FloatVector()->data(); - const double *false_data = falseValues_value->FloatVector()->data(); + const double *true_data = trueValues_value->FloatData(); + const double *false_data = falseValues_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(test_count); @@ -1538,8 +1538,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueString) { - const std::vector &true_vec = (*trueValues_value->StringVector()); - const std::vector &false_vec = (*falseValues_value->StringVector()); + const std::string *true_vec = trueValues_value->StringData(); + const std::string *false_vec = falseValues_value->StringData(); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(test_count); @@ -1556,8 +1556,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a if (trueValues_class != falseValues_class) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ifelse): objects of different types cannot be mixed in function ifelse()." << EidosTerminate(nullptr); - EidosObject * const *true_vec = trueValues_value->ObjectElementVector()->data(); - EidosObject * const *false_vec = falseValues_value->ObjectElementVector()->data(); + EidosObject * const *true_vec = trueValues_value->ObjectData(); + EidosObject * const *false_vec = falseValues_value->ObjectData(); EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); @@ -1780,7 +1780,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { eidos_logical_t value0 = x_value->LogicalAtIndex(0, nullptr); - const eidos_logical_t *logical_data1 = table_value->LogicalVector()->data(); + const eidos_logical_t *logical_data1 = table_value->LogicalData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == logical_data1[table_index]) @@ -1792,7 +1792,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueInt) { int64_t value0 = x_value->IntAtIndex(0, nullptr); - const int64_t *int_data1 = table_value->IntVector()->data(); + const int64_t *int_data1 = table_value->IntData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == int_data1[table_index]) @@ -1804,7 +1804,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueFloat) { double value0 = x_value->FloatAtIndex(0, nullptr); - const double *float_data1 = table_value->FloatVector()->data(); + const double *float_data1 = table_value->FloatData(); for (table_index = 0; table_index < table_count; ++table_index) { @@ -1820,7 +1820,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueString) { const std::string &value0 = ((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); - const std::vector &string_vec1 = *table_value->StringVector(); + const std::string *string_vec1 = table_value->StringData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == string_vec1[table_index]) @@ -1832,7 +1832,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else // if (x_type == EidosValueType::kValueObject) { EidosObject *value0 = x_value->ObjectElementAtIndex(0, nullptr); - EidosObject * const *objelement_vec1 = table_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec1 = table_value->ObjectData(); for (table_index = 0; table_index < table_count; ++table_index) if (value0 == objelement_vec1[table_index]) @@ -1853,7 +1853,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { eidos_logical_t value1 = table_value->LogicalAtIndex(0, nullptr); - const eidos_logical_t *logical_data0 = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data0 = x_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(logical_data0[value_index] == value1 ? 0 : -1, value_index); @@ -1861,7 +1861,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueInt) { int64_t value1 = table_value->IntAtIndex(0, nullptr); - const int64_t *int_data0 = x_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(int_data0[value_index] == value1 ? 0 : -1, value_index); @@ -1869,7 +1869,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueFloat) { double value1 = table_value->FloatAtIndex(0, nullptr); - const double *float_data0 = x_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -1881,7 +1881,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueString) { const std::string &value1 = ((EidosValue_String *)table_value)->StringRefAtIndex(0, nullptr); - const std::vector &string_vec0 = *x_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(string_vec0[value_index] == value1 ? 0 : -1, value_index); @@ -1889,7 +1889,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else if (x_type == EidosValueType::kValueObject) { EidosObject *value1 = table_value->ObjectElementAtIndex(0, nullptr); - EidosObject * const *objelement_vec0 = x_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec0 = x_value->ObjectData(); for (int value_index = 0; value_index < x_count; ++value_index) int_result->set_int_no_check(objelement_vec0[value_index] == value1 ? 0 : -1, value_index); @@ -1906,8 +1906,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { - const eidos_logical_t *logical_data0 = x_value->LogicalVector()->data(); - const eidos_logical_t *logical_data1 = table_value->LogicalVector()->data(); + const eidos_logical_t *logical_data0 = x_value->LogicalData(); + const eidos_logical_t *logical_data1 = table_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) { @@ -1920,8 +1920,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueInt) { - const int64_t *int_data0 = x_value->IntVector()->data(); - const int64_t *int_data1 = table_value->IntVector()->data(); + const int64_t *int_data0 = x_value->IntData(); + const int64_t *int_data1 = table_value->IntData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -1966,8 +1966,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - const double *float_data0 = x_value->FloatVector()->data(); - const double *float_data1 = table_value->FloatVector()->data(); + const double *float_data0 = x_value->FloatData(); + const double *float_data1 = table_value->FloatData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -2018,8 +2018,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueString) { - const std::vector &string_vec0 = *x_value->StringVector(); - const std::vector &string_vec1 = *table_value->StringVector(); + const std::string *string_vec0 = x_value->StringData(); + const std::string *string_vec1 = table_value->StringData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -2065,8 +2065,8 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueObject) { - EidosObject * const *objelement_vec0 = x_value->ObjectElementVector()->data(); - EidosObject * const *objelement_vec1 = table_value->ObjectElementVector()->data(); + EidosObject * const *objelement_vec0 = x_value->ObjectData(); + EidosObject * const *objelement_vec1 = table_value->ObjectData(); if ((x_count >= 500) && (table_count >= 5)) // a guess based on timing data; will be platform-dependent and dataset-dependent { @@ -2142,13 +2142,13 @@ EidosValue_SP Eidos_ExecuteFunction_order(const std::vector &p_ar std::vector order; if (x_type == EidosValueType::kValueLogical) - order = EidosSortIndexes(x_value->LogicalVector()->data(), x_count, ascending); + order = EidosSortIndexes(x_value->LogicalData(), x_count, ascending); else if (x_type == EidosValueType::kValueInt) - order = EidosSortIndexes(x_value->IntVector()->data(), x_count, ascending); + order = EidosSortIndexes(x_value->IntData(), x_count, ascending); else if (x_type == EidosValueType::kValueFloat) - order = EidosSortIndexes(x_value->FloatVector()->data(), x_count, ascending); + order = EidosSortIndexes(x_value->FloatData(), x_count, ascending); else if (x_type == EidosValueType::kValueString) - order = EidosSortIndexes(*x_value->StringVector(), ascending); + order = EidosSortIndexes(x_value->StringData(), x_count, ascending); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(order)); result_SP = EidosValue_SP(int_result); @@ -2337,7 +2337,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg { // construct our vector of pairs: std::pair - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int index = 0; index < x_count; ++index) pairs.emplace_back(int_data[index], index); @@ -2417,7 +2417,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg { // construct our vector of pairs: std::pair - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int index = 0; index < x_count; ++index) pairs.emplace_back(float_data[index], index); @@ -2606,7 +2606,7 @@ EidosValue_SP Eidos_ExecuteFunction_tabulate(const std::vector &p // set up to work with either a singleton or a non-singleton vector int64_t singleton_value = (value_count == 1) ? bin_value->IntAtIndex(0, nullptr) : 0; - const int64_t *int_data = (value_count == 1) ? &singleton_value : bin_value->IntVector()->data(); + const int64_t *int_data = (value_count == 1) ? &singleton_value : bin_value->IntData(); // determine maxbin int64_t maxbin; @@ -2709,7 +2709,7 @@ EidosValue_SP Eidos_ExecuteFunction_which(const std::vector &p_ar EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); result_SP = EidosValue_SP(int_result); @@ -2746,7 +2746,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2762,7 +2762,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2778,7 +2778,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2794,7 +2794,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2836,7 +2836,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const eidos_logical_t *logical_data = x_value->LogicalVector()->data(); + const eidos_logical_t *logical_data = x_value->LogicalData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2852,7 +2852,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API - const int64_t *int_data = x_value->IntVector()->data(); + const int64_t *int_data = x_value->IntData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2868,7 +2868,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API - const double *float_data = x_value->FloatVector()->data(); + const double *float_data = x_value->FloatData(); for (int value_index = 1; value_index < x_count; ++value_index) { @@ -2884,7 +2884,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_count > 1) { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API - const std::vector &string_vec = *x_value->StringVector(); + const std::string *string_vec = x_value->StringData(); for (int value_index = 1; value_index < x_count; ++value_index) { diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 4ac3f1d5f..b09a43e6f 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -396,7 +396,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, else if (second_child_count) { // fast vector access for the non-singleton case - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_idx = 0; value_idx < second_child_count; value_idx++) { @@ -479,7 +479,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, if (subset_count != dim_size) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): the '[]' operator requires that the size() of a logical index operand must match the corresponding dimension of the indexed operand." << EidosTerminate(parent_token); - const eidos_logical_t *logical_index_data = subset_value->LogicalVector()->data(); + const eidos_logical_t *logical_index_data = subset_value->LogicalData(); for (int dim_index = 0; dim_index < dim_size; dim_index++) if (logical_index_data[dim_index]) @@ -1750,7 +1750,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Subset(const EidosASTNode *p_node) if (subset_count != dim_size) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): the '[]' operator requires that the size() of a logical index operand must match the corresponding dimension of the indexed operand." << EidosTerminate(operator_token); - const eidos_logical_t *logical_index_data = subset_value->LogicalVector()->data(); + const eidos_logical_t *logical_index_data = subset_value->LogicalData(); for (int dim_index = 0; dim_index < dim_size; dim_index++) if (logical_index_data[dim_index]) @@ -2019,8 +2019,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2046,7 +2046,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (first_child_count == 1) { int64_t singleton_int = first_child_value->IntAtIndex(0, operator_token); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); @@ -2069,7 +2069,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); int64_t singleton_int = second_child_value->IntAtIndex(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2115,24 +2115,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + second_child_data[value_index], value_index); @@ -2149,14 +2149,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float + second_child_data[value_index], value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float + second_child_data[value_index], value_index); @@ -2172,14 +2172,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + singleton_float, value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] + singleton_float, value_index); @@ -2238,7 +2238,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2268,7 +2268,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2322,8 +2322,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2349,7 +2349,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) else if (first_child_count == 1) { int64_t singleton_int = first_child_value->IntAtIndex(0, operator_token); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); @@ -2372,7 +2372,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); int64_t singleton_int = second_child_value->IntAtIndex(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2415,24 +2415,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - second_child_data[value_index], value_index); @@ -2449,14 +2449,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float - second_child_data[value_index], value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float - second_child_data[value_index], value_index); @@ -2472,14 +2472,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - singleton_float, value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] - singleton_float, value_index); @@ -2549,32 +2549,32 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], second_child_data[value_index]), value_index); @@ -2591,14 +2591,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(fmod(singleton_float, second_child_data[value_index]), value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(fmod(singleton_float, second_child_data[value_index]), value_index); @@ -2614,14 +2614,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], singleton_float), value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(fmod(first_child_data[value_index], singleton_float), value_index); @@ -2694,8 +2694,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) } else { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2731,24 +2731,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] * second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] * second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] * second_child_data[value_index], value_index); @@ -2783,7 +2783,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) // OK, we've got good operands; calculate the result. If both operands are int, the result is int, otherwise float. if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *any_count_data = any_count_child->IntVector()->data(); + const int64_t *any_count_data = any_count_child->IntData(); int64_t singleton_int = one_count_child->IntAtIndex(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(any_count); @@ -2807,7 +2807,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) } else if (any_type == EidosValueType::kValueInt) { - const int64_t *any_count_data = any_count_child->IntVector()->data(); + const int64_t *any_count_data = any_count_child->IntData(); double singleton_float = one_count_child->FloatAtIndex(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2819,7 +2819,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) } else // (any_type == EidosValueType::kValueFloat) { - const double *any_count_data = any_count_child->FloatVector()->data(); + const double *any_count_data = any_count_child->FloatData(); double singleton_float = one_count_child->FloatAtIndex(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2894,32 +2894,32 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / second_child_data[value_index], value_index); } else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / second_child_data[value_index], value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / (double)second_child_data[value_index], value_index); @@ -2936,14 +2936,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float / second_child_data[value_index], value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(singleton_float / second_child_data[value_index], value_index); @@ -2959,14 +2959,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / singleton_float, value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(first_child_data[value_index] / singleton_float, value_index); @@ -3071,32 +3071,32 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueInt)) { - const double *first_child_data = first_child_value->FloatVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const double *first_child_data = first_child_value->FloatData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); } else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueFloat)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const double *second_child_data = second_child_value->FloatVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); } else // ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], second_child_data[value_index]), value_index); @@ -3113,14 +3113,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) if (second_child_type == EidosValueType::kValueInt) { - const int64_t *second_child_data = second_child_value->IntVector()->data(); + const int64_t *second_child_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(pow(singleton_float, second_child_data[value_index]), value_index); } else // (second_child_type == EidosValueType::kValueFloat) { - const double *second_child_data = second_child_value->FloatVector()->data(); + const double *second_child_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) float_result->set_float_no_check(pow(singleton_float, second_child_data[value_index]), value_index); @@ -3136,14 +3136,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueInt) { - const int64_t *first_child_data = first_child_value->IntVector()->data(); + const int64_t *first_child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], singleton_float), value_index); } else // (first_child_type == EidosValueType::kValueFloat) { - const double *first_child_data = first_child_value->FloatVector()->data(); + const double *first_child_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(pow(first_child_data[value_index], singleton_float), value_index); @@ -3648,21 +3648,21 @@ EidosValue_SP EidosInterpreter::Evaluate_Not(const EidosASTNode *p_node) if (first_child_type == EidosValueType::kValueLogical) { - const eidos_logical_t *child_data = first_child_value->LogicalVector()->data(); + const eidos_logical_t *child_data = first_child_value->LogicalData(); for (int value_index = 0; value_index < first_child_count; ++value_index) result->set_logical_no_check(!child_data[value_index], value_index); } else if (first_child_type == EidosValueType::kValueInt) { - const int64_t *child_data = first_child_value->IntVector()->data(); + const int64_t *child_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) result->set_logical_no_check(child_data[value_index] == 0, value_index); } else if (first_child_type == EidosValueType::kValueString) { - const std::vector &child_vec = (*first_child_value->StringVector()); + const std::string *child_vec = first_child_value->StringData(); for (int value_index = 0; value_index < first_child_count; ++value_index) result->set_logical_no_check(child_vec[value_index].length() == 0, value_index); @@ -3735,7 +3735,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) { case EidosTokenType::kTokenPlus: { - int64_t &operand1_value = int_singleton->IntValue_Mutable(); + int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; bool overflow = Eidos_add_overflow(operand1_value, operand2_value, &operand1_value); if (overflow) @@ -3744,7 +3744,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } case EidosTokenType::kTokenMinus: { - int64_t &operand1_value = int_singleton->IntValue_Mutable(); + int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; bool overflow = Eidos_sub_overflow(operand1_value, operand2_value, &operand1_value); if (overflow) @@ -3753,7 +3753,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } case EidosTokenType::kTokenMult: { - int64_t &operand1_value = int_singleton->IntValue_Mutable(); + int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; bool overflow = Eidos_mul_overflow(operand1_value, operand2_value, &operand1_value); if (overflow) @@ -3766,7 +3766,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } else { - int64_t *int_data = lvalue->IntVector_Mutable()->data(); + int64_t *int_data = lvalue->IntData_Mutable(); switch (compound_operator) { @@ -3827,24 +3827,24 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) switch (compound_operator) { case EidosTokenType::kTokenPlus: - float_singleton->FloatValue_Mutable() += operand2_value; + float_singleton->FloatData_Mutable()[0] += operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenMinus: - float_singleton->FloatValue_Mutable() -= operand2_value; + float_singleton->FloatData_Mutable()[0] -= operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenMult: - float_singleton->FloatValue_Mutable() *= operand2_value; + float_singleton->FloatData_Mutable()[0] *= operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenDiv: - float_singleton->FloatValue_Mutable() /= operand2_value; + float_singleton->FloatData_Mutable()[0] /= operand2_value; goto compoundAssignmentSuccess; case EidosTokenType::kTokenMod: { - double &operand1_value = float_singleton->FloatValue_Mutable(); + double &operand1_value = float_singleton->FloatData_Mutable()[0]; operand1_value = fmod(operand1_value, operand2_value); goto compoundAssignmentSuccess; @@ -3852,7 +3852,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) case EidosTokenType::kTokenExp: { - double &operand1_value = float_singleton->FloatValue_Mutable(); + double &operand1_value = float_singleton->FloatData_Mutable()[0]; operand1_value = pow(operand1_value, operand2_value); goto compoundAssignmentSuccess; @@ -3866,7 +3866,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) } else { - double *float_data = lvalue->FloatVector_Mutable()->data(); + double *float_data = lvalue->FloatData_Mutable(); switch (compound_operator) { @@ -4054,8 +4054,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access - const double *float1_data = first_child_value->FloatVector()->data(); - const double *float2_data = second_child_value->FloatVector()->data(); + const double *float1_data = first_child_value->FloatData(); + const double *float2_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float1_data[value_index] == float2_data[value_index], value_index); @@ -4063,8 +4063,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access - const int64_t *int1_data = first_child_value->IntVector()->data(); - const int64_t *int2_data = second_child_value->IntVector()->data(); + const int64_t *int1_data = first_child_value->IntData(); + const int64_t *int2_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int1_data[value_index] == int2_data[value_index], value_index); @@ -4072,8 +4072,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueObject) && (second_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject * const *obj1_vec = first_child_value->ObjectElementVector()->data(); - EidosObject * const *obj2_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj1_vec = first_child_value->ObjectData(); + EidosObject * const *obj2_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj1_vec[value_index] == obj2_vec[value_index], value_index); @@ -4111,7 +4111,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float1 = first_child_value->FloatAtIndex(0, operator_token); - const double *float_data = second_child_value->FloatVector()->data(); + const double *float_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(float1 == float_data[value_index], value_index); @@ -4120,7 +4120,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int1 = first_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = second_child_value->IntVector()->data(); + const int64_t *int_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(int1 == int_data[value_index], value_index); @@ -4129,7 +4129,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj1 = first_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(obj1 == obj_vec[value_index], value_index); @@ -4166,7 +4166,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float2 = second_child_value->FloatAtIndex(0, operator_token); - const double *float_data = first_child_value->FloatVector()->data(); + const double *float_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float_data[value_index] == float2, value_index); @@ -4175,7 +4175,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int2 = second_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = first_child_value->IntVector()->data(); + const int64_t *int_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int_data[value_index] == int2, value_index); @@ -4184,7 +4184,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj2 = second_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = first_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = first_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj_vec[value_index] == obj2, value_index); @@ -4880,8 +4880,8 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access - const double *float1_data = first_child_value->FloatVector()->data(); - const double *float2_data = second_child_value->FloatVector()->data(); + const double *float1_data = first_child_value->FloatData(); + const double *float2_data = second_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float1_data[value_index] != float2_data[value_index], value_index); @@ -4889,8 +4889,8 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access - const int64_t *int1_data = first_child_value->IntVector()->data(); - const int64_t *int2_data = second_child_value->IntVector()->data(); + const int64_t *int1_data = first_child_value->IntData(); + const int64_t *int2_data = second_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int1_data[value_index] != int2_data[value_index], value_index); @@ -4898,8 +4898,8 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((first_child_type == EidosValueType::kValueObject) && (second_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject * const *obj1_vec = first_child_value->ObjectElementVector()->data(); - EidosObject * const *obj2_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj1_vec = first_child_value->ObjectData(); + EidosObject * const *obj2_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj1_vec[value_index] != obj2_vec[value_index], value_index); @@ -4937,7 +4937,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float1 = first_child_value->FloatAtIndex(0, operator_token); - const double *float_data = second_child_value->FloatVector()->data(); + const double *float_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(float1 != float_data[value_index], value_index); @@ -4946,7 +4946,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int1 = first_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = second_child_value->IntVector()->data(); + const int64_t *int_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(int1 != int_data[value_index], value_index); @@ -4955,7 +4955,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj1 = first_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = second_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < second_child_count; ++value_index) logical_result->set_logical_no_check(obj1 != obj_vec[value_index], value_index); @@ -4992,7 +4992,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float double float2 = second_child_value->FloatAtIndex(0, operator_token); - const double *float_data = first_child_value->FloatVector()->data(); + const double *float_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(float_data[value_index] != float2, value_index); @@ -5001,7 +5001,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int int64_t int2 = second_child_value->IntAtIndex(0, operator_token); - const int64_t *int_data = first_child_value->IntVector()->data(); + const int64_t *int_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(int_data[value_index] != int2, value_index); @@ -5010,7 +5010,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) { // Direct object-to-object compare can be optimized through vector access EidosObject *obj2 = second_child_value->ObjectElementAtIndex(0, operator_token); - EidosObject * const *obj_vec = first_child_value->ObjectElementVector()->data(); + EidosObject * const *obj_vec = first_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) logical_result->set_logical_no_check(obj_vec[value_index] != obj2, value_index); @@ -5809,7 +5809,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) // EidosValue that we stick new values into – much, much faster. if (range_type == EidosValueType::kValueInt) { - const int64_t *range_data = range_value->IntVector()->data(); + const int64_t *range_data = range_value->IntData(); EidosValue_Int_singleton_SP index_value_SP = EidosValue_Int_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); EidosValue_Int_singleton *index_value = index_value_SP.get(); @@ -5842,7 +5842,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueFloat) { - const double *range_data = range_value->FloatVector()->data(); + const double *range_data = range_value->FloatData(); EidosValue_Float_singleton_SP index_value_SP = EidosValue_Float_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0)); EidosValue_Float_singleton *index_value = index_value_SP.get(); @@ -5875,7 +5875,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueString) { - const std::vector &range_vec = *range_value->StringVector(); + const std::string *range_vec = range_value->StringData(); EidosValue_String_singleton_SP index_value_SP = EidosValue_String_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_empty_string)); EidosValue_String_singleton *index_value = index_value_SP.get(); @@ -5908,7 +5908,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueObject) { - EidosObject * const *range_vec = range_value->ObjectElementVector()->data(); + EidosObject * const *range_vec = range_value->ObjectData(); EidosValue_Object_singleton_SP index_value_SP = EidosValue_Object_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(nullptr, ((EidosValue_Object *)range_value.get())->Class())); EidosValue_Object_singleton *index_value = index_value_SP.get(); @@ -5941,7 +5941,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) } else if (range_type == EidosValueType::kValueLogical) { - const eidos_logical_t *range_data = range_value->LogicalVector()->data(); + const eidos_logical_t *range_data = range_value->LogicalData(); EidosValue_Logical_SP index_value_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *index_value = index_value_SP->resize_no_initialize(1); diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index bf659f6f5..fd33e90f9 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -871,11 +871,6 @@ const std::string &EidosValue_VOID::ElementType(void) const return gEidosStr_void; } -int EidosValue_VOID::Count_Virtual(void) const -{ - return 0; -} - void EidosValue_VOID::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { #pragma unused(p_idx) @@ -952,11 +947,6 @@ const std::string &EidosValue_NULL::ElementType(void) const return gEidosStr_NULL; } -int EidosValue_NULL::Count_Virtual(void) const -{ - return 0; -} - void EidosValue_NULL::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { #pragma unused(p_idx) @@ -1052,11 +1042,6 @@ const std::string &EidosValue_Logical::ElementType(void) const return gEidosStr_logical; } -int EidosValue_Logical::Count_Virtual(void) const -{ - return (int)count_; -} - void EidosValue_Logical::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { eidos_logical_t value = values_[p_idx]; @@ -1077,7 +1062,7 @@ nlohmann::json EidosValue_Logical::JSONRepresentation(void) const eidos_logical_t EidosValue_Logical::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1085,7 +1070,7 @@ eidos_logical_t EidosValue_Logical::LogicalAtIndex(int p_idx, const EidosToken * std::string EidosValue_Logical::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? gEidosStr_T : gEidosStr_F); @@ -1093,7 +1078,7 @@ std::string EidosValue_Logical::StringAtIndex(int p_idx, const EidosToken *p_bla int64_t EidosValue_Logical::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? 1 : 0); @@ -1101,7 +1086,7 @@ int64_t EidosValue_Logical::IntAtIndex(int p_idx, const EidosToken *p_blame_toke double EidosValue_Logical::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? 1.0 : 0.0); @@ -1109,7 +1094,7 @@ double EidosValue_Logical::FloatAtIndex(int p_idx, const EidosToken *p_blame_tok EidosValue_SP EidosValue_Logical::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); @@ -1117,7 +1102,7 @@ EidosValue_SP EidosValue_Logical::GetValueAtIndex(const int p_idx, const EidosTo void EidosValue_Logical::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); values_[p_idx] = p_value.LogicalAtIndex(0, p_blame_token); @@ -1316,11 +1301,6 @@ EidosValue_String_vector::EidosValue_String_vector(std::initializer_list= (int)values_.size())) @@ -1408,11 +1388,6 @@ void EidosValue_String_vector::Sort(bool p_ascending) // EidosValue_String_singleton #pragma mark EidosValue_String_singleton -int EidosValue_String_singleton::Count_Virtual(void) const -{ - return 1; -} - eidos_logical_t EidosValue_String_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -1591,14 +1566,9 @@ EidosValue_Int_vector::EidosValue_Int_vector(const int64_t *p_values, size_t p_c set_int_no_check(p_values[index], index); } -int EidosValue_Int_vector::Count_Virtual(void) const -{ - return (int)count_; -} - eidos_logical_t EidosValue_Int_vector::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] == 0 ? false : true); @@ -1606,7 +1576,7 @@ eidos_logical_t EidosValue_Int_vector::LogicalAtIndex(int p_idx, const EidosToke std::string EidosValue_Int_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return std::to_string(values_[p_idx]); // way faster than std::ostringstream @@ -1614,7 +1584,7 @@ std::string EidosValue_Int_vector::StringAtIndex(int p_idx, const EidosToken *p_ int64_t EidosValue_Int_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1622,7 +1592,7 @@ int64_t EidosValue_Int_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_t double EidosValue_Int_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1630,7 +1600,7 @@ double EidosValue_Int_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_ EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(values_[p_idx])); @@ -1638,7 +1608,7 @@ EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const Eido void EidosValue_Int_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); values_[p_idx] = p_value.IntAtIndex(0, p_blame_token); @@ -1718,11 +1688,6 @@ void EidosValue_Int_vector::erase_index(size_t p_index) // EidosValue_Int_singleton #pragma mark EidosValue_Int_singleton -int EidosValue_Int_singleton::Count_Virtual(void) const -{ - return 1; -} - eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -1862,14 +1827,9 @@ EidosValue_Float_vector::EidosValue_Float_vector(const double *p_values, size_t set_float_no_check(p_values[index], index); } -int EidosValue_Float_vector::Count_Virtual(void) const -{ - return (int)count_; -} - eidos_logical_t EidosValue_Float_vector::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; @@ -1882,7 +1842,7 @@ eidos_logical_t EidosValue_Float_vector::LogicalAtIndex(int p_idx, const EidosTo std::string EidosValue_Float_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosStringForFloat(values_[p_idx]); @@ -1890,7 +1850,7 @@ std::string EidosValue_Float_vector::StringAtIndex(int p_idx, const EidosToken * int64_t EidosValue_Float_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; @@ -1909,7 +1869,7 @@ int64_t EidosValue_Float_vector::IntAtIndex(int p_idx, const EidosToken *p_blame double EidosValue_Float_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -1917,7 +1877,7 @@ double EidosValue_Float_vector::FloatAtIndex(int p_idx, const EidosToken *p_blam EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(values_[p_idx])); @@ -1925,7 +1885,7 @@ EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const Ei void EidosValue_Float_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); values_[p_idx] = p_value.FloatAtIndex(0, p_blame_token); @@ -2008,11 +1968,6 @@ void EidosValue_Float_vector::erase_index(size_t p_index) // EidosValue_Float_singleton #pragma mark EidosValue_Float_singleton -int EidosValue_Float_singleton::Count_Virtual(void) const -{ - return 1; -} - eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -2161,9 +2116,7 @@ EidosValue_Object::~EidosValue_Object(void) // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments void EidosValue_Object_vector::PatchPointersByAdding(std::uintptr_t p_pointer_difference) { - size_t value_count = size(); - - for (size_t i = 0; i < value_count; ++i) + for (size_t i = 0; i < count_; ++i) { std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; @@ -2175,9 +2128,7 @@ void EidosValue_Object_vector::PatchPointersByAdding(std::uintptr_t p_pointer_di // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments void EidosValue_Object_vector::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) { - size_t value_count = size(); - - for (size_t i = 0; i < value_count; ++i) + for (size_t i = 0; i < count_; ++i) { std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; @@ -2249,7 +2200,7 @@ nlohmann::json EidosValue_Object::JSONRepresentation(void) const EidosValue_Object_vector::EidosValue_Object_vector(const EidosValue_Object_vector &p_original) : EidosValue_Object(false, p_original.Class()) { - size_t count = p_original.size(); + size_t count = p_original.Count(); EidosObject * const *values = p_original.data(); resize_no_initialize_RR(count); @@ -2333,14 +2284,9 @@ EidosValue_Object_vector::~EidosValue_Object_vector(void) free(values_); } -int EidosValue_Object_vector::Count_Virtual(void) const -{ - return (int)size(); -} - EidosObject *EidosValue_Object_vector::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; @@ -2348,7 +2294,7 @@ EidosObject *EidosValue_Object_vector::ObjectElementAtIndex(int p_idx, const Eid EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(values_[p_idx], Class())); @@ -2356,7 +2302,7 @@ EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const E void EidosValue_Object_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) { - if ((p_idx < 0) || (p_idx >= (int)size())) + if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); EidosObject *new_value = p_value.ObjectElementAtIndex(0, p_blame_token); @@ -2404,7 +2350,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce // blame token; all errors will be attributed to that function automatically. // length 0 is already sorted - if (size() == 0) + if (count_ == 0) return; // figure out what type the property returns @@ -2557,7 +2503,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringID p_property_id) const { - size_t values_size = (size_t)size(); + size_t values_size = count_; const EidosPropertySignature *signature = class_->SignatureForProperty(p_property_id); if (!signature) @@ -2692,7 +2638,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope // We have to check the count ourselves; the signature does not do that for us size_t p_value_count = p_value.Count(); - size_t values_size = (size_t)size(); + size_t values_size = count_; if (p_value_count == 1) { @@ -2742,7 +2688,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { // This is an instance method, so it gets dispatched to all of our elements - auto values_size = size(); + auto values_size = count_; if (values_size == 0) { @@ -2807,6 +2753,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ // timed all of this, and it really does make a difference; calling a method on a large object vector is very // common, and these optimizations make a substantial difference. In fact, I'm tempted to go even further, // down the road I went down with accelerated properties, but I will hold off on that for now. :-> + // BCH 12/20/2023: the XData() methods now allow us to avoid IsSingleton() and treat the cases jointly. EidosValueMask sig_mask = (p_method_signature->return_mask_ & kEidosValueMaskFlagStrip); bool return_is_singleton = (p_method_signature->return_mask_ & kEidosValueMaskSingleton); @@ -2886,7 +2833,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ { // No singleton special-case for logical; EidosValue_Logical is always a vector int return_count = temp_result->Count(); - const eidos_logical_t *return_data = temp_result->LogicalVector()->data(); + const eidos_logical_t *return_data = temp_result->LogicalData(); for (int return_index = 0; return_index < return_count; return_index++) logical_result->push_logical(return_data[return_index]); @@ -2912,12 +2859,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ p_method_signature->CheckReturn(*temp_result); #endif if (temp_result->Type() == EidosValueType::kValueInt) - { - if (temp_result->IsSingleton()) - integer_result->push_int_no_check(((EidosValue_Int_singleton *)temp_result.get())->IntValue()); - else - integer_result->push_int_no_check(temp_result->IntAtIndex(0, nullptr)); // should not generally get hit since the method should return a singleton - } + integer_result->push_int_no_check(temp_result->IntData()[0]); // else it is a NULL, discard it } } @@ -2932,18 +2874,10 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ if (temp_result->Type() == EidosValueType::kValueInt) { int return_count = temp_result->Count(); + const int64_t *return_data = temp_result->IntData(); - if ((return_count == 1) && temp_result->IsSingleton()) - { - integer_result->push_int(((EidosValue_Int_singleton *)temp_result.get())->IntValue()); - } - else - { - const int64_t *return_data = temp_result->IntVector()->data(); - - for (int return_index = 0; return_index < return_count; return_index++) - integer_result->push_int(return_data[return_index]); - } + for (int return_index = 0; return_index < return_count; return_index++) + integer_result->push_int(return_data[return_index]); } // else it is a NULL, discard it } @@ -2966,12 +2900,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ p_method_signature->CheckReturn(*temp_result); #endif if (temp_result->Type() == EidosValueType::kValueFloat) - { - if (temp_result->IsSingleton()) - float_result->push_float_no_check(((EidosValue_Float_singleton *)temp_result.get())->FloatValue()); - else - float_result->push_float_no_check(temp_result->FloatAtIndex(0, nullptr)); // should not generally get hit since the method should return a singleton - } + float_result->push_float_no_check(temp_result->FloatData()[0]); // else it is a NULL, discard it } } @@ -2986,18 +2915,10 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ if (temp_result->Type() == EidosValueType::kValueFloat) { int return_count = temp_result->Count(); + const double *return_data = temp_result->FloatData(); - if ((return_count == 1) && temp_result->IsSingleton()) - { - float_result->push_float(((EidosValue_Float_singleton *)temp_result.get())->FloatValue()); - } - else - { - const double *return_data = temp_result->FloatVector()->data(); - - for (int return_index = 0; return_index < return_count; return_index++) - float_result->push_float(return_data[return_index]); - } + for (int return_index = 0; return_index < return_count; return_index++) + float_result->push_float(return_data[return_index]); } // else it is a NULL, discard it } @@ -3024,12 +2945,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ p_method_signature->CheckReturn(*temp_result); #endif if (temp_result->Type() == EidosValueType::kValueObject) - { - if (temp_result->IsSingleton()) - object_result->push_object_element_no_check_CRR(((EidosValue_Object_singleton *)temp_result.get())->ObjectElementValue()); - else - object_result->push_object_element_no_check_CRR(temp_result->ObjectElementAtIndex(0, nullptr)); // should not generally get hit since the method should return a singleton - } + object_result->push_object_element_no_check_CRR(temp_result->ObjectData()[0]); // else it is a NULL, discard it } } @@ -3044,18 +2960,10 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ if (temp_result->Type() == EidosValueType::kValueObject) { int return_count = temp_result->Count(); + EidosObject * const *return_data = temp_result->ObjectData(); - if ((return_count == 1) && temp_result->IsSingleton()) - { - object_result->push_object_element_CRR(((EidosValue_Object_singleton *)temp_result.get())->ObjectElementValue()); - } - else - { - EidosObject * const *return_data = temp_result->ObjectElementVector()->data(); - - for (int return_index = 0; return_index < return_count; return_index++) - object_result->push_object_element_CRR(return_data[return_index]); - } + for (int return_index = 0; return_index < return_count; return_index++) + object_result->push_object_element_CRR(return_data[return_index]); } // else it is a NULL, discard it } @@ -3230,11 +3138,6 @@ EidosValue_Object_singleton::~EidosValue_Object_singleton(void) static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead } -int EidosValue_Object_singleton::Count_Virtual(void) const -{ - return 1; -} - EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 61d4ca3cb..e89d24c00 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -156,6 +156,7 @@ class EidosValue protected: mutable uint32_t intrusive_ref_count_; // used by Eidos_intrusive_ptr + const EidosValueType cached_type_; // allows Type() to be an inline function; cached at construction uint8_t invisible_; // as in R; if true, the value will not normally be printed to the console uint8_t is_singleton_; // allows Count() and IsSingleton() to be inline; cached at construction @@ -177,6 +178,13 @@ class EidosValue EidosValue(EidosValueType p_value_type, bool p_singleton); // must construct with a type identifier and singleton flag, which will be cached virtual ~EidosValue(void); + // methods that raise due to various causes, used to avoid duplication and allow efficient inlining + void RaiseForUnimplementedVectorCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForUnsupportedConversionCall(const EidosToken *p_blame_token) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForCapacityViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForRangeViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForRetainReleaseViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + // basic methods inline __attribute__((always_inline)) EidosValueType Type(void) const { return cached_type_; } // the type of the vector, cached at construction inline __attribute__((always_inline)) bool IsSingleton(void) const { return is_singleton_; } // true is the subclass is a singleton subclass (not just if Count()==1) @@ -210,29 +218,23 @@ class EidosValue virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) = 0; // copy a value virtual void Sort(bool p_ascending) = 0; - // Methods to get a type-specific vector for fast manipulation; these raise if called on a value that does not support them. - // This is much faster than using dynamic_cast to achieve the same effect, and much safer than using static_cast + non-virtual function. - // Note that these methods are conventionally used in Eidos by immediately dereferencing to create a reference to the vector; this - // should be safe, since these methods should always raise rather than returning nullptr. - void RaiseForUnimplementedVectorCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForUnsupportedConversionCall(const EidosToken *p_blame_token) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForCapacityViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForRangeViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForRetainReleaseViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - - virtual const EidosValue_Logical *LogicalVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Logical *LogicalVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const std::vector *StringVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual std::vector *StringVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const EidosValue_Int_vector *IntVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Int_vector *IntVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const EidosValue_Float_vector *FloatVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Float_vector *FloatVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const EidosValue_Object_vector *ObjectElementVector(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosValue_Object_vector *ObjectElementVector_Mutable(void) { RaiseForUnimplementedVectorCall(); } + // Methods to get a type-specific pointer directly to the data of the EidosValue. This is generally good for either + // accessing the values without changing them, or changing them but not changing the length of the vector. You must + // explicitly request mutability. If you want to change the length of the vector, you will want to actually get the + // type-specific vector subclass using dynamic_cast, but it is rare not to already have that pointer in such cases. + virtual const eidos_logical_t *LogicalData(void) const { RaiseForUnimplementedVectorCall(); } + virtual eidos_logical_t *LogicalData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const std::string *StringData(void) const { RaiseForUnimplementedVectorCall(); } + virtual std::string *StringData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const int64_t *IntData(void) const { RaiseForUnimplementedVectorCall(); } + virtual int64_t *IntData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const double *FloatData(void) const { RaiseForUnimplementedVectorCall(); } + virtual double *FloatData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual EidosObject * const *ObjectData(void) const { RaiseForUnimplementedVectorCall(); } + virtual EidosObject **ObjectData_Mutable(void) { RaiseForUnimplementedVectorCall(); } // Dimension support, for matrices and arrays - inline __attribute__((always_inline)) bool IsArray(void) const { return !!dim_; } // true if we have a dimensions buffer – any array, including a matrix + inline __attribute__((always_inline)) bool IsMatrixOrArray(void) const { return !!dim_; } // true if we have a dimensions buffer inline __attribute__((always_inline)) int DimensionCount(void) const { return (!dim_) ? 1 : (int)*dim_; } // 1 for vectors, 2 for matrices, 2...n for arrays (1 not allowed for arrays) inline __attribute__((always_inline)) const int64_t *Dimensions(void) const { return (!dim_) ? nullptr : dim_ + 1; } // nullptr or a pointer into the dim_ buffer @@ -331,13 +333,13 @@ inline __attribute__((always_inline)) void Eidos_intrusive_ptr_release(const Eid // which should be used for all void values. // -class EidosValue_VOID : public EidosValue +class EidosValue_VOID final : public EidosValue { private: typedef EidosValue super; protected: - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 0; } public: EidosValue_VOID(const EidosValue_VOID &p_original) = delete; // no copy-construct @@ -378,13 +380,13 @@ class EidosValue_VOID : public EidosValue // representing invisible versus non-invisible NULL. // -class EidosValue_NULL : public EidosValue +class EidosValue_NULL final : public EidosValue { private: typedef EidosValue super; protected: - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 0; } public: EidosValue_NULL(const EidosValue_NULL &p_original) = delete; // no copy-construct @@ -426,10 +428,10 @@ class EidosValue_NULL : public EidosValue // logical the EidosValue_Logical class itself is a non-abstract class that models a vector of logical // values; there is no singleton version. There is a subclass, EidosValue_Logical_const, that is used // by the two shared T and F EidosValues, gStaticEidosValue_LogicalT and gStaticEidosValue_LogicalF; -// it tries to enforce constness on those globals by making the virtual function LogicalVector_Mutable(), -// which is used to go from an EidosValue* to a EidosValue_Logical*, raise, and by making other virtual +// it tries to enforce constness on those globals by making the virtual function LogicalData_Mutable(), +// which is used to get a mutable pointer to the eidos_logical_t data, raise, and by making other virtual // functions that would modify the value raise as well. This is not entirely bullet-proof, since one -// could cast to EidosValue_Logical instead of using LogicalVector_Mutable(), but you're not supposed +// could cast to EidosValue_Logical instead of using LogicalData_Mutable(), but you're not supposed // to do that. EidosValue_Logical_const pretends to be a singleton class, by setting is_singleton_, // but that is probably non-essential. // @@ -446,7 +448,7 @@ class EidosValue_Logical : public EidosValue protected: explicit EidosValue_Logical(eidos_logical_t p_logical1); // protected to encourage use of EidosValue_Logical_const for this - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Logical(const EidosValue_Logical &p_original) = delete; // no copy-construct @@ -462,8 +464,8 @@ class EidosValue_Logical : public EidosValue virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; - virtual const EidosValue_Logical *LogicalVector(void) const override { return this; } - virtual EidosValue_Logical *LogicalVector_Mutable(void) override { return this; } + virtual const eidos_logical_t *LogicalData(void) const override { return values_; } + virtual eidos_logical_t *LogicalData_Mutable(void) override { return values_; } virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -487,7 +489,6 @@ class EidosValue_Logical : public EidosValue inline __attribute__((always_inline)) eidos_logical_t *data(void) { return values_; } inline __attribute__((always_inline)) const eidos_logical_t *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } inline __attribute__((always_inline)) void push_logical(eidos_logical_t p_logical) { if (count_ == capacity_) expand(); @@ -509,7 +510,7 @@ class EidosValue_Logical : public EidosValue } }; -class EidosValue_Logical_const : public EidosValue_Logical +class EidosValue_Logical_const final : public EidosValue_Logical { private: typedef EidosValue_Logical super; @@ -529,7 +530,7 @@ class EidosValue_Logical_const : public EidosValue_Logical virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because this subclass represents only truly immutable objects - virtual EidosValue_Logical *LogicalVector_Mutable(void) override { RaiseForUnimplementedVectorCall(); } + virtual eidos_logical_t *LogicalData_Mutable(void) override { RaiseForUnimplementedVectorCall(); } virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -577,7 +578,7 @@ class EidosValue_String : public EidosValue virtual void Sort(bool p_ascending) override = 0; }; -class EidosValue_String_vector : public EidosValue_String +class EidosValue_String_vector final : public EidosValue_String { private: typedef EidosValue_String super; @@ -587,7 +588,7 @@ class EidosValue_String_vector : public EidosValue_String // not initializing the memory belonging to a std::string, so the malloc strategy doesn't work std::vector values_; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)values_.size(); } public: EidosValue_String_vector(const EidosValue_String_vector &p_original) = delete; // no copy-construct @@ -601,8 +602,10 @@ class EidosValue_String_vector : public EidosValue_String explicit EidosValue_String_vector(std::initializer_list p_init_list); inline virtual ~EidosValue_String_vector(void) override { } - virtual const std::vector *StringVector(void) const override { return &values_; } - virtual std::vector *StringVector_Mutable(void) override { return &values_; } + virtual const std::string *StringData(void) const override { return values_.data(); } + virtual std::string *StringData_Mutable(void) override { return values_.data(); } + std::vector &StringVectorData(void) { return values_; } // to get the std::vector for direct modification + inline __attribute__((always_inline)) void PushString(const std::string &p_string) { values_.emplace_back(p_string); } inline __attribute__((always_inline)) EidosValue_String_vector *Reserve(int p_reserved_size) { values_.reserve(p_reserved_size); return this; } @@ -621,7 +624,7 @@ class EidosValue_String_vector : public EidosValue_String virtual void Sort(bool p_ascending) override; }; -class EidosValue_String_singleton : public EidosValue_String +class EidosValue_String_singleton final : public EidosValue_String { private: typedef EidosValue_String super; @@ -630,7 +633,7 @@ class EidosValue_String_singleton : public EidosValue_String std::string value_; EidosScript *cached_script_ = nullptr; // cached by executeLambda(), apply(), and sapply() to avoid multiple tokenize/parse overhead - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_String_singleton(const EidosValue_String_singleton &p_original) = delete; // no copy-construct @@ -639,8 +642,10 @@ class EidosValue_String_singleton : public EidosValue_String explicit inline EidosValue_String_singleton(const std::string &p_string1) : EidosValue_String(true), value_(p_string1) { } inline virtual ~EidosValue_String_singleton(void) override { delete cached_script_; } - inline __attribute__((always_inline)) const std::string &StringValue(void) const { return value_; } inline __attribute__((always_inline)) std::string &StringValue_Mutable(void) { delete cached_script_; cached_script_ = nullptr; return value_; } // very dangerous; do not use + + virtual const std::string *StringData(void) const override { return &value_; } + virtual std::string *StringData_Mutable(void) override { delete cached_script_; cached_script_ = nullptr; return &value_; } // very dangerous; do not use inline __attribute__((always_inline)) void SetValue(const std::string &p_string) { delete cached_script_; cached_script_ = nullptr; value_ = p_string; } // very dangerous; used only in Evaluate_For() virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -706,7 +711,7 @@ class EidosValue_Int : public EidosValue virtual void Sort(bool p_ascending) override = 0; }; -class EidosValue_Int_vector : public EidosValue_Int +class EidosValue_Int_vector final : public EidosValue_Int { private: typedef EidosValue_Int super; @@ -715,7 +720,7 @@ class EidosValue_Int_vector : public EidosValue_Int int64_t *values_ = nullptr; size_t count_ = 0, capacity_ = 0; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Int_vector(const EidosValue_Int_vector &p_original) = delete; // no copy-construct @@ -730,8 +735,8 @@ class EidosValue_Int_vector : public EidosValue_Int explicit EidosValue_Int_vector(const int64_t *p_values, size_t p_count); inline virtual ~EidosValue_Int_vector(void) override { free(values_); } - virtual const EidosValue_Int_vector *IntVector(void) const override { return this; } - virtual EidosValue_Int_vector *IntVector_Mutable(void) override { return this; } + virtual const int64_t *IntData(void) const override { return values_; } + virtual int64_t *IntData_Mutable(void) override { return values_; } virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -754,7 +759,6 @@ class EidosValue_Int_vector : public EidosValue_Int inline __attribute__((always_inline)) int64_t *data(void) { return values_; } inline __attribute__((always_inline)) const int64_t *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } inline __attribute__((always_inline)) void push_int(int64_t p_int) { if (count_ == capacity_) expand(); @@ -776,7 +780,7 @@ class EidosValue_Int_vector : public EidosValue_Int } }; -class EidosValue_Int_singleton : public EidosValue_Int +class EidosValue_Int_singleton final : public EidosValue_Int { private: typedef EidosValue_Int super; @@ -784,7 +788,7 @@ class EidosValue_Int_singleton : public EidosValue_Int protected: int64_t value_; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_Int_singleton(const EidosValue_Int_singleton &p_original) = delete; // no copy-construct @@ -793,8 +797,8 @@ class EidosValue_Int_singleton : public EidosValue_Int explicit inline EidosValue_Int_singleton(int64_t p_int1) : EidosValue_Int(true), value_(p_int1) { } inline virtual ~EidosValue_Int_singleton(void) override { } - inline __attribute__((always_inline)) int64_t IntValue(void) const { return value_; } - inline __attribute__((always_inline)) int64_t &IntValue_Mutable(void) { return value_; } // very dangerous; used only in Evaluate_Assign() + virtual const int64_t *IntData(void) const override { return &value_; } + virtual int64_t *IntData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() inline __attribute__((always_inline)) void SetValue(int64_t p_int) { value_ = p_int; } // very dangerous; used only in Evaluate_For() virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -855,7 +859,7 @@ class EidosValue_Float : public EidosValue virtual void Sort(bool p_ascending) override = 0; }; -class EidosValue_Float_vector : public EidosValue_Float +class EidosValue_Float_vector final : public EidosValue_Float { private: typedef EidosValue_Float super; @@ -864,7 +868,7 @@ class EidosValue_Float_vector : public EidosValue_Float double *values_ = nullptr; size_t count_ = 0, capacity_ = 0; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Float_vector(const EidosValue_Float_vector &p_original) = delete; // no copy-construct @@ -877,8 +881,8 @@ class EidosValue_Float_vector : public EidosValue_Float explicit EidosValue_Float_vector(const double *p_values, size_t p_count); inline virtual ~EidosValue_Float_vector(void) override { free(values_); } - virtual const EidosValue_Float_vector *FloatVector(void) const override { return this; } - virtual EidosValue_Float_vector *FloatVector_Mutable(void) override { return this; } + virtual const double *FloatData(void) const override { return values_; } + virtual double *FloatData_Mutable(void) override { return values_; } virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -901,7 +905,6 @@ class EidosValue_Float_vector : public EidosValue_Float inline __attribute__((always_inline)) double *data(void) { return values_; } inline __attribute__((always_inline)) const double *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } inline __attribute__((always_inline)) void push_float(double p_float) { if (count_ == capacity_) expand(); @@ -923,7 +926,7 @@ class EidosValue_Float_vector : public EidosValue_Float } }; -class EidosValue_Float_singleton : public EidosValue_Float +class EidosValue_Float_singleton final : public EidosValue_Float { private: typedef EidosValue_Float super; @@ -931,7 +934,7 @@ class EidosValue_Float_singleton : public EidosValue_Float protected: double value_; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_Float_singleton(const EidosValue_Float_singleton &p_original) = delete; // no copy-construct @@ -940,8 +943,8 @@ class EidosValue_Float_singleton : public EidosValue_Float explicit inline EidosValue_Float_singleton(double p_float1) : EidosValue_Float(true), value_(p_float1) { } inline virtual ~EidosValue_Float_singleton(void) override { } - inline __attribute__((always_inline)) double FloatValue(void) const { return value_; } - inline __attribute__((always_inline)) double &FloatValue_Mutable(void) { return value_; } // very dangerous; used only in Evaluate_Assign() + virtual const double *FloatData(void) const override { return &value_; } + virtual double *FloatData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() inline __attribute__((always_inline)) void SetValue(double p_float) { value_ = p_float; } // very dangerous; used only in Evaluate_For() virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; @@ -1046,7 +1049,7 @@ class EidosValue_Object : public EidosValue virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) = 0; }; -class EidosValue_Object_vector : public EidosValue_Object +class EidosValue_Object_vector final : public EidosValue_Object { private: typedef EidosValue_Object super; @@ -1055,7 +1058,7 @@ class EidosValue_Object_vector : public EidosValue_Object EidosObject **values_ = nullptr; // these may use a retain/release system of ownership; see below size_t count_ = 0, capacity_ = 0; - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Object_vector(const EidosValue_Object_vector &p_original); // can copy-construct @@ -1074,8 +1077,8 @@ class EidosValue_Object_vector : public EidosValue_Object virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual const EidosValue_Object_vector *ObjectElementVector(void) const override { return this; } - virtual EidosValue_Object_vector *ObjectElementVector_Mutable(void) override { return this; } + virtual EidosObject * const *ObjectData(void) const override { return values_; } + virtual EidosObject **ObjectData_Mutable(void) override { return values_; } virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; @@ -1105,7 +1108,6 @@ class EidosValue_Object_vector : public EidosValue_Object inline __attribute__((always_inline)) EidosObject **data(void) { return values_; } // the accessors below should be used to modify, since they handle Retain()/Release() inline __attribute__((always_inline)) EidosObject * const *data(void) const { return values_; } - inline __attribute__((always_inline)) size_t size(void) const { return count_; } // fast accessors; you can use the _RR or _NORR versions in a tight loop to avoid overhead, when you know // whether the EidosObject subclass you are using inherits from EidosDictionaryRetained or not; @@ -1302,7 +1304,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -class EidosValue_Object_singleton : public EidosValue_Object +class EidosValue_Object_singleton final : public EidosValue_Object { private: typedef EidosValue_Object super; @@ -1310,7 +1312,7 @@ class EidosValue_Object_singleton : public EidosValue_Object protected: EidosObject *value_; // these may use a retain/release system of ownership; see below - virtual int Count_Virtual(void) const override; + virtual int Count_Virtual(void) const override { return 1; } public: EidosValue_Object_singleton(const EidosValue_Object_singleton &p_original) = delete; // no copy-construct @@ -1326,8 +1328,8 @@ class EidosValue_Object_singleton : public EidosValue_Object virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - inline __attribute__((always_inline)) EidosObject *ObjectElementValue(void) const { return value_; } - inline __attribute__((always_inline)) EidosObject * &ObjectElementValue_Mutable(void) { return value_; } // very dangerous; do not use + virtual EidosObject * const *ObjectData(void) const override { return &value_; } + virtual EidosObject **ObjectData_Mutable(void) override { return &value_; } // very dangerous; do not use void SetValue(EidosObject *p_element); // very dangerous; used only in Evaluate_For() virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; From e373deee5bf52df36edde7c6efb4c1807d5c89d7 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Thu, 21 Dec 2023 11:01:15 -0500 Subject: [PATCH 02/18] differentiate casting vs. non-casting element accesses --- eidos/eidos_ast_node.cpp | 4 +- eidos/eidos_class_DataFrame.cpp | 30 +- eidos/eidos_class_Dictionary.cpp | 38 +-- eidos/eidos_class_Image.cpp | 8 +- eidos/eidos_class_Object.cpp | 4 +- eidos/eidos_class_TestElement.cpp | 10 +- eidos/eidos_functions.cpp | 46 +-- eidos/eidos_functions_colors.cpp | 52 +-- eidos/eidos_functions_distributions.cpp | 202 ++++++------ eidos/eidos_functions_files.cpp | 34 +- eidos/eidos_functions_math.cpp | 186 +++++------ eidos/eidos_functions_matrices.cpp | 50 +-- eidos/eidos_functions_other.cpp | 70 ++-- eidos/eidos_functions_stats.cpp | 90 +++--- eidos/eidos_functions_strings.cpp | 58 ++-- eidos/eidos_functions_values.cpp | 200 ++++++------ eidos/eidos_interpreter.cpp | 406 ++++++++++++------------ eidos/eidos_script.cpp | 4 +- eidos/eidos_value.cpp | 234 +++++++++----- eidos/eidos_value.h | 161 +++++----- 20 files changed, 980 insertions(+), 907 deletions(-) diff --git a/eidos/eidos_ast_node.cpp b/eidos/eidos_ast_node.cpp index 645998aed..42064b533 100644 --- a/eidos/eidos_ast_node.cpp +++ b/eidos/eidos_ast_node.cpp @@ -391,14 +391,14 @@ bool EidosASTNode::HasCachedNumericValue(void) const double EidosASTNode::CachedNumericValue(void) const { if ((token_->token_type_ == EidosTokenType::kTokenNumber) && cached_literal_value_ && (cached_literal_value_->Count() == 1)) - return cached_literal_value_->FloatAtIndex(0, nullptr); + return cached_literal_value_->FloatAtIndex_CAST(0, nullptr); if ((token_->token_type_ == EidosTokenType::kTokenMinus) && (children_.size() == 1)) { const EidosASTNode *minus_child = children_[0]; if ((minus_child->token_->token_type_ == EidosTokenType::kTokenNumber) && minus_child->cached_literal_value_ && (minus_child->cached_literal_value_->Count() == 1)) - return -minus_child->cached_literal_value_->FloatAtIndex(0, nullptr); + return -minus_child->cached_literal_value_->FloatAtIndex_CAST(0, nullptr); } EIDOS_TERMINATION << "ERROR (EidosASTNode::CachedNumericValue): (internal error) no cached numeric value" << EidosTerminate(nullptr); diff --git a/eidos/eidos_class_DataFrame.cpp b/eidos/eidos_class_DataFrame.cpp index aafc5fcb0..3aa42dc6e 100644 --- a/eidos/eidos_class_DataFrame.cpp +++ b/eidos/eidos_class_DataFrame.cpp @@ -85,7 +85,7 @@ EidosDataFrame *EidosDataFrame::SubsetColumns(EidosValue *index_value) for (int i = 0; i < index_count; ++i) { - int64_t index = index_value->IntAtIndex(i, nullptr); + int64_t index = index_value->IntAtIndex_NOCAST(i, nullptr); if ((index < 0) || (index >= key_count)) EIDOS_TERMINATION << "ERROR (EidosDataFrame::SubsetColumns): column index out of range (" << index << " not in [0, " << (key_count - 1) << "])." << EidosTerminate(nullptr); @@ -103,7 +103,7 @@ EidosDataFrame *EidosDataFrame::SubsetColumns(EidosValue *index_value) { for (int i = 0; i < index_count; ++i) { - const std::string &key = ((EidosValue_String *)index_value)->StringRefAtIndex(i, nullptr); + const std::string &key = ((EidosValue_String *)index_value)->StringRefAtIndex_NOCAST(i, nullptr); auto value_iter = symbols->find(key); @@ -122,7 +122,7 @@ EidosDataFrame *EidosDataFrame::SubsetColumns(EidosValue *index_value) for (int i = 0; i < index_count; ++i) { - bool selected = index_value->LogicalAtIndex(i, nullptr); + bool selected = index_value->LogicalAtIndex_NOCAST(i, nullptr); if (selected) { @@ -535,7 +535,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_cbind(EidosGlobalStringID p_method_i for (int arg_index = 0; arg_index < arg_count; ++arg_index) { - EidosObject *source_obj = arg->ObjectElementAtIndex(arg_index, nullptr); + EidosObject *source_obj = arg->ObjectElementAtIndex_NOCAST(arg_index, nullptr); EidosDictionaryUnretained *source = dynamic_cast(source_obj); if (!source) @@ -568,7 +568,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_rbind(EidosGlobalStringID p_method_i for (int arg_index = 0; arg_index < arg_count; ++arg_index) { - EidosObject *source_obj = arg->ObjectElementAtIndex(arg_index, nullptr); + EidosObject *source_obj = arg->ObjectElementAtIndex_NOCAST(arg_index, nullptr); EidosDictionaryUnretained *source = dynamic_cast(source_obj); if (!source) @@ -675,7 +675,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subsetRows(EidosGlobalStringID p_met EidosValue *index_value = p_arguments[0].get(); EidosValue *drop_value = p_arguments[1].get(); - EidosDataFrame *objectElement = SubsetRows(index_value, drop_value->LogicalAtIndex(0, nullptr)); + EidosDataFrame *objectElement = SubsetRows(index_value, drop_value->LogicalAtIndex_NOCAST(0, nullptr)); objectElement->ContentsChanged("subsetRows()"); EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); @@ -724,7 +724,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorStringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string file_path = Eidos_ResolvedPath(base_path); std::ifstream file_stream(file_path.c_str()); @@ -737,10 +737,10 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorStringAtIndex(0, nullptr); - std::string quote_string = quote_value->StringAtIndex(0, nullptr); - std::string dec_string = dec_value->StringAtIndex(0, nullptr); - std::string comment_string = comment_value->StringAtIndex(0, nullptr); + std::string sep_string = sep_value->StringAtIndex_NOCAST(0, nullptr); + std::string quote_string = quote_value->StringAtIndex_NOCAST(0, nullptr); + std::string dec_string = dec_value->StringAtIndex_NOCAST(0, nullptr); + std::string comment_string = comment_value->StringAtIndex_NOCAST(0, nullptr); if (sep_string.length() > 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_readCSV): readCSV() requires that sep be a string of exactly one character, or the empty string \"\"." << EidosTerminate(nullptr); @@ -966,7 +966,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vector columnNames; - if ((colNames_value->Type() == EidosValueType::kValueLogical) && (colNames_value->Count() == 1) && (colNames_value->LogicalAtIndex(0, nullptr) == true)) + if ((colNames_value->Type() == EidosValueType::kValueLogical) && (colNames_value->Count() == 1) && (colNames_value->LogicalAtIndex_NOCAST(0, nullptr) == true)) { // colNames == T means "a header row is present, use it" if (rows.size() == 0) @@ -975,7 +975,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorType() == EidosValueType::kValueLogical) && (colNames_value->Count() == 1) && (colNames_value->LogicalAtIndex(0, nullptr) == false)) + else if ((colNames_value->Type() == EidosValueType::kValueLogical) && (colNames_value->Count() == 1) && (colNames_value->LogicalAtIndex_NOCAST(0, nullptr) == false)) { // colNames == F means "autogenerate column names of the form X1, X2, ..." for (int col_index = 0; col_index < ncols; ++col_index) @@ -991,7 +991,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorStringAtIndex(col_index, nullptr); + std::string colname = colNames_value->StringAtIndex_NOCAST(col_index, nullptr); auto check_iter = std::find(columnNames.begin(), columnNames.end(), colname); if (check_iter != columnNames.end()) @@ -1033,7 +1033,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorType() == EidosValueType::kValueString) { - std::string colTypes_string = colTypes_value->StringAtIndex(0, nullptr); + std::string colTypes_string = colTypes_value->StringAtIndex_NOCAST(0, nullptr); for (char ch : colTypes_string) { diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index 855f44c0b..f3e2308d3 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -409,19 +409,19 @@ EidosValue_SP EidosDictionaryUnretained::Serialization_CSV(const std::string &p_ case EidosValueType::kValueObject: EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::Serialization_CSV): cannot serialize values of type object to CSV/TSV." << EidosTerminate(nullptr); - case EidosValueType::kValueLogical: ss << (value->LogicalAtIndex(row_index, nullptr) ? "TRUE" : "FALSE"); break; - case EidosValueType::kValueInt: ss << value->IntAtIndex(row_index, nullptr); break; + case EidosValueType::kValueLogical: ss << (value->LogicalAtIndex_NOCAST(row_index, nullptr) ? "TRUE" : "FALSE"); break; + case EidosValueType::kValueInt: ss << value->IntAtIndex_NOCAST(row_index, nullptr); break; case EidosValueType::kValueFloat: { int old_precision = gEidosFloatOutputPrecision; gEidosFloatOutputPrecision = EIDOS_DBL_DIGS - 2; // try to avoid ugly values that exhibit the precision limits - ss << EidosStringForFloat(value->FloatAtIndex(row_index, nullptr)); + ss << EidosStringForFloat(value->FloatAtIndex_NOCAST(row_index, nullptr)); gEidosFloatOutputPrecision = old_precision; break; } case EidosValueType::kValueString: { - ss << Eidos_string_escaped_CSV(value->StringAtIndex(row_index, nullptr)); + ss << Eidos_string_escaped_CSV(value->StringAtIndex_NOCAST(row_index, nullptr)); break; } } @@ -1081,7 +1081,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_addKeysAndValuesFrom(Eido // Check that source is a subclass of EidosDictionaryUnretained. We do this check here because we want to avoid making // EidosDictionaryUnretained visible in the public API; we want to pretend that there is just one class, Dictionary. // I'm not sure whether that's going to be right in the long term, but I want to keep my options open for now. - EidosDictionaryUnretained *source = dynamic_cast(source_value->ObjectElementAtIndex(0, nullptr)); + EidosDictionaryUnretained *source = dynamic_cast(source_value->ObjectElementAtIndex_NOCAST(0, nullptr)); if (!source) EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::ExecuteMethod_addKeysAndValuesFrom): addKeysAndValuesFrom() can only take values from a Dictionary or a subclass of Dictionary." << EidosTerminate(nullptr); @@ -1104,7 +1104,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_appendKeysAndValuesFrom(E // Loop through elements in source and handle them sequentially for (int value_index = 0; value_index < source_count; ++value_index) { - EidosDictionaryUnretained *source = dynamic_cast(source_value->ObjectElementAtIndex(value_index, nullptr)); + EidosDictionaryUnretained *source = dynamic_cast(source_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); // Check that source is a subclass of EidosDictionaryUnretained. We do this check here because we want to avoid making // EidosDictionaryUnretained visible in the public API; we want to pretend that there is just one class, Dictionary. @@ -1138,7 +1138,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_compactIndices(EidosGloba { #pragma unused (p_method_id, p_interpreter) EidosValue *preserveOrder_value = p_arguments[0].get(); - bool preserveOrder = preserveOrder_value->LogicalAtIndex(0, nullptr); + bool preserveOrder = preserveOrder_value->LogicalAtIndex_NOCAST(0, nullptr); if (!KeysAreIntegers()) EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::ExecuteMethod_compactIndices): compactIndices() can only be called on a dictionary that uses integer keys." << EidosTerminate(nullptr); @@ -1235,7 +1235,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_getRowValues(EidosGlobalS { const EidosDictionaryHashTable_StringKeys *symbols = DictionarySymbols_StringKeys(); const std::vector keys = SortedKeys_StringKeys(); - bool drop = drop_value->LogicalAtIndex(0, nullptr); + bool drop = drop_value->LogicalAtIndex_NOCAST(0, nullptr); for (const std::string &key : keys) { @@ -1254,7 +1254,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_getRowValues(EidosGlobalS { const EidosDictionaryHashTable_IntegerKeys *symbols = DictionarySymbols_IntegerKeys(); const std::vector keys = SortedKeys_IntegerKeys(); - bool drop = drop_value->LogicalAtIndex(0, nullptr); + bool drop = drop_value->LogicalAtIndex_NOCAST(0, nullptr); for (int64_t key : keys) { @@ -1294,7 +1294,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_getValue(EidosGlobalStrin if (key_value->Type() != EidosValueType::kValueString) EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::ExecuteMethod_getValue): an integer key was supplied to getValue(), but the target dictionary uses string keys." << EidosTerminate(nullptr); - const std::string &key = ((EidosValue_String *)key_value)->StringRefAtIndex(0, nullptr); + const std::string &key = ((EidosValue_String *)key_value)->StringRefAtIndex_NOCAST(0, nullptr); const EidosDictionaryHashTable_StringKeys *symbols = DictionarySymbols_StringKeys(); auto found_iter = symbols->find(key); @@ -1309,7 +1309,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_getValue(EidosGlobalStrin if (key_value->Type() != EidosValueType::kValueInt) EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::ExecuteMethod_getValue): a string key was supplied to getValue(), but the target dictionary uses integer keys." << EidosTerminate(nullptr); - int64_t key = ((EidosValue_Int *)key_value)->IntAtIndex(0, nullptr); + int64_t key = ((EidosValue_Int *)key_value)->IntAtIndex_NOCAST(0, nullptr); const EidosDictionaryHashTable_IntegerKeys *symbols = DictionarySymbols_IntegerKeys(); auto found_iter = symbols->find(key); @@ -1327,7 +1327,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_identicalContents(EidosGl { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *x_value = p_arguments[0].get(); - EidosObject *x_object = x_value->ObjectElementAtIndex(0, nullptr); + EidosObject *x_object = x_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosDictionaryUnretained *x_dict = dynamic_cast(x_object); if (!x_dict) @@ -1429,13 +1429,13 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_Accelerated_setValue(Eido // targets. That made me nervous, and was hard to reconcile with DataFrame, so I removed it. if (key_value->Type() == EidosValueType::kValueString) { - const std::string &key = ((EidosValue_String *)key_value)->StringRefAtIndex(0, nullptr); + const std::string &key = ((EidosValue_String *)key_value)->StringRefAtIndex_NOCAST(0, nullptr); element->SetKeyValue_StringKeys(key, value); } else { - int64_t key = ((EidosValue_Int *)key_value)->IntAtIndex(0, nullptr); + int64_t key = ((EidosValue_Int *)key_value)->IntAtIndex_NOCAST(0, nullptr); element->SetKeyValue_IntegerKeys(key, value); } @@ -1452,7 +1452,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_serialize(EidosGlobalStri { #pragma unused (p_method_id, p_interpreter) EidosValue_String *string_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &format_name = string_value->StringRefAtIndex(0, nullptr); + const std::string &format_name = string_value->StringRefAtIndex_NOCAST(0, nullptr); if (format_name == "slim") { @@ -1580,7 +1580,7 @@ void EidosDictionaryRetained::ConstructFromEidos(const std::vectorType() == EidosValueType::kValueString) { // Construct from a JSON string - std::string json_string = source_value->StringAtIndex(0, nullptr); + std::string json_string = source_value->StringAtIndex_NOCAST(0, nullptr); nlohmann::json json_rep; try { @@ -1594,7 +1594,7 @@ void EidosDictionaryRetained::ConstructFromEidos(const std::vectorType() != EidosValueType::kValueObject) ? nullptr : dynamic_cast(source_value->ObjectElementAtIndex(0, nullptr)); + EidosDictionaryUnretained *source = (source_value->Type() != EidosValueType::kValueObject) ? nullptr : dynamic_cast(source_value->ObjectElementAtIndex_NOCAST(0, nullptr)); if (!source) EIDOS_TERMINATION << "ERROR (" << p_caller_name << "): " << p_constructor_name << "(x) requires that x be a singleton Dictionary (or a singleton subclass of Dictionary)." << EidosTerminate(nullptr); @@ -1624,13 +1624,13 @@ void EidosDictionaryRetained::ConstructFromEidos(const std::vectorStringRefAtIndex(0, nullptr), value); + SetKeyValue_StringKeys(key_string_value->StringRefAtIndex_NOCAST(0, nullptr), value); } else if (key->Type() == EidosValueType::kValueInt) { EidosValue_Int *key_integer_value = (EidosValue_Int *)key; - SetKeyValue_IntegerKeys(key_integer_value->IntAtIndex(0, nullptr), value); + SetKeyValue_IntegerKeys(key_integer_value->IntAtIndex_NOCAST(0, nullptr), value); } else { diff --git a/eidos/eidos_class_Image.cpp b/eidos/eidos_class_Image.cpp index 034e78b98..80cce4e40 100644 --- a/eidos/eidos_class_Image.cpp +++ b/eidos/eidos_class_Image.cpp @@ -228,7 +228,7 @@ EidosValue_SP EidosImage::ExecuteMethod_write(EidosGlobalStringID p_method_id, c #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *filePath_value = p_arguments[0].get(); - std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex(0, nullptr)); + std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex_NOCAST(0, nullptr)); unsigned error; @@ -260,7 +260,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorType() == EidosValueType::kValueString) && (p_arguments[0]->Count() == 1)) { EidosValue_String *filePath_value = (EidosValue_String *)p_arguments[0].get(); - objectElement = new EidosImage(filePath_value->StringRefAtIndex(0, nullptr)); + objectElement = new EidosImage(filePath_value->StringRefAtIndex_NOCAST(0, nullptr)); } else if ((p_arguments.size() == 1) && ((p_arguments[0]->Type() == EidosValueType::kValueInt) || (p_arguments[0]->Type() == EidosValueType::kValueFloat)) && @@ -284,7 +284,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorData(); - int64_t int_value = numeric_value->IntAtIndex(0, nullptr); + int64_t int_value = numeric_value->IntAtIndex_NOCAST(0, nullptr); if ((int_value < 0) || (int_value > 255)) EIDOS_TERMINATION << "ERROR (Eidos_Instantiate_EidosImage): Image(), when passed an integer vector, requires values to be in [0, 255]." << EidosTerminate(); @@ -323,7 +323,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorData(); - double float_value = numeric_value->FloatAtIndex(0, nullptr); + double float_value = numeric_value->FloatAtIndex_NOCAST(0, nullptr); if ((float_value < 0.0) || (float_value > 1.0)) EIDOS_TERMINATION << "ERROR (Eidos_Instantiate_EidosImage): Image(), when passed a float vector, requires values to be in [0.0, 1.0]." << EidosTerminate(); diff --git a/eidos/eidos_class_Object.cpp b/eidos/eidos_class_Object.cpp index ff2761f64..877b25646 100644 --- a/eidos/eidos_class_Object.cpp +++ b/eidos/eidos_class_Object.cpp @@ -603,7 +603,7 @@ EidosValue_SP EidosClass::ExecuteMethod_propertySignature(EidosGlobalStringID p_ std::ostream &output_stream = p_interpreter.ExecutionOutputStream(); bool has_match_string = (p_arguments[0]->Type() == EidosValueType::kValueString); EidosValue_String *propertyName_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &match_string = (has_match_string ? propertyName_value->StringRefAtIndex(0, nullptr) : gEidosStr_empty_string); + const std::string &match_string = (has_match_string ? propertyName_value->StringRefAtIndex_NOCAST(0, nullptr) : gEidosStr_empty_string); const std::vector *properties = Properties(); bool signature_found = false; @@ -634,7 +634,7 @@ EidosValue_SP EidosClass::ExecuteMethod_methodSignature(EidosGlobalStringID p_me std::ostream &output_stream = p_interpreter.ExecutionOutputStream(); bool has_match_string = (p_arguments[0]->Type() == EidosValueType::kValueString); EidosValue_String *methodName_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &match_string = (has_match_string ? methodName_value->StringRefAtIndex(0, nullptr) : gEidosStr_empty_string); + const std::string &match_string = (has_match_string ? methodName_value->StringRefAtIndex_NOCAST(0, nullptr) : gEidosStr_empty_string); const std::vector *methods = Methods(); bool signature_found = false; diff --git a/eidos/eidos_class_TestElement.cpp b/eidos/eidos_class_TestElement.cpp index 1b58c0c8d..e98512f08 100644 --- a/eidos/eidos_class_TestElement.cpp +++ b/eidos/eidos_class_TestElement.cpp @@ -96,7 +96,7 @@ void EidosTestElement::SetProperty(EidosGlobalStringID p_property_id, const Eido { if (p_property_id == gEidosID__yolk) // ACCELERATED { - yolk_ = p_value.IntAtIndex(0, nullptr); + yolk_ = p_value.IntAtIndex_NOCAST(0, nullptr); return; } @@ -109,7 +109,7 @@ void EidosTestElement::SetProperty_Accelerated__yolk(EidosObject **p_elements, s { if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) ((EidosTestElement *)(p_elements[element_index]))->yolk_ = source_value; @@ -175,7 +175,7 @@ static EidosValue_SP Eidos_Instantiate_EidosTestElement(const std::vectorIntAtIndex(0, nullptr)); + EidosTestElement *objectElement = new EidosTestElement(yolk_value->IntAtIndex_NOCAST(0, nullptr)); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosTestElement_Class)); // objectElement is now retained by result_SP, so we can release it @@ -293,7 +293,7 @@ void EidosTestElementNRR::SetProperty(EidosGlobalStringID p_property_id, const E { if (p_property_id == gEidosID__yolk) // ACCELERATED { - yolk_ = p_value.IntAtIndex(0, nullptr); + yolk_ = p_value.IntAtIndex_NOCAST(0, nullptr); return; } @@ -318,7 +318,7 @@ static EidosValue_SP Eidos_Instantiate_EidosTestElementNRR(const std::vectorIntAtIndex(0, nullptr)); + EidosTestElementNRR *objectElement = new EidosTestElementNRR(yolk_value->IntAtIndex_NOCAST(0, nullptr)); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosTestElementNRR_Class)); // Note that since these are not under retain/release, and Eidos has no logic to keep track of them and release them, they just leak diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 400738c11..03d3dd05e 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -404,18 +404,18 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa // Handle singleton comparison separately, to allow the use of the fast vector API below if (x_type == EidosValueType::kValueLogical) { - if (x_value->LogicalAtIndex(0, nullptr) != y_value->LogicalAtIndex(0, nullptr)) + if (x_value->LogicalAtIndex_NOCAST(0, nullptr) != y_value->LogicalAtIndex_NOCAST(0, nullptr)) return false; } else if (x_type == EidosValueType::kValueInt) { - if (x_value->IntAtIndex(0, nullptr) != y_value->IntAtIndex(0, nullptr)) + if (x_value->IntAtIndex_NOCAST(0, nullptr) != y_value->IntAtIndex_NOCAST(0, nullptr)) return false; } else if (x_type == EidosValueType::kValueFloat) { - double xv = x_value->FloatAtIndex(0, nullptr); - double yv = y_value->FloatAtIndex(0, nullptr); + double xv = x_value->FloatAtIndex_NOCAST(0, nullptr); + double yv = y_value->FloatAtIndex_NOCAST(0, nullptr); if (!std::isnan(xv) || !std::isnan(yv)) if (xv != yv) @@ -423,15 +423,15 @@ bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compa } else if (x_type == EidosValueType::kValueString) { - const std::string &x_string = ((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); - const std::string &y_string = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &x_string = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &y_string = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); if (x_string != y_string) return false; } else if (x_type == EidosValueType::kValueObject) { - if (x_value->ObjectElementAtIndex(0, nullptr) != y_value->ObjectElementAtIndex(0, nullptr)) + if (x_value->ObjectElementAtIndex_NOCAST(0, nullptr) != y_value->ObjectElementAtIndex_NOCAST(0, nullptr)) return false; } } @@ -624,7 +624,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value_count == 1) { - result->set_int_no_check(arg_value->IntAtIndex(0, nullptr), result_set_index++); + result->set_int_no_check(arg_value->IntAtIndex_CAST(0, nullptr), result_set_index++); } else if (arg_value_count) { @@ -645,7 +645,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen else { for (int value_index = 0; value_index < arg_value_count; ++value_index) - result->set_int_no_check(arg_value->IntAtIndex(value_index, nullptr), result_set_index++); + result->set_int_no_check(arg_value->IntAtIndex_CAST(value_index, nullptr), result_set_index++); } } } @@ -665,7 +665,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value_count == 1) { - result->set_float_no_check(arg_value->FloatAtIndex(0, nullptr), result_set_index++); + result->set_float_no_check(arg_value->FloatAtIndex_CAST(0, nullptr), result_set_index++); } else if (arg_value_count) { @@ -686,7 +686,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen else { for (int value_index = 0; value_index < arg_value_count; ++value_index) - result->set_float_no_check(arg_value->FloatAtIndex(value_index, nullptr), result_set_index++); + result->set_float_no_check(arg_value->FloatAtIndex_CAST(value_index, nullptr), result_set_index++); } } } @@ -705,7 +705,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value_count == 1) { - result->PushString(arg_value->StringAtIndex(0, nullptr)); + result->PushString(arg_value->StringAtIndex_CAST(0, nullptr)); } else if (arg_value_count) { @@ -720,7 +720,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen else { for (int value_index = 0; value_index < arg_value_count; ++value_index) - result->PushString(arg_value->StringAtIndex(value_index, nullptr)); + result->PushString(arg_value->StringAtIndex_CAST(value_index, nullptr)); } } } @@ -741,9 +741,9 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen if (arg_value_count == 1) { if (result->UsesRetainRelease()) - result->set_object_element_no_check_no_previous_RR(arg_value->ObjectElementAtIndex(0, nullptr), result_set_index++); + result->set_object_element_no_check_no_previous_RR(arg_value->ObjectElementAtIndex_NOCAST(0, nullptr), result_set_index++); else - result->set_object_element_no_check_NORR(arg_value->ObjectElementAtIndex(0, nullptr), result_set_index++); + result->set_object_element_no_check_NORR(arg_value->ObjectElementAtIndex_NOCAST(0, nullptr), result_set_index++); } else if (arg_value_count) { @@ -1128,7 +1128,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa { // Subsetting with a singleton int/float vector is common and should return a singleton value for speed // This is guaranteed to return a singleton value (when available) - int index_value = (int)p_indices->IntAtIndex(0, p_error_token); + int index_value = (int)p_indices->IntAtIndex_CAST(0, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1150,7 +1150,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1194,7 +1194,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // float indices; we use IntAtIndex() since it has complex behavior for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1238,7 +1238,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // float indices; we use IntAtIndex() since it has complex behavior for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1282,7 +1282,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // float indices; we use IntAtIndex() since it has complex behavior for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1326,7 +1326,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // float indices; we use IntAtIndex() since it has complex behavior for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1370,7 +1370,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa // float indices; we use IntAtIndex() since it has complex behavior for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1394,7 +1394,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex(value_idx, p_error_token); + int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { diff --git a/eidos/eidos_functions_colors.cpp b/eidos/eidos_functions_colors.cpp index 362d62a40..6eee38792 100644 --- a/eidos/eidos_functions_colors.cpp +++ b/eidos/eidos_functions_colors.cpp @@ -40,7 +40,7 @@ EidosValue_SP Eidos_ExecuteFunction_cmColors(const std::vector &p EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t n = n_value->IntAtIndex(0, nullptr); + int64_t n = n_value->IntAtIndex_NOCAST(0, nullptr); char hex_chars[8]; if ((n < 0) || (n > 100000)) @@ -70,7 +70,7 @@ EidosValue_SP Eidos_ExecuteFunction_colors(const std::vector &p_a EidosValue *x_value = p_arguments[0].get(); EidosValue_String *name_value = (EidosValue_String *)p_arguments[1].get(); - const std::string &name = name_value->StringRefAtIndex(0, nullptr); + const std::string &name = name_value->StringRefAtIndex_NOCAST(0, nullptr); EidosColorPalette palette; char hex_chars[8]; @@ -95,7 +95,7 @@ EidosValue_SP Eidos_ExecuteFunction_colors(const std::vector &p_a if (x_value->Count() != 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_colors): colors() requires an integer x parameter value to be singleton (the number of colors to generate)." << EidosTerminate(nullptr); - int64_t x = x_value->IntAtIndex(0, nullptr); + int64_t x = x_value->IntAtIndex_NOCAST(0, nullptr); if ((x < 0) || (x > 100000)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_colors): colors() requires 0 <= x <= 100000." << EidosTerminate(nullptr); @@ -122,7 +122,7 @@ EidosValue_SP Eidos_ExecuteFunction_colors(const std::vector &p_a for (int value_index = 0; value_index < color_count; ++value_index) { - double fraction = x_value->FloatAtIndex(value_index, nullptr); + double fraction = x_value->FloatAtIndex_NOCAST(value_index, nullptr); double red, green, blue; Eidos_ColorPaletteLookup(fraction, palette, red, green, blue); @@ -146,7 +146,7 @@ EidosValue_SP Eidos_ExecuteFunction_color2rgb(const std::vector & if (color_count == 1) { - Eidos_GetColorComponents(color_value->StringRefAtIndex(0, nullptr), &r, &g, &b); + Eidos_GetColorComponents(color_value->StringRefAtIndex_NOCAST(0, nullptr), &r, &g, &b); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{r, g, b}); } @@ -157,7 +157,7 @@ EidosValue_SP Eidos_ExecuteFunction_color2rgb(const std::vector & for (int value_index = 0; value_index < color_count; ++value_index) { - Eidos_GetColorComponents(color_value->StringRefAtIndex(value_index, nullptr), &r, &g, &b); + Eidos_GetColorComponents(color_value->StringRefAtIndex_NOCAST(value_index, nullptr), &r, &g, &b); float_result->set_float_no_check(r, value_index); float_result->set_float_no_check(g, value_index + color_count); float_result->set_float_no_check(b, value_index + color_count + color_count); @@ -178,7 +178,7 @@ EidosValue_SP Eidos_ExecuteFunction_heatColors(const std::vector EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t n = n_value->IntAtIndex(0, nullptr); + int64_t n = n_value->IntAtIndex_NOCAST(0, nullptr); char hex_chars[8]; if ((n < 0) || (n > 100000)) @@ -219,9 +219,9 @@ EidosValue_SP Eidos_ExecuteFunction_hsv2rgb(const std::vector &p_ for (int value_index = 0; value_index < color_count; ++value_index) { - double h = hsv_value->FloatAtIndex(value_index, nullptr); - double s = hsv_value->FloatAtIndex(value_index + color_count, nullptr); - double v = hsv_value->FloatAtIndex(value_index + color_count + color_count, nullptr); + double h = hsv_value->FloatAtIndex_NOCAST(value_index, nullptr); + double s = hsv_value->FloatAtIndex_NOCAST(value_index + color_count, nullptr); + double v = hsv_value->FloatAtIndex_NOCAST(value_index + color_count + color_count, nullptr); double r, g, b; Eidos_HSV2RGB(h, s, v, &r, &g, &b); @@ -248,27 +248,27 @@ EidosValue_SP Eidos_ExecuteFunction_rainbow(const std::vector &p_ EidosValue *end_value = p_arguments[4].get(); EidosValue *ccw_value = p_arguments[5].get(); - int64_t n = n_value->IntAtIndex(0, nullptr); + int64_t n = n_value->IntAtIndex_NOCAST(0, nullptr); if ((n < 0) || (n > 100000)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rainbow): rainbow() requires 0 <= n <= 100000." << EidosTerminate(nullptr); - double s = s_value->FloatAtIndex(0, nullptr); + double s = s_value->FloatAtIndex_NOCAST(0, nullptr); if ((s < 0.0) || (s > 1.0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rainbow): rainbow() requires HSV saturation s to be in the interval [0.0, 1.0]." << EidosTerminate(nullptr); - double v = v_value->FloatAtIndex(0, nullptr); + double v = v_value->FloatAtIndex_NOCAST(0, nullptr); if ((v < 0.0) || (v > 1.0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rainbow): rainbow() requires HSV value v to be in the interval [0.0, 1.0]." << EidosTerminate(nullptr); - double start = start_value->FloatAtIndex(0, nullptr); + double start = start_value->FloatAtIndex_NOCAST(0, nullptr); if ((start < 0.0) || (start > 1.0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rainbow): rainbow() requires HSV hue start to be in the interval [0.0, 1.0]." << EidosTerminate(nullptr); - double end = (end_value->Type() == EidosValueType::kValueNULL) ? ((n-1) / (double)n) : end_value->FloatAtIndex(0, nullptr); + double end = (end_value->Type() == EidosValueType::kValueNULL) ? ((n-1) / (double)n) : end_value->FloatAtIndex_NOCAST(0, nullptr); if ((n > 0) && ((end < 0.0) || (end > 1.0))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rainbow): rainbow() requires HSV hue end to be in the interval [0.0, 1.0], or NULL." << EidosTerminate(nullptr); @@ -276,7 +276,7 @@ EidosValue_SP Eidos_ExecuteFunction_rainbow(const std::vector &p_ if ((n > 1) && (start == end)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rainbow): rainbow() requires start != end." << EidosTerminate(nullptr); - eidos_logical_t ccw = ccw_value->LogicalAtIndex(0, nullptr); + eidos_logical_t ccw = ccw_value->LogicalAtIndex_NOCAST(0, nullptr); if (ccw && (end < start)) end += 1.0; @@ -320,9 +320,9 @@ EidosValue_SP Eidos_ExecuteFunction_rgb2color(const std::vector & if ((rgb_value->DimensionCount() == 1) && (rgb_count == 3)) { - double r = rgb_value->FloatAtIndex(0, nullptr); - double g = rgb_value->FloatAtIndex(1, nullptr); - double b = rgb_value->FloatAtIndex(2, nullptr); + double r = rgb_value->FloatAtIndex_NOCAST(0, nullptr); + double g = rgb_value->FloatAtIndex_NOCAST(1, nullptr); + double b = rgb_value->FloatAtIndex_NOCAST(2, nullptr); if (std::isnan(r) || std::isnan(g) || std::isnan(b)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgb2color): color component with value NAN is not legal." << EidosTerminate(); @@ -339,9 +339,9 @@ EidosValue_SP Eidos_ExecuteFunction_rgb2color(const std::vector & for (int value_index = 0; value_index < color_count; ++value_index) { - double r = rgb_value->FloatAtIndex(value_index, nullptr); - double g = rgb_value->FloatAtIndex(value_index + color_count, nullptr); - double b = rgb_value->FloatAtIndex(value_index + color_count + color_count, nullptr); + double r = rgb_value->FloatAtIndex_NOCAST(value_index, nullptr); + double g = rgb_value->FloatAtIndex_NOCAST(value_index + color_count, nullptr); + double b = rgb_value->FloatAtIndex_NOCAST(value_index + color_count + color_count, nullptr); if (std::isnan(r) || std::isnan(g) || std::isnan(b)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgb2color): color component with value NAN is not legal." << EidosTerminate(); @@ -373,9 +373,9 @@ EidosValue_SP Eidos_ExecuteFunction_rgb2hsv(const std::vector &p_ for (int value_index = 0; value_index < color_count; ++value_index) { - double r = rgb_value->FloatAtIndex(value_index, nullptr); - double g = rgb_value->FloatAtIndex(value_index + color_count, nullptr); - double b = rgb_value->FloatAtIndex(value_index + color_count + color_count, nullptr); + double r = rgb_value->FloatAtIndex_NOCAST(value_index, nullptr); + double g = rgb_value->FloatAtIndex_NOCAST(value_index + color_count, nullptr); + double b = rgb_value->FloatAtIndex_NOCAST(value_index + color_count + color_count, nullptr); double h, s, v; Eidos_RGB2HSV(r, g, b, &h, &s, &v); @@ -397,7 +397,7 @@ EidosValue_SP Eidos_ExecuteFunction_terrainColors(const std::vectorIntAtIndex(0, nullptr); + int64_t n = n_value->IntAtIndex_NOCAST(0, nullptr); char hex_chars[8]; if ((n < 0) || (n > 100000)) diff --git a/eidos/eidos_functions_distributions.cpp b/eidos/eidos_functions_distributions.cpp index 89475272f..94f0cc1b5 100644 --- a/eidos/eidos_functions_distributions.cpp +++ b/eidos/eidos_functions_distributions.cpp @@ -73,8 +73,8 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vector 0." << EidosTerminate(nullptr); - bool rightmostClosed = arg_rightmostClosed->LogicalAtIndex(0, nullptr); - bool allInside = arg_allInside->LogicalAtIndex(0, nullptr); + bool rightmostClosed = arg_rightmostClosed->LogicalAtIndex_NOCAST(0, nullptr); + bool allInside = arg_allInside->LogicalAtIndex_NOCAST(0, nullptr); #if !(EIDOS_FIND_INTERVAL_USE_BINARY_SEARCH) // Used by the old linear-search algorithm @@ -357,13 +357,13 @@ EidosValue_SP Eidos_ExecuteFunction_dmvnorm(const std::vector &p_ try { for (int dim_index = 0; dim_index < d; ++dim_index) - gsl_vector_set(gsl_mu, dim_index, arg_mu->FloatAtIndex(dim_index, nullptr)); + gsl_vector_set(gsl_mu, dim_index, arg_mu->FloatAtIndex_CAST(dim_index, nullptr)); for (int row_index = 0; row_index < d; ++row_index) { for (int col_index = 0; col_index < d; ++col_index) { - double value = arg_sigma->FloatAtIndex(row_index + col_index * d, nullptr); + double value = arg_sigma->FloatAtIndex_CAST(row_index + col_index * d, nullptr); if (std::isnan(value)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dmvnorm): function dmvnorm() does not allow sigma to contain NANs." << EidosTerminate(nullptr); // oddly, GSL does not raise an error on this! @@ -468,8 +468,8 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dnorm): function dnorm() requires sd to be of length 1 or equal in length to x." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); if (mu_singleton && sigma_singleton) { @@ -482,7 +482,7 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gaussian_pdf(arg_quantile->FloatAtIndex(0, nullptr) - mu0, sigma0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gaussian_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr) - mu0, sigma0))); } else { @@ -508,8 +508,8 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar #pragma omp parallel for schedule(static) default(none) shared(num_quantiles) firstprivate(float_data, float_result, mu_singleton, sigma_singleton, mu0, sigma0, arg_mu, arg_sigma) reduction(||: saw_error) if(num_quantiles >= EIDOS_OMPMIN_DNORM_2) num_threads(thread_count) for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex(value_index, nullptr)); - double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex(value_index, nullptr)); + double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST(value_index, nullptr)); + double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex_CAST(value_index, nullptr)); if (sigma <= 0.0) { @@ -548,8 +548,8 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_probs)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_qnorm): function qnorm() requires sd to be of length 1 or equal in length to x." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); if (mu_singleton && sigma_singleton) { @@ -558,7 +558,7 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar if (num_probs == 1) { - const double float_prob = arg_prob->FloatAtIndex(0, nullptr); + const double float_prob = arg_prob->FloatAtIndex_NOCAST(0, nullptr); if (float_prob < 0.0 || float_prob > 1.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_qnorm): function qnorm() requires 0.0 <= p <= 1.0 (" << EidosStringForFloat(float_prob) << " supplied)." << EidosTerminate(nullptr); @@ -585,8 +585,8 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar for (int value_index = 0; value_index < num_probs; ++value_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex(value_index, nullptr)); - double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex(value_index, nullptr)); + double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST(value_index, nullptr)); + double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex_CAST(value_index, nullptr)); if (float_data[value_index] < 0.0 || float_data[value_index] > 1.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_qnorm): function qnorm() requires 0.0 <= p <= 1.0 (" << EidosStringForFloat(float_data[value_index]) << " supplied)." << EidosTerminate(nullptr); @@ -622,8 +622,8 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_pnorm): function pnorm() requires sd to be of length 1 or equal in length to q." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); if (mu_singleton && sigma_singleton) { @@ -632,7 +632,7 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_cdf_gaussian_P(arg_quantile->FloatAtIndex(0, nullptr) - mu0, sigma0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_cdf_gaussian_P(arg_quantile->FloatAtIndex_NOCAST(0, nullptr) - mu0, sigma0))); } else { @@ -652,8 +652,8 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex(value_index, nullptr)); - double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex(value_index, nullptr)); + double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST(value_index, nullptr)); + double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex_CAST(value_index, nullptr)); if (sigma <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_pnorm): function pnorm() requires sd > 0.0 (" << EidosStringForFloat(sigma) << " supplied)." << EidosTerminate(nullptr); @@ -686,8 +686,8 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar if (!beta_singleton && (arg_beta_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dbeta): function dbeta() requires beta to be of length 1 or equal in length to x." << EidosTerminate(nullptr); - double alpha0 = (arg_alpha_count ? arg_alpha->FloatAtIndex(0, nullptr) : 0.0); - double beta0 = (arg_beta_count ? arg_beta->FloatAtIndex(0, nullptr) : 0.0); + double alpha0 = (arg_alpha_count ? arg_alpha->FloatAtIndex_CAST(0, nullptr) : 0.0); + double beta0 = (arg_beta_count ? arg_beta->FloatAtIndex_CAST(0, nullptr) : 0.0); if (alpha_singleton && beta_singleton) { @@ -698,7 +698,7 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_beta_pdf(arg_quantile->FloatAtIndex(0, nullptr), alpha0, beta0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_beta_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), alpha0, beta0))); } else { @@ -718,8 +718,8 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double alpha = (alpha_singleton ? alpha0 : arg_alpha->FloatAtIndex(value_index, nullptr)); - double beta = (beta_singleton ? beta0 : arg_beta->FloatAtIndex(value_index, nullptr)); + double alpha = (alpha_singleton ? alpha0 : arg_alpha->FloatAtIndex_CAST(value_index, nullptr)); + double beta = (beta_singleton ? beta0 : arg_beta->FloatAtIndex_CAST(value_index, nullptr)); if (!(alpha > 0.0)) // true for NaN EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dbeta): function dbeta() requires alpha > 0.0 (" << EidosStringForFloat(alpha) << " supplied)." << EidosTerminate(nullptr); @@ -741,7 +741,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_alpha = p_arguments[1].get(); EidosValue *arg_beta = p_arguments[2].get(); int arg_alpha_count = arg_alpha->Count(); @@ -756,8 +756,8 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar if (!beta_singleton && (arg_beta_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rbeta): function rbeta() requires beta to be of length 1 or n." << EidosTerminate(nullptr); - double alpha0 = (arg_alpha_count ? arg_alpha->FloatAtIndex(0, nullptr) : 0.0); - double beta0 = (arg_beta_count ? arg_beta->FloatAtIndex(0, nullptr) : 0.0); + double alpha0 = (arg_alpha_count ? arg_alpha->FloatAtIndex_CAST(0, nullptr) : 0.0); + double beta0 = (arg_beta_count ? arg_beta->FloatAtIndex_CAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (alpha_singleton && beta_singleton) @@ -787,8 +787,8 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double alpha = (alpha_singleton ? alpha0 : arg_alpha->FloatAtIndex(draw_index, nullptr)); - double beta = (beta_singleton ? beta0 : arg_beta->FloatAtIndex(draw_index, nullptr)); + double alpha = (alpha_singleton ? alpha0 : arg_alpha->FloatAtIndex_CAST(draw_index, nullptr)); + double beta = (beta_singleton ? beta0 : arg_beta->FloatAtIndex_CAST(draw_index, nullptr)); if (alpha <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rbeta): function rbeta() requires alpha > 0.0 (" << EidosStringForFloat(alpha) << " supplied)." << EidosTerminate(nullptr); @@ -810,7 +810,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbinom(const std::vector &p_a EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_size = p_arguments[1].get(); EidosValue *arg_prob = p_arguments[2].get(); int arg_size_count = arg_size->Count(); @@ -825,8 +825,8 @@ EidosValue_SP Eidos_ExecuteFunction_rbinom(const std::vector &p_a if (!prob_singleton && (arg_prob_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rbinom): function rbinom() requires prob to be of length 1 or n." << EidosTerminate(nullptr); - int size0 = (int)arg_size->IntAtIndex(0, nullptr); - double probability0 = arg_prob->FloatAtIndex(0, nullptr); + int size0 = (int)arg_size->IntAtIndex_NOCAST(0, nullptr); + double probability0 = arg_prob->FloatAtIndex_NOCAST(0, nullptr); if (size_singleton && prob_singleton) { @@ -896,8 +896,8 @@ EidosValue_SP Eidos_ExecuteFunction_rbinom(const std::vector &p_a #pragma omp for schedule(dynamic, 1024) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - int size = (size_singleton ? size0 : (int)arg_size->IntAtIndex((int)draw_index, nullptr)); - double probability = (prob_singleton ? probability0 : arg_prob->FloatAtIndex((int)draw_index, nullptr)); + int size = (size_singleton ? size0 : (int)arg_size->IntAtIndex_NOCAST((int)draw_index, nullptr)); + double probability = (prob_singleton ? probability0 : arg_prob->FloatAtIndex_NOCAST((int)draw_index, nullptr)); if (size < 0) { @@ -933,7 +933,7 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ EidosValue *n_value = p_arguments[0].get(); EidosValue *arg_location = p_arguments[1].get(); EidosValue *arg_scale = p_arguments[2].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); int arg_location_count = arg_location->Count(); int arg_scale_count = arg_scale->Count(); bool location_singleton = (arg_location_count == 1); @@ -946,8 +946,8 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ if (!scale_singleton && (arg_scale_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rcauchy): function rcauchy() requires scale to be of length 1 or n." << EidosTerminate(nullptr); - double location0 = (arg_location_count ? arg_location->FloatAtIndex(0, nullptr) : 0.0); - double scale0 = (arg_scale_count ? arg_scale->FloatAtIndex(0, nullptr) : 1.0); + double location0 = (arg_location_count ? arg_location->FloatAtIndex_CAST(0, nullptr) : 0.0); + double scale0 = (arg_scale_count ? arg_scale->FloatAtIndex_CAST(0, nullptr) : 1.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (location_singleton && scale_singleton) @@ -975,8 +975,8 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double location = (location_singleton ? location0 : arg_location->FloatAtIndex(draw_index, nullptr)); - double scale = (scale_singleton ? scale0 : arg_scale->FloatAtIndex(draw_index, nullptr)); + double location = (location_singleton ? location0 : arg_location->FloatAtIndex_CAST(draw_index, nullptr)); + double scale = (scale_singleton ? scale0 : arg_scale->FloatAtIndex_CAST(draw_index, nullptr)); if (scale <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rcauchy): function rcauchy() requires scale > 0.0 (" << EidosStringForFloat(scale) << " supplied)." << EidosTerminate(nullptr); @@ -998,7 +998,7 @@ EidosValue_SP Eidos_ExecuteFunction_rdunif(const std::vector &p_a EidosValue *n_value = p_arguments[0].get(); EidosValue *arg_min = p_arguments[1].get(); EidosValue *arg_max = p_arguments[2].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); int arg_min_count = arg_min->Count(); int arg_max_count = arg_max->Count(); bool min_singleton = (arg_min_count == 1); @@ -1011,8 +1011,8 @@ EidosValue_SP Eidos_ExecuteFunction_rdunif(const std::vector &p_a if (!max_singleton && (arg_max_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rdunif): function rdunif() requires max to be of length 1 or n." << EidosTerminate(nullptr); - int64_t min_value0 = (arg_min_count ? arg_min->IntAtIndex(0, nullptr) : 0); - int64_t max_value0 = (arg_max_count ? arg_max->IntAtIndex(0, nullptr) : 1); + int64_t min_value0 = (arg_min_count ? arg_min->IntAtIndex_NOCAST(0, nullptr) : 0); + int64_t max_value0 = (arg_max_count ? arg_max->IntAtIndex_NOCAST(0, nullptr) : 1); if (min_singleton && max_singleton) { @@ -1082,8 +1082,8 @@ EidosValue_SP Eidos_ExecuteFunction_rdunif(const std::vector &p_a #pragma omp for schedule(dynamic, 1024) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - int64_t min_value = (min_singleton ? min_value0 : arg_min->IntAtIndex((int)draw_index, nullptr)); - int64_t max_value = (max_singleton ? max_value0 : arg_max->IntAtIndex((int)draw_index, nullptr)); + int64_t min_value = (min_singleton ? min_value0 : arg_min->IntAtIndex_NOCAST((int)draw_index, nullptr)); + int64_t max_value = (max_singleton ? max_value0 : arg_max->IntAtIndex_NOCAST((int)draw_index, nullptr)); int64_t count = (max_value - min_value) + 1; if (max_value < min_value) @@ -1121,11 +1121,11 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg if (mu_singleton) { - double mu0 = arg_mu->FloatAtIndex(0, nullptr); + double mu0 = arg_mu->FloatAtIndex_CAST(0, nullptr); if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_exponential_pdf(arg_quantile->FloatAtIndex(0, nullptr), mu0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_exponential_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), mu0))); } else { @@ -1145,7 +1145,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mu = arg_mu->FloatAtIndex(value_index, nullptr); + double mu = arg_mu->FloatAtIndex_CAST(value_index, nullptr); float_result->set_float_no_check(gsl_ran_exponential_pdf(float_data[value_index], mu), value_index); } @@ -1163,7 +1163,7 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg EidosValue *n_value = p_arguments[0].get(); EidosValue *arg_mu = p_arguments[1].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); int arg_mu_count = arg_mu->Count(); bool mu_singleton = (arg_mu_count == 1); @@ -1174,7 +1174,7 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg if (mu_singleton) { - double mu0 = arg_mu->FloatAtIndex(0, nullptr); + double mu0 = arg_mu->FloatAtIndex_CAST(0, nullptr); if (num_draws == 1) { @@ -1211,7 +1211,7 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double mu = arg_mu->FloatAtIndex((int)draw_index, nullptr); + double mu = arg_mu->FloatAtIndex_CAST((int)draw_index, nullptr); float_result->set_float_no_check(gsl_ran_exponential(rng, mu), draw_index); } @@ -1229,7 +1229,7 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_d1 = p_arguments[1].get(); EidosValue *arg_d2 = p_arguments[2].get(); int arg_d1_count = arg_d1->Count(); @@ -1244,8 +1244,8 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum if (!d2_singleton && (arg_d2_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rf): function rf() requires d2 to be of length 1 or n." << EidosTerminate(nullptr); - double d1_0 = (arg_d1_count ? arg_d1->FloatAtIndex(0, nullptr) : 0.0); - double d2_0 = (arg_d2_count ? arg_d2->FloatAtIndex(0, nullptr) : 0.0); + double d1_0 = (arg_d1_count ? arg_d1->FloatAtIndex_CAST(0, nullptr) : 0.0); + double d2_0 = (arg_d2_count ? arg_d2->FloatAtIndex_CAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (d1_singleton && d2_singleton) @@ -1275,8 +1275,8 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double d1 = (d1_singleton ? d1_0 : arg_d1->FloatAtIndex(draw_index, nullptr)); - double d2 = (d2_singleton ? d2_0 : arg_d2->FloatAtIndex(draw_index, nullptr)); + double d1 = (d1_singleton ? d1_0 : arg_d1->FloatAtIndex_CAST(draw_index, nullptr)); + double d2 = (d2_singleton ? d2_0 : arg_d2->FloatAtIndex_CAST(draw_index, nullptr)); if (d1 <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rf): function rf() requires d1 > 0.0 (" << EidosStringForFloat(d1) << " supplied)." << EidosTerminate(nullptr); @@ -1311,8 +1311,8 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a if (!shape_singleton && (arg_shape_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dgamma): function dgamma() requires shape to be of length 1 or n." << EidosTerminate(nullptr); - double mean0 = (arg_mean_count ? arg_mean->FloatAtIndex(0, nullptr) : 1.0); - double shape0 = (arg_shape_count ? arg_shape->FloatAtIndex(0, nullptr) : 0.0); + double mean0 = (arg_mean_count ? arg_mean->FloatAtIndex_CAST(0, nullptr) : 1.0); + double shape0 = (arg_shape_count ? arg_shape->FloatAtIndex_CAST(0, nullptr) : 0.0); if (mean_singleton && shape_singleton) { @@ -1321,7 +1321,7 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gamma_pdf(arg_quantile->FloatAtIndex(0, nullptr), shape0, mean0/shape0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gamma_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), shape0, mean0/shape0))); } else { @@ -1343,8 +1343,8 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mean = (mean_singleton ? mean0 : arg_mean->FloatAtIndex(value_index, nullptr)); - double shape = (shape_singleton ? shape0 : arg_shape->FloatAtIndex(value_index, nullptr)); + double mean = (mean_singleton ? mean0 : arg_mean->FloatAtIndex_CAST(value_index, nullptr)); + double shape = (shape_singleton ? shape0 : arg_shape->FloatAtIndex_CAST(value_index, nullptr)); if (!(shape > 0.0)) // true for NaN EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dgamma): function dgamma() requires shape > 0.0 (" << EidosStringForFloat(shape) << " supplied)." << EidosTerminate(nullptr); @@ -1364,7 +1364,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_mean = p_arguments[1].get(); EidosValue *arg_shape = p_arguments[2].get(); int arg_mean_count = arg_mean->Count(); @@ -1379,8 +1379,8 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a if (!shape_singleton && (arg_shape_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgamma): function rgamma() requires shape to be of length 1 or n." << EidosTerminate(nullptr); - double mean0 = (arg_mean_count ? arg_mean->FloatAtIndex(0, nullptr) : 1.0); - double shape0 = (arg_shape_count ? arg_shape->FloatAtIndex(0, nullptr) : 0.0); + double mean0 = (arg_mean_count ? arg_mean->FloatAtIndex_CAST(0, nullptr) : 1.0); + double shape0 = (arg_shape_count ? arg_shape->FloatAtIndex_CAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (mean_singleton && shape_singleton) @@ -1410,8 +1410,8 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double mean = (mean_singleton ? mean0 : arg_mean->FloatAtIndex(draw_index, nullptr)); - double shape = (shape_singleton ? shape0 : arg_shape->FloatAtIndex(draw_index, nullptr)); + double mean = (mean_singleton ? mean0 : arg_mean->FloatAtIndex_CAST(draw_index, nullptr)); + double shape = (shape_singleton ? shape0 : arg_shape->FloatAtIndex_CAST(draw_index, nullptr)); if (shape <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgamma): function rgamma() requires shape > 0.0 (" << EidosStringForFloat(shape) << " supplied)." << EidosTerminate(nullptr); @@ -1431,7 +1431,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgeom(const std::vector &p_ar EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_p = p_arguments[1].get(); int arg_p_count = arg_p->Count(); bool p_singleton = (arg_p_count == 1); @@ -1450,7 +1450,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgeom(const std::vector &p_ar if (p_singleton) { - double p0 = arg_p->FloatAtIndex(0, nullptr); + double p0 = arg_p->FloatAtIndex_NOCAST(0, nullptr); if ((p0 <= 0.0) || (p0 > 1.0) || std::isnan(p0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgeom): function rgeom() requires 0.0 < p <= 1.0 (" << EidosStringForFloat(p0) << " supplied)." << EidosTerminate(nullptr); @@ -1482,7 +1482,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgeom(const std::vector &p_ar for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double p = arg_p->FloatAtIndex(draw_index, nullptr); + double p = arg_p->FloatAtIndex_NOCAST(draw_index, nullptr); if ((p <= 0.0) || (p >= 1.0) || std::isnan(p)) { @@ -1512,7 +1512,7 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a EidosValue *n_value = p_arguments[0].get(); EidosValue *arg_meanlog = p_arguments[1].get(); EidosValue *arg_sdlog = p_arguments[2].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); int arg_meanlog_count = arg_meanlog->Count(); int arg_sdlog_count = arg_sdlog->Count(); bool meanlog_singleton = (arg_meanlog_count == 1); @@ -1525,8 +1525,8 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a if (!sdlog_singleton && (arg_sdlog_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rlnorm): function rlnorm() requires sdlog to be of length 1 or n." << EidosTerminate(nullptr); - double meanlog0 = (arg_meanlog_count ? arg_meanlog->FloatAtIndex(0, nullptr) : 0.0); - double sdlog0 = (arg_sdlog_count ? arg_sdlog->FloatAtIndex(0, nullptr) : 1.0); + double meanlog0 = (arg_meanlog_count ? arg_meanlog->FloatAtIndex_CAST(0, nullptr) : 0.0); + double sdlog0 = (arg_sdlog_count ? arg_sdlog->FloatAtIndex_CAST(0, nullptr) : 1.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (meanlog_singleton && sdlog_singleton) @@ -1551,8 +1551,8 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double meanlog = (meanlog_singleton ? meanlog0 : arg_meanlog->FloatAtIndex(draw_index, nullptr)); - double sdlog = (sdlog_singleton ? sdlog0 : arg_sdlog->FloatAtIndex(draw_index, nullptr)); + double meanlog = (meanlog_singleton ? meanlog0 : arg_meanlog->FloatAtIndex_CAST(draw_index, nullptr)); + double sdlog = (sdlog_singleton ? sdlog0 : arg_sdlog->FloatAtIndex_CAST(draw_index, nullptr)); float_result->set_float_no_check(gsl_ran_lognormal(rng, meanlog, sdlog), draw_index); } @@ -1569,7 +1569,7 @@ EidosValue_SP Eidos_ExecuteFunction_rmvnorm(const std::vector &p_ EidosValue *arg_n = p_arguments[0].get(); EidosValue *arg_mu = p_arguments[1].get(); EidosValue *arg_sigma = p_arguments[2].get(); - int64_t num_draws = arg_n->IntAtIndex(0, nullptr); + int64_t num_draws = arg_n->IntAtIndex_NOCAST(0, nullptr); int mu_count = arg_mu->Count(); int mu_dimcount = arg_mu->DimensionCount(); int sigma_dimcount = arg_sigma->DimensionCount(); @@ -1588,7 +1588,7 @@ EidosValue_SP Eidos_ExecuteFunction_rmvnorm(const std::vector &p_ for (int row_index = 0; row_index < d; ++row_index) for (int col_index = 0; col_index < d; ++col_index) - if (std::isnan(arg_sigma->FloatAtIndex(row_index + col_index * d, nullptr))) + if (std::isnan(arg_sigma->FloatAtIndex_CAST(row_index + col_index * d, nullptr))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rmvnorm): function rmvnorm() does not allow sigma to contain NANs." << EidosTerminate(nullptr); // oddly, GSL does not raise an error on this! // Set up the GSL vectors @@ -1601,11 +1601,11 @@ EidosValue_SP Eidos_ExecuteFunction_rmvnorm(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rmvnorm): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); for (int dim_index = 0; dim_index < d; ++dim_index) - gsl_vector_set(gsl_mu, dim_index, arg_mu->FloatAtIndex(dim_index, nullptr)); + gsl_vector_set(gsl_mu, dim_index, arg_mu->FloatAtIndex_CAST(dim_index, nullptr)); for (int row_index = 0; row_index < d; ++row_index) for (int col_index = 0; col_index < d; ++col_index) - gsl_matrix_set(gsl_Sigma, row_index, col_index, arg_sigma->FloatAtIndex(row_index + col_index * d, nullptr)); + gsl_matrix_set(gsl_Sigma, row_index, col_index, arg_sigma->FloatAtIndex_CAST(row_index + col_index * d, nullptr)); gsl_matrix_memcpy(gsl_L, gsl_Sigma); @@ -1680,7 +1680,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_size = p_arguments[1].get(); EidosValue *arg_prob = p_arguments[2].get(); int arg_size_count = arg_size->Count(); @@ -1695,8 +1695,8 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ if (!prob_singleton && (arg_prob_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnbinom): function rnbinom() requires prob to be of length 1 or n." << EidosTerminate(nullptr); - double size0 = arg_size->FloatAtIndex(0, nullptr); - double probability0 = arg_prob->FloatAtIndex(0, nullptr); + double size0 = arg_size->FloatAtIndex_CAST(0, nullptr); + double probability0 = arg_prob->FloatAtIndex_NOCAST(0, nullptr); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (size_singleton && prob_singleton) @@ -1726,8 +1726,8 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double size = (size_singleton ? size0 : arg_size->FloatAtIndex(draw_index, nullptr)); - double probability = (prob_singleton ? probability0 : arg_prob->FloatAtIndex(draw_index, nullptr)); + double size = (size_singleton ? size0 : arg_size->FloatAtIndex_CAST(draw_index, nullptr)); + double probability = (prob_singleton ? probability0 : arg_prob->FloatAtIndex_NOCAST(draw_index, nullptr)); if ((size < 0) || std::isnan(size)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnbinom): function rnbinom() requires size >= 0 (" << size << " supplied)." << EidosTerminate(nullptr); @@ -1751,7 +1751,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar EidosValue *n_value = p_arguments[0].get(); EidosValue *arg_mu = p_arguments[1].get(); EidosValue *arg_sigma = p_arguments[2].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); int arg_mu_count = arg_mu->Count(); int arg_sigma_count = arg_sigma->Count(); bool mu_singleton = (arg_mu_count == 1); @@ -1764,8 +1764,8 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnorm): function rnorm() requires sd to be of length 1 or n." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); if (sigma_singleton && (sigma0 < 0.0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnorm): function rnorm() requires sd >= 0.0 (" << EidosStringForFloat(sigma0) << " supplied)." << EidosTerminate(nullptr); @@ -1802,7 +1802,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double mu = arg_mu->FloatAtIndex((int)draw_index, nullptr); + double mu = arg_mu->FloatAtIndex_CAST((int)draw_index, nullptr); float_result->set_float_no_check(gsl_ran_gaussian(rng, sigma0) + mu, draw_index); } @@ -1820,8 +1820,8 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex((int)draw_index, nullptr)); - double sigma = arg_sigma->FloatAtIndex((int)draw_index, nullptr); + double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST((int)draw_index, nullptr)); + double sigma = arg_sigma->FloatAtIndex_CAST((int)draw_index, nullptr); if (sigma < 0.0) { @@ -1848,7 +1848,7 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_lambda = p_arguments[1].get(); int arg_lambda_count = arg_lambda->Count(); bool lambda_singleton = (arg_lambda_count == 1); @@ -1864,7 +1864,7 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar if (lambda_singleton) { - double lambda0 = arg_lambda->FloatAtIndex(0, nullptr); + double lambda0 = arg_lambda->FloatAtIndex_CAST(0, nullptr); if ((lambda0 <= 0.0) || std::isnan(lambda0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rpois): function rpois() requires lambda > 0.0 (" << EidosStringForFloat(lambda0) << " supplied)." << EidosTerminate(nullptr); @@ -1906,7 +1906,7 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar #pragma omp for schedule(dynamic, 1024) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double lambda = arg_lambda->FloatAtIndex((int)draw_index, nullptr); + double lambda = arg_lambda->FloatAtIndex_CAST((int)draw_index, nullptr); if ((lambda <= 0.0) || std::isnan(lambda)) { @@ -1935,7 +1935,7 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar EidosValue *n_value = p_arguments[0].get(); EidosValue *arg_min = p_arguments[1].get(); EidosValue *arg_max = p_arguments[2].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); int arg_min_count = arg_min->Count(); int arg_max_count = arg_max->Count(); bool min_singleton = (arg_min_count == 1); @@ -1948,8 +1948,8 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar if (!max_singleton && (arg_max_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_runif): function runif() requires max to be of length 1 or n." << EidosTerminate(nullptr); - double min_value0 = (arg_min_count ? arg_min->FloatAtIndex(0, nullptr) : 0.0); - double max_value0 = (arg_max_count ? arg_max->FloatAtIndex(0, nullptr) : 1.0); + double min_value0 = (arg_min_count ? arg_min->FloatAtIndex_CAST(0, nullptr) : 0.0); + double max_value0 = (arg_max_count ? arg_max->FloatAtIndex_CAST(0, nullptr) : 1.0); if (min_singleton && max_singleton && (min_value0 == 0.0) && (max_value0 == 1.0)) { @@ -2022,8 +2022,8 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double min_value = (min_singleton ? min_value0 : arg_min->FloatAtIndex((int)draw_index, nullptr)); - double max_value = (max_singleton ? max_value0 : arg_max->FloatAtIndex((int)draw_index, nullptr)); + double min_value = (min_singleton ? min_value0 : arg_min->FloatAtIndex_CAST((int)draw_index, nullptr)); + double max_value = (max_singleton ? max_value0 : arg_max->FloatAtIndex_CAST((int)draw_index, nullptr)); double range = max_value - min_value; if (range < 0.0) @@ -2052,7 +2052,7 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); EidosValue *arg_lambda = p_arguments[1].get(); EidosValue *arg_k = p_arguments[2].get(); int arg_lambda_count = arg_lambda->Count(); @@ -2067,8 +2067,8 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p if (!k_singleton && (arg_k_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rweibull): function rweibull() requires k to be of length 1 or n." << EidosTerminate(nullptr); - double lambda0 = (arg_lambda_count ? arg_lambda->FloatAtIndex(0, nullptr) : 0.0); - double k0 = (arg_k_count ? arg_k->FloatAtIndex(0, nullptr) : 0.0); + double lambda0 = (arg_lambda_count ? arg_lambda->FloatAtIndex_CAST(0, nullptr) : 0.0); + double k0 = (arg_k_count ? arg_k->FloatAtIndex_CAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (lambda_singleton && k_singleton) @@ -2098,8 +2098,8 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double lambda = (lambda_singleton ? lambda0 : arg_lambda->FloatAtIndex(draw_index, nullptr)); - double k = (k_singleton ? k0 : arg_k->FloatAtIndex(draw_index, nullptr)); + double lambda = (lambda_singleton ? lambda0 : arg_lambda->FloatAtIndex_CAST(draw_index, nullptr)); + double k = (k_singleton ? k0 : arg_k->FloatAtIndex_CAST(draw_index, nullptr)); if (lambda <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rweibull): function rweibull() requires lambda > 0.0 (" << EidosStringForFloat(lambda) << " supplied)." << EidosTerminate(nullptr); diff --git a/eidos/eidos_functions_files.cpp b/eidos/eidos_functions_files.cpp index b9f075b2d..d03b3838f 100644 --- a/eidos/eidos_functions_files.cpp +++ b/eidos/eidos_functions_files.cpp @@ -47,7 +47,7 @@ EidosValue_SP Eidos_ExecuteFunction_createDirectory(const std::vectorStringAtIndex(0, nullptr); + std::string base_path = path_value->StringAtIndex_NOCAST(0, nullptr); std::string error_string; bool success = Eidos_CreateDirectory(base_path, &error_string); @@ -67,7 +67,7 @@ EidosValue_SP Eidos_ExecuteFunction_deleteFile(const std::vector EidosValue_SP result_SP(nullptr); EidosValue *filePath_value = p_arguments[0].get(); - std::string base_path = filePath_value->StringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string file_path = Eidos_ResolvedPath(base_path); result_SP = ((remove(file_path.c_str()) == 0) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); @@ -83,7 +83,7 @@ EidosValue_SP Eidos_ExecuteFunction_fileExists(const std::vector EidosValue_SP result_SP(nullptr); EidosValue *filePath_value = p_arguments[0].get(); - std::string base_path = filePath_value->StringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string file_path = Eidos_ResolvedPath(base_path); struct stat file_info; @@ -102,11 +102,11 @@ EidosValue_SP Eidos_ExecuteFunction_filesAtPath(const std::vector EidosValue_SP result_SP(nullptr); EidosValue *path_value = p_arguments[0].get(); - std::string base_path = path_value->StringAtIndex(0, nullptr); + std::string base_path = path_value->StringAtIndex_NOCAST(0, nullptr); int base_path_length = (int)base_path.length(); bool base_path_ends_in_slash = (base_path_length > 0) && (base_path[base_path_length-1] == '/'); std::string path = Eidos_ResolvedPath(base_path); - bool fullPaths = p_arguments[1]->LogicalAtIndex(0, nullptr); + bool fullPaths = p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr); // this code modified from GNU: http://www.gnu.org/software/libc/manual/html_node/Simple-Directory-Lister.html#Simple-Directory-Lister // I'm not sure if it works on Windows... sigh... @@ -179,7 +179,7 @@ EidosValue_SP Eidos_ExecuteFunction_readFile(const std::vector &p EidosValue_SP result_SP(nullptr); EidosValue *filePath_value = p_arguments[0].get(); - std::string base_path = filePath_value->StringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string file_path = Eidos_ResolvedPath(base_path); // read the contents in @@ -225,7 +225,7 @@ EidosValue_SP Eidos_ExecuteFunction_setwd(const std::vector &p_ar // Now set the path EidosValue *filePath_value = p_arguments[0].get(); - std::string base_path = filePath_value->StringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string final_path = Eidos_ResolvedPath(base_path); errno = 0; @@ -249,7 +249,7 @@ EidosValue_SP Eidos_ExecuteFunction_flushFile(const std::vector & // Note that this function ignores matrix/array attributes, and always returns a vector, by design EidosValue *filePath_value = p_arguments[0].get(); - std::string base_path = filePath_value->StringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string file_path = Eidos_ResolvedPath(base_path); // note that writeFile() adds ".gz" to the filename if compression is specified and it is not already present; we don't, @@ -267,7 +267,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeFile(const std::vector & // Note that this function ignores matrix/array attributes, and always returns a vector, by design EidosValue *filePath_value = p_arguments[0].get(); - std::string base_path = filePath_value->StringAtIndex(0, nullptr); + std::string base_path = filePath_value->StringAtIndex_NOCAST(0, nullptr); std::string file_path = Eidos_ResolvedPath(base_path); // the second argument is the file contents to write, which we put into a vector @@ -278,13 +278,13 @@ EidosValue_SP Eidos_ExecuteFunction_writeFile(const std::vector & contents_buffer.reserve(contents_count); for (int value_index = 0; value_index < contents_count; ++value_index) - contents_buffer.emplace_back(&contents_value->StringRefAtIndex(value_index, nullptr)); + contents_buffer.emplace_back(&contents_value->StringRefAtIndex_NOCAST(value_index, nullptr)); // the third argument is an optional append flag, F by default - bool append = p_arguments[2]->LogicalAtIndex(0, nullptr); + bool append = p_arguments[2]->LogicalAtIndex_NOCAST(0, nullptr); // and then there is a flag for optional gzip compression - bool do_compress = p_arguments[3]->LogicalAtIndex(0, nullptr); + bool do_compress = p_arguments[3]->LogicalAtIndex_NOCAST(0, nullptr); if (do_compress && !Eidos_string_hasSuffix(file_path, ".gz")) file_path.append(".gz"); @@ -325,16 +325,16 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vectorStringAtIndex(0, nullptr); + std::string prefix = prefix_value->StringAtIndex_NOCAST(0, nullptr); EidosValue *suffix_value = p_arguments[1].get(); - std::string suffix = suffix_value->StringAtIndex(0, nullptr); + std::string suffix = suffix_value->StringAtIndex_NOCAST(0, nullptr); // the third argument is the file contents to write EidosValue_String *contents_value = (EidosValue_String *)p_arguments[2].get(); int contents_count = contents_value->Count(); // and then there is a flag for optional gzip compression - bool do_compress = p_arguments[3]->LogicalAtIndex(0, nullptr); + bool do_compress = p_arguments[3]->LogicalAtIndex_NOCAST(0, nullptr); if (do_compress && !Eidos_string_hasSuffix(suffix, ".gz")) suffix.append(".gz"); @@ -393,7 +393,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vectorStringAtIndex(0, nullptr); + outstream << contents_value->StringAtIndex_NOCAST(0, nullptr); } else { @@ -454,7 +454,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vectorStringAtIndex(0, nullptr); // no final newline in this case, so the user can precisely specify the file contents if desired + file_stream << contents_value->StringAtIndex_NOCAST(0, nullptr); // no final newline in this case, so the user can precisely specify the file contents if desired } else { diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index f1d724c70..728253d69 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -65,7 +65,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu // This is an overflow-safe version of: //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(llabs(x_value->IntAtIndex(0, nullptr))); - int64_t operand = x_value->IntAtIndex(0, nullptr); + int64_t operand = x_value->IntAtIndex_NOCAST(0, nullptr); // the absolute value of INT64_MIN cannot be represented in int64_t if (operand == INT64_MIN) @@ -103,7 +103,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fabs(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fabs(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { @@ -135,7 +135,7 @@ EidosValue_SP Eidos_ExecuteFunction_acos(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(acos(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(acos(x_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -143,7 +143,7 @@ EidosValue_SP Eidos_ExecuteFunction_acos(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(acos(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(acos(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -161,7 +161,7 @@ EidosValue_SP Eidos_ExecuteFunction_asin(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(asin(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(asin(x_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -169,7 +169,7 @@ EidosValue_SP Eidos_ExecuteFunction_asin(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(asin(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(asin(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -187,7 +187,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan(x_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -195,7 +195,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(atan(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(atan(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -226,7 +226,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan2(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan2(x_value->FloatAtIndex(0, nullptr), y_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan2(x_value->FloatAtIndex_CAST(0, nullptr), y_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -234,7 +234,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan2(const std::vector &p_ar result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(atan2(x_value->FloatAtIndex(value_index, nullptr), y_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(atan2(x_value->FloatAtIndex_CAST(value_index, nullptr), y_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } // Copy dimensions from whichever operand we chose at the beginning @@ -253,7 +253,7 @@ EidosValue_SP Eidos_ExecuteFunction_ceil(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(ceil(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(ceil(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { @@ -284,7 +284,7 @@ EidosValue_SP Eidos_ExecuteFunction_cos(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cos(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cos(x_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -292,7 +292,7 @@ EidosValue_SP Eidos_ExecuteFunction_cos(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(cos(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(cos(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -313,7 +313,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); } else { @@ -340,7 +340,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -376,7 +376,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); } else { @@ -403,7 +403,7 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -437,7 +437,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(exp(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(exp(x_value->FloatAtIndex_CAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -445,7 +445,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(exp(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(exp(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -475,7 +475,7 @@ EidosValue_SP Eidos_ExecuteFunction_floor(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(floor(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(floor(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { @@ -516,8 +516,8 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector if ((x_count == 1) && (y_count == 1)) { - int64_t int1 = x_value->IntAtIndex(0, nullptr); - int64_t int2 = y_value->IntAtIndex(0, nullptr); + int64_t int1 = x_value->IntAtIndex_NOCAST(0, nullptr); + int64_t int2 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int2 == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_integerDiv): function integerDiv() cannot perform division by 0." << EidosTerminate(nullptr); @@ -546,7 +546,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector } else if (x_count == 1) { - int64_t int1 = x_value->IntAtIndex(0, nullptr); + int64_t int1 = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); @@ -564,7 +564,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector else if (y_count == 1) { const int64_t *int1_data = x_value->IntData(); - int64_t int2 = y_value->IntAtIndex(0, nullptr); + int64_t int2 = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -617,8 +617,8 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector if ((x_count == 1) && (y_count == 1)) { - int64_t int1 = x_value->IntAtIndex(0, nullptr); - int64_t int2 = y_value->IntAtIndex(0, nullptr); + int64_t int1 = x_value->IntAtIndex_NOCAST(0, nullptr); + int64_t int2 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int2 == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_integerMod): function integerMod() cannot perform modulo by 0." << EidosTerminate(nullptr); @@ -647,7 +647,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector } else if (x_count == 1) { - int64_t int1 = x_value->IntAtIndex(0, nullptr); + int64_t int1 = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int2_data = y_value->IntData(); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); @@ -665,7 +665,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector else if (y_count == 1) { const int64_t *int1_data = x_value->IntData(); - int64_t int2 = y_value->IntAtIndex(0, nullptr); + int64_t int2 = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); @@ -709,9 +709,9 @@ EidosValue_SP Eidos_ExecuteFunction_isFinite(const std::vector &p if (x_count == 1) { if (x_value ->DimensionCount() == 1) - result_SP = (std::isfinite(x_value->FloatAtIndex(0, nullptr)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); + result_SP = (std::isfinite(x_value->FloatAtIndex_NOCAST(0, nullptr)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); else - result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical{std::isfinite(x_value->FloatAtIndex(0, nullptr))}); + result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical{std::isfinite(x_value->FloatAtIndex_NOCAST(0, nullptr))}); } else { @@ -741,9 +741,9 @@ EidosValue_SP Eidos_ExecuteFunction_isInfinite(const std::vector if (x_count == 1) { if (x_value ->DimensionCount() == 1) - result_SP = (std::isinf(x_value->FloatAtIndex(0, nullptr)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); + result_SP = (std::isinf(x_value->FloatAtIndex_NOCAST(0, nullptr)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); else - result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical{(eidos_logical_t)std::isinf(x_value->FloatAtIndex(0, nullptr))}); + result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical{(eidos_logical_t)std::isinf(x_value->FloatAtIndex_NOCAST(0, nullptr))}); } else { @@ -773,9 +773,9 @@ EidosValue_SP Eidos_ExecuteFunction_isNAN(const std::vector &p_ar if (x_count == 1) { if (x_value ->DimensionCount() == 1) - result_SP = (std::isnan(x_value->FloatAtIndex(0, nullptr)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); + result_SP = (std::isnan(x_value->FloatAtIndex_NOCAST(0, nullptr)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); else - result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical{(eidos_logical_t)std::isnan(x_value->FloatAtIndex(0, nullptr))}); + result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical{(eidos_logical_t)std::isnan(x_value->FloatAtIndex_NOCAST(0, nullptr))}); } else { @@ -805,7 +805,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log(x_value->FloatAtIndex_CAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -813,7 +813,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(log(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(log(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -844,7 +844,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log10(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log10(x_value->FloatAtIndex_CAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -852,7 +852,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(log10(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(log10(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -883,7 +883,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log2(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log2(x_value->FloatAtIndex_CAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -891,7 +891,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(log2(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(log2(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -924,7 +924,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); } else { @@ -966,7 +966,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -994,7 +994,7 @@ EidosValue_SP Eidos_ExecuteFunction_round(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(round(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(round(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { @@ -1137,7 +1137,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr), int1 = y_value->IntAtIndex(0, nullptr); + int64_t int0 = x_value->IntAtIndex_NOCAST(0, nullptr), int1 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int0 == int1) result_SP = gStaticEidosValue_Integer_ZeroVec; @@ -1146,7 +1146,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr), float1 = y_value->FloatAtIndex(0, nullptr); + double float0 = x_value->FloatAtIndex_NOCAST(0, nullptr), float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); if ((std::isnan(float0) && std::isnan(float1)) || (float0 == float1)) result_SP = gStaticEidosValue_Float_ZeroVec; @@ -1155,8 +1155,8 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); - const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &string0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); if (string0 == string1) result_SP = gStaticEidosValue_String_ZeroVec; @@ -1165,7 +1165,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr), *obj1 = y_value->ObjectElementAtIndex(0, nullptr); + EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) result_SP = x_value->NewMatchingType(); @@ -1178,7 +1178,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr); + int64_t int0 = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int_data = y_value->IntData(); for (int value_index = 0; value_index < y_count; ++value_index) @@ -1189,7 +1189,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr); + double float0 = x_value->FloatAtIndex_NOCAST(0, nullptr); const double *float_data = y_value->FloatData(); for (int value_index = 0; value_index < y_count; ++value_index) @@ -1204,7 +1204,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &string0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string *string_vec = y_value->StringData(); for (int value_index = 0; value_index < y_count; ++value_index) @@ -1215,7 +1215,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr); + EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject * const *object_vec = y_value->ObjectData(); for (int value_index = 0; value_index < y_count; ++value_index) @@ -1234,7 +1234,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex(0, nullptr); + int64_t int1 = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); @@ -1247,7 +1247,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex(0, nullptr); + double float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); double *float_data = float_vec->FloatData_Mutable(); @@ -1264,7 +1264,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); std::vector &string_vec = string_vector_obj->StringVectorData(); @@ -1277,7 +1277,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex(0, nullptr); + EidosObject *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); @@ -1541,7 +1541,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorIntAtIndex(0, nullptr), int1 = y_value->IntAtIndex(0, nullptr); + int64_t int0 = x_value->IntAtIndex_NOCAST(0, nullptr), int1 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int0 == int1) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int0)); @@ -1550,7 +1550,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatAtIndex(0, nullptr), float1 = y_value->FloatAtIndex(0, nullptr); + double float0 = x_value->FloatAtIndex_NOCAST(0, nullptr), float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); if ((std::isnan(float0) && std::isnan(float1)) || (float0 == float1)) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(float0)); @@ -1559,8 +1559,8 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorStringRefAtIndex(0, nullptr); - const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &string0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); if (string0 == string1) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string0)); @@ -1569,7 +1569,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementAtIndex(0, nullptr), *obj1 = y_value->ObjectElementAtIndex(0, nullptr); + EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); @@ -1591,7 +1591,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorIntAtIndex(0, nullptr); + int64_t value = y_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int_data = x_value->IntData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) @@ -1603,7 +1603,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatAtIndex(0, nullptr); + double value0 = y_value->FloatAtIndex_NOCAST(0, nullptr); const double *float_data = x_value->FloatData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) @@ -1619,7 +1619,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &value = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string *string_vec = x_value->StringData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) @@ -1631,7 +1631,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementAtIndex(0, nullptr); + EidosObject *value = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject * const *object_vec = x_value->ObjectData(); for (int scan_index = 0; scan_index < x_count; ++scan_index) @@ -1908,7 +1908,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntAtIndex(0, nullptr), int1 = y_value->IntAtIndex(0, nullptr); + int64_t int0 = x_value->IntAtIndex_NOCAST(0, nullptr), int1 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int0 == int1) result_SP = gStaticEidosValue_Integer_ZeroVec; @@ -1917,7 +1917,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatAtIndex(0, nullptr), float1 = y_value->FloatAtIndex(0, nullptr); + double float0 = x_value->FloatAtIndex_NOCAST(0, nullptr), float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); if ((std::isnan(float0) && std::isnan(float1)) || (float0 == float1)) result_SP = gStaticEidosValue_Float_ZeroVec; @@ -1926,8 +1926,8 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorStringRefAtIndex(0, nullptr); - const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &string0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); if (string0 == string1) result_SP = gStaticEidosValue_String_ZeroVec; @@ -1936,7 +1936,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementAtIndex(0, nullptr), *obj1 = y_value->ObjectElementAtIndex(0, nullptr); + EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) result_SP = x_value->NewMatchingType(); @@ -1963,7 +1963,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntAtIndex(0, nullptr); + int64_t int1 = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); int value_index; @@ -1979,7 +1979,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatAtIndex(0, nullptr); + double float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); double *float_data = float_vec->FloatData_Mutable(); int value_index; @@ -1999,7 +1999,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); std::vector &string_vec = string_vector_obj->StringVectorData(); int value_index; @@ -2015,7 +2015,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementAtIndex(0, nullptr); + EidosObject *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); int value_index; @@ -2377,7 +2377,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p // Make a bit of an effort to produce a singleton result, while handling the singleton/singleton case if (arg_type == EidosValueType::kValueInt) { - int64_t int0 = x_value->IntAtIndex(0, nullptr), int1 = y_value->IntAtIndex(0, nullptr); + int64_t int0 = x_value->IntAtIndex_NOCAST(0, nullptr), int1 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int0 == int1) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int0)); @@ -2386,7 +2386,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } else if (arg_type == EidosValueType::kValueFloat) { - double float0 = x_value->FloatAtIndex(0, nullptr), float1 = y_value->FloatAtIndex(0, nullptr); + double float0 = x_value->FloatAtIndex_NOCAST(0, nullptr), float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); if ((std::isnan(float0) && std::isnan(float1)) || (float0 == float1)) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(float0)); @@ -2395,8 +2395,8 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } else if (arg_type == EidosValueType::kValueString) { - const std::string &string0 = ((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); - const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &string0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); if (string0 == string1) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string0)); @@ -2405,7 +2405,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } else if (arg_type == EidosValueType::kValueObject) { - EidosObject *obj0 = x_value->ObjectElementAtIndex(0, nullptr), *obj1 = y_value->ObjectElementAtIndex(0, nullptr); + EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); @@ -2431,7 +2431,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p // result_SP is modifiable and is guaranteed to be a vector, so now add y if necessary using the fast APIs if (arg_type == EidosValueType::kValueInt) { - int64_t value = y_value->IntAtIndex(0, nullptr); + int64_t value = y_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int_data = result_SP->IntData(); int scan_index; @@ -2450,7 +2450,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } else if (arg_type == EidosValueType::kValueFloat) { - double value1 = y_value->FloatAtIndex(0, nullptr); + double value1 = y_value->FloatAtIndex_NOCAST(0, nullptr); const double *float_data = result_SP->FloatData(); int scan_index; @@ -2471,7 +2471,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } else if (arg_type == EidosValueType::kValueString) { - const std::string &value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &value = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string *string_data = result_SP->StringData(); int scan_index; @@ -2491,7 +2491,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } else if (arg_type == EidosValueType::kValueObject) { - EidosObject *value = y_value->ObjectElementAtIndex(0, nullptr); + EidosObject *value = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject * const *object_data = result_SP->ObjectData(); int scan_index; @@ -2532,7 +2532,7 @@ EidosValue_SP Eidos_ExecuteFunction_sin(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sin(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sin(x_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -2540,7 +2540,7 @@ EidosValue_SP Eidos_ExecuteFunction_sin(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(sin(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(sin(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -2559,7 +2559,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sqrt(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sqrt(x_value->FloatAtIndex_CAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -2567,7 +2567,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(sqrt(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(sqrt(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -2601,7 +2601,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); } else #ifndef _OPENMP @@ -2666,7 +2666,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -2709,7 +2709,7 @@ EidosValue_SP Eidos_ExecuteFunction_sumExact(const std::vector &p if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -2733,7 +2733,7 @@ EidosValue_SP Eidos_ExecuteFunction_tan(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(tan(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(tan(x_value->FloatAtIndex_CAST(0, nullptr)))); } else { @@ -2741,7 +2741,7 @@ EidosValue_SP Eidos_ExecuteFunction_tan(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(tan(x_value->FloatAtIndex(value_index, nullptr)), value_index); + float_result->set_float_no_check(tan(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -2759,7 +2759,7 @@ EidosValue_SP Eidos_ExecuteFunction_trunc(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(trunc(x_value->FloatAtIndex(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(trunc(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index 514d867ec..d54945c7f 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -59,14 +59,14 @@ EidosValue_SP Eidos_ExecuteFunction_apply(const std::vector &p_ar for (int margin_index = 0; margin_index < margin_count; ++margin_index) { - int64_t margin = margin_value->IntAtIndex(margin_index, nullptr); + int64_t margin = margin_value->IntAtIndex_NOCAST(margin_index, nullptr); if ((margin < 0) || (margin >= x_dimcount)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_apply): specified margin " << margin << " is out of range in function apply(); margin indices are zero-based, and thus must be from 0 to size(dim(x)) - 1." << EidosTerminate(nullptr); for (int margin_index_2 = 0; margin_index_2 < margin_index; ++margin_index_2) { - int64_t margin_2 = margin_value->IntAtIndex(margin_index_2, nullptr); + int64_t margin_2 = margin_value->IntAtIndex_NOCAST(margin_index_2, nullptr); if (margin_2 == margin) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_apply): specified margin " << margin << " was already specified to function apply(); a given margin may be specified only once." << EidosTerminate(nullptr); @@ -91,7 +91,7 @@ EidosValue_SP Eidos_ExecuteFunction_apply(const std::vector &p_ar // We try to do tokenization and parsing once per script, by caching the script inside the EidosValue_String_singleton instance if (!script) { - script = new EidosScript(lambda_value->StringAtIndex(0, nullptr), -1); + script = new EidosScript(lambda_value->StringAtIndex_NOCAST(0, nullptr), -1); gEidosErrorContext = EidosErrorContext{{-1, -1, -1, -1}, script, true}; @@ -297,7 +297,7 @@ EidosValue_SP Eidos_ExecuteFunction_array(const std::vector &p_ar for (int dim_index = 0; dim_index < dim_count; ++dim_index) { - int64_t dim = dim_value->IntAtIndex(dim_index, nullptr); + int64_t dim = dim_value->IntAtIndex_NOCAST(dim_index, nullptr); if (dim < 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_array): function array() requires that all dimensions be >= 1." << EidosTerminate(nullptr); @@ -516,8 +516,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrix(const std::vector &p_a bool nrow_null = (nrow_value->Type() == EidosValueType::kValueNULL); bool ncol_null = (ncol_value->Type() == EidosValueType::kValueNULL); - int64_t nrow = nrow_null ? -1 : nrow_value->IntAtIndex(0, nullptr); - int64_t ncol = ncol_null ? -1 : ncol_value->IntAtIndex(0, nullptr); + int64_t nrow = nrow_null ? -1 : nrow_value->IntAtIndex_NOCAST(0, nullptr); + int64_t ncol = ncol_null ? -1 : ncol_value->IntAtIndex_NOCAST(0, nullptr); if ((!nrow_null && (nrow <= 0)) || (!ncol_null && (ncol <= 0))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_matrix): dimension <= 0 requested, which is not allowed." << EidosTerminate(nullptr); @@ -548,14 +548,14 @@ EidosValue_SP Eidos_ExecuteFunction_matrix(const std::vector &p_a } else { - nrow = nrow_value->IntAtIndex(0, nullptr); - ncol = ncol_value->IntAtIndex(0, nullptr); + nrow = nrow_value->IntAtIndex_NOCAST(0, nullptr); + ncol = ncol_value->IntAtIndex_NOCAST(0, nullptr); if (data_count != nrow * ncol) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_matrix): function matrix() requires a data vector with a length equal to the product of the proposed number of rows and columns." << EidosTerminate(nullptr); } - eidos_logical_t byrow = byrow_value->LogicalAtIndex(0, nullptr); + eidos_logical_t byrow = byrow_value->LogicalAtIndex_NOCAST(0, nullptr); if (byrow) { @@ -635,8 +635,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector // a 1x1 vector multiplied by a 1x1 vector if (x_type == EidosValueType::kValueInt) { - int64_t x_singleton = x_value->IntAtIndex(0, nullptr); - int64_t y_singleton = y_value->IntAtIndex(0, nullptr); + int64_t x_singleton = x_value->IntAtIndex_NOCAST(0, nullptr); + int64_t y_singleton = y_value->IntAtIndex_NOCAST(0, nullptr); int64_t multiply_result; bool overflow = Eidos_mul_overflow(x_singleton, y_singleton, &multiply_result); @@ -647,8 +647,8 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector } else // (x_type == EidosValueType::kValueFloat) { - double x_singleton = x_value->FloatAtIndex(0, nullptr); - double y_singleton = y_value->FloatAtIndex(0, nullptr); + double x_singleton = x_value->FloatAtIndex_NOCAST(0, nullptr); + double y_singleton = y_value->FloatAtIndex_NOCAST(0, nullptr); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_singleton * y_singleton)); } @@ -658,7 +658,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector // a 1x1 vector multiplied by a row vector if (x_type == EidosValueType::kValueInt) { - int64_t x_singleton = x_value->IntAtIndex(0, nullptr); + int64_t x_singleton = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *y_data = y_value->IntData(); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -677,7 +677,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector } else // (x_type == EidosValueType::kValueFloat) { - double x_singleton = x_value->FloatAtIndex(0, nullptr); + double x_singleton = x_value->FloatAtIndex_NOCAST(0, nullptr); const double *y_data = y_value->FloatData(); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -692,7 +692,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector if (x_type == EidosValueType::kValueInt) { const int64_t *x_data = x_value->IntData(); - int64_t y_singleton = y_value->IntAtIndex(0, nullptr); + int64_t y_singleton = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -711,7 +711,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector else // (x_type == EidosValueType::kValueFloat) { const double *x_data = x_value->FloatData(); - double y_singleton = y_value->FloatAtIndex(0, nullptr); + double y_singleton = y_value->FloatAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); @@ -999,7 +999,7 @@ EidosValue_SP Eidos_ExecuteFunction_lowerTri(const std::vector &p // contributed by Nick O'Brien (@nobrien97) EidosValue *x_value = p_arguments[0].get(); - eidos_logical_t diag = p_arguments[1].get()->LogicalAtIndex(0, nullptr); + eidos_logical_t diag = p_arguments[1].get()->LogicalAtIndex_NOCAST(0, nullptr); if (x_value->DimensionCount() != 2) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_lowerTri): in function lowerTri() x is not a matrix." << EidosTerminate(nullptr); @@ -1047,7 +1047,7 @@ EidosValue_SP Eidos_ExecuteFunction_upperTri(const std::vector &p // contributed by Nick O'Brien (@nobrien97) EidosValue *x_value = p_arguments[0].get(); - eidos_logical_t diag = p_arguments[1].get()->LogicalAtIndex(0, nullptr); + eidos_logical_t diag = p_arguments[1].get()->LogicalAtIndex_NOCAST(0, nullptr); if (x_value->DimensionCount() != 2) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_upperTri): in function upperTri() x is not a matrix." << EidosTerminate(nullptr); @@ -1141,10 +1141,10 @@ EidosValue_SP Eidos_ExecuteFunction_diag(const std::vector &p_arg } // 2: If x is 1 and nrow is non-NULL, return an identity matrix of size nrow (by ncol, if specified) - if ((x_type == EidosValueType::kValueInt) && (x_count == 1) && (x_value->IntAtIndex(0, nullptr) == 1) && !nrow_null) + if ((x_type == EidosValueType::kValueInt) && (x_count == 1) && (x_value->IntAtIndex_NOCAST(0, nullptr) == 1) && !nrow_null) { - int64_t nrow = nrow_value->IntAtIndex(0, nullptr); - int64_t ncol = (ncol_null ? nrow : ncol_value->IntAtIndex(0, nullptr)); + int64_t nrow = nrow_value->IntAtIndex_NOCAST(0, nullptr); + int64_t ncol = (ncol_null ? nrow : ncol_value->IntAtIndex_NOCAST(0, nullptr)); if ((nrow < 1) || (ncol < 1)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_diag): in function diag() when an identity matrix is being generated, both dimensions of that matrix must be >= 1." << EidosTerminate(nullptr); @@ -1165,7 +1165,7 @@ EidosValue_SP Eidos_ExecuteFunction_diag(const std::vector &p_arg // 3: If x is a singleton integer, nrow/ncol must not be set, and a square identity matrix of size x is returned if ((x_type == EidosValueType::kValueInt) && (x_count == 1) && nrow_null && ncol_null) { - int64_t size = x_value->IntAtIndex(0, nullptr); + int64_t size = x_value->IntAtIndex_NOCAST(0, nullptr); if (size < 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_diag): in function diag() when x specificies an identity matrix size, that size must be >= 1." << EidosTerminate(nullptr); @@ -1186,8 +1186,8 @@ EidosValue_SP Eidos_ExecuteFunction_diag(const std::vector &p_arg // 4: If x is a logical/integer/float vector of length >= 2, use the values of x for the diagonal if (((x_type == EidosValueType::kValueLogical) || (x_type == EidosValueType::kValueInt) || (x_type == EidosValueType::kValueFloat)) && (x_count >= 2)) { - int64_t nrow = (nrow_null ? x_count : nrow_value->IntAtIndex(0, nullptr)); - int64_t ncol = (ncol_null ? nrow : ncol_value->IntAtIndex(0, nullptr)); // it is weird that the default is nrow, not x_count, but this mirrors R's behavior + int64_t nrow = (nrow_null ? x_count : nrow_value->IntAtIndex_NOCAST(0, nullptr)); + int64_t ncol = (ncol_null ? nrow : ncol_value->IntAtIndex_NOCAST(0, nullptr)); // it is weird that the default is nrow, not x_count, but this mirrors R's behavior int64_t max_diag_index = std::min(nrow, ncol); if (max_diag_index != x_count) diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 9e2385014..039149ace 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -76,7 +76,7 @@ EidosValue_SP Eidos_ExecuteFunction_assert(const std::vector &p_a if (message_value->Type() != EidosValueType::kValueNULL) { - std::string &&stop_string = message_value->StringAtIndex(0, nullptr); + std::string &&stop_string = message_value->StringAtIndex_NOCAST(0, nullptr); p_interpreter.ErrorOutputStream() << stop_string << std::endl; @@ -99,7 +99,7 @@ EidosValue_SP Eidos_ExecuteFunction_beep(const std::vector &p_arg // Note that this function ignores matrix/array attributes, and always returns a vector, by design EidosValue *soundName_value = p_arguments[0].get(); - std::string name_string = ((soundName_value->Type() == EidosValueType::kValueString) ? soundName_value->StringAtIndex(0, nullptr) : gEidosStr_empty_string); + std::string name_string = ((soundName_value->Type() == EidosValueType::kValueString) ? soundName_value->StringAtIndex_NOCAST(0, nullptr) : gEidosStr_empty_string); std::string beep_error = Eidos_Beep(name_string); @@ -144,7 +144,7 @@ EidosValue_SP Eidos_ExecuteFunction_clock(__attribute__((unused)) const std::vec // Note that this function ignores matrix/array attributes, and always returns a vector, by design EidosValue_String *string_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &type_name = string_value->StringRefAtIndex(0, nullptr); + const std::string &type_name = string_value->StringRefAtIndex_NOCAST(0, nullptr); if (type_name == "cpu") { @@ -205,7 +205,7 @@ EidosValue_SP Eidos_ExecuteFunction_defineConstant(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &symbol_name = symbol_value->StringRefAtIndex_NOCAST(0, nullptr); const EidosValue_SP &x_value_sp = p_arguments[1]; EidosGlobalStringID symbol_id = EidosStringRegistry::GlobalStringIDForString(symbol_name); EidosSymbolTable &symbols = p_interpreter.SymbolTable(); @@ -231,7 +231,7 @@ EidosValue_SP Eidos_ExecuteFunction_defineGlobal(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &symbol_name = symbol_value->StringRefAtIndex_NOCAST(0, nullptr); const EidosValue_SP &x_value_sp = p_arguments[1]; EidosGlobalStringID symbol_id = EidosStringRegistry::GlobalStringIDForString(symbol_name); EidosSymbolTable &symbols = p_interpreter.SymbolTable(); @@ -261,7 +261,7 @@ EidosValue_SP Eidos_ExecuteFunction_doCall(const std::vector &p_a EidosValue_SP result_SP(nullptr); EidosValue_String *functionName_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &function_name = functionName_value->StringRefAtIndex(0, nullptr); + const std::string &function_name = functionName_value->StringRefAtIndex_NOCAST(0, nullptr); // Copy the argument list; this is a little slow, but not a big deal, and it provides protection against re-entrancy std::vector arguments; @@ -341,7 +341,7 @@ EidosValue_SP Eidos_ExecuteLambdaInternal(const std::vector &p_ar // We try to do tokenization and parsing once per script, by caching the script inside the EidosValue_String_singleton instance if (!script) { - script = new EidosScript(lambdaSource_value->StringAtIndex(0, nullptr), -1); + script = new EidosScript(lambdaSource_value->StringAtIndex_NOCAST(0, nullptr), -1); gEidosErrorContext = EidosErrorContext{{-1, -1, -1, -1}, script, true}; @@ -382,12 +382,12 @@ EidosValue_SP Eidos_ExecuteLambdaInternal(const std::vector &p_ar if (timed_value_type == EidosValueType::kValueLogical) { - if (timed_value->LogicalAtIndex(0, nullptr)) + if (timed_value->LogicalAtIndex_NOCAST(0, nullptr)) timed = true; } else if (timed_value_type == EidosValueType::kValueString) { - const std::string &timed_string = timed_value->StringRefAtIndex(0, nullptr); + const std::string &timed_string = timed_value->StringRefAtIndex_NOCAST(0, nullptr); if (timed_string == "cpu") { @@ -504,7 +504,7 @@ EidosValue_SP Eidos_ExecuteFunction_exists(const std::vector &p_a if ((symbol_count == 1) && (symbol_value->DimensionCount() == 1)) { // Use the global constants, but only if we do not have to impose a dimensionality upon the value below - EidosGlobalStringID symbol_id = EidosStringRegistry::GlobalStringIDForString(symbol_value->StringRefAtIndex(0, nullptr)); + EidosGlobalStringID symbol_id = EidosStringRegistry::GlobalStringIDForString(symbol_value->StringRefAtIndex_NOCAST(0, nullptr)); result_SP = (symbols.ContainsSymbol(symbol_id) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); } @@ -515,7 +515,7 @@ EidosValue_SP Eidos_ExecuteFunction_exists(const std::vector &p_a for (int value_index = 0; value_index < symbol_count; ++value_index) { - EidosGlobalStringID symbol_id = EidosStringRegistry::GlobalStringIDForString(symbol_value->StringRefAtIndex(value_index, nullptr)); + EidosGlobalStringID symbol_id = EidosStringRegistry::GlobalStringIDForString(symbol_value->StringRefAtIndex_NOCAST(value_index, nullptr)); logical_result->set_logical_no_check(symbols.ContainsSymbol(symbol_id), value_index); } @@ -534,7 +534,7 @@ EidosValue_SP Eidos_ExecuteFunction_functionSignature(const std::vectorType() == EidosValueType::kValueString); - std::string match_string = (function_name_specified ? functionName_value->StringAtIndex(0, nullptr) : gEidosStr_empty_string); + std::string match_string = (function_name_specified ? functionName_value->StringAtIndex_NOCAST(0, nullptr) : gEidosStr_empty_string); bool signature_found = false; // function_map_ is already alphabetized since maps keep sorted order @@ -580,7 +580,7 @@ EidosValue_SP Eidos_ExecuteFunction_functionSource(const std::vectorStringAtIndex(0, nullptr); + std::string match_string = functionName_value->StringAtIndex_NOCAST(0, nullptr); // function_map_ is already alphabetized since maps keep sorted order EidosFunctionMap &function_map = p_interpreter.FunctionMap(); @@ -674,7 +674,7 @@ EidosValue_SP Eidos_ExecuteFunction_ls(__attribute__((unused)) const std::vector { // Note that this function ignores matrix/array attributes, and always returns a vector, by design - bool showSymbolTables = p_arguments[0]->LogicalAtIndex(0, nullptr); + bool showSymbolTables = p_arguments[0]->LogicalAtIndex_NOCAST(0, nullptr); std::ostream &outstream = p_interpreter.ExecutionOutputStream(); EidosSymbolTable ¤t_symbol_table = p_interpreter.SymbolTable(); @@ -869,7 +869,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelSetNumThreads(__attribute__((unused) if (numThreads_value->Type() == EidosValueType::kValueInt) { // An explicit override has been requested, even if numThreads == gEidosMaxThreads - numThreads = numThreads_value->IntAtIndex(0, nullptr); + numThreads = numThreads_value->IntAtIndex_NOCAST(0, nullptr); gEidosNumThreadsOverride = true; } else @@ -909,7 +909,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelSetTaskThreadCounts(__attribute__((u // Check that source is a subclass of EidosDictionaryUnretained. We do this check here because we want to avoid making // EidosDictionaryUnretained visible in the public API; we want to pretend that there is just one class, Dictionary. // I'm not sure whether that's going to be right in the long term, but I want to keep my options open for now. - EidosDictionaryUnretained *source = dynamic_cast(source_value->ObjectElementAtIndex(0, nullptr)); + EidosDictionaryUnretained *source = dynamic_cast(source_value->ObjectElementAtIndex_NOCAST(0, nullptr)); if (!source) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_parallelSetTaskThreadCounts): parallelSetTaskThreadCounts() can only take values from a Dictionary or a subclass of Dictionary." << EidosTerminate(nullptr); @@ -928,7 +928,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelSetTaskThreadCounts(__attribute__((u if ((value->Type() == EidosValueType::kValueInt) && (value->Count() == 1)) { - int64_t value_int64 = value->IntAtIndex(0, nullptr); + int64_t value_int64 = value->IntAtIndex_NOCAST(0, nullptr); if ((value_int64 < 1) || (value_int64 > EIDOS_OMP_MAX_THREADS)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_parallelSetTaskThreadCounts): parallelSetTaskThreadCounts() requires thread counts to be in [1, " << EIDOS_OMP_MAX_THREADS << "]." << EidosTerminate(nullptr); @@ -1103,7 +1103,7 @@ EidosValue_SP Eidos_ExecuteFunction_rm(const std::vector &p_argum int variableNames_count = variableNames_value->Count(); for (int value_index = 0; value_index < variableNames_count; ++value_index) - symbols_to_remove.emplace_back(variableNames_value->StringAtIndex(value_index, nullptr)); + symbols_to_remove.emplace_back(variableNames_value->StringAtIndex_NOCAST(value_index, nullptr)); } for (std::string &symbol : symbols_to_remove) @@ -1127,7 +1127,7 @@ EidosValue_SP Eidos_ExecuteFunction_sapply(const std::vector &p_a // Determine the simplification mode requested EidosValue_String *simplify_value = (EidosValue_String *)p_arguments[2].get(); - const std::string &simplify_string = simplify_value->StringRefAtIndex(0, nullptr); + const std::string &simplify_string = simplify_value->StringRefAtIndex_NOCAST(0, nullptr); int simplify; if (simplify_string == "vector") simplify = 0; @@ -1151,7 +1151,7 @@ EidosValue_SP Eidos_ExecuteFunction_sapply(const std::vector &p_a // We try to do tokenization and parsing once per script, by caching the script inside the EidosValue_String_singleton instance if (!script) { - script = new EidosScript(lambda_value->StringAtIndex(0, nullptr), -1); + script = new EidosScript(lambda_value->StringAtIndex_NOCAST(0, nullptr), -1); gEidosErrorContext = EidosErrorContext{{-1, -1, -1, -1}, script, true}; @@ -1287,7 +1287,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSeed(const std::vector &p_ EidosValue *seed_value = p_arguments[0].get(); - Eidos_SetRNGSeed(seed_value->IntAtIndex(0, nullptr)); + Eidos_SetRNGSeed(seed_value->IntAtIndex_NOCAST(0, nullptr)); return gStaticEidosValueVOID; } @@ -1303,7 +1303,7 @@ EidosValue_SP Eidos_ExecuteFunction_stop(const std::vector &p_arg if (message_value->Type() != EidosValueType::kValueNULL) { - std::string &&stop_string = p_arguments[0]->StringAtIndex(0, nullptr); + std::string &&stop_string = p_arguments[0]->StringAtIndex_NOCAST(0, nullptr); p_interpreter.ErrorOutputStream() << stop_string << std::endl; @@ -1322,7 +1322,7 @@ EidosValue_SP Eidos_ExecuteFunction_stop(const std::vector &p_arg EidosValue_SP Eidos_ExecuteFunction_suppressWarnings(const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosValue *suppress_value = p_arguments[0].get(); - eidos_logical_t new_suppress = suppress_value->LogicalAtIndex(0, nullptr); + eidos_logical_t new_suppress = suppress_value->LogicalAtIndex_NOCAST(0, nullptr); eidos_logical_t old_suppress = gEidosSuppressWarnings; gEidosSuppressWarnings = new_suppress; @@ -1334,7 +1334,7 @@ EidosValue_SP Eidos_ExecuteFunction_suppressWarnings(const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosValue *key_value = p_arguments[0].get(); - std::string key = key_value->StringAtIndex(0, nullptr); + std::string key = key_value->StringAtIndex_NOCAST(0, nullptr); if (key == "os") { @@ -1422,15 +1422,15 @@ EidosValue_SP Eidos_ExecuteFunction_system(const std::vector &p_a EidosValue_String *command_value = (EidosValue_String *)p_arguments[0].get(); EidosValue_String *args_value = (EidosValue_String *)p_arguments[1].get(); int arg_count = args_value->Count(); - bool has_args = ((arg_count > 1) || ((arg_count == 1) && (args_value->StringRefAtIndex(0, nullptr).length() > 0))); + bool has_args = ((arg_count > 1) || ((arg_count == 1) && (args_value->StringRefAtIndex_NOCAST(0, nullptr).length() > 0))); EidosValue_String *input_value = (EidosValue_String *)p_arguments[2].get(); int input_count = input_value->Count(); - bool has_input = ((input_count > 1) || ((input_count == 1) && (input_value->StringRefAtIndex(0, nullptr).length() > 0))); - bool redirect_stderr = p_arguments[3]->LogicalAtIndex(0, nullptr); - bool wait = p_arguments[4]->LogicalAtIndex(0, nullptr); + bool has_input = ((input_count > 1) || ((input_count == 1) && (input_value->StringRefAtIndex_NOCAST(0, nullptr).length() > 0))); + bool redirect_stderr = p_arguments[3]->LogicalAtIndex_NOCAST(0, nullptr); + bool wait = p_arguments[4]->LogicalAtIndex_NOCAST(0, nullptr); // Construct the command string - std::string command_string = command_value->StringRefAtIndex(0, nullptr); + std::string command_string = command_value->StringRefAtIndex_NOCAST(0, nullptr); if (command_string.length() == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_system): a non-empty command string must be supplied to system()." << EidosTerminate(nullptr); @@ -1440,7 +1440,7 @@ EidosValue_SP Eidos_ExecuteFunction_system(const std::vector &p_a for (int value_index = 0; value_index < arg_count; ++value_index) { command_string.append(" "); - command_string.append(args_value->StringRefAtIndex(value_index, nullptr)); + command_string.append(args_value->StringRefAtIndex_NOCAST(value_index, nullptr)); } } @@ -1464,7 +1464,7 @@ EidosValue_SP Eidos_ExecuteFunction_system(const std::vector &p_a if (input_count == 1) { - file_stream << input_value->StringRefAtIndex(0, nullptr); // no final newline in this case, so the user can precisely specify the file contents if desired + file_stream << input_value->StringRefAtIndex_NOCAST(0, nullptr); // no final newline in this case, so the user can precisely specify the file contents if desired } else { @@ -1577,14 +1577,14 @@ EidosValue_SP Eidos_ExecuteFunction_usage(__attribute__((unused)) const std::vec if (type_value->Type() == EidosValueType::kValueLogical) { // old-style API, through SLiM 4.0.1 (but still supported): logical value, F == current RSS, T == peak RSS - bool peak = type_value->LogicalAtIndex(0, nullptr); + bool peak = type_value->LogicalAtIndex_NOCAST(0, nullptr); usage = (peak ? Eidos_GetPeakRSS() : Eidos_GetCurrentRSS()); } else { // new-style API, after SLiM 4.0.1: string value, "rss" == current RSS, "rss_peak" = peak RSS, "vm" = current VM - std::string type = type_value->StringAtIndex(0, nullptr); + std::string type = type_value->StringAtIndex_NOCAST(0, nullptr); if (type == "rss") usage = Eidos_GetCurrentRSS(); @@ -1609,7 +1609,7 @@ EidosValue_SP Eidos_ExecuteFunction_version(__attribute__((unused)) const std::v EidosValue_SP result_SP(nullptr); - bool print = p_arguments[0]->LogicalAtIndex(0, nullptr); + bool print = p_arguments[0]->LogicalAtIndex_NOCAST(0, nullptr); if (print) { @@ -1644,7 +1644,7 @@ EidosValue_SP SLiM_ExecuteFunction__startBenchmark(const std::vectorStringAtIndex(0, nullptr); + std::string type = type_value->StringAtIndex_NOCAST(0, nullptr); if (type == "SAMPLE_INDEX") gEidosBenchmarkType = EidosBenchmarkType::k_SAMPLE_INDEX; else if (type == "TABULATE_MAXBIN") gEidosBenchmarkType = EidosBenchmarkType::k_TABULATE_MAXBIN; diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index f015ec17f..c1e064b33 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -58,8 +58,8 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - mean_x += x_value->FloatAtIndex(value_index, nullptr); - mean_y += y_value->FloatAtIndex(value_index, nullptr); + mean_x += x_value->FloatAtIndex_CAST(value_index, nullptr); + mean_y += y_value->FloatAtIndex_CAST(value_index, nullptr); } mean_x /= count; @@ -70,8 +70,8 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - double dx = x_value->FloatAtIndex(value_index, nullptr) - mean_x; - double dy = y_value->FloatAtIndex(value_index, nullptr) - mean_y; + double dx = x_value->FloatAtIndex_CAST(value_index, nullptr) - mean_x; + double dy = y_value->FloatAtIndex_CAST(value_index, nullptr) - mean_y; ss_x += dx * dx; ss_y += dy * dy; @@ -112,8 +112,8 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - mean_x += x_value->FloatAtIndex(value_index, nullptr); - mean_y += y_value->FloatAtIndex(value_index, nullptr); + mean_x += x_value->FloatAtIndex_CAST(value_index, nullptr); + mean_y += y_value->FloatAtIndex_CAST(value_index, nullptr); } mean_x /= count; @@ -124,8 +124,8 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - double temp_x = (x_value->FloatAtIndex(value_index, nullptr) - mean_x); - double temp_y = (y_value->FloatAtIndex(value_index, nullptr) - mean_y); + double temp_x = (x_value->FloatAtIndex_CAST(value_index, nullptr) - mean_x); + double temp_y = (y_value->FloatAtIndex_CAST(value_index, nullptr) - mean_y); cov += temp_x * temp_y; } @@ -197,7 +197,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else if (x_type == EidosValueType::kValueInt) { - int64_t max = p_arguments[first_nonempty_argument]->IntAtIndex(0, nullptr); + int64_t max = p_arguments[first_nonempty_argument]->IntAtIndex_NOCAST(0, nullptr); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -206,7 +206,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu if (arg_count == 1) { - int64_t temp = arg_value->IntAtIndex(0, nullptr); + int64_t temp = arg_value->IntAtIndex_NOCAST(0, nullptr); if (max < temp) max = temp; } @@ -233,7 +233,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else if (x_type == EidosValueType::kValueFloat) { - double max = p_arguments[first_nonempty_argument]->FloatAtIndex(0, nullptr); + double max = p_arguments[first_nonempty_argument]->FloatAtIndex_NOCAST(0, nullptr); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -242,7 +242,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu if (arg_count == 1) { - double temp = arg_value->FloatAtIndex(0, nullptr); + double temp = arg_value->FloatAtIndex_NOCAST(0, nullptr); // if there is a NAN the result is always NAN, so we don't need to scan further if (std::isnan(temp)) @@ -283,7 +283,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } else if (x_type == EidosValueType::kValueString) { - const std::string *max = &(((EidosValue_String *)(p_arguments[first_nonempty_argument].get()))->StringRefAtIndex(0, nullptr)); + const std::string *max = &(((EidosValue_String *)(p_arguments[first_nonempty_argument].get()))->StringRefAtIndex_NOCAST(0, nullptr)); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -292,7 +292,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu if (arg_count == 1) { - const std::string &temp = arg_value->StringRefAtIndex(0, nullptr); + const std::string &temp = arg_value->StringRefAtIndex_NOCAST(0, nullptr); if (*max < temp) max = &temp; } @@ -331,14 +331,14 @@ EidosValue_SP Eidos_ExecuteFunction_mean(const std::vector &p_arg } else if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_CAST(0, nullptr))); } else { // Call sum() to do the addition for us, since it takes exactly the same arguments; it will return numeric$ which we treat as float$ // Note this means we inherit the parallelization/vectorization behavior of sum(); we have no separate benchmarks for mean() EidosValue_SP sum_value = Eidos_ExecuteFunction_sum(p_arguments, p_interpreter); - double sum = sum_value->FloatAtIndex(0, nullptr); + double sum = sum_value->FloatAtIndex_CAST(0, nullptr); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum / x_count)); } @@ -403,7 +403,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else if (x_type == EidosValueType::kValueInt) { - int64_t min = p_arguments[first_nonempty_argument]->IntAtIndex(0, nullptr); + int64_t min = p_arguments[first_nonempty_argument]->IntAtIndex_NOCAST(0, nullptr); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -412,7 +412,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu if (arg_count == 1) { - int64_t temp = arg_value->IntAtIndex(0, nullptr); + int64_t temp = arg_value->IntAtIndex_NOCAST(0, nullptr); if (min > temp) min = temp; } @@ -439,7 +439,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else if (x_type == EidosValueType::kValueFloat) { - double min = p_arguments[first_nonempty_argument]->FloatAtIndex(0, nullptr); + double min = p_arguments[first_nonempty_argument]->FloatAtIndex_NOCAST(0, nullptr); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -448,7 +448,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu if (arg_count == 1) { - double temp = arg_value->FloatAtIndex(0, nullptr); + double temp = arg_value->FloatAtIndex_NOCAST(0, nullptr); // if there is a NAN the result is always NAN, so we don't need to scan further if (std::isnan(temp)) @@ -489,7 +489,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } else if (x_type == EidosValueType::kValueString) { - const std::string *min = &(((EidosValue_String *)(p_arguments[first_nonempty_argument].get()))->StringRefAtIndex(0, nullptr)); + const std::string *min = &(((EidosValue_String *)(p_arguments[first_nonempty_argument].get()))->StringRefAtIndex_NOCAST(0, nullptr)); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -498,7 +498,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu if (arg_count == 1) { - const std::string &temp = arg_value->StringRefAtIndex(0, nullptr); + const std::string &temp = arg_value->StringRefAtIndex_NOCAST(0, nullptr); if (*min > temp) min = &temp; } @@ -562,7 +562,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg // if there is a NAN the result is always NAN if (x_type == EidosValueType::kValueFloat) - if (std::isnan(x_value->FloatAtIndex(0, nullptr)) || std::isnan(y_value->FloatAtIndex(0, nullptr))) + if (std::isnan(x_value->FloatAtIndex_NOCAST(0, nullptr)) || std::isnan(y_value->FloatAtIndex_NOCAST(0, nullptr))) return gStaticEidosValue_FloatNAN; if (CompareEidosValues(*x_value, 0, *y_value, 0, EidosComparisonOperator::kLess, nullptr)) @@ -585,7 +585,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg if (x_type == EidosValueType::kValueLogical) { const eidos_logical_t *logical0_data = x_value->LogicalData(); - eidos_logical_t y_singleton_value = y_value->LogicalAtIndex(0, nullptr); + eidos_logical_t y_singleton_value = y_value->LogicalAtIndex_NOCAST(0, nullptr); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -595,7 +595,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg else if (x_type == EidosValueType::kValueInt) { const int64_t * __restrict__ int0_data = x_value->IntData(); - int64_t y_singleton_value = y_value->IntAtIndex(0, nullptr); + int64_t y_singleton_value = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -621,7 +621,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg else if (x_type == EidosValueType::kValueFloat) { const double * __restrict__ float0_data = x_value->FloatData(); - double y_singleton_value = y_value->FloatAtIndex(0, nullptr); + double y_singleton_value = y_value->FloatAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -641,7 +641,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg else if (x_type == EidosValueType::kValueString) { const std::string *string0_vec = x_value->StringData(); - const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -760,7 +760,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg // if there is a NAN the result is always NAN if (x_type == EidosValueType::kValueFloat) - if (std::isnan(x_value->FloatAtIndex(0, nullptr)) || std::isnan(y_value->FloatAtIndex(0, nullptr))) + if (std::isnan(x_value->FloatAtIndex_NOCAST(0, nullptr)) || std::isnan(y_value->FloatAtIndex_NOCAST(0, nullptr))) return gStaticEidosValue_FloatNAN; if (CompareEidosValues(*x_value, 0, *y_value, 0, EidosComparisonOperator::kGreater, nullptr)) @@ -783,7 +783,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg if (x_type == EidosValueType::kValueLogical) { const eidos_logical_t *logical0_data = x_value->LogicalData(); - eidos_logical_t y_singleton_value = y_value->LogicalAtIndex(0, nullptr); + eidos_logical_t y_singleton_value = y_value->LogicalAtIndex_NOCAST(0, nullptr); EidosValue_Logical *logical_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->resize_no_initialize(x_count); result_SP = EidosValue_SP(logical_result); @@ -793,7 +793,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg else if (x_type == EidosValueType::kValueInt) { const int64_t * __restrict__ int0_data = x_value->IntData(); - int64_t y_singleton_value = y_value->IntAtIndex(0, nullptr); + int64_t y_singleton_value = y_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -809,7 +809,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg else if (x_type == EidosValueType::kValueFloat) { const double * __restrict__ float0_data = x_value->FloatData(); - double y_singleton_value = y_value->FloatAtIndex(0, nullptr); + double y_singleton_value = y_value->FloatAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -829,7 +829,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg else if (x_type == EidosValueType::kValueString) { const std::string *string0_vec = x_value->StringData(); - const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex(0, nullptr); + const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); @@ -939,7 +939,7 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p { for (int probs_index = 0; probs_index < probs_count; ++probs_index) { - double prob = probs_value->FloatAtIndex(probs_index, nullptr); + double prob = probs_value->FloatAtIndex_NOCAST(probs_index, nullptr); if ((prob < 0.0) || (prob > 1.0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_quantile): function quantile() requires probabilities to be in [0, 1]." << EidosTerminate(nullptr); @@ -954,7 +954,7 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p if (x_count == 1) { // All quantiles of a singleton are the value of the singleton; the probabilities don't matter as long as they're in range (checked above) - double x_singleton = x_value->FloatAtIndex(0, nullptr); + double x_singleton = x_value->FloatAtIndex_CAST(0, nullptr); if (std::isnan(x_singleton)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_quantile): quantiles of NAN are undefined." << EidosTerminate(nullptr); @@ -993,11 +993,11 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p int64_t lo = (int64_t)std::floor(index); int64_t hi = (int64_t)std::ceil(index); - double quantile = x_value->FloatAtIndex((int)order[lo], nullptr); + double quantile = x_value->FloatAtIndex_CAST((int)order[lo], nullptr); if (lo != hi) { double h = index - lo; quantile *= (1.0 - h); - quantile += h * x_value->FloatAtIndex((int)order[hi], nullptr); + quantile += h * x_value->FloatAtIndex_CAST((int)order[hi], nullptr); } float_result->set_float_no_check(quantile, probs_index); @@ -1051,7 +1051,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(2); result_SP = EidosValue_SP(int_result); - int64_t max = p_arguments[first_nonempty_argument]->IntAtIndex(0, nullptr); + int64_t max = p_arguments[first_nonempty_argument]->IntAtIndex_NOCAST(0, nullptr); int64_t min = max; for (int arg_index = 0; arg_index < argument_count; ++arg_index) @@ -1061,7 +1061,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar if (arg_count == 1) { - int64_t temp = arg_value->IntAtIndex(0, nullptr); + int64_t temp = arg_value->IntAtIndex_NOCAST(0, nullptr); if (max < temp) max = temp; else if (min > temp) @@ -1090,7 +1090,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(2); result_SP = EidosValue_SP(float_result); - double max = p_arguments[first_nonempty_argument]->FloatAtIndex(0, nullptr); + double max = p_arguments[first_nonempty_argument]->FloatAtIndex_NOCAST(0, nullptr); double min = max; for (int arg_index = 0; arg_index < argument_count; ++arg_index) @@ -1100,7 +1100,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar if (arg_count == 1) { - double temp = arg_value->FloatAtIndex(0, nullptr); + double temp = arg_value->FloatAtIndex_NOCAST(0, nullptr); // if there is a NAN, the range is always (NAN,NAN); short-circuit if (std::isnan(temp)) @@ -1162,13 +1162,13 @@ EidosValue_SP Eidos_ExecuteFunction_sd(const std::vector &p_argum double sd = 0; for (int value_index = 0; value_index < x_count; ++value_index) - mean += x_value->FloatAtIndex(value_index, nullptr); + mean += x_value->FloatAtIndex_CAST(value_index, nullptr); mean /= x_count; for (int value_index = 0; value_index < x_count; ++value_index) { - double temp = (x_value->FloatAtIndex(value_index, nullptr) - mean); + double temp = (x_value->FloatAtIndex_CAST(value_index, nullptr) - mean); sd += temp * temp; } @@ -1223,7 +1223,7 @@ EidosValue_SP Eidos_ExecuteFunction_ttest(const std::vector &p_ar else if (mu_type != EidosValueType::kValueNULL) { // This is the x & mu case, which is a one-sample t-test - double mu = mu_value->FloatAtIndex(0, nullptr); + double mu = mu_value->FloatAtIndex_NOCAST(0, nullptr); pvalue = Eidos_TTest_OneSample(vec1, x_count, mu, nullptr); } @@ -1250,7 +1250,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu double mean = 0; for (int value_index = 0; value_index < x_count; ++value_index) - mean += x_value->FloatAtIndex(value_index, nullptr); + mean += x_value->FloatAtIndex_CAST(value_index, nullptr); mean /= x_count; @@ -1259,7 +1259,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu for (int value_index = 0; value_index < x_count; ++value_index) { - double temp = (x_value->FloatAtIndex(value_index, nullptr) - mean); + double temp = (x_value->FloatAtIndex_CAST(value_index, nullptr) - mean); var += temp * temp; } diff --git a/eidos/eidos_functions_strings.cpp b/eidos/eidos_functions_strings.cpp index 51162cbed..e689e187a 100644 --- a/eidos/eidos_functions_strings.cpp +++ b/eidos/eidos_functions_strings.cpp @@ -47,14 +47,14 @@ EidosValue_SP Eidos_ExecuteFunction_grep(const std::vector &p_arg EidosValue_Logical *invert_value = (EidosValue_Logical *)(p_arguments[6].get()); // Figure out our parameters - const std::string &pattern = pattern_value->StringRefAtIndex(0, nullptr); + const std::string &pattern = pattern_value->StringRefAtIndex_NOCAST(0, nullptr); size_t pattern_length = pattern.length(); int x_count = x_value->Count(); - bool ignoreCase = ignoreCase_value->LogicalAtIndex(0, nullptr); - const std::string &grammar = grammar_value->StringRefAtIndex(0, nullptr); - const std::string &value = value_value->StringRefAtIndex(0, nullptr); - bool fixed = fixed_value->LogicalAtIndex(0, nullptr); - bool invert = invert_value->LogicalAtIndex(0, nullptr); + bool ignoreCase = ignoreCase_value->LogicalAtIndex_NOCAST(0, nullptr); + const std::string &grammar = grammar_value->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &value = value_value->StringRefAtIndex_NOCAST(0, nullptr); + bool fixed = fixed_value->LogicalAtIndex_NOCAST(0, nullptr); + bool invert = invert_value->LogicalAtIndex_NOCAST(0, nullptr); if (pattern_length == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_grep): function grep() requires pattern to be of length >= 1." << EidosTerminate(nullptr); @@ -117,7 +117,7 @@ EidosValue_SP Eidos_ExecuteFunction_grep(const std::vector &p_arg // pattern is a fixed string, so use basic C++ string searching, honoring ignoreCase and invert for (int i = 0; i < x_count; ++i) { - const std::string &x_element = x_value->StringRefAtIndex(i, nullptr); + const std::string &x_element = x_value->StringRefAtIndex_NOCAST(i, nullptr); size_t match_pos = std::string::npos; // not valid when invert==T, which is why "match" is disallowed then bool is_match = false; @@ -181,7 +181,7 @@ EidosValue_SP Eidos_ExecuteFunction_grep(const std::vector &p_arg for (int i = 0; i < x_count; ++i) { - const std::string &x_element = x_value->StringRefAtIndex(i, nullptr); + const std::string &x_element = x_value->StringRefAtIndex_NOCAST(i, nullptr); std::smatch match_info; bool is_match = std::regex_search(x_element, match_info, pattern_regex); @@ -230,7 +230,7 @@ EidosValue_SP Eidos_ExecuteFunction_nchar(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->StringRefAtIndex(0, nullptr).size())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->StringRefAtIndex_NOCAST(0, nullptr).size())); } else { @@ -258,8 +258,8 @@ EidosValue_SP Eidos_ExecuteFunction_strcontains(const std::vector EidosValue_Int *pos_value = (EidosValue_Int *)(p_arguments[2].get()); int x_count = x_value->Count(); - const std::string &s = s_value->StringRefAtIndex(0, nullptr); - int64_t pos = pos_value->IntAtIndex(0, nullptr); + const std::string &s = s_value->StringRefAtIndex_NOCAST(0, nullptr); + int64_t pos = pos_value->IntAtIndex_NOCAST(0, nullptr); if (s.length() == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_strcontains): function strcontains() requires s to be of length >= 1." << EidosTerminate(nullptr); @@ -268,7 +268,7 @@ EidosValue_SP Eidos_ExecuteFunction_strcontains(const std::vector if (x_count == 1) { - const std::string &x = x_value->StringRefAtIndex(0, nullptr); + const std::string &x = x_value->StringRefAtIndex_NOCAST(0, nullptr); size_t index = x.find(s, pos); if (x_value ->DimensionCount() == 1) @@ -305,8 +305,8 @@ EidosValue_SP Eidos_ExecuteFunction_strfind(const std::vector &p_ EidosValue_Int *pos_value = (EidosValue_Int *)(p_arguments[2].get()); int x_count = x_value->Count(); - const std::string &s = s_value->StringRefAtIndex(0, nullptr); - int64_t pos = pos_value->IntAtIndex(0, nullptr); + const std::string &s = s_value->StringRefAtIndex_NOCAST(0, nullptr); + int64_t pos = pos_value->IntAtIndex_NOCAST(0, nullptr); if (s.length() == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_strfind): function strfind() requires s to be of length >= 1." << EidosTerminate(nullptr); @@ -315,7 +315,7 @@ EidosValue_SP Eidos_ExecuteFunction_strfind(const std::vector &p_ if (x_count == 1) { - const std::string &x = x_value->StringRefAtIndex(0, nullptr); + const std::string &x = x_value->StringRefAtIndex_NOCAST(0, nullptr); size_t index = x.find(s, pos); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(index == std::string::npos ? -1 : (int64_t)index)); } @@ -347,14 +347,14 @@ EidosValue_SP Eidos_ExecuteFunction_strprefix(const std::vector & EidosValue_String *s_value = (EidosValue_String *)(p_arguments[1].get()); int x_count = x_value->Count(); - const std::string &s = s_value->StringRefAtIndex(0, nullptr); + const std::string &s = s_value->StringRefAtIndex_NOCAST(0, nullptr); if (s.length() == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_strprefix): function strprefix() requires s to be of length >= 1." << EidosTerminate(nullptr); if (x_count == 1) { - const std::string &x = x_value->StringRefAtIndex(0, nullptr); + const std::string &x = x_value->StringRefAtIndex_NOCAST(0, nullptr); bool has_prefix = Eidos_string_hasPrefix(x, s); if (x_value ->DimensionCount() == 1) @@ -393,8 +393,8 @@ EidosValue_SP Eidos_ExecuteFunction_strsplit(const std::vector &p EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); result_SP = EidosValue_SP(string_result); - const std::string &joined_string = x_value->StringRefAtIndex(0, nullptr); - const std::string &separator = sep_value->StringAtIndex(0, nullptr); + const std::string &joined_string = x_value->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &separator = sep_value->StringAtIndex_NOCAST(0, nullptr); std::string::size_type start_idx = 0, sep_idx; if (separator.length() == 0) @@ -435,14 +435,14 @@ EidosValue_SP Eidos_ExecuteFunction_strsuffix(const std::vector & EidosValue_String *s_value = (EidosValue_String *)(p_arguments[1].get()); int x_count = x_value->Count(); - const std::string &s = s_value->StringRefAtIndex(0, nullptr); + const std::string &s = s_value->StringRefAtIndex_NOCAST(0, nullptr); if (s.length() == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_strsuffix): function strsuffix() requires s to be of length >= 1." << EidosTerminate(nullptr); if (x_count == 1) { - const std::string &x = x_value->StringRefAtIndex(0, nullptr); + const std::string &x = x_value->StringRefAtIndex_NOCAST(0, nullptr); bool has_prefix = Eidos_string_hasSuffix(x, s); if (x_value ->DimensionCount() == 1) @@ -483,7 +483,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (x_count == 1) { - const std::string &string_value = x_value->StringRefAtIndex(0, nullptr); + const std::string &string_value = x_value->StringRefAtIndex_NOCAST(0, nullptr); int64_t len = (int64_t)string_value.size(); EidosValue *arg_first = p_arguments[1].get(); int arg_first_count = arg_first->Count(); @@ -491,7 +491,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (arg_first_count != x_count) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_substr): function substr() requires the size of first to be 1, or equal to the size of x." << EidosTerminate(nullptr); - int64_t first0 = arg_first->IntAtIndex(0, nullptr); + int64_t first0 = arg_first->IntAtIndex_NOCAST(0, nullptr); if (arg_last_type != EidosValueType::kValueNULL) { @@ -501,7 +501,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (arg_last_count != x_count) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_substr): function substr() requires the size of last to be 1, or equal to the size of x." << EidosTerminate(nullptr); - int64_t last0 = arg_last->IntAtIndex(0, nullptr); + int64_t last0 = arg_last->IntAtIndex_NOCAST(0, nullptr); int64_t clamped_first = (int)first0; int64_t clamped_last = (int)last0; @@ -540,7 +540,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); result_SP = EidosValue_SP(string_result); - int64_t first0 = arg_first->IntAtIndex(0, nullptr); + int64_t first0 = arg_first->IntAtIndex_NOCAST(0, nullptr); if (arg_last_type != EidosValueType::kValueNULL) { @@ -551,14 +551,14 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (!last_singleton && (arg_last_count != x_count)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_substr): function substr() requires the size of last to be 1, or equal to the size of x." << EidosTerminate(nullptr); - int64_t last0 = arg_last->IntAtIndex(0, nullptr); + int64_t last0 = arg_last->IntAtIndex_NOCAST(0, nullptr); for (int value_index = 0; value_index < x_count; ++value_index) { const std::string &str = string_vec[value_index]; int64_t len = (int64_t)str.size(); - int64_t clamped_first = (first_singleton ? first0 : arg_first->IntAtIndex(value_index, nullptr)); - int64_t clamped_last = (last_singleton ? last0 : arg_last->IntAtIndex(value_index, nullptr)); + int64_t clamped_first = (first_singleton ? first0 : arg_first->IntAtIndex_NOCAST(value_index, nullptr)); + int64_t clamped_last = (last_singleton ? last0 : arg_last->IntAtIndex_NOCAST(value_index, nullptr)); if (clamped_first < 0) clamped_first = 0; if (clamped_last >= len) clamped_last = (int)len - 1; @@ -576,7 +576,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a { const std::string &str = string_vec[value_index]; int64_t len = (int64_t)str.size(); - int64_t clamped_first = (first_singleton ? first0 : arg_first->IntAtIndex(value_index, nullptr)); + int64_t clamped_first = (first_singleton ? first0 : arg_first->IntAtIndex_NOCAST(value_index, nullptr)); if (clamped_first < 0) clamped_first = 0; diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 8088d5344..63e532a21 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -84,7 +84,7 @@ EidosValue_SP Eidos_ExecuteFunction_float(const std::vector &p_ar EidosValue_SP result_SP(nullptr); EidosValue *length_value = p_arguments[0].get(); - int64_t element_count = length_value->IntAtIndex(0, nullptr); + int64_t element_count = length_value->IntAtIndex_NOCAST(0, nullptr); if (element_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_float): function float() requires length to be greater than or equal to 0 (" << element_count << " supplied)." << EidosTerminate(nullptr); @@ -112,8 +112,8 @@ EidosValue_SP Eidos_ExecuteFunction_integer(const std::vector &p_ EidosValue *fill1_value = p_arguments[1].get(); EidosValue *fill2_value = p_arguments[2].get(); EidosValue *fill2Indices_value = p_arguments[3].get(); - int64_t element_count = length_value->IntAtIndex(0, nullptr); - int64_t fill1 = fill1_value->IntAtIndex(0, nullptr); + int64_t element_count = length_value->IntAtIndex_NOCAST(0, nullptr); + int64_t fill1 = fill1_value->IntAtIndex_NOCAST(0, nullptr); if (element_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_integer): function integer() requires length to be greater than or equal to 0 (" << element_count << " supplied)." << EidosTerminate(nullptr); @@ -129,13 +129,13 @@ EidosValue_SP Eidos_ExecuteFunction_integer(const std::vector &p_ if (fill2Indices_value->Type() == EidosValueType::kValueInt) { - int64_t fill2 = fill2_value->IntAtIndex(0, nullptr); + int64_t fill2 = fill2_value->IntAtIndex_NOCAST(0, nullptr); int64_t *result_data = int_result->data(); int positions_count = fill2Indices_value->Count(); if (positions_count == 1) { - int64_t position = fill2Indices_value->IntAtIndex(0, nullptr); + int64_t position = fill2Indices_value->IntAtIndex_NOCAST(0, nullptr); if ((position < 0) || (position >= element_count)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_integer): function integer() requires positions in fill2Indices to be between 0 and length - 1 (" << position << " supplied)." << EidosTerminate(nullptr); @@ -169,7 +169,7 @@ EidosValue_SP Eidos_ExecuteFunction_logical(const std::vector &p_ EidosValue_SP result_SP(nullptr); EidosValue *length_value = p_arguments[0].get(); - int64_t element_count = length_value->IntAtIndex(0, nullptr); + int64_t element_count = length_value->IntAtIndex_NOCAST(0, nullptr); if (element_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_logical): function logical() requires length to be greater than or equal to 0 (" << element_count << " supplied)." << EidosTerminate(nullptr); @@ -209,7 +209,7 @@ EidosValue_SP Eidos_ExecuteFunction_rep(const std::vector &p_argu int x_count = x_value->Count(); EidosValue *count_value = p_arguments[1].get(); - int64_t rep_count = count_value->IntAtIndex(0, nullptr); + int64_t rep_count = count_value->IntAtIndex_NOCAST(0, nullptr); if (rep_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rep): function rep() requires count to be greater than or equal to 0 (" << rep_count << " supplied)." << EidosTerminate(nullptr); @@ -243,7 +243,7 @@ EidosValue_SP Eidos_ExecuteFunction_repEach(const std::vector &p_ if (count_count == 1) { - int64_t rep_count = count_value->IntAtIndex(0, nullptr); + int64_t rep_count = count_value->IntAtIndex_NOCAST(0, nullptr); if (rep_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_repEach): function repEach() requires count to be greater than or equal to 0 (" << rep_count << " supplied)." << EidosTerminate(nullptr); @@ -256,7 +256,7 @@ EidosValue_SP Eidos_ExecuteFunction_repEach(const std::vector &p_ { for (int value_idx = 0; value_idx < x_count; value_idx++) { - int64_t rep_count = count_value->IntAtIndex(value_idx, nullptr); + int64_t rep_count = count_value->IntAtIndex_NOCAST(value_idx, nullptr); if (rep_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_repEach): function repEach() requires all elements of count to be greater than or equal to 0 (" << rep_count << " supplied)." << EidosTerminate(nullptr); @@ -282,8 +282,8 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a EidosValue *x_value = p_arguments[0].get(); EidosValueType x_type = x_value->Type(); - int64_t sample_size = p_arguments[1]->IntAtIndex(0, nullptr); - bool replace = p_arguments[2]->LogicalAtIndex(0, nullptr); + int64_t sample_size = p_arguments[1]->IntAtIndex_NOCAST(0, nullptr); + bool replace = p_arguments[2]->LogicalAtIndex_NOCAST(0, nullptr); EidosValue *weights_value = p_arguments[3].get(); int x_count = x_value->Count(); @@ -316,7 +316,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a if (weights_count == 1) { - double weight = weights_value->FloatAtIndex(0, nullptr); + double weight = weights_value->FloatAtIndex_CAST(0, nullptr); if ((weight < 0.0) || std::isnan(weight)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_sample): function sample() requires all weights to be non-negative (" << EidosStringForFloat(weight) << " supplied)." << EidosTerminate(nullptr); @@ -904,9 +904,9 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu EidosValue *length_value = p_arguments[3].get(); EidosValueType length_type = length_value->Type(); - if ((from_type == EidosValueType::kValueFloat) && !std::isfinite(from_value->FloatAtIndex(0, nullptr))) + if ((from_type == EidosValueType::kValueFloat) && !std::isfinite(from_value->FloatAtIndex_NOCAST(0, nullptr))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() requires a finite value for the 'from' parameter." << EidosTerminate(nullptr); - if ((to_type == EidosValueType::kValueFloat) && !std::isfinite(to_value->FloatAtIndex(0, nullptr))) + if ((to_type == EidosValueType::kValueFloat) && !std::isfinite(to_value->FloatAtIndex_NOCAST(0, nullptr))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() requires a finite value for the 'to' parameter." << EidosTerminate(nullptr); if ((by_type != EidosValueType::kValueNULL) && (length_type != EidosValueType::kValueNULL)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() may be supplied with either 'by' or 'length', but not both." << EidosTerminate(nullptr); @@ -914,7 +914,7 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if (length_type != EidosValueType::kValueNULL) { // A length value has been supplied, so we guarantee a vector of that length even if from==to - int64_t length = length_value->IntAtIndex(0, nullptr); + int64_t length = length_value->IntAtIndex_NOCAST(0, nullptr); if (length <= 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() requires that length, if supplied, must be > 0." << EidosTerminate(nullptr); @@ -924,8 +924,8 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if ((from_type == EidosValueType::kValueFloat) || (to_type == EidosValueType::kValueFloat)) { // a float value was given, so we will generate a float sequence in all cases - double first_value = from_value->FloatAtIndex(0, nullptr); - double second_value = to_value->FloatAtIndex(0, nullptr); + double first_value = from_value->FloatAtIndex_CAST(0, nullptr); + double second_value = to_value->FloatAtIndex_CAST(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(length); result_SP = EidosValue_SP(float_result); @@ -943,8 +943,8 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu else { // int values were given, so whether we generate a float sequence or an int sequence depends on whether length divides evenly - int64_t first_value = from_value->IntAtIndex(0, nullptr); - int64_t second_value = to_value->IntAtIndex(0, nullptr); + int64_t first_value = from_value->IntAtIndex_NOCAST(0, nullptr); + int64_t second_value = to_value->IntAtIndex_NOCAST(0, nullptr); if (length == 1) { @@ -986,10 +986,10 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if ((from_type == EidosValueType::kValueFloat) || (to_type == EidosValueType::kValueFloat) || (by_type == EidosValueType::kValueFloat)) { // float return case - double first_value = from_value->FloatAtIndex(0, nullptr); - double second_value = to_value->FloatAtIndex(0, nullptr); + double first_value = from_value->FloatAtIndex_CAST(0, nullptr); + double second_value = to_value->FloatAtIndex_CAST(0, nullptr); double default_by = ((first_value < second_value) ? 1 : -1); - double by = ((by_type != EidosValueType::kValueNULL) ? by_value->FloatAtIndex(0, nullptr) : default_by); + double by = ((by_type != EidosValueType::kValueNULL) ? by_value->FloatAtIndex_CAST(0, nullptr) : default_by); if (by == 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() requires by != 0." << EidosTerminate(nullptr); @@ -1011,10 +1011,10 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu else { // int return case - int64_t first_value = from_value->IntAtIndex(0, nullptr); - int64_t second_value = to_value->IntAtIndex(0, nullptr); + int64_t first_value = from_value->IntAtIndex_NOCAST(0, nullptr); + int64_t second_value = to_value->IntAtIndex_NOCAST(0, nullptr); int64_t default_by = ((first_value < second_value) ? 1 : -1); - int64_t by = ((by_type != EidosValueType::kValueNULL) ? by_value->IntAtIndex(0, nullptr) : default_by); + int64_t by = ((by_type != EidosValueType::kValueNULL) ? by_value->IntAtIndex_NOCAST(0, nullptr) : default_by); if (by == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() requires by != 0." << EidosTerminate(nullptr); @@ -1063,7 +1063,7 @@ EidosValue_SP Eidos_ExecuteFunction_seqLen(const std::vector &p_a EidosValue_SP result_SP(nullptr); EidosValue *length_value = p_arguments[0].get(); - int64_t length = length_value->IntAtIndex(0, nullptr); + int64_t length = length_value->IntAtIndex_NOCAST(0, nullptr); if (length < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seqLen): function seqLen() requires length to be greater than or equal to 0 (" << length << " supplied)." << EidosTerminate(nullptr); @@ -1085,7 +1085,7 @@ EidosValue_SP Eidos_ExecuteFunction_string(const std::vector &p_a EidosValue_SP result_SP(nullptr); EidosValue *length_value = p_arguments[0].get(); - int64_t element_count = length_value->IntAtIndex(0, nullptr); + int64_t element_count = length_value->IntAtIndex_NOCAST(0, nullptr); if (element_count < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_string): function string() requires length to be greater than or equal to 0 (" << element_count << " supplied)." << EidosTerminate(nullptr); @@ -1185,8 +1185,8 @@ EidosValue_SP Eidos_ExecuteFunction_cat(const std::vector &p_argu EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); EidosValueType x_type = x_value->Type(); - std::string separator = p_arguments[1]->StringAtIndex(0, nullptr); - eidos_logical_t use_error_stream = p_arguments[2]->LogicalAtIndex(0, nullptr); + std::string separator = p_arguments[1]->StringAtIndex_NOCAST(0, nullptr); + eidos_logical_t use_error_stream = p_arguments[2]->LogicalAtIndex_NOCAST(0, nullptr); std::ostream &output_stream = (use_error_stream ? p_interpreter.ErrorOutputStream() : p_interpreter.ExecutionOutputStream()); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1195,9 +1195,9 @@ EidosValue_SP Eidos_ExecuteFunction_cat(const std::vector &p_argu output_stream << separator; if (x_type == EidosValueType::kValueObject) - output_stream << *x_value->ObjectElementAtIndex(value_index, nullptr); + output_stream << *x_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); else - output_stream << x_value->StringAtIndex(value_index, nullptr); + output_stream << x_value->StringAtIndex_CAST(value_index, nullptr); } return gStaticEidosValueVOID; @@ -1212,8 +1212,8 @@ EidosValue_SP Eidos_ExecuteFunction_catn(const std::vector &p_arg EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); EidosValueType x_type = x_value->Type(); - std::string separator = p_arguments[1]->StringAtIndex(0, nullptr); - eidos_logical_t use_error_stream = p_arguments[2]->LogicalAtIndex(0, nullptr); + std::string separator = p_arguments[1]->StringAtIndex_NOCAST(0, nullptr); + eidos_logical_t use_error_stream = p_arguments[2]->LogicalAtIndex_NOCAST(0, nullptr); std::ostream &output_stream = (use_error_stream ? p_interpreter.ErrorOutputStream() : p_interpreter.ExecutionOutputStream()); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1222,9 +1222,9 @@ EidosValue_SP Eidos_ExecuteFunction_catn(const std::vector &p_arg output_stream << separator; if (x_type == EidosValueType::kValueObject) - output_stream << *x_value->ObjectElementAtIndex(value_index, nullptr); + output_stream << *x_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); else - output_stream << x_value->StringAtIndex(value_index, nullptr); + output_stream << x_value->StringAtIndex_CAST(value_index, nullptr); } output_stream << std::endl; @@ -1240,7 +1240,7 @@ EidosValue_SP Eidos_ExecuteFunction_format(const std::vector &p_a EidosValue_SP result_SP(nullptr); EidosValue *format_value = p_arguments[0].get(); - std::string format = format_value->StringAtIndex(0, nullptr); + std::string format = format_value->StringAtIndex_NOCAST(0, nullptr); EidosValue *x_value = p_arguments[1].get(); EidosValueType x_type = x_value->Type(); int x_count = x_value->Count(); @@ -1438,9 +1438,9 @@ EidosValue_SP Eidos_ExecuteFunction_format(const std::vector &p_a std::string result_string; if (x_type == EidosValueType::kValueInt) - result_string = EidosStringFormat(format, x_value->IntAtIndex(0, nullptr)); + result_string = EidosStringFormat(format, x_value->IntAtIndex_NOCAST(0, nullptr)); else if (x_type == EidosValueType::kValueFloat) - result_string = EidosStringFormat(format, x_value->FloatAtIndex(0, nullptr)); + result_string = EidosStringFormat(format, x_value->FloatAtIndex_NOCAST(0, nullptr)); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(result_string)); } @@ -1453,12 +1453,12 @@ EidosValue_SP Eidos_ExecuteFunction_format(const std::vector &p_a if (x_type == EidosValueType::kValueInt) { for (int value_index = 0; value_index < x_count; ++value_index) - string_result->PushString(EidosStringFormat(format, x_value->IntAtIndex(value_index, nullptr))); + string_result->PushString(EidosStringFormat(format, x_value->IntAtIndex_NOCAST(value_index, nullptr))); } else if (x_type == EidosValueType::kValueFloat) { for (int value_index = 0; value_index < x_count; ++value_index) - string_result->PushString(EidosStringFormat(format, x_value->FloatAtIndex(value_index, nullptr))); + string_result->PushString(EidosStringFormat(format, x_value->FloatAtIndex_NOCAST(value_index, nullptr))); } } @@ -1599,8 +1599,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a // Use direct access to make this fast if (trueValues_type == EidosValueType::kValueLogical) { - eidos_logical_t true_value = trueValues_value->LogicalAtIndex(0, nullptr); - eidos_logical_t false_value = falseValues_value->LogicalAtIndex(0, nullptr); + eidos_logical_t true_value = trueValues_value->LogicalAtIndex_NOCAST(0, nullptr); + eidos_logical_t false_value = falseValues_value->LogicalAtIndex_NOCAST(0, nullptr); EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->resize_no_initialize(test_count); @@ -1611,8 +1611,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueInt) { - int64_t true_value = trueValues_value->IntAtIndex(0, nullptr); - int64_t false_value = falseValues_value->IntAtIndex(0, nullptr); + int64_t true_value = trueValues_value->IntAtIndex_NOCAST(0, nullptr); + int64_t false_value = falseValues_value->IntAtIndex_NOCAST(0, nullptr); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(test_count); @@ -1623,8 +1623,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueFloat) { - double true_value = trueValues_value->FloatAtIndex(0, nullptr); - double false_value = falseValues_value->FloatAtIndex(0, nullptr); + double true_value = trueValues_value->FloatAtIndex_NOCAST(0, nullptr); + double false_value = falseValues_value->FloatAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(test_count); @@ -1635,8 +1635,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a } else if (trueValues_type == EidosValueType::kValueString) { - const std::string &true_value = ((EidosValue_String *)trueValues_value)->StringRefAtIndex(0, nullptr); - const std::string &false_value = ((EidosValue_String *)falseValues_value)->StringRefAtIndex(0, nullptr); + const std::string &true_value = ((EidosValue_String *)trueValues_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &false_value = ((EidosValue_String *)falseValues_value)->StringRefAtIndex_NOCAST(0, nullptr); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(test_count); @@ -1653,8 +1653,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a if (trueValues_class != falseValues_class) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_ifelse): objects of different types cannot be mixed in function ifelse()." << EidosTerminate(nullptr); - EidosObject *true_value = trueValues_value->ObjectElementAtIndex(0, nullptr); - EidosObject *false_value = falseValues_value->ObjectElementAtIndex(0, nullptr); + EidosObject *true_value = trueValues_value->ObjectElementAtIndex_NOCAST(0, nullptr); + EidosObject *false_value = falseValues_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); @@ -1756,22 +1756,22 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar { // Handle singleton matching separately, to allow the use of the fast vector API below if (x_type == EidosValueType::kValueLogical) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->LogicalAtIndex(0, nullptr) == table_value->LogicalAtIndex(0, nullptr) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->LogicalAtIndex_NOCAST(0, nullptr) == table_value->LogicalAtIndex_NOCAST(0, nullptr) ? 0 : -1)); else if (x_type == EidosValueType::kValueInt) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex(0, nullptr) == table_value->IntAtIndex(0, nullptr) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr) == table_value->IntAtIndex_NOCAST(0, nullptr) ? 0 : -1)); else if (x_type == EidosValueType::kValueFloat) { - double f0 = x_value->FloatAtIndex(0, nullptr), f1 = table_value->FloatAtIndex(0, nullptr); + double f0 = x_value->FloatAtIndex_NOCAST(0, nullptr), f1 = table_value->FloatAtIndex_NOCAST(0, nullptr); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(((std::isnan(f0) && std::isnan(f1)) || (f0 == f1)) ? 0 : -1)); } else if (x_type == EidosValueType::kValueString) { - const std::string &s0 = ((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); - const std::string &s1 = ((EidosValue_String *)table_value)->StringRefAtIndex(0, nullptr); + const std::string &s0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &s1 = ((EidosValue_String *)table_value)->StringRefAtIndex_NOCAST(0, nullptr); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(s0 == s1 ? 0 : -1)); } else if (x_type == EidosValueType::kValueObject) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->ObjectElementAtIndex(0, nullptr) == table_value->ObjectElementAtIndex(0, nullptr) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->ObjectElementAtIndex_NOCAST(0, nullptr) == table_value->ObjectElementAtIndex_NOCAST(0, nullptr) ? 0 : -1)); } else if (x_count == 1) // && (table_count != 1) { @@ -1779,7 +1779,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { - eidos_logical_t value0 = x_value->LogicalAtIndex(0, nullptr); + eidos_logical_t value0 = x_value->LogicalAtIndex_NOCAST(0, nullptr); const eidos_logical_t *logical_data1 = table_value->LogicalData(); for (table_index = 0; table_index < table_count; ++table_index) @@ -1791,7 +1791,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueInt) { - int64_t value0 = x_value->IntAtIndex(0, nullptr); + int64_t value0 = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int_data1 = table_value->IntData(); for (table_index = 0; table_index < table_count; ++table_index) @@ -1803,7 +1803,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - double value0 = x_value->FloatAtIndex(0, nullptr); + double value0 = x_value->FloatAtIndex_NOCAST(0, nullptr); const double *float_data1 = table_value->FloatData(); for (table_index = 0; table_index < table_count; ++table_index) @@ -1819,7 +1819,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueString) { - const std::string &value0 = ((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); + const std::string &value0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string *string_vec1 = table_value->StringData(); for (table_index = 0; table_index < table_count; ++table_index) @@ -1831,7 +1831,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else // if (x_type == EidosValueType::kValueObject) { - EidosObject *value0 = x_value->ObjectElementAtIndex(0, nullptr); + EidosObject *value0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject * const *objelement_vec1 = table_value->ObjectData(); for (table_index = 0; table_index < table_count; ++table_index) @@ -1852,7 +1852,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if (x_type == EidosValueType::kValueLogical) { - eidos_logical_t value1 = table_value->LogicalAtIndex(0, nullptr); + eidos_logical_t value1 = table_value->LogicalAtIndex_NOCAST(0, nullptr); const eidos_logical_t *logical_data0 = x_value->LogicalData(); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1860,7 +1860,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueInt) { - int64_t value1 = table_value->IntAtIndex(0, nullptr); + int64_t value1 = table_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int_data0 = x_value->IntData(); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1868,7 +1868,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - double value1 = table_value->FloatAtIndex(0, nullptr); + double value1 = table_value->FloatAtIndex_NOCAST(0, nullptr); const double *float_data0 = x_value->FloatData(); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1880,7 +1880,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueString) { - const std::string &value1 = ((EidosValue_String *)table_value)->StringRefAtIndex(0, nullptr); + const std::string &value1 = ((EidosValue_String *)table_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string *string_vec0 = x_value->StringData(); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1888,7 +1888,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar } else if (x_type == EidosValueType::kValueObject) { - EidosObject *value1 = table_value->ObjectElementAtIndex(0, nullptr); + EidosObject *value1 = table_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject * const *objelement_vec0 = x_value->ObjectData(); for (int value_index = 0; value_index < x_count; ++value_index) @@ -2138,7 +2138,7 @@ EidosValue_SP Eidos_ExecuteFunction_order(const std::vector &p_ar { // Here we handle the vector cases, which can be done with direct access EidosValueType x_type = x_value->Type(); - bool ascending = p_arguments[1]->LogicalAtIndex(0, nullptr); + bool ascending = p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr); std::vector order; if (x_type == EidosValueType::kValueLogical) @@ -2164,7 +2164,7 @@ EidosValue_SP Eidos_ExecuteFunction_paste(const std::vector &p_ar // SYNCH WITH paste0() BELOW! size_t argument_count = p_arguments.size(); - std::string separator = p_arguments[argument_count - 1]->StringAtIndex(0, nullptr); + std::string separator = p_arguments[argument_count - 1]->StringAtIndex_NOCAST(0, nullptr); std::string result_string; // SLiM 3.5 breaks backward compatibility for paste() because the second argument, which would have been interpreted as "sep=" @@ -2173,7 +2173,7 @@ EidosValue_SP Eidos_ExecuteFunction_paste(const std::vector &p_ar if ((argument_count == 3) && (separator == " ") && ((p_arguments[1]->Type() == EidosValueType::kValueString) && (p_arguments[1]->Count() == 1))) { - std::string pseudosep = p_arguments[1]->StringAtIndex(0, nullptr); // perhaps intended as sep, and now sep=" " has been used as a default? + std::string pseudosep = p_arguments[1]->StringAtIndex_NOCAST(0, nullptr); // perhaps intended as sep, and now sep=" " has been used as a default? if ((pseudosep == "") || (pseudosep == " ") || (pseudosep == "\t") || (pseudosep == "\n") || (pseudosep == ",") || (pseudosep == ", ") || (pseudosep == " , ") || (pseudosep == ";") || (pseudosep == "; ") || (pseudosep == " ; ")) { @@ -2197,12 +2197,12 @@ EidosValue_SP Eidos_ExecuteFunction_paste(const std::vector &p_ar { std::ostringstream oss; - oss << *x_value->ObjectElementAtIndex(value_index, nullptr); + oss << *x_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); result_string.append(oss.str()); } else - result_string.append(x_value->StringAtIndex(value_index, nullptr)); + result_string.append(x_value->StringAtIndex_CAST(value_index, nullptr)); } } @@ -2230,12 +2230,12 @@ EidosValue_SP Eidos_ExecuteFunction_paste0(const std::vector &p_a { std::ostringstream oss; - oss << *x_value->ObjectElementAtIndex(value_index, nullptr); + oss << *x_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); result_string.append(oss.str()); } else - result_string.append(x_value->StringAtIndex(value_index, nullptr)); + result_string.append(x_value->StringAtIndex_CAST(value_index, nullptr)); } } @@ -2246,7 +2246,7 @@ EidosValue_SP Eidos_ExecuteFunction_paste0(const std::vector &p_a EidosValue_SP Eidos_ExecuteFunction_print(const std::vector &p_arguments, EidosInterpreter &p_interpreter) { EidosValue *x_value = p_arguments[0].get(); - eidos_logical_t use_error_stream = p_arguments[1]->LogicalAtIndex(0, nullptr); + eidos_logical_t use_error_stream = p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr); std::ostream &output_stream = (use_error_stream ? p_interpreter.ErrorOutputStream() : p_interpreter.ExecutionOutputStream()); output_stream << *x_value << std::endl; @@ -2275,7 +2275,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg kTiesMin } TiesMethod; - std::string tiesMethod_string = tiesMethod_value->StringAtIndex(0, nullptr); + std::string tiesMethod_string = tiesMethod_value->StringAtIndex_NOCAST(0, nullptr); TiesMethod tiesMethod; if (tiesMethod_string == "average") @@ -2546,7 +2546,7 @@ EidosValue_SP Eidos_ExecuteFunction_sort(const std::vector &p_arg for (int value_index = 0; value_index < x_count; ++value_index) result->PushValueFromIndexOfEidosValue(value_index, *x_value, nullptr); - result->Sort(p_arguments[1]->LogicalAtIndex(0, nullptr)); + result->Sort(p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr)); return result_SP; } @@ -2566,15 +2566,15 @@ EidosValue_SP Eidos_ExecuteFunction_sortBy(const std::vector &p_a if (object_result->UsesRetainRelease()) { for (int value_index = 0; value_index < x_count; ++value_index) - object_result->set_object_element_no_check_no_previous_RR(x_value->ObjectElementAtIndex(value_index, nullptr), value_index); + object_result->set_object_element_no_check_no_previous_RR(x_value->ObjectElementAtIndex_NOCAST(value_index, nullptr), value_index); } else { for (int value_index = 0; value_index < x_count; ++value_index) - object_result->set_object_element_no_check_NORR(x_value->ObjectElementAtIndex(value_index, nullptr), value_index); + object_result->set_object_element_no_check_NORR(x_value->ObjectElementAtIndex_NOCAST(value_index, nullptr), value_index); } - object_result->SortBy(p_arguments[1]->StringAtIndex(0, nullptr), p_arguments[2]->LogicalAtIndex(0, nullptr)); + object_result->SortBy(p_arguments[1]->StringAtIndex_NOCAST(0, nullptr), p_arguments[2]->LogicalAtIndex_NOCAST(0, nullptr)); return result_SP; } @@ -2583,7 +2583,7 @@ EidosValue_SP Eidos_ExecuteFunction_sortBy(const std::vector &p_a EidosValue_SP Eidos_ExecuteFunction_str(const std::vector &p_arguments, EidosInterpreter &p_interpreter) { EidosValue *x_value = p_arguments[0].get(); - eidos_logical_t use_error_stream = p_arguments[1]->LogicalAtIndex(0, nullptr); + eidos_logical_t use_error_stream = p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr); std::ostream &output_stream = (use_error_stream ? p_interpreter.ErrorOutputStream() : p_interpreter.ExecutionOutputStream()); x_value->PrintStructure(output_stream, 2); @@ -2604,9 +2604,7 @@ EidosValue_SP Eidos_ExecuteFunction_tabulate(const std::vector &p EidosValue *maxbin_value = p_arguments[1].get(); EidosValueType maxbin_type = maxbin_value->Type(); - // set up to work with either a singleton or a non-singleton vector - int64_t singleton_value = (value_count == 1) ? bin_value->IntAtIndex(0, nullptr) : 0; - const int64_t *int_data = (value_count == 1) ? &singleton_value : bin_value->IntData(); + const int64_t *int_data = bin_value->IntData(); // determine maxbin int64_t maxbin; @@ -2628,7 +2626,7 @@ EidosValue_SP Eidos_ExecuteFunction_tabulate(const std::vector &p } else { - maxbin = maxbin_value->IntAtIndex(0, nullptr); + maxbin = maxbin_value->IntAtIndex_NOCAST(0, nullptr); } if (maxbin < 0) @@ -2697,7 +2695,7 @@ EidosValue_SP Eidos_ExecuteFunction_unique(const std::vector &p_a { // Note that this function ignores matrix/array attributes, and always returns a vector, by design - return UniqueEidosValue(p_arguments[0].get(), false, p_arguments[1]->LogicalAtIndex(0, nullptr)); + return UniqueEidosValue(p_arguments[0].get(), false, p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr)); } // (integer)which(logical x) @@ -2741,7 +2739,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p if (x_type == EidosValueType::kValueLogical) { - eidos_logical_t max = x_value->LogicalAtIndex(0, nullptr); + eidos_logical_t max = x_value->LogicalAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2757,7 +2755,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p } else if (x_type == EidosValueType::kValueInt) { - int64_t max = x_value->IntAtIndex(0, nullptr); + int64_t max = x_value->IntAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2773,7 +2771,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p } else if (x_type == EidosValueType::kValueFloat) { - double max = x_value->FloatAtIndex(0, nullptr); + double max = x_value->FloatAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2789,7 +2787,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p } else if (x_type == EidosValueType::kValueString) { - const std::string *max = &((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); + const std::string *max = &((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2831,7 +2829,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p if (x_type == EidosValueType::kValueLogical) { - eidos_logical_t min = x_value->LogicalAtIndex(0, nullptr); + eidos_logical_t min = x_value->LogicalAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2847,7 +2845,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p } else if (x_type == EidosValueType::kValueInt) { - int64_t min = x_value->IntAtIndex(0, nullptr); + int64_t min = x_value->IntAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2863,7 +2861,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p } else if (x_type == EidosValueType::kValueFloat) { - double min = x_value->FloatAtIndex(0, nullptr); + double min = x_value->FloatAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2879,7 +2877,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p } else if (x_type == EidosValueType::kValueString) { - const std::string *min = &((EidosValue_String *)x_value)->StringRefAtIndex(0, nullptr); + const std::string *min = &((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); if (x_count > 1) { @@ -2920,7 +2918,7 @@ EidosValue_SP Eidos_ExecuteFunction_asFloat(const std::vector &p_ if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_CAST(0, nullptr))); } else { @@ -2928,7 +2926,7 @@ EidosValue_SP Eidos_ExecuteFunction_asFloat(const std::vector &p_ result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(x_value->FloatAtIndex(value_index, nullptr), value_index); + float_result->set_float_no_check(x_value->FloatAtIndex_CAST(value_index, nullptr), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -2946,7 +2944,7 @@ EidosValue_SP Eidos_ExecuteFunction_asInteger(const std::vector & if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_CAST(0, nullptr))); } else { @@ -2954,7 +2952,7 @@ EidosValue_SP Eidos_ExecuteFunction_asInteger(const std::vector & result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) - int_result->set_int_no_check(x_value->IntAtIndex(value_index, nullptr), value_index); + int_result->set_int_no_check(x_value->IntAtIndex_CAST(value_index, nullptr), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -2973,7 +2971,7 @@ EidosValue_SP Eidos_ExecuteFunction_asLogical(const std::vector & if ((x_count == 1) && (x_value->DimensionCount() == 1)) { // Use the global constants, but only if we do not have to impose a dimensionality upon the value below - result_SP = (x_value->LogicalAtIndex(0, nullptr) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); + result_SP = (x_value->LogicalAtIndex_CAST(0, nullptr) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); } else { @@ -2981,7 +2979,7 @@ EidosValue_SP Eidos_ExecuteFunction_asLogical(const std::vector & result_SP = EidosValue_SP(logical_result); for (int value_index = 0; value_index < x_count; ++value_index) - logical_result->set_logical_no_check(x_value->LogicalAtIndex(value_index, nullptr), value_index); + logical_result->set_logical_no_check(x_value->LogicalAtIndex_CAST(value_index, nullptr), value_index); result_SP->CopyDimensionsFromValue(x_value); } @@ -3003,7 +3001,7 @@ EidosValue_SP Eidos_ExecuteFunction_asString(const std::vector &p } else if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(x_value->StringAtIndex(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(x_value->StringAtIndex_CAST(0, nullptr))); } else { @@ -3011,7 +3009,7 @@ EidosValue_SP Eidos_ExecuteFunction_asString(const std::vector &p result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < x_count; ++value_index) - string_result->PushString(x_value->StringAtIndex(value_index, nullptr)); + string_result->PushString(x_value->StringAtIndex_CAST(value_index, nullptr)); } result_SP->CopyDimensionsFromValue(x_value); diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index b09a43e6f..e5d0c31ee 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -373,7 +373,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, for (int value_idx = 0; value_idx < second_child_count; value_idx++) { - eidos_logical_t logical_value = second_child_value->LogicalAtIndex(value_idx, parent_token); + eidos_logical_t logical_value = second_child_value->LogicalAtIndex_NOCAST(value_idx, parent_token); if (logical_value) p_indices_ptr->emplace_back(base_indices[value_idx]); @@ -386,7 +386,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, { if (second_child_count == 1) { - int64_t index_value = second_child_value->IntAtIndex(0, parent_token); + int64_t index_value = second_child_value->IntAtIndex_NOCAST(0, parent_token); if ((index_value < 0) || (index_value >= base_indices_count)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); @@ -415,7 +415,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, // for EidosValue_Float that we want to get here; subsetting with float vectors is slow, don't do it. for (int value_idx = 0; value_idx < second_child_count; value_idx++) { - int64_t index_value = second_child_value->IntAtIndex(value_idx, parent_token); + int64_t index_value = second_child_value->IntAtIndex_CAST(value_idx, parent_token); if ((index_value < 0) || (index_value >= base_indices_count)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); @@ -490,7 +490,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, // We have a float or integer subset, which selects indices within inclusion_indices for (int index_index = 0; index_index < subset_count; index_index++) { - int64_t index_value = subset_value->IntAtIndex(index_index, parent_token); + int64_t index_value = subset_value->IntAtIndex_CAST(index_index, parent_token); if ((index_value < 0) || (index_value >= dim_size)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); @@ -912,8 +912,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { - int64_t first_int = p_first_child_value.IntAtIndex(0, operator_token); - int64_t second_int = p_second_child_value.IntAtIndex(0, operator_token); + int64_t first_int = p_first_child_value.IntAtIndex_NOCAST(0, operator_token); + int64_t second_int = p_second_child_value.IntAtIndex_NOCAST(0, operator_token); if (first_int <= second_int) { @@ -944,8 +944,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode } else { - double first_float = p_first_child_value.FloatAtIndex(0, operator_token); - double second_float = p_second_child_value.FloatAtIndex(0, operator_token); + double first_float = p_first_child_value.FloatAtIndex_CAST(0, operator_token); + double second_float = p_second_child_value.FloatAtIndex_CAST(0, operator_token); if (std::isnan(first_float) || std::isnan(second_float)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_Evaluate_RangeExpr_Internal): operands of the ':' operator must not be NAN." << EidosTerminate(operator_token); @@ -1670,7 +1670,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Subset(const EidosASTNode *p_node) // This can be commented out harmlessly; this case is also handled below, just slower if ((child_count == 2) && (child_type == EidosValueType::kValueInt) && (child_value->Count() == 1) && (child_value->DimensionCount() == 1)) { - int subset_index = (int)child_value->IntAtIndex(0, operator_token); + int subset_index = (int)child_value->IntAtIndex_NOCAST(0, operator_token); result_SP = first_child_value->GetValueAtIndex(subset_index, operator_token); @@ -1761,7 +1761,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Subset(const EidosASTNode *p_node) // We have a float or integer subset, which selects indices within inclusion_indices for (int index_index = 0; index_index < subset_count; index_index++) { - int64_t index_value = subset_value->IntAtIndex(index_index, operator_token); + int64_t index_value = subset_value->IntAtIndex_CAST(index_index, operator_token); if ((index_value < 0) || (index_value >= dim_size)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(operator_token); @@ -1952,8 +1952,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if ((first_child_count == 1) && (second_child_count == 1)) { - const std::string &&first_string = (first_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : first_child_value->StringAtIndex(0, operator_token); - const std::string &&second_string = (second_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : second_child_value->StringAtIndex(0, operator_token); + const std::string &&first_string = (first_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : first_child_value->StringAtIndex_CAST(0, operator_token); + const std::string &&second_string = (second_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : second_child_value->StringAtIndex_CAST(0, operator_token); result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(first_string + second_string)); } @@ -1965,29 +1965,29 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) EidosValue_String_vector *string_result = string_result_SP->Reserve(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) - string_result->PushString(first_child_value->StringAtIndex(value_index, operator_token) + second_child_value->StringAtIndex(value_index, operator_token)); + string_result->PushString(first_child_value->StringAtIndex_CAST(value_index, operator_token) + second_child_value->StringAtIndex_CAST(value_index, operator_token)); result_SP = string_result_SP; } else if (first_child_count == 1) { - std::string singleton_string = (first_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : first_child_value->StringAtIndex(0, operator_token); + std::string singleton_string = (first_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : first_child_value->StringAtIndex_CAST(0, operator_token); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(second_child_count); for (int value_index = 0; value_index < second_child_count; ++value_index) - string_result->PushString(singleton_string + second_child_value->StringAtIndex(value_index, operator_token)); + string_result->PushString(singleton_string + second_child_value->StringAtIndex_CAST(value_index, operator_token)); result_SP = string_result_SP; } else if (second_child_count == 1) { - std::string singleton_string = (second_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : second_child_value->StringAtIndex(0, operator_token); + std::string singleton_string = (second_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : second_child_value->StringAtIndex_CAST(0, operator_token); EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) - string_result->PushString(first_child_value->StringAtIndex(value_index, operator_token) + singleton_string); + string_result->PushString(first_child_value->StringAtIndex_CAST(value_index, operator_token) + singleton_string); result_SP = string_result_SP; } @@ -2007,8 +2007,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) // This is an overflow-safe version of: //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex(0, operator_token) + second_child_value->IntAtIndex(0, operator_token)); - int64_t first_operand = first_child_value->IntAtIndex(0, operator_token); - int64_t second_operand = second_child_value->IntAtIndex(0, operator_token); + int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); + int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t add_result; bool overflow = Eidos_add_overflow(first_operand, second_operand, &add_result); @@ -2045,7 +2045,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (first_child_count == 1) { - int64_t singleton_int = first_child_value->IntAtIndex(0, operator_token); + int64_t singleton_int = first_child_value->IntAtIndex_NOCAST(0, operator_token); const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); @@ -2070,7 +2070,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (second_child_count == 1) { const int64_t *first_child_data = first_child_value->IntData(); - int64_t singleton_int = second_child_value->IntAtIndex(0, operator_token); + int64_t singleton_int = second_child_value->IntAtIndex_NOCAST(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2106,7 +2106,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex(0, operator_token) + second_child_value->FloatAtIndex(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) + second_child_value->FloatAtIndex_CAST(0, operator_token))); } else { @@ -2143,7 +2143,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex(0, operator_token); + double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2166,7 +2166,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex(0, operator_token); + double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2227,7 +2227,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) // This is an overflow-safe version of: //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-first_child_value->IntAtIndex(0, operator_token)); - int64_t operand = first_child_value->IntAtIndex(0, operator_token); + int64_t operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t subtract_result; bool overflow = Eidos_sub_overflow((int64_t)0, operand, &subtract_result); @@ -2264,7 +2264,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(-first_child_value->FloatAtIndex(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(-first_child_value->FloatAtIndex_NOCAST(0, operator_token))); } else { @@ -2310,8 +2310,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) // This is an overflow-safe version of: //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex(0, operator_token) - second_child_value->IntAtIndex(0, operator_token)); - int64_t first_operand = first_child_value->IntAtIndex(0, operator_token); - int64_t second_operand = second_child_value->IntAtIndex(0, operator_token); + int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); + int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t subtract_result; bool overflow = Eidos_sub_overflow(first_operand, second_operand, &subtract_result); @@ -2348,7 +2348,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (first_child_count == 1) { - int64_t singleton_int = first_child_value->IntAtIndex(0, operator_token); + int64_t singleton_int = first_child_value->IntAtIndex_NOCAST(0, operator_token); const int64_t *second_child_data = second_child_value->IntData(); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); @@ -2373,7 +2373,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) else if (second_child_count == 1) { const int64_t *first_child_data = first_child_value->IntData(); - int64_t singleton_int = second_child_value->IntAtIndex(0, operator_token); + int64_t singleton_int = second_child_value->IntAtIndex_NOCAST(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); @@ -2406,7 +2406,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex(0, operator_token) - second_child_value->FloatAtIndex(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) - second_child_value->FloatAtIndex_CAST(0, operator_token))); } else { @@ -2443,7 +2443,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex(0, operator_token); + double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2466,7 +2466,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex(0, operator_token); + double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2540,7 +2540,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fmod(first_child_value->FloatAtIndex(0, operator_token), second_child_value->FloatAtIndex(0, operator_token)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fmod(first_child_value->FloatAtIndex_CAST(0, operator_token), second_child_value->FloatAtIndex_CAST(0, operator_token)))); } else { @@ -2585,7 +2585,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex(0, operator_token); + double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2608,7 +2608,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex(0, operator_token); + double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2682,8 +2682,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) // This is an overflow-safe version of: //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex(0, operator_token) * second_child_value->IntAtIndex(0, operator_token)); - int64_t first_operand = first_child_value->IntAtIndex(0, operator_token); - int64_t second_operand = second_child_value->IntAtIndex(0, operator_token); + int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); + int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t multiply_result; bool overflow = Eidos_mul_overflow(first_operand, second_operand, &multiply_result); @@ -2722,7 +2722,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex(0, operator_token) * second_child_value->FloatAtIndex(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) * second_child_value->FloatAtIndex_CAST(0, operator_token))); } else { @@ -2784,7 +2784,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) if ((first_child_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { const int64_t *any_count_data = any_count_child->IntData(); - int64_t singleton_int = one_count_child->IntAtIndex(0, operator_token); + int64_t singleton_int = one_count_child->IntAtIndex_NOCAST(0, operator_token); EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(any_count); @@ -2808,7 +2808,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) else if (any_type == EidosValueType::kValueInt) { const int64_t *any_count_data = any_count_child->IntData(); - double singleton_float = one_count_child->FloatAtIndex(0, operator_token); + double singleton_float = one_count_child->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2820,7 +2820,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) else // (any_type == EidosValueType::kValueFloat) { const double *any_count_data = any_count_child->FloatData(); - double singleton_float = one_count_child->FloatAtIndex(0, operator_token); + double singleton_float = one_count_child->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2885,7 +2885,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex(0, operator_token) / second_child_value->FloatAtIndex(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) / second_child_value->FloatAtIndex_CAST(0, operator_token))); } else { @@ -2930,7 +2930,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex(0, operator_token); + double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2953,7 +2953,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex(0, operator_token); + double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -3010,7 +3010,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Conditional(const EidosASTNode *p_node) } else if (condition_result->Count() == 1) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); if (condition_logical) result_SP = FastEvaluateNode(p_node->children_[1]); @@ -3062,7 +3062,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(pow(first_child_value->FloatAtIndex(0, operator_token), second_child_value->FloatAtIndex(0, operator_token)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(pow(first_child_value->FloatAtIndex_CAST(0, operator_token), second_child_value->FloatAtIndex_CAST(0, operator_token)))); } else { @@ -3107,7 +3107,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex(0, operator_token); + double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -3130,7 +3130,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex(0, operator_token); + double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -3271,7 +3271,7 @@ EidosValue_SP EidosInterpreter::Evaluate_And(const EidosASTNode *p_node) if (child_count == 1) { // if we have a singleton, avoid allocating a result yet, by using logical_result instead - logical_result = child_result->LogicalAtIndex(0, operator_token); + logical_result = child_result->LogicalAtIndex_CAST(0, operator_token); result_count = 1; } else if ((child_type == EidosValueType::kValueLogical) && (child_result->UseCount() == 1)) @@ -3289,7 +3289,7 @@ EidosValue_SP EidosInterpreter::Evaluate_And(const EidosASTNode *p_node) EidosValue_Logical *result = result_SP.get(); for (int value_index = 0; value_index < child_count; ++value_index) - result->set_logical_no_check(child_result->LogicalAtIndex(value_index, operator_token), value_index); + result->set_logical_no_check(child_result->LogicalAtIndex_CAST(value_index, operator_token), value_index); } } else @@ -3301,7 +3301,7 @@ EidosValue_SP EidosInterpreter::Evaluate_And(const EidosASTNode *p_node) if (child_count == 1) { // if child_logical is T, it has no effect on result; if it is F, it turns result to all F - eidos_logical_t child_logical = child_result->LogicalAtIndex(0, operator_token); + eidos_logical_t child_logical = child_result->LogicalAtIndex_CAST(0, operator_token); if (!child_logical) { @@ -3328,7 +3328,7 @@ EidosValue_SP EidosInterpreter::Evaluate_And(const EidosASTNode *p_node) if (result_SP) { // we have a result allocated; work with that - result_logical = result_SP->LogicalAtIndex(0, operator_token); + result_logical = result_SP->LogicalAtIndex_CAST(0, operator_token); } else { @@ -3343,7 +3343,7 @@ EidosValue_SP EidosInterpreter::Evaluate_And(const EidosASTNode *p_node) if (result_logical) for (int value_index = 0; value_index < child_count; ++value_index) - result->set_logical_no_check(child_result->LogicalAtIndex(value_index, operator_token), value_index); + result->set_logical_no_check(child_result->LogicalAtIndex_CAST(value_index, operator_token), value_index); else for (int value_index = 0; value_index < child_count; ++value_index) result->set_logical_no_check(false, value_index); @@ -3354,7 +3354,7 @@ EidosValue_SP EidosInterpreter::Evaluate_And(const EidosASTNode *p_node) EidosValue_Logical *result = result_SP.get(); for (int value_index = 0; value_index < result_count; ++value_index) - if (!child_result->LogicalAtIndex(value_index, operator_token)) + if (!child_result->LogicalAtIndex_CAST(value_index, operator_token)) result->set_logical_no_check(false, value_index); } } @@ -3492,7 +3492,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Or(const EidosASTNode *p_node) if (child_count == 1) { // if we have a singleton, avoid allocating a result yet, by using logical_result instead - logical_result = child_result->LogicalAtIndex(0, operator_token); + logical_result = child_result->LogicalAtIndex_CAST(0, operator_token); result_count = 1; } else if ((child_type == EidosValueType::kValueLogical) && (child_result->UseCount() == 1)) @@ -3510,7 +3510,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Or(const EidosASTNode *p_node) EidosValue_Logical *result = result_SP.get(); for (int value_index = 0; value_index < child_count; ++value_index) - result->set_logical_no_check(child_result->LogicalAtIndex(value_index, operator_token), value_index); + result->set_logical_no_check(child_result->LogicalAtIndex_CAST(value_index, operator_token), value_index); } } else @@ -3522,7 +3522,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Or(const EidosASTNode *p_node) if (child_count == 1) { // if child_logical is F, it has no effect on result; if it is T, it turns result to all T - eidos_logical_t child_logical = child_result->LogicalAtIndex(0, operator_token); + eidos_logical_t child_logical = child_result->LogicalAtIndex_CAST(0, operator_token); if (child_logical) { @@ -3549,7 +3549,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Or(const EidosASTNode *p_node) if (result_SP) { // we have a result allocated; work with that - result_logical = result_SP->LogicalAtIndex(0, operator_token); + result_logical = result_SP->LogicalAtIndex_CAST(0, operator_token); } else { @@ -3567,7 +3567,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Or(const EidosASTNode *p_node) result->set_logical_no_check(true, value_index); else for (int value_index = 0; value_index < child_count; ++value_index) - result->set_logical_no_check(child_result->LogicalAtIndex(value_index, operator_token), value_index); + result->set_logical_no_check(child_result->LogicalAtIndex_CAST(value_index, operator_token), value_index); } else { @@ -3575,7 +3575,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Or(const EidosASTNode *p_node) EidosValue_Logical *result = result_SP.get(); for (int value_index = 0; value_index < result_count; ++value_index) - if (child_result->LogicalAtIndex(value_index, operator_token)) + if (child_result->LogicalAtIndex_CAST(value_index, operator_token)) result->set_logical_no_check(true, value_index); } } @@ -3637,7 +3637,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Not(const EidosASTNode *p_node) if ((first_child_count == 1) && (first_child_dimcount == 1)) { // If we're generating a singleton non-array result, use cached static logical values - result_SP = (first_child_value->LogicalAtIndex(0, operator_token) ? gStaticEidosValue_LogicalF : gStaticEidosValue_LogicalT); + result_SP = (first_child_value->LogicalAtIndex_CAST(0, operator_token) ? gStaticEidosValue_LogicalF : gStaticEidosValue_LogicalT); } else { @@ -3671,7 +3671,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Not(const EidosASTNode *p_node) { // General case; hit by type float, since we don't want to duplicate the NAN check here for (int value_index = 0; value_index < first_child_count; ++value_index) - result->set_logical_no_check(!first_child_value->LogicalAtIndex(value_index, operator_token), value_index); + result->set_logical_no_check(!first_child_value->LogicalAtIndex_CAST(value_index, operator_token), value_index); } result_SP->CopyDimensionsFromValue(first_child_value.get()); @@ -3725,7 +3725,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) if (cached_operand2->Type() == EidosValueType::kValueInt) { EidosTokenType compound_operator = rvalue_node->token_->token_type_; - int64_t operand2_value = cached_operand2->IntAtIndex(0, nullptr); + int64_t operand2_value = cached_operand2->IntAtIndex_NOCAST(0, nullptr); if ((lvalue_count == 1) && lvalue->IsSingleton()) { @@ -3818,7 +3818,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) EidosASTNode *rvalue_node = p_node->children_[1]; // the operator node EidosValue *cached_operand2 = rvalue_node->children_[1]->cached_literal_value_.get(); // the numeric constant EidosTokenType compound_operator = rvalue_node->token_->token_type_; - double operand2_value = cached_operand2->FloatAtIndex(0, nullptr); // might be an int64_t and get converted + double operand2_value = cached_operand2->FloatAtIndex_CAST(0, nullptr); // might be an int64_t and get converted if ((lvalue_count == 1) && lvalue->IsSingleton()) { @@ -4033,11 +4033,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex(0, operator_token) == second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex(0, operator_token) == second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex(0, operator_token) == second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex(0, operator_token) == second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex(0, operator_token) == second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex_CAST(0, operator_token) == second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex_CAST(0, operator_token) == second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex_CAST(0, operator_token) == second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex_CAST(0, operator_token) == second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) == second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: equal = false; break; // never hit } @@ -4087,11 +4087,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex(value_index, operator_token) == second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex(value_index, operator_token) == second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex(value_index, operator_token) == second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex(value_index, operator_token) == second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex(value_index, operator_token) == second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) == second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex_CAST(value_index, operator_token) == second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) == second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex_CAST(value_index, operator_token) == second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) == second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: equal = false; break; // never hit } @@ -4110,7 +4110,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) if ((promotion_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float - double float1 = first_child_value->FloatAtIndex(0, operator_token); + double float1 = first_child_value->FloatAtIndex_CAST(0, operator_token); const double *float_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) @@ -4119,7 +4119,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int - int64_t int1 = first_child_value->IntAtIndex(0, operator_token); + int64_t int1 = first_child_value->IntAtIndex_CAST(0, operator_token); const int64_t *int_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) @@ -4128,7 +4128,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueObject) && (second_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject *obj1 = first_child_value->ObjectElementAtIndex(0, operator_token); + EidosObject *obj1 = first_child_value->ObjectElementAtIndex_CAST(0, operator_token); EidosObject * const *obj_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < second_child_count; ++value_index) @@ -4143,11 +4143,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex(0, operator_token) == second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex(0, operator_token) == second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex(0, operator_token) == second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex(0, operator_token) == second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex(0, operator_token) == second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex_CAST(0, operator_token) == second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex_CAST(0, operator_token) == second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex_CAST(0, operator_token) == second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex_CAST(0, operator_token) == second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) == second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: equal = false; break; // never hit } @@ -4165,7 +4165,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) if ((promotion_type == EidosValueType::kValueFloat) && (first_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float - double float2 = second_child_value->FloatAtIndex(0, operator_token); + double float2 = second_child_value->FloatAtIndex_CAST(0, operator_token); const double *float_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) @@ -4174,7 +4174,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueInt) && (first_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int - int64_t int2 = second_child_value->IntAtIndex(0, operator_token); + int64_t int2 = second_child_value->IntAtIndex_CAST(0, operator_token); const int64_t *int_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) @@ -4183,7 +4183,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueObject) && (first_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject *obj2 = second_child_value->ObjectElementAtIndex(0, operator_token); + EidosObject *obj2 = second_child_value->ObjectElementAtIndex_CAST(0, operator_token); EidosObject * const *obj_vec = first_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) @@ -4198,11 +4198,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Eq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex(value_index, operator_token) == second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex(value_index, operator_token) == second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex(value_index, operator_token) == second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex(value_index, operator_token) == second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex(value_index, operator_token) == second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: equal = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) == second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: equal = (first_child_value->IntAtIndex_CAST(value_index, operator_token) == second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: equal = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) == second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: equal = (first_child_value->StringAtIndex_CAST(value_index, operator_token) == second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: equal = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) == second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: equal = false; break; // never hit } @@ -4272,11 +4272,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Lt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex(0, operator_token) < second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex(0, operator_token) < second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex(0, operator_token) < second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex(0, operator_token) < second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex(0, operator_token) < second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex_CAST(0, operator_token) < second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex_CAST(0, operator_token) < second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex_CAST(0, operator_token) < second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex_CAST(0, operator_token) < second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) < second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: lt = false; break; // never hit } @@ -4296,11 +4296,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Lt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex(value_index, operator_token) < second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex(value_index, operator_token) < second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex(value_index, operator_token) < second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex(value_index, operator_token) < second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex(value_index, operator_token) < second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) < second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex_CAST(value_index, operator_token) < second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) < second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex_CAST(value_index, operator_token) < second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) < second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: lt = false; break; // never hit } @@ -4321,11 +4321,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Lt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex(0, operator_token) < second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex(0, operator_token) < second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex(0, operator_token) < second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex(0, operator_token) < second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex(0, operator_token) < second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex_CAST(0, operator_token) < second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex_CAST(0, operator_token) < second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex_CAST(0, operator_token) < second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex_CAST(0, operator_token) < second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) < second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: lt = false; break; // never hit } @@ -4345,11 +4345,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Lt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex(value_index, operator_token) < second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex(value_index, operator_token) < second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex(value_index, operator_token) < second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex(value_index, operator_token) < second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex(value_index, operator_token) < second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: lt = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) < second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: lt = (first_child_value->IntAtIndex_CAST(value_index, operator_token) < second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: lt = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) < second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: lt = (first_child_value->StringAtIndex_CAST(value_index, operator_token) < second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: lt = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) < second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: lt = false; break; // never hit } @@ -4419,11 +4419,11 @@ EidosValue_SP EidosInterpreter::Evaluate_LtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex(0, operator_token) <= second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex(0, operator_token) <= second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex(0, operator_token) <= second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex(0, operator_token) <= second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex(0, operator_token) <= second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex_CAST(0, operator_token) <= second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex_CAST(0, operator_token) <= second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex_CAST(0, operator_token) <= second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex_CAST(0, operator_token) <= second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) <= second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: lteq = false; break; // never hit } @@ -4443,11 +4443,11 @@ EidosValue_SP EidosInterpreter::Evaluate_LtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex(value_index, operator_token) <= second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex(value_index, operator_token) <= second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex(value_index, operator_token) <= second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex(value_index, operator_token) <= second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex(value_index, operator_token) <= second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) <= second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex_CAST(value_index, operator_token) <= second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) <= second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex_CAST(value_index, operator_token) <= second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) <= second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: lteq = false; break; // never hit } @@ -4468,11 +4468,11 @@ EidosValue_SP EidosInterpreter::Evaluate_LtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex(0, operator_token) <= second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex(0, operator_token) <= second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex(0, operator_token) <= second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex(0, operator_token) <= second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex(0, operator_token) <= second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex_CAST(0, operator_token) <= second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex_CAST(0, operator_token) <= second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex_CAST(0, operator_token) <= second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex_CAST(0, operator_token) <= second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) <= second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: lteq = false; break; // never hit } @@ -4492,11 +4492,11 @@ EidosValue_SP EidosInterpreter::Evaluate_LtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex(value_index, operator_token) <= second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex(value_index, operator_token) <= second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex(value_index, operator_token) <= second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex(value_index, operator_token) <= second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex(value_index, operator_token) <= second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: lteq = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) <= second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: lteq = (first_child_value->IntAtIndex_CAST(value_index, operator_token) <= second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: lteq = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) <= second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: lteq = (first_child_value->StringAtIndex_CAST(value_index, operator_token) <= second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: lteq = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) <= second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: lteq = false; break; // never hit } @@ -4566,11 +4566,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Gt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex(0, operator_token) > second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex(0, operator_token) > second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex(0, operator_token) > second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex(0, operator_token) > second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex(0, operator_token) > second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex_CAST(0, operator_token) > second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex_CAST(0, operator_token) > second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex_CAST(0, operator_token) > second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex_CAST(0, operator_token) > second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) > second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: gt = false; break; // never hit } @@ -4590,11 +4590,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Gt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex(value_index, operator_token) > second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex(value_index, operator_token) > second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex(value_index, operator_token) > second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex(value_index, operator_token) > second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex(value_index, operator_token) > second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) > second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex_CAST(value_index, operator_token) > second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) > second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex_CAST(value_index, operator_token) > second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) > second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: gt = false; break; // never hit } @@ -4615,11 +4615,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Gt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex(0, operator_token) > second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex(0, operator_token) > second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex(0, operator_token) > second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex(0, operator_token) > second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex(0, operator_token) > second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex_CAST(0, operator_token) > second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex_CAST(0, operator_token) > second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex_CAST(0, operator_token) > second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex_CAST(0, operator_token) > second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) > second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: gt = false; break; // never hit } @@ -4639,11 +4639,11 @@ EidosValue_SP EidosInterpreter::Evaluate_Gt(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex(value_index, operator_token) > second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex(value_index, operator_token) > second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex(value_index, operator_token) > second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex(value_index, operator_token) > second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex(value_index, operator_token) > second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: gt = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) > second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: gt = (first_child_value->IntAtIndex_CAST(value_index, operator_token) > second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: gt = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) > second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: gt = (first_child_value->StringAtIndex_CAST(value_index, operator_token) > second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: gt = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) > second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: gt = false; break; // never hit } @@ -4713,11 +4713,11 @@ EidosValue_SP EidosInterpreter::Evaluate_GtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex(0, operator_token) >= second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex(0, operator_token) >= second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex(0, operator_token) >= second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex(0, operator_token) >= second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex(0, operator_token) >= second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex_CAST(0, operator_token) >= second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex_CAST(0, operator_token) >= second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex_CAST(0, operator_token) >= second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex_CAST(0, operator_token) >= second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) >= second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: gteq = false; break; // never hit } @@ -4737,11 +4737,11 @@ EidosValue_SP EidosInterpreter::Evaluate_GtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex(value_index, operator_token) >= second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex(value_index, operator_token) >= second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex(value_index, operator_token) >= second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex(value_index, operator_token) >= second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex(value_index, operator_token) >= second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) >= second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex_CAST(value_index, operator_token) >= second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) >= second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex_CAST(value_index, operator_token) >= second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) >= second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: gteq = false; break; // never hit } @@ -4762,11 +4762,11 @@ EidosValue_SP EidosInterpreter::Evaluate_GtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex(0, operator_token) >= second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex(0, operator_token) >= second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex(0, operator_token) >= second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex(0, operator_token) >= second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex(0, operator_token) >= second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex_CAST(0, operator_token) >= second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex_CAST(0, operator_token) >= second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex_CAST(0, operator_token) >= second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex_CAST(0, operator_token) >= second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) >= second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: gteq = false; break; // never hit } @@ -4786,11 +4786,11 @@ EidosValue_SP EidosInterpreter::Evaluate_GtEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex(value_index, operator_token) >= second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex(value_index, operator_token) >= second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex(value_index, operator_token) >= second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex(value_index, operator_token) >= second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex(value_index, operator_token) >= second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: gteq = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) >= second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: gteq = (first_child_value->IntAtIndex_CAST(value_index, operator_token) >= second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: gteq = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) >= second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: gteq = (first_child_value->StringAtIndex_CAST(value_index, operator_token) >= second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: gteq = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) >= second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: gteq = false; break; // never hit } @@ -4858,11 +4858,11 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex(0, operator_token) != second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex(0, operator_token) != second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex(0, operator_token) != second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex(0, operator_token) != second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex(0, operator_token) != second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex_CAST(0, operator_token) != second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex_CAST(0, operator_token) != second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex_CAST(0, operator_token) != second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex_CAST(0, operator_token) != second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) != second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: notequal = false; break; // never hit } @@ -4913,11 +4913,11 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex(value_index, operator_token) != second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex(value_index, operator_token) != second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex(value_index, operator_token) != second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex(value_index, operator_token) != second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex(value_index, operator_token) != second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) != second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex_CAST(value_index, operator_token) != second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) != second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex_CAST(value_index, operator_token) != second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) != second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: notequal = false; break; // never hit } @@ -4936,7 +4936,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) if ((promotion_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float - double float1 = first_child_value->FloatAtIndex(0, operator_token); + double float1 = first_child_value->FloatAtIndex_CAST(0, operator_token); const double *float_data = second_child_value->FloatData(); for (int value_index = 0; value_index < second_child_count; ++value_index) @@ -4945,7 +4945,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueInt) && (second_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int - int64_t int1 = first_child_value->IntAtIndex(0, operator_token); + int64_t int1 = first_child_value->IntAtIndex_CAST(0, operator_token); const int64_t *int_data = second_child_value->IntData(); for (int value_index = 0; value_index < second_child_count; ++value_index) @@ -4954,7 +4954,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueObject) && (second_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject *obj1 = first_child_value->ObjectElementAtIndex(0, operator_token); + EidosObject *obj1 = first_child_value->ObjectElementAtIndex_CAST(0, operator_token); EidosObject * const *obj_vec = second_child_value->ObjectData(); for (int value_index = 0; value_index < second_child_count; ++value_index) @@ -4969,11 +4969,11 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex(0, operator_token) != second_child_value->LogicalAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex(0, operator_token) != second_child_value->IntAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex(0, operator_token) != second_child_value->FloatAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex(0, operator_token) != second_child_value->StringAtIndex(value_index, operator_token)); break; - case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex(0, operator_token) != second_child_value->ObjectElementAtIndex(value_index, operator_token)); break; + case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex_CAST(0, operator_token) != second_child_value->LogicalAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex_CAST(0, operator_token) != second_child_value->IntAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex_CAST(0, operator_token) != second_child_value->FloatAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex_CAST(0, operator_token) != second_child_value->StringAtIndex_CAST(value_index, operator_token)); break; + case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex_CAST(0, operator_token) != second_child_value->ObjectElementAtIndex_CAST(value_index, operator_token)); break; default: notequal = false; break; // never hit } @@ -4991,7 +4991,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) if ((promotion_type == EidosValueType::kValueFloat) && (first_child_type == EidosValueType::kValueFloat)) { // Direct float-to-float compare can be optimized through vector access; note the singleton might get promoted to float - double float2 = second_child_value->FloatAtIndex(0, operator_token); + double float2 = second_child_value->FloatAtIndex_CAST(0, operator_token); const double *float_data = first_child_value->FloatData(); for (int value_index = 0; value_index < first_child_count; ++value_index) @@ -5000,7 +5000,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueInt) && (first_child_type == EidosValueType::kValueInt)) { // Direct int-to-int compare can be optimized through vector access; note the singleton might get promoted to int - int64_t int2 = second_child_value->IntAtIndex(0, operator_token); + int64_t int2 = second_child_value->IntAtIndex_CAST(0, operator_token); const int64_t *int_data = first_child_value->IntData(); for (int value_index = 0; value_index < first_child_count; ++value_index) @@ -5009,7 +5009,7 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) else if ((promotion_type == EidosValueType::kValueObject) && (first_child_type == EidosValueType::kValueObject)) { // Direct object-to-object compare can be optimized through vector access - EidosObject *obj2 = second_child_value->ObjectElementAtIndex(0, operator_token); + EidosObject *obj2 = second_child_value->ObjectElementAtIndex_CAST(0, operator_token); EidosObject * const *obj_vec = first_child_value->ObjectData(); for (int value_index = 0; value_index < first_child_count; ++value_index) @@ -5024,11 +5024,11 @@ EidosValue_SP EidosInterpreter::Evaluate_NotEq(const EidosASTNode *p_node) switch (promotion_type) { - case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex(value_index, operator_token) != second_child_value->LogicalAtIndex(0, operator_token)); break; - case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex(value_index, operator_token) != second_child_value->IntAtIndex(0, operator_token)); break; - case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex(value_index, operator_token) != second_child_value->FloatAtIndex(0, operator_token)); break; - case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex(value_index, operator_token) != second_child_value->StringAtIndex(0, operator_token)); break; - case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex(value_index, operator_token) != second_child_value->ObjectElementAtIndex(0, operator_token)); break; + case EidosValueType::kValueLogical: notequal = (first_child_value->LogicalAtIndex_CAST(value_index, operator_token) != second_child_value->LogicalAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueInt: notequal = (first_child_value->IntAtIndex_CAST(value_index, operator_token) != second_child_value->IntAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueFloat: notequal = (first_child_value->FloatAtIndex_CAST(value_index, operator_token) != second_child_value->FloatAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueString: notequal = (first_child_value->StringAtIndex_CAST(value_index, operator_token) != second_child_value->StringAtIndex_CAST(0, operator_token)); break; + case EidosValueType::kValueObject: notequal = (first_child_value->ObjectElementAtIndex_CAST(value_index, operator_token) != second_child_value->ObjectElementAtIndex_CAST(0, operator_token)); break; default: notequal = false; break; // never hit } @@ -5286,7 +5286,7 @@ EidosValue_SP EidosInterpreter::Evaluate_If(const EidosASTNode *p_node) } else if (condition_result->Count() == 1) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); if (condition_logical) { @@ -5419,7 +5419,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Do(const EidosASTNode *p_node) } else if (condition_result->Count() == 1) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); if (!condition_logical) break; @@ -5480,7 +5480,7 @@ EidosValue_SP EidosInterpreter::Evaluate_While(const EidosASTNode *p_node) } else if (condition_result->Count() == 1) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); if (!condition_logical) break; @@ -5596,8 +5596,8 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) // OK, we have a simple integer:integer range, so this should be very straightforward simpleIntegerRange = true; - start_int = range_start_value->IntAtIndex(0, nullptr); - end_int = range_end_value->IntAtIndex(0, nullptr); + start_int = range_start_value->IntAtIndex_NOCAST(0, nullptr); + end_int = range_end_value->IntAtIndex_NOCAST(0, nullptr); } else { @@ -5658,7 +5658,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) if (argument_value->Count() != 1) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_For): argument 1 (length) must be a singleton (size() == 1) for function seqLen(), but size() == " << argument_value->Count() << "." << EidosTerminate(call_name_node->token_); - int64_t length = argument_value->IntAtIndex(0, call_name_node->token_); + int64_t length = argument_value->IntAtIndex_NOCAST(0, call_name_node->token_); if (length < 0) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_For): function seqLen() requires length to be greater than or equal to 0 (" << length << " supplied)." << EidosTerminate(call_name_node->token_); diff --git a/eidos/eidos_script.cpp b/eidos/eidos_script.cpp index 29f1ca874..7a48b69e2 100644 --- a/eidos/eidos_script.cpp +++ b/eidos/eidos_script.cpp @@ -2405,12 +2405,12 @@ EidosASTNode *EidosScript::Parse_DefaultValue(void) if (numeric_value->Type() == EidosValueType::kValueFloat) { - double float_value = numeric_value->FloatAtIndex(0, current_token_); + double float_value = numeric_value->FloatAtIndex_NOCAST(0, current_token_); negated_value = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(-float_value)); } else if (numeric_value->Type() == EidosValueType::kValueInt) { - int64_t int_value = numeric_value->IntAtIndex(0, current_token_); + int64_t int_value = numeric_value->IntAtIndex_NOCAST(0, current_token_); negated_value = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-int_value)); // note that overflow is not possible } else diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index fd33e90f9..9cdc433d7 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -230,8 +230,8 @@ bool CompareEidosValues(const EidosValue &p_value1, int p_index1, const EidosVal // comparing one object to another is legal, but objects cannot be compared to other types if ((type1 == EidosValueType::kValueObject) && (type2 == EidosValueType::kValueObject)) { - EidosObject *element1 = p_value1.ObjectElementAtIndex(p_index1, p_blame_token); - EidosObject *element2 = p_value2.ObjectElementAtIndex(p_index2, p_blame_token); + EidosObject *element1 = p_value1.ObjectElementAtIndex_NOCAST(p_index1, p_blame_token); + EidosObject *element2 = p_value2.ObjectElementAtIndex_NOCAST(p_index2, p_blame_token); if (p_operator == EidosComparisonOperator::kEqual) return (element1 == element2); else if (p_operator == EidosComparisonOperator::kNotEqual) return (element1 != element2); @@ -242,8 +242,8 @@ bool CompareEidosValues(const EidosValue &p_value1, int p_index1, const EidosVal // string is the highest type, so we promote to string if either operand is a string if ((type1 == EidosValueType::kValueString) || (type2 == EidosValueType::kValueString)) { - std::string string1 = p_value1.StringAtIndex(p_index1, p_blame_token); - std::string string2 = p_value2.StringAtIndex(p_index2, p_blame_token); + std::string string1 = p_value1.StringAtIndex_CAST(p_index1, p_blame_token); + std::string string2 = p_value2.StringAtIndex_CAST(p_index2, p_blame_token); int compare_result = string1.compare(string2); // not guaranteed to be -1 / 0 / +1, just negative / 0 / positive switch (p_operator) { @@ -259,8 +259,8 @@ bool CompareEidosValues(const EidosValue &p_value1, int p_index1, const EidosVal // float is the next highest type, so we promote to float if either operand is a float if ((type1 == EidosValueType::kValueFloat) || (type2 == EidosValueType::kValueFloat)) { - double float1 = p_value1.FloatAtIndex(p_index1, p_blame_token); - double float2 = p_value2.FloatAtIndex(p_index2, p_blame_token); + double float1 = p_value1.FloatAtIndex_CAST(p_index1, p_blame_token); + double float2 = p_value2.FloatAtIndex_CAST(p_index2, p_blame_token); switch (p_operator) { case EidosComparisonOperator::kLess: return (float1 < float2); @@ -275,8 +275,8 @@ bool CompareEidosValues(const EidosValue &p_value1, int p_index1, const EidosVal // int is the next highest type, so we promote to int if either operand is a int if ((type1 == EidosValueType::kValueInt) || (type2 == EidosValueType::kValueInt)) { - int64_t int1 = p_value1.IntAtIndex(p_index1, p_blame_token); - int64_t int2 = p_value2.IntAtIndex(p_index2, p_blame_token); + int64_t int1 = p_value1.IntAtIndex_CAST(p_index1, p_blame_token); + int64_t int2 = p_value2.IntAtIndex_CAST(p_index2, p_blame_token); switch (p_operator) { case EidosComparisonOperator::kLess: return (int1 < int2); @@ -291,8 +291,8 @@ bool CompareEidosValues(const EidosValue &p_value1, int p_index1, const EidosVal // logical is the next highest type, so we promote to logical if either operand is a logical if ((type1 == EidosValueType::kValueLogical) || (type2 == EidosValueType::kValueLogical)) { - eidos_logical_t logical1 = p_value1.LogicalAtIndex(p_index1, p_blame_token); - eidos_logical_t logical2 = p_value2.LogicalAtIndex(p_index2, p_blame_token); + eidos_logical_t logical1 = p_value1.LogicalAtIndex_CAST(p_index1, p_blame_token); + eidos_logical_t logical2 = p_value2.LogicalAtIndex_CAST(p_index2, p_blame_token); switch (p_operator) { case EidosComparisonOperator::kLess: return (logical1 < logical2); @@ -339,44 +339,44 @@ EidosValue::~EidosValue(void) free(dim_); } -eidos_logical_t EidosValue::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) EIDOS_TERMINATION << "ERROR (EidosValue::LogicalAtIndex): operand type " << this->Type() << " cannot be converted to type logical." << EidosTerminate(p_blame_token); } -std::string EidosValue::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) EIDOS_TERMINATION << "ERROR (EidosValue::StringAtIndex): operand type " << this->Type() << " cannot be converted to type string." << EidosTerminate(p_blame_token); } -int64_t EidosValue::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) EIDOS_TERMINATION << "ERROR (EidosValue::IntAtIndex): operand type " << this->Type() << " cannot be converted to type integer." << EidosTerminate(p_blame_token); } -double EidosValue::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) EIDOS_TERMINATION << "ERROR (EidosValue::FloatAtIndex): operand type " << this->Type() << " cannot be converted to type float." << EidosTerminate(p_blame_token); } -EidosObject *EidosValue::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) EIDOS_TERMINATION << "ERROR (EidosValue::ObjectElementAtIndex): operand type " << this->Type() << " cannot be converted to type object." << EidosTerminate(p_blame_token); } -void EidosValue::RaiseForUnimplementedVectorCall(void) const +void EidosValue::RaiseForIncorrectTypeCall(void) const { - EIDOS_TERMINATION << "ERROR (EidosValue::RaiseForUnimplementedVectorCall): (internal error) direct vector access attempted on an EidosValue type that does not support it." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue::RaiseForIncorrectTypeCall): (internal error) direct vector access attempted on an EidosValue type of the incorrect type." << EidosTerminate(nullptr); } -void EidosValue::RaiseForUnsupportedConversionCall(const EidosToken *p_blame_token) const +void EidosValue::RaiseForImmutabilityCall(void) const { - EIDOS_TERMINATION << "ERROR (EidosValue::RaiseForUnsupportedConversionCall): an EidosValue cannot be converted to the requested type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue::RaiseForImmutabilityCall): (internal error) mutable direct vector access attempted on an immutable EidosValue." << EidosTerminate(nullptr); } void EidosValue::RaiseForCapacityViolation(void) const @@ -1060,7 +1060,7 @@ nlohmann::json EidosValue_Logical::JSONRepresentation(void) const return json_object; } -eidos_logical_t EidosValue_Logical::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_Logical::LogicalAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1068,7 +1068,15 @@ eidos_logical_t EidosValue_Logical::LogicalAtIndex(int p_idx, const EidosToken * return values_[p_idx]; } -std::string EidosValue_Logical::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_Logical::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +{ + if ((p_idx < 0) || (p_idx >= (int)count_)) + EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return values_[p_idx]; +} + +std::string EidosValue_Logical::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1076,7 +1084,7 @@ std::string EidosValue_Logical::StringAtIndex(int p_idx, const EidosToken *p_bla return (values_[p_idx] ? gEidosStr_T : gEidosStr_F); } -int64_t EidosValue_Logical::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Logical::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1084,7 +1092,7 @@ int64_t EidosValue_Logical::IntAtIndex(int p_idx, const EidosToken *p_blame_toke return (values_[p_idx] ? 1 : 0); } -double EidosValue_Logical::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Logical::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1105,7 +1113,7 @@ void EidosValue_Logical::SetValueAtIndex(const int p_idx, const EidosValue &p_va if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Logical::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - values_[p_idx] = p_value.LogicalAtIndex(0, p_blame_token); + values_[p_idx] = p_value.LogicalAtIndex_CAST(0, p_blame_token); } EidosValue_SP EidosValue_Logical::CopyValues(void) const @@ -1121,7 +1129,7 @@ EidosValue_SP EidosValue_Logical::NewMatchingType(void) const void EidosValue_Logical::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { if (p_source_script_value.Type() == EidosValueType::kValueLogical) - push_logical(p_source_script_value.LogicalAtIndex(p_idx, p_blame_token)); + push_logical(p_source_script_value.LogicalAtIndex_NOCAST(p_idx, p_blame_token)); else EIDOS_TERMINATION << "ERROR (EidosValue_Logical::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } @@ -1264,7 +1272,7 @@ EidosValue_SP EidosValue_String::NewMatchingType(void) const void EidosValue_String::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { - const std::string &value = StringAtIndex(p_idx, nullptr); + const std::string &value = StringRefAtIndex_NOCAST(p_idx, nullptr); // Emit a quoted string with backslash escapes as needed p_ostream << Eidos_string_escaped(value, EidosStringQuoting::kChooseQuotes); @@ -1276,7 +1284,7 @@ nlohmann::json EidosValue_String::JSONRepresentation(void) const int count = Count(); for (int i = 0; i < count; ++i) - json_object.emplace_back(StringRefAtIndex(i, nullptr)); + json_object.emplace_back(StringAtIndex_NOCAST(i, nullptr)); return json_object; } @@ -1301,31 +1309,39 @@ EidosValue_String_vector::EidosValue_String_vector(std::initializer_list= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return (values_[p_idx].length() > 0); + return values_[p_idx]; } -std::string EidosValue_String_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +const std::string &EidosValue_String_vector::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringRefAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -const std::string &EidosValue_String_vector::StringRefAtIndex(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_String_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringRefAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return (values_[p_idx].length() > 0); +} + +std::string EidosValue_String_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +{ + if ((p_idx < 0) || (p_idx >= (int)values_.size())) + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -int64_t EidosValue_String_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_String_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1341,7 +1357,7 @@ int64_t EidosValue_String_vector::IntAtIndex(int p_idx, const EidosToken *p_blam return static_cast(converted_value); } -double EidosValue_String_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_String_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1362,7 +1378,7 @@ void EidosValue_String_vector::SetValueAtIndex(const int p_idx, const EidosValue if ((p_idx < 0) || (p_idx >= (int)values_.size())) EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - values_[p_idx] = p_value.StringAtIndex(0, p_blame_token); + values_[p_idx] = p_value.StringAtIndex_CAST(0, p_blame_token); } EidosValue_SP EidosValue_String_vector::CopyValues(void) const @@ -1373,7 +1389,7 @@ EidosValue_SP EidosValue_String_vector::CopyValues(void) const void EidosValue_String_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { if (p_source_script_value.Type() == EidosValueType::kValueString) - values_.emplace_back(p_source_script_value.StringAtIndex(p_idx, p_blame_token)); + values_.emplace_back(p_source_script_value.StringAtIndex_NOCAST(p_idx, p_blame_token)); else EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } @@ -1388,31 +1404,39 @@ void EidosValue_String_vector::Sort(bool p_ascending) // EidosValue_String_singleton #pragma mark EidosValue_String_singleton -eidos_logical_t EidosValue_String_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_String_singleton::StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return (value_.length() > 0); + return value_; } -std::string EidosValue_String_singleton::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +const std::string &EidosValue_String_singleton::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringRefAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } -const std::string &EidosValue_String_singleton::StringRefAtIndex(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_String_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringRefAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return (value_.length() > 0); +} + +std::string EidosValue_String_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +{ + if (p_idx != 0) + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } -int64_t EidosValue_String_singleton::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_String_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1428,7 +1452,7 @@ int64_t EidosValue_String_singleton::IntAtIndex(int p_idx, const EidosToken *p_b return static_cast(converted_value); } -double EidosValue_String_singleton::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_String_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1497,7 +1521,7 @@ EidosValue_SP EidosValue_Int::NewMatchingType(void) const void EidosValue_Int::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { - int64_t value = IntAtIndex(p_idx, nullptr); + int64_t value = IntAtIndex_NOCAST(p_idx, nullptr); p_ostream << value; } @@ -1508,7 +1532,7 @@ nlohmann::json EidosValue_Int::JSONRepresentation(void) const int count = Count(); for (int i = 0; i < count; ++i) - json_object.emplace_back(IntAtIndex(i, nullptr)); + json_object.emplace_back(IntAtIndex_NOCAST(i, nullptr)); return json_object; } @@ -1566,7 +1590,15 @@ EidosValue_Int_vector::EidosValue_Int_vector(const int64_t *p_values, size_t p_c set_int_no_check(p_values[index], index); } -eidos_logical_t EidosValue_Int_vector::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Int_vector::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + if ((p_idx < 0) || (p_idx >= (int)count_)) + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return values_[p_idx]; +} + +eidos_logical_t EidosValue_Int_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1574,7 +1606,7 @@ eidos_logical_t EidosValue_Int_vector::LogicalAtIndex(int p_idx, const EidosToke return (values_[p_idx] == 0 ? false : true); } -std::string EidosValue_Int_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_Int_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1582,7 +1614,7 @@ std::string EidosValue_Int_vector::StringAtIndex(int p_idx, const EidosToken *p_ return std::to_string(values_[p_idx]); // way faster than std::ostringstream } -int64_t EidosValue_Int_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Int_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1590,7 +1622,7 @@ int64_t EidosValue_Int_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_t return values_[p_idx]; } -double EidosValue_Int_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Int_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1611,7 +1643,7 @@ void EidosValue_Int_vector::SetValueAtIndex(const int p_idx, const EidosValue &p if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - values_[p_idx] = p_value.IntAtIndex(0, p_blame_token); + values_[p_idx] = p_value.IntAtIndex_CAST(0, p_blame_token); } EidosValue_SP EidosValue_Int_vector::CopyValues(void) const @@ -1622,7 +1654,7 @@ EidosValue_SP EidosValue_Int_vector::CopyValues(void) const void EidosValue_Int_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { if (p_source_script_value.Type() == EidosValueType::kValueInt) - push_int(p_source_script_value.IntAtIndex(p_idx, p_blame_token)); + push_int(p_source_script_value.IntAtIndex_NOCAST(p_idx, p_blame_token)); else EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } @@ -1688,7 +1720,15 @@ void EidosValue_Int_vector::erase_index(size_t p_index) // EidosValue_Int_singleton #pragma mark EidosValue_Int_singleton -eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Int_singleton::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + if (p_idx != 0) + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return value_; +} + +eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1696,7 +1736,7 @@ eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex(int p_idx, const EidosT return (value_ == 0 ? false : true); } -std::string EidosValue_Int_singleton::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_Int_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1704,7 +1744,7 @@ std::string EidosValue_Int_singleton::StringAtIndex(int p_idx, const EidosToken return std::to_string(value_); // way faster than std::ostringstream } -int64_t EidosValue_Int_singleton::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Int_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1712,7 +1752,7 @@ int64_t EidosValue_Int_singleton::IntAtIndex(int p_idx, const EidosToken *p_blam return value_; } -double EidosValue_Int_singleton::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Int_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1782,7 +1822,7 @@ EidosValue_SP EidosValue_Float::NewMatchingType(void) const void EidosValue_Float::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { - p_ostream << EidosStringForFloat(FloatAtIndex(p_idx, nullptr)); + p_ostream << EidosStringForFloat(FloatAtIndex_NOCAST(p_idx, nullptr)); } nlohmann::json EidosValue_Float::JSONRepresentation(void) const @@ -1791,7 +1831,7 @@ nlohmann::json EidosValue_Float::JSONRepresentation(void) const int count = Count(); for (int i = 0; i < count; ++i) - json_object.emplace_back(FloatAtIndex(i, nullptr)); + json_object.emplace_back(FloatAtIndex_NOCAST(i, nullptr)); return json_object; } @@ -1827,7 +1867,15 @@ EidosValue_Float_vector::EidosValue_Float_vector(const double *p_values, size_t set_float_no_check(p_values[index], index); } -eidos_logical_t EidosValue_Float_vector::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float_vector::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + if ((p_idx < 0) || (p_idx >= (int)count_)) + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return values_[p_idx]; +} + +eidos_logical_t EidosValue_Float_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1840,7 +1888,7 @@ eidos_logical_t EidosValue_Float_vector::LogicalAtIndex(int p_idx, const EidosTo return (value == 0 ? false : true); } -std::string EidosValue_Float_vector::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_Float_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1848,7 +1896,7 @@ std::string EidosValue_Float_vector::StringAtIndex(int p_idx, const EidosToken * return EidosStringForFloat(values_[p_idx]); } -int64_t EidosValue_Float_vector::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Float_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1867,7 +1915,7 @@ int64_t EidosValue_Float_vector::IntAtIndex(int p_idx, const EidosToken *p_blame return static_cast(value); } -double EidosValue_Float_vector::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1888,7 +1936,7 @@ void EidosValue_Float_vector::SetValueAtIndex(const int p_idx, const EidosValue if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - values_[p_idx] = p_value.FloatAtIndex(0, p_blame_token); + values_[p_idx] = p_value.FloatAtIndex_CAST(0, p_blame_token); } EidosValue_SP EidosValue_Float_vector::CopyValues(void) const @@ -1899,7 +1947,7 @@ EidosValue_SP EidosValue_Float_vector::CopyValues(void) const void EidosValue_Float_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { if (p_source_script_value.Type() == EidosValueType::kValueFloat) - push_float(p_source_script_value.FloatAtIndex(p_idx, p_blame_token)); + push_float(p_source_script_value.FloatAtIndex_NOCAST(p_idx, p_blame_token)); else EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } @@ -1968,7 +2016,15 @@ void EidosValue_Float_vector::erase_index(size_t p_index) // EidosValue_Float_singleton #pragma mark EidosValue_Float_singleton -eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float_singleton::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + if (p_idx != 0) + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return value_; +} + +eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1979,7 +2035,7 @@ eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex(int p_idx, const Eido return (value_ == 0 ? false : true); } -std::string EidosValue_Float_singleton::StringAtIndex(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_Float_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -1987,7 +2043,7 @@ std::string EidosValue_Float_singleton::StringAtIndex(int p_idx, const EidosToke return EidosStringForFloat(value_); } -int64_t EidosValue_Float_singleton::IntAtIndex(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Float_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -2004,7 +2060,7 @@ int64_t EidosValue_Float_singleton::IntAtIndex(int p_idx, const EidosToken *p_bl return static_cast(value_); } -double EidosValue_Float_singleton::FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -2178,7 +2234,7 @@ void EidosValue_Object::Sort(bool p_ascending) void EidosValue_Object::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const { - EidosObject *value = ObjectElementAtIndex(p_idx, nullptr); + EidosObject *value = ObjectElementAtIndex_NOCAST(p_idx, nullptr); p_ostream << *value; } @@ -2189,7 +2245,7 @@ nlohmann::json EidosValue_Object::JSONRepresentation(void) const int count = Count(); for (int i = 0; i < count; ++i) - json_object.emplace_back(ObjectElementAtIndex(i, nullptr)->JSONRepresentation()); + json_object.emplace_back(ObjectElementAtIndex_NOCAST(i, nullptr)->JSONRepresentation()); return json_object; } @@ -2284,7 +2340,15 @@ EidosValue_Object_vector::~EidosValue_Object_vector(void) free(values_); } -EidosObject *EidosValue_Object_vector::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + if ((p_idx < 0) || (p_idx >= (int)count_)) + EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return values_[p_idx]; +} + +EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); @@ -2305,7 +2369,7 @@ void EidosValue_Object_vector::SetValueAtIndex(const int p_idx, const EidosValue if ((p_idx < 0) || (p_idx >= (int)count_)) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - EidosObject *new_value = p_value.ObjectElementAtIndex(0, p_blame_token); + EidosObject *new_value = p_value.ObjectElementAtIndex_CAST(0, p_blame_token); DeclareClassFromElement(new_value); @@ -2327,7 +2391,7 @@ EidosValue_SP EidosValue_Object_vector::CopyValues(void) const void EidosValue_Object_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { if (p_source_script_value.Type() == EidosValueType::kValueObject) - push_object_element_CRR(p_source_script_value.ObjectElementAtIndex(p_idx, p_blame_token)); + push_object_element_CRR(p_source_script_value.ObjectElementAtIndex_NOCAST(p_idx, p_blame_token)); else EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } @@ -2382,7 +2446,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce if (temp_result->Type() != property_type) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); - sortable_pairs.emplace_back(temp_result->LogicalAtIndex(0, nullptr), value); + sortable_pairs.emplace_back(temp_result->LogicalAtIndex_NOCAST(0, nullptr), value); } // sort the vector of pairs @@ -2415,7 +2479,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce if (temp_result->Type() != property_type) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); - sortable_pairs.emplace_back(temp_result->IntAtIndex(0, nullptr), value); + sortable_pairs.emplace_back(temp_result->IntAtIndex_NOCAST(0, nullptr), value); } // sort the vector of pairs @@ -2448,7 +2512,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce if (temp_result->Type() != property_type) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); - sortable_pairs.emplace_back(temp_result->FloatAtIndex(0, nullptr), value); + sortable_pairs.emplace_back(temp_result->FloatAtIndex_NOCAST(0, nullptr), value); } // sort the vector of pairs @@ -2481,7 +2545,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce if (temp_result->Type() != property_type) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); - sortable_pairs.emplace_back(temp_result->StringAtIndex(0, nullptr), value); + sortable_pairs.emplace_back(temp_result->StringAtIndex_NOCAST(0, nullptr), value); } // sort the vector of pairs @@ -3138,7 +3202,15 @@ EidosValue_Object_singleton::~EidosValue_Object_singleton(void) static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead } -EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + if (p_idx != 0) + EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return value_; +} + +EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index e89d24c00..f65bf29d0 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -179,8 +179,8 @@ class EidosValue virtual ~EidosValue(void); // methods that raise due to various causes, used to avoid duplication and allow efficient inlining - void RaiseForUnimplementedVectorCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); - void RaiseForUnsupportedConversionCall(const EidosToken *p_blame_token) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForIncorrectTypeCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); + void RaiseForImmutabilityCall(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); void RaiseForCapacityViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); void RaiseForRangeViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); void RaiseForRetainReleaseViolation(void) const __attribute__((__noreturn__)) __attribute__((analyzer_noreturn)); @@ -204,12 +204,19 @@ class EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const = 0; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) = 0; - // fetching individual values; these convert type if necessary, and (base class behavior) raise if impossible - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const = 0; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const = 0; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const = 0; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const = 0; - virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const = 0; + // fetching individual values; the CAST versions convert type if necessary, and (base class behavior) raise if impossible + // these are relatively slow convenience accessors; to get values across a large vector, the XData() methods below are preferred + virtual eidos_logical_t LogicalAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + virtual std::string StringAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + virtual int64_t IntAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + virtual double FloatAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + virtual EidosObject *ObjectElementAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; + virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; // methods to allow type-agnostic manipulation of EidosValues virtual EidosValue_SP VectorBasedCopy(void) const; // just calls CopyValues() by default, but guarantees a mutable copy @@ -222,16 +229,16 @@ class EidosValue // accessing the values without changing them, or changing them but not changing the length of the vector. You must // explicitly request mutability. If you want to change the length of the vector, you will want to actually get the // type-specific vector subclass using dynamic_cast, but it is rare not to already have that pointer in such cases. - virtual const eidos_logical_t *LogicalData(void) const { RaiseForUnimplementedVectorCall(); } - virtual eidos_logical_t *LogicalData_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const std::string *StringData(void) const { RaiseForUnimplementedVectorCall(); } - virtual std::string *StringData_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const int64_t *IntData(void) const { RaiseForUnimplementedVectorCall(); } - virtual int64_t *IntData_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual const double *FloatData(void) const { RaiseForUnimplementedVectorCall(); } - virtual double *FloatData_Mutable(void) { RaiseForUnimplementedVectorCall(); } - virtual EidosObject * const *ObjectData(void) const { RaiseForUnimplementedVectorCall(); } - virtual EidosObject **ObjectData_Mutable(void) { RaiseForUnimplementedVectorCall(); } + virtual const eidos_logical_t *LogicalData(void) const { RaiseForIncorrectTypeCall(); } + virtual eidos_logical_t *LogicalData_Mutable(void) { RaiseForIncorrectTypeCall(); } + virtual const std::string *StringData(void) const { RaiseForIncorrectTypeCall(); } + virtual std::string *StringData_Mutable(void) { RaiseForIncorrectTypeCall(); } + virtual const int64_t *IntData(void) const { RaiseForIncorrectTypeCall(); } + virtual int64_t *IntData_Mutable(void) { RaiseForIncorrectTypeCall(); } + virtual const double *FloatData(void) const { RaiseForIncorrectTypeCall(); } + virtual double *FloatData_Mutable(void) { RaiseForIncorrectTypeCall(); } + virtual EidosObject * const *ObjectData(void) const { RaiseForIncorrectTypeCall(); } + virtual EidosObject **ObjectData_Mutable(void) { RaiseForIncorrectTypeCall(); } // Dimension support, for matrices and arrays inline __attribute__((always_inline)) bool IsMatrixOrArray(void) const { return !!dim_; } // true if we have a dimensions buffer @@ -357,12 +364,6 @@ class EidosValue_VOID final : public EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; - virtual eidos_logical_t LogicalAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual std::string StringAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual int64_t IntAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual EidosValue_SP CopyValues(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; @@ -405,12 +406,6 @@ class EidosValue_NULL final : public EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; - virtual eidos_logical_t LogicalAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual std::string StringAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual int64_t IntAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual EidosValue_SP CopyValues(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; @@ -467,11 +462,12 @@ class EidosValue_Logical : public EidosValue virtual const eidos_logical_t *LogicalData(void) const override { return values_; } virtual eidos_logical_t *LogicalData_Mutable(void) override { return values_; } - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual eidos_logical_t LogicalAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; @@ -530,7 +526,7 @@ class EidosValue_Logical_const final : public EidosValue_Logical virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because this subclass represents only truly immutable objects - virtual eidos_logical_t *LogicalData_Mutable(void) override { RaiseForUnimplementedVectorCall(); } + virtual eidos_logical_t *LogicalData_Mutable(void) override { RaiseForImmutabilityCall(); } virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -568,7 +564,8 @@ class EidosValue_String : public EidosValue virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; - virtual const std::string &StringRefAtIndex(int p_idx, const EidosToken *p_blame_token) const = 0; // const reference for speed + virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; + virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const = 0; // const reference for speed virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; @@ -609,12 +606,13 @@ class EidosValue_String_vector final : public EidosValue_String inline __attribute__((always_inline)) void PushString(const std::string &p_string) { values_.emplace_back(p_string); } inline __attribute__((always_inline)) EidosValue_String_vector *Reserve(int p_reserved_size) { values_.reserve(p_reserved_size); return this; } - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual const std::string &StringRefAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; @@ -648,12 +646,13 @@ class EidosValue_String_singleton final : public EidosValue_String virtual std::string *StringData_Mutable(void) override { delete cached_script_; cached_script_ = nullptr; return &value_; } // very dangerous; do not use inline __attribute__((always_inline)) void SetValue(const std::string &p_string) { delete cached_script_; cached_script_ = nullptr; value_ = p_string; } // very dangerous; used only in Evaluate_For() - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual const std::string &StringRefAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; @@ -702,6 +701,7 @@ class EidosValue_Int : public EidosValue virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; + virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; @@ -738,11 +738,12 @@ class EidosValue_Int_vector final : public EidosValue_Int virtual const int64_t *IntData(void) const override { return values_; } virtual int64_t *IntData_Mutable(void) override { return values_; } - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; @@ -801,11 +802,12 @@ class EidosValue_Int_singleton final : public EidosValue_Int virtual int64_t *IntData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() inline __attribute__((always_inline)) void SetValue(int64_t p_int) { value_ = p_int; } // very dangerous; used only in Evaluate_For() - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; @@ -850,6 +852,7 @@ class EidosValue_Float : public EidosValue virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; + virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; @@ -884,11 +887,12 @@ class EidosValue_Float_vector final : public EidosValue_Float virtual const double *FloatData(void) const override { return values_; } virtual double *FloatData_Mutable(void) override { return values_; } - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; @@ -947,11 +951,12 @@ class EidosValue_Float_singleton final : public EidosValue_Float virtual double *FloatData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() inline __attribute__((always_inline)) void SetValue(double p_float) { value_ = p_float; } // very dangerous; used only in Evaluate_For() - virtual eidos_logical_t LogicalAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject *ObjectElementAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; + virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; @@ -1029,6 +1034,8 @@ class EidosValue_Object : public EidosValue virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; + virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override = 0; + virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; @@ -1071,11 +1078,9 @@ class EidosValue_Object_vector final : public EidosValue_Object explicit EidosValue_Object_vector(EidosObject **p_values, size_t p_count, const EidosClass *p_class); virtual ~EidosValue_Object_vector(void) override; - virtual eidos_logical_t LogicalAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual std::string StringAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual int64_t IntAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const override; + virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosObject * const *ObjectData(void) const override { return values_; } virtual EidosObject **ObjectData_Mutable(void) override { return values_; } @@ -1322,11 +1327,9 @@ class EidosValue_Object_singleton final : public EidosValue_Object explicit EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class, bool p_register_for_patching); // a variant for self-pointer EidosValues; not for general use virtual ~EidosValue_Object_singleton(void) override; - virtual eidos_logical_t LogicalAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual std::string StringAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual int64_t IntAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual double FloatAtIndex(__attribute__((unused)) int p_idx, const EidosToken *p_blame_token) const override { RaiseForUnsupportedConversionCall(p_blame_token); }; - virtual EidosObject *ObjectElementAtIndex(int p_idx, const EidosToken *p_blame_token) const override; + virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + + virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosObject * const *ObjectData(void) const override { return &value_; } virtual EidosObject **ObjectData_Mutable(void) override { return &value_; } // very dangerous; do not use From 619ecfbb0659254cf61b99d55333cc2c7365a054 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Thu, 21 Dec 2023 12:51:45 -0500 Subject: [PATCH 03/18] remove SetValueAtIndex() --- eidos/eidos_interpreter.cpp | 203 +++++++++++++++++---------- eidos/eidos_symbol_table.cpp | 4 +- eidos/eidos_test_operators_other.cpp | 13 +- eidos/eidos_value.cpp | 93 ------------ eidos/eidos_value.h | 37 ++--- 5 files changed, 156 insertions(+), 194 deletions(-) diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index e5d0c31ee..57030ecf3 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -273,14 +273,7 @@ EidosValue_SP EidosInterpreter::EvaluateInterpreterBlock(bool p_print_output, bo // A subscript has been encountered as the top-level operation on the left-hand side of an assignment – x[5] = y, x.foo[5] = y, or more // complex cases like x[3:10].foo[2:5][1:2] = y. The job of this function is to determine the identity of the symbol host (x, x, and // x[3:10], respectively), the name of the property within the symbol host (none, foo, and foo, respectively), and the indices of the final -// subscript operation (5, 5, and {3,4}, respectively), and return them to the caller, who will assign into those subscripts. Note that -// complex cases work only because of several other aspects of Eidos. Notably, subscripting of an object creates a new object, but -// the new object refers to the same elements as the parent object, by pointer; this means that x[5].foo = y works, because x[5] refers to -// the same element, by pointer, as x does. If Eidos did not have these shared-value semantics, assignment would be much trickier, -// since Eidos cannot use a symbol table to store values, in general (since many values accessible through script are stored in private -// representations kept by external classes in the Context). In other words, assignment relies upon the fact that a temporary object -// constructed by Evaluate_Node() refers to the same underlying element objects as the original source of the elements does, and thus -// assigning into the temporary also assigns into the original. +// subscript operation (5, 5, and {3,4}, respectively), and return them to the caller, who will assign into those subscripts. void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, EidosGlobalStringID *p_property_string_id_ptr, std::vector *p_indices_ptr, const EidosASTNode *p_parent_node) { // The left operand is the thing we're subscripting. If it is an identifier or a dot operator, then we are the deepest (i.e. first) @@ -597,22 +590,22 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, { EIDOS_ASSERT_CHILD_COUNT_X(p_parent_node, "identifier", "EidosInterpreter::_ProcessSubsetAssignment", 0, parent_token); - EidosValue_SP identifier_value_SP = global_symbols_->GetValueOrRaiseForASTNode(p_parent_node); + bool identifier_is_const = false; + EidosValue_SP identifier_value_SP = global_symbols_->GetValueOrRaiseForASTNode_IsConst(p_parent_node, &identifier_is_const); EidosValue *identifier_value = identifier_value_SP.get(); - // OK, a little bit of trickiness here. We've got the base value from the symbol table. The problem is that it - // could be one of our singleton subclasses, for speed. We almost never change EidosValue instances once - // they are constructed, which is why we can use singleton subclasses so pervasively. But this is one place – - // the only place, in fact, I think – where that can bite us, because we do in fact need to modify the original - // EidosValue. The fix is to detect that we have a singleton value, and actually replace it in the symbol table - // with a vector-based copy that we can manipulate. A little gross, but this is the price we pay for speed... - if (identifier_value->IsSingleton()) + if (identifier_is_const) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): identifier '" << EidosStringRegistry::StringForGlobalStringID(p_parent_node->cached_stringID_) << "' cannot be redefined because it is a constant." << EidosTerminate(nullptr); + + // BCH 12/21/2023: We used to munge singletons into vectors here, because we didn't have the tools to modify the + // element in a singleton value. That limitation has now been fixed, so this munging is no longer necessary. + /*if (identifier_value->IsSingleton()) { identifier_value_SP = identifier_value->VectorBasedCopy(); identifier_value = identifier_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(p_parent_node->cached_stringID_, identifier_value_SP); - } + }*/ *p_base_value_ptr = std::move(identifier_value_SP); @@ -664,88 +657,142 @@ void EidosInterpreter::_AssignRValueToLValue(EidosValue_SP p_rvalue, const Eidos int index_count = (int)indices.size(); int rvalue_count = p_rvalue->Count(); - if (rvalue_count == 1) + if ((rvalue_count != 1) && (rvalue_count != index_count)) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): assignment to a subscript requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); + + if (property_string_id != gEidosID_none) { - if (property_string_id == gEidosID_none) + // This would be a multiplex assignment of one value to (maybe) more than one index in a property of a symbol host: x.foo[5:10] = 10, + // or a one-to-one assignment of values to indices in a property of a symbol host: x.foo[5:10] = 5:10 + + // BCH 12/8/2017: We used to allow assignments of the form host.property[indices] = rvalue. I have decided to change Eidos policy + // to disallow that form of assignment. Conceptually, it sort of doesn't make sense, because it implies fetching the property + // values and assigning into a subset of those fetched values; but the fetched values are not an lvalue at that point. We did it + // anyway through a semantic rearrangement, but I now think that was a bad idea. The conceptual problem became more stark with the + // addition of matrices and arrays; if host is a matrix/array, host[i,j,...] is too, and so assigning into a host with that form of + // subset makes conceptual sense, and host[i,j,...].property = rvalue makes sense as well – fetch the indexed values and assign + // into their property. But host.property[i,j,...] = rvalue does not make sense, because host.property is always a vector, and + // cannot be subset in that way! So the underlying contradiction in the old policy is exposed. Time for it to change. + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): cannot assign into a subset of a property; not an lvalue." << EidosTerminate(nullptr); + } + + if (!TypeCheckAssignmentOfEidosValueIntoEidosValue(*p_rvalue, *base_value)) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): type mismatch in assignment (" << p_rvalue->Type() << " versus " << base_value->Type() << ")." << EidosTerminate(nullptr); + + // Assignments like x[logical(0)] = y, where y is zero-length, are no-ops as long as they're not errors + if (index_count == 0) + return; + + // At this point, we have either a multiplex assignment of one value to (maybe) more than one index in a symbol host: x[5:10] = 10, when + // (rvalue_count == 1), or a one-to-one assignment of values to indices in a symbol host: x[5:10] = 5:10, when (rvalue_count == index_count) + // We handle them both together, as far as we can. BCH 12/21/2023: This used to be done with SetValueAtIndex(); that method has been removed. + switch (base_value->Type()) + { + case EidosValueType::kValueLogical: { - if (!TypeCheckAssignmentOfEidosValueIntoEidosValue(*p_rvalue, *base_value)) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): type mismatch in assignment (" << p_rvalue->Type() << " versus " << base_value->Type() << ")." << EidosTerminate(nullptr); + eidos_logical_t *base_value_data = base_value->LogicalData_Mutable(); - // we have a multiplex assignment of one value to (maybe) more than one index in a symbol host: x[5:10] = 10 - for (int value_idx = 0; value_idx < index_count; value_idx++) - base_value->SetValueAtIndex(indices[value_idx], *p_rvalue, nullptr); + if (rvalue_count == 1) + { + eidos_logical_t rvalue = p_rvalue->LogicalAtIndex_CAST(0, nullptr); + + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = rvalue; + } + else + { + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = p_rvalue->LogicalAtIndex_CAST(value_idx, nullptr); + } + break; } - else + case EidosValueType::kValueInt: { - // we have a multiplex assignment of one value to (maybe) more than one index in a property of a symbol host: x.foo[5:10] = 10 - // here we use the guarantee that the member operator returns one result per element, and that elements following sharing semantics, - // to rearrange this assignment from host.property[indices] = rvalue to host[indices].property = rvalue; this must be equivalent! - - // BCH 12/8/2017: We used to allow assignments of the form host.property[indices] = rvalue. I have decided to change Eidos policy - // to disallow that form of assignment. Conceptually, it sort of doesn't make sense, because it implies fetching the property - // values and assigning into a subset of those fetched values; but the fetched values are not an lvalue at that point. We did it - // anyway through a semantic rearrangement, but I now think that was a bad idea. The conceptual problem became more stark with the - // addition of matrices and arrays; if host is a matrix/array, host[i,j,...] is too, and so assigning into a host with that form of - // subset makes conceptual sense, and host[i,j,...].property = rvalue makes sense as well – fetch the indexed values and assign - // into their property. But host.property[i,j,...] = rvalue does not make sense, because host.property is always a vector, and - // cannot be subset in that way! So the underlying contradiction in the old policy is exposed. Time for it to change. - - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): cannot assign into a subset of a property; not an lvalue." << EidosTerminate(nullptr); - - /* - for (int value_idx = 0; value_idx < index_count; value_idx++) + int64_t *base_value_data = base_value->IntData_Mutable(); + + if (rvalue_count == 1) { - EidosValue_SP temp_lvalue = base_value->GetValueAtIndex(indices[value_idx], nullptr); + int64_t rvalue = p_rvalue->IntAtIndex_CAST(0, nullptr); - if (temp_lvalue->Type() != EidosValueType::kValueObject) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): (internal error) dot operator used with non-object value." << EidosTerminate(nullptr); - - static_cast(temp_lvalue.get())->SetPropertyOfElements(property_string_id, *p_rvalue); - }*/ + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = rvalue; + } + else + { + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = p_rvalue->IntAtIndex_CAST(value_idx, nullptr); + } + break; } - } - else if (index_count == rvalue_count) - { - if (property_string_id == gEidosID_none) + case EidosValueType::kValueFloat: { - if (!TypeCheckAssignmentOfEidosValueIntoEidosValue(*p_rvalue, *base_value)) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): type mismatch in assignment (" << p_rvalue->Type() << " versus " << base_value->Type() << ")." << EidosTerminate(nullptr); + double *base_value_data = base_value->FloatData_Mutable(); - // we have a one-to-one assignment of values to indices in a symbol host: x[5:10] = 5:10 - for (int value_idx = 0; value_idx < index_count; value_idx++) + if (rvalue_count == 1) { - EidosValue_SP temp_rvalue = p_rvalue->GetValueAtIndex(value_idx, nullptr); + double rvalue = p_rvalue->FloatAtIndex_CAST(0, nullptr); - base_value->SetValueAtIndex(indices[value_idx], *temp_rvalue, nullptr); + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = rvalue; + } + else + { + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = p_rvalue->FloatAtIndex_CAST(value_idx, nullptr); } + break; } - else + case EidosValueType::kValueString: { - // we have a one-to-one assignment of values to indices in a property of a symbol host: x.foo[5:10] = 5:10 - // as above, we rearrange this assignment from host.property[indices1] = rvalue[indices2] to host[indices1].property = rvalue[indices2] - - // BCH 12/8/2017: As above, this form of assignment is no longer legal in Eidos. See the longer comment above. - - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): cannot assign into a subset of a property; not an lvalue." << EidosTerminate(nullptr); + std::string *base_value_data = base_value->StringData_Mutable(); - /* - for (int value_idx = 0; value_idx < index_count; value_idx++) + if (rvalue_count == 1) { - EidosValue_SP temp_lvalue = base_value->GetValueAtIndex(indices[value_idx], nullptr); - EidosValue_SP temp_rvalue = p_rvalue->GetValueAtIndex(value_idx, nullptr); + std::string rvalue = p_rvalue->StringAtIndex_CAST(0, nullptr); - if (temp_lvalue->Type() != EidosValueType::kValueObject) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): (internal error) dot operator used with non-object value." << EidosTerminate(nullptr); + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = rvalue; + } + else + { + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_value_data[indices[value_idx]] = p_rvalue->StringAtIndex_CAST(value_idx, nullptr); + } + break; + } + case EidosValueType::kValueObject: + { + EidosValue_Object_vector *base_object_vector = dynamic_cast(base_value.get()); + + if (base_object_vector) + { + if (rvalue_count == 1) + { + EidosObject *rvalue = p_rvalue->ObjectElementAtIndex_CAST(0, nullptr); + + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_object_vector->set_object_element_no_check_CRR(rvalue, indices[value_idx]); + } + else + { + for (int value_idx = 0; value_idx < index_count; value_idx++) + base_object_vector->set_object_element_no_check_CRR(p_rvalue->ObjectElementAtIndex_CAST(value_idx, nullptr), indices[value_idx]); + } + } + else + { + // true singleton case; we can't use set_object_element_no_check_CRR() to set the element + // note (rvalue_count == 1) must be true here, so there is only one case to handle + EidosValue_Object_singleton *base_object_singleton = dynamic_cast(base_value.get()); + EidosObject *rvalue = p_rvalue->ObjectElementAtIndex_CAST(0, nullptr); - static_cast(temp_lvalue.get())->SetPropertyOfElements(property_string_id, *temp_rvalue); - }*/ + base_object_singleton->set_object_element_no_check_CRR(rvalue, 0); + } + break; } + default: + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): cannot do subset assignment into type " << base_value->Type() << ")." << EidosTerminate(nullptr); } - else - { - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): assignment to a subscript requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); - } - break; } case EidosTokenType::kTokenDot: diff --git a/eidos/eidos_symbol_table.cpp b/eidos/eidos_symbol_table.cpp index 9b88aa2fb..399fb7579 100644 --- a/eidos/eidos_symbol_table.cpp +++ b/eidos/eidos_symbol_table.cpp @@ -461,8 +461,8 @@ void EidosSymbolTable::SetValueForSymbolNoCopy(EidosGlobalStringID p_symbol_name // If a few cases, however, we want to play funny games and prevent that copy from occurring so that we can munge // values directly inside a value we just set in the symbol table. Evaluate_For() is the worst offender in this // because it wants to set up an index variable once and then munge its value directly each time through the loop, - // for speed. _ProcessSubsetAssignment() also does it in one case, where it needs to change a singleton into a - // vector value so that it can do a subscripted assignment. For that special purpose, this function is provided. + // for speed. For that special purpose, this function is provided. + // // DO NOT USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING! It can lead to seriously weird behavior if used incorrectly. if (p_value->Invisible()) EIDOS_TERMINATION << "ERROR (EidosSymbolTable::SetValueForSymbolNoCopy): (internal) no copy requested with invisible value." << EidosTerminate(nullptr); diff --git a/eidos/eidos_test_operators_other.cpp b/eidos/eidos_test_operators_other.cpp index d60008eeb..5836fd591 100644 --- a/eidos/eidos_test_operators_other.cpp +++ b/eidos/eidos_test_operators_other.cpp @@ -219,6 +219,11 @@ void _RunOperatorAssignTests(void) EidosAssertScriptRaise("x = 1:5; x[NAN] = 3;", 10, "cannot be converted"); EidosAssertScriptRaise("x = 1:5; x[c(0.0, 2, NAN)] = c(5, 7, 3);", 10, "cannot be converted"); + EidosAssertScriptSuccess_I("x = _Test(9); x = _Test(7); x._yolk;", 7); + EidosAssertScriptSuccess_I("x = _Test(9); x[0] = _Test(7); x._yolk;", 7); + EidosAssertScriptSuccess_IV("x = c(_Test(9), _Test(5)); x[0] = _Test(7); x._yolk;", {7, 5}); + EidosAssertScriptSuccess_IV("x = c(_Test(9), _Test(5)); x[1] = _Test(7); x._yolk;", {9, 7}); + EidosAssertScriptRaise("x = 5:9; x[matrix(0)] = 3;", 10, "matrix or array index operand is not supported"); EidosAssertScriptRaise("x = 5:9; x[matrix(0:2)] = 3;", 10, "matrix or array index operand is not supported"); EidosAssertScriptRaise("x = 5:9; x[matrix(T)] = 3;", 10, "matrix or array index operand is not supported"); @@ -237,10 +242,10 @@ void _RunOperatorAssignTests(void) EidosAssertScriptSuccess_L("x = matrix(5:9); x[c(T,F,T,T,F)] = 3; identical(x, matrix(c(3,6,3,3,9)));", true); // operator = (especially in conjunction with matrix/array-style subsetting with operator []) - EidosAssertScriptSuccess_VOID("NULL[logical(0)] = NULL;"); // technically legal, as no assignment is done - EidosAssertScriptRaise("NULL[logical(0),] = NULL;", 4, "too many subset arguments"); - EidosAssertScriptRaise("NULL[logical(0),logical(0)] = NULL;", 4, "too many subset arguments"); - EidosAssertScriptRaise("NULL[,] = NULL;", 4, "too many subset arguments"); + EidosAssertScriptRaise("NULL[logical(0)] = NULL;", 17, "cannot be redefined because it is a constant"); + EidosAssertScriptRaise("NULL[logical(0),] = NULL;", 18, "cannot be redefined because it is a constant"); + EidosAssertScriptRaise("NULL[logical(0),logical(0)] = NULL;", 28, "cannot be redefined because it is a constant"); + EidosAssertScriptRaise("NULL[,] = NULL;", 8, "cannot be redefined because it is a constant"); EidosAssertScriptSuccess_VOID("x = NULL; x[logical(0)] = NULL;"); // technically legal, as no assignment is done EidosAssertScriptRaise("x = NULL; x[logical(0),] = NULL;", 11, "too many subset arguments"); EidosAssertScriptRaise("x = NULL; x[logical(0),logical(0)] = NULL;", 11, "too many subset arguments"); diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 9cdc433d7..6a7533b37 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -888,12 +888,6 @@ EidosValue_SP EidosValue_VOID::GetValueAtIndex(const int p_idx, const EidosToken EIDOS_TERMINATION << "ERROR (EidosValue_VOID::GetValueAtIndex): (internal error) illegal on void." << EidosTerminate(p_blame_token); } -void EidosValue_VOID::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_VOID::SetValueAtIndex): (internal error) illegal on void." << EidosTerminate(p_blame_token); -} - EidosValue_SP EidosValue_VOID::CopyValues(void) const { EIDOS_TERMINATION << "ERROR (EidosValue_VOID::CopyValues): (internal error) illegal on void." << EidosTerminate(nullptr); @@ -966,12 +960,6 @@ EidosValue_SP EidosValue_NULL::GetValueAtIndex(const int p_idx, const EidosToken return gStaticEidosValueNULL; } -void EidosValue_NULL::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_NULL::SetValueAtIndex): operand type " << this->Type() << " does not support setting values with the subscript operator ('[]')." << EidosTerminate(p_blame_token); -} - EidosValue_SP EidosValue_NULL::CopyValues(void) const { return gStaticEidosValueNULL; @@ -1108,14 +1096,6 @@ EidosValue_SP EidosValue_Logical::GetValueAtIndex(const int p_idx, const EidosTo return (values_[p_idx] ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); } -void EidosValue_Logical::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ - if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - values_[p_idx] = p_value.LogicalAtIndex_CAST(0, p_blame_token); -} - EidosValue_SP EidosValue_Logical::CopyValues(void) const { return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(values_, count_))->CopyDimensionsFromValue(this)); @@ -1226,12 +1206,6 @@ EidosValue_SP EidosValue_Logical_const::VectorBasedCopy(void) const return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(values_, count_))->CopyDimensionsFromValue(this)); // same as EidosValue_Logical::, but let's not rely on that } -void EidosValue_Logical_const::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical_const::SetValueAtIndex): (internal error) EidosValue_Logical_const is not modifiable." << EidosTerminate(p_blame_token); -} - void EidosValue_Logical_const::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) @@ -1373,14 +1347,6 @@ EidosValue_SP EidosValue_String_vector::GetValueAtIndex(const int p_idx, const E return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(values_[p_idx])); } -void EidosValue_String_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ - if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - values_[p_idx] = p_value.StringAtIndex_CAST(0, p_blame_token); -} - EidosValue_SP EidosValue_String_vector::CopyValues(void) const { return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(values_))->CopyDimensionsFromValue(this)); @@ -1483,12 +1449,6 @@ EidosValue_SP EidosValue_String_singleton::VectorBasedCopy(void) const return new_vec; } -void EidosValue_String_singleton::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::SetValueAtIndex): (internal error) EidosValue_String_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - void EidosValue_String_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) @@ -1638,14 +1598,6 @@ EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const Eido return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(values_[p_idx])); } -void EidosValue_Int_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ - if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - values_[p_idx] = p_value.IntAtIndex_CAST(0, p_blame_token); -} - EidosValue_SP EidosValue_Int_vector::CopyValues(void) const { return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(values_, count_))->CopyDimensionsFromValue(this)); @@ -1784,12 +1736,6 @@ EidosValue_SP EidosValue_Int_singleton::VectorBasedCopy(void) const return new_vec; } -void EidosValue_Int_singleton::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::SetValueAtIndex): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - void EidosValue_Int_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) @@ -1931,14 +1877,6 @@ EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const Ei return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(values_[p_idx])); } -void EidosValue_Float_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ - if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - values_[p_idx] = p_value.FloatAtIndex_CAST(0, p_blame_token); -} - EidosValue_SP EidosValue_Float_vector::CopyValues(void) const { return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(values_, count_))->CopyDimensionsFromValue(this)); @@ -2092,12 +2030,6 @@ EidosValue_SP EidosValue_Float_singleton::VectorBasedCopy(void) const return new_vec; } -void EidosValue_Float_singleton::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::SetValueAtIndex): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - void EidosValue_Float_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) @@ -2364,25 +2296,6 @@ EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const E return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(values_[p_idx], Class())); } -void EidosValue_Object_vector::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ - if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - EidosObject *new_value = p_value.ObjectElementAtIndex_CAST(0, p_blame_token); - - DeclareClassFromElement(new_value); - - if (class_uses_retain_release_) - { - static_cast(new_value)->Retain(); // unsafe cast to avoid virtual function overhead - if (values_[p_idx]) - static_cast(values_[p_idx])->Release(); // unsafe cast to avoid virtual function overhead - } - - values_[p_idx] = new_value; -} - EidosValue_SP EidosValue_Object_vector::CopyValues(void) const { return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(*this))->CopyDimensionsFromValue(this)); @@ -3258,12 +3171,6 @@ EidosValue_SP EidosValue_Object_singleton::VectorBasedCopy(void) const return new_vec; } -void EidosValue_Object_singleton::SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_value) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::SetValueAtIndex): (internal error) EidosValue_Object_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - void EidosValue_Object_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index f65bf29d0..6c526d32d 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -202,7 +202,6 @@ class EidosValue // basic subscript access; abstract here since we want to force subclasses to define this virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const = 0; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) = 0; // fetching individual values; the CAST versions convert type if necessary, and (base class behavior) raise if impossible // these are relatively slow convenience accessors; to get values across a large vector, the XData() methods below are preferred @@ -362,7 +361,6 @@ class EidosValue_VOID final : public EidosValue virtual nlohmann::json JSONRepresentation(void) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; @@ -404,7 +402,6 @@ class EidosValue_NULL final : public EidosValue virtual nlohmann::json JSONRepresentation(void) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; @@ -470,7 +467,6 @@ class EidosValue_Logical : public EidosValue virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; @@ -527,7 +523,6 @@ class EidosValue_Logical_const final : public EidosValue_Logical // prohibited actions because this subclass represents only truly immutable objects virtual eidos_logical_t *LogicalData_Mutable(void) override { RaiseForImmutabilityCall(); } - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; }; @@ -567,7 +562,6 @@ class EidosValue_String : public EidosValue virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const = 0; // const reference for speed virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; virtual EidosValue_SP CopyValues(void) const override = 0; virtual EidosValue_SP NewMatchingType(void) const override; @@ -615,7 +609,6 @@ class EidosValue_String_vector final : public EidosValue_String virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; @@ -660,7 +653,6 @@ class EidosValue_String_singleton final : public EidosValue_String virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because there is no backing vector - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -703,7 +695,6 @@ class EidosValue_Int : public EidosValue virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; virtual EidosValue_SP CopyValues(void) const override = 0; virtual EidosValue_SP NewMatchingType(void) const override; @@ -746,7 +737,6 @@ class EidosValue_Int_vector final : public EidosValue_Int virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; @@ -815,7 +805,6 @@ class EidosValue_Int_singleton final : public EidosValue_Int virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because there is no backing vector - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; }; @@ -854,7 +843,6 @@ class EidosValue_Float : public EidosValue virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; virtual EidosValue_SP CopyValues(void) const override = 0; virtual EidosValue_SP NewMatchingType(void) const override; @@ -895,7 +883,6 @@ class EidosValue_Float_vector final : public EidosValue_Float virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; @@ -964,7 +951,6 @@ class EidosValue_Float_singleton final : public EidosValue_Float virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because there is no backing vector - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; }; @@ -1037,7 +1023,6 @@ class EidosValue_Object : public EidosValue virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override = 0; virtual EidosValue_SP CopyValues(void) const override = 0; virtual EidosValue_SP NewMatchingType(void) const override; @@ -1086,7 +1071,6 @@ class EidosValue_Object_vector final : public EidosValue_Object virtual EidosObject **ObjectData_Mutable(void) override { return values_; } virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual EidosValue_SP CopyValues(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; @@ -1341,7 +1325,6 @@ class EidosValue_Object_singleton final : public EidosValue_Object virtual EidosValue_SP VectorBasedCopy(void) const override; // prohibited actions because there is no backing vector - virtual void SetValueAtIndex(const int p_idx, const EidosValue &p_value, const EidosToken *p_blame_token) override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a @@ -1354,8 +1337,28 @@ class EidosValue_Object_singleton final : public EidosValue_Object // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) override; virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) override; + + // We support just this method, from EidosValue_Object_vector's suite of setters, for now + void set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index); // checks for retain/release }; +inline __attribute__((always_inline)) void EidosValue_Object_singleton::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) +{ +#if DEBUG + // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors + if (p_index >= 1) RaiseForRangeViolation(); + DeclareClassFromElement(p_object, true); // require a prior matching declaration +#endif + if (class_uses_retain_release_) + { + static_cast(p_object)->Retain(); // unsafe cast to avoid virtual function overhead + if (value_) + static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead + } + + value_ = p_object; +} + #endif /* defined(__Eidos__eidos_value__) */ From af069a7e69fb4a91701d7bc2f6a6e0961e896c52 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Thu, 21 Dec 2023 18:33:48 -0500 Subject: [PATCH 04/18] adding NumericAtIndex_NOCAST() --- eidos/eidos_ast_node.cpp | 4 +- eidos/eidos_functions_distributions.cpp | 132 ++++++++++++------------ eidos/eidos_functions_math.cpp | 48 ++++----- eidos/eidos_functions_stats.cpp | 30 +++--- eidos/eidos_functions_values.cpp | 12 +-- eidos/eidos_interpreter.cpp | 42 ++++---- eidos/eidos_value.cpp | 36 +++++++ eidos/eidos_value.h | 20 +++- 8 files changed, 188 insertions(+), 136 deletions(-) diff --git a/eidos/eidos_ast_node.cpp b/eidos/eidos_ast_node.cpp index 42064b533..b8fd69c85 100644 --- a/eidos/eidos_ast_node.cpp +++ b/eidos/eidos_ast_node.cpp @@ -391,14 +391,14 @@ bool EidosASTNode::HasCachedNumericValue(void) const double EidosASTNode::CachedNumericValue(void) const { if ((token_->token_type_ == EidosTokenType::kTokenNumber) && cached_literal_value_ && (cached_literal_value_->Count() == 1)) - return cached_literal_value_->FloatAtIndex_CAST(0, nullptr); + return cached_literal_value_->NumericAtIndex_NOCAST(0, nullptr); if ((token_->token_type_ == EidosTokenType::kTokenMinus) && (children_.size() == 1)) { const EidosASTNode *minus_child = children_[0]; if ((minus_child->token_->token_type_ == EidosTokenType::kTokenNumber) && minus_child->cached_literal_value_ && (minus_child->cached_literal_value_->Count() == 1)) - return -minus_child->cached_literal_value_->FloatAtIndex_CAST(0, nullptr); + return -minus_child->cached_literal_value_->NumericAtIndex_NOCAST(0, nullptr); } EIDOS_TERMINATION << "ERROR (EidosASTNode::CachedNumericValue): (internal error) no cached numeric value" << EidosTerminate(nullptr); diff --git a/eidos/eidos_functions_distributions.cpp b/eidos/eidos_functions_distributions.cpp index 94f0cc1b5..d65278588 100644 --- a/eidos/eidos_functions_distributions.cpp +++ b/eidos/eidos_functions_distributions.cpp @@ -357,13 +357,13 @@ EidosValue_SP Eidos_ExecuteFunction_dmvnorm(const std::vector &p_ try { for (int dim_index = 0; dim_index < d; ++dim_index) - gsl_vector_set(gsl_mu, dim_index, arg_mu->FloatAtIndex_CAST(dim_index, nullptr)); + gsl_vector_set(gsl_mu, dim_index, arg_mu->NumericAtIndex_NOCAST(dim_index, nullptr)); for (int row_index = 0; row_index < d; ++row_index) { for (int col_index = 0; col_index < d; ++col_index) { - double value = arg_sigma->FloatAtIndex_CAST(row_index + col_index * d, nullptr); + double value = arg_sigma->NumericAtIndex_NOCAST(row_index + col_index * d, nullptr); if (std::isnan(value)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dmvnorm): function dmvnorm() does not allow sigma to contain NANs." << EidosTerminate(nullptr); // oddly, GSL does not raise an error on this! @@ -468,8 +468,8 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dnorm): function dnorm() requires sd to be of length 1 or equal in length to x." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->NumericAtIndex_NOCAST(0, nullptr) : 1.0); if (mu_singleton && sigma_singleton) { @@ -508,8 +508,8 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar #pragma omp parallel for schedule(static) default(none) shared(num_quantiles) firstprivate(float_data, float_result, mu_singleton, sigma_singleton, mu0, sigma0, arg_mu, arg_sigma) reduction(||: saw_error) if(num_quantiles >= EIDOS_OMPMIN_DNORM_2) num_threads(thread_count) for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST(value_index, nullptr)); - double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex_CAST(value_index, nullptr)); + double mu = (mu_singleton ? mu0 : arg_mu->NumericAtIndex_NOCAST(value_index, nullptr)); + double sigma = (sigma_singleton ? sigma0 : arg_sigma->NumericAtIndex_NOCAST(value_index, nullptr)); if (sigma <= 0.0) { @@ -548,8 +548,8 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_probs)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_qnorm): function qnorm() requires sd to be of length 1 or equal in length to x." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->NumericAtIndex_NOCAST(0, nullptr) : 1.0); if (mu_singleton && sigma_singleton) { @@ -585,8 +585,8 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar for (int value_index = 0; value_index < num_probs; ++value_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST(value_index, nullptr)); - double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex_CAST(value_index, nullptr)); + double mu = (mu_singleton ? mu0 : arg_mu->NumericAtIndex_NOCAST(value_index, nullptr)); + double sigma = (sigma_singleton ? sigma0 : arg_sigma->NumericAtIndex_NOCAST(value_index, nullptr)); if (float_data[value_index] < 0.0 || float_data[value_index] > 1.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_qnorm): function qnorm() requires 0.0 <= p <= 1.0 (" << EidosStringForFloat(float_data[value_index]) << " supplied)." << EidosTerminate(nullptr); @@ -622,8 +622,8 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_pnorm): function pnorm() requires sd to be of length 1 or equal in length to q." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->NumericAtIndex_NOCAST(0, nullptr) : 1.0); if (mu_singleton && sigma_singleton) { @@ -652,8 +652,8 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST(value_index, nullptr)); - double sigma = (sigma_singleton ? sigma0 : arg_sigma->FloatAtIndex_CAST(value_index, nullptr)); + double mu = (mu_singleton ? mu0 : arg_mu->NumericAtIndex_NOCAST(value_index, nullptr)); + double sigma = (sigma_singleton ? sigma0 : arg_sigma->NumericAtIndex_NOCAST(value_index, nullptr)); if (sigma <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_pnorm): function pnorm() requires sd > 0.0 (" << EidosStringForFloat(sigma) << " supplied)." << EidosTerminate(nullptr); @@ -686,8 +686,8 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar if (!beta_singleton && (arg_beta_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dbeta): function dbeta() requires beta to be of length 1 or equal in length to x." << EidosTerminate(nullptr); - double alpha0 = (arg_alpha_count ? arg_alpha->FloatAtIndex_CAST(0, nullptr) : 0.0); - double beta0 = (arg_beta_count ? arg_beta->FloatAtIndex_CAST(0, nullptr) : 0.0); + double alpha0 = (arg_alpha_count ? arg_alpha->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double beta0 = (arg_beta_count ? arg_beta->NumericAtIndex_NOCAST(0, nullptr) : 0.0); if (alpha_singleton && beta_singleton) { @@ -718,8 +718,8 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double alpha = (alpha_singleton ? alpha0 : arg_alpha->FloatAtIndex_CAST(value_index, nullptr)); - double beta = (beta_singleton ? beta0 : arg_beta->FloatAtIndex_CAST(value_index, nullptr)); + double alpha = (alpha_singleton ? alpha0 : arg_alpha->NumericAtIndex_NOCAST(value_index, nullptr)); + double beta = (beta_singleton ? beta0 : arg_beta->NumericAtIndex_NOCAST(value_index, nullptr)); if (!(alpha > 0.0)) // true for NaN EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dbeta): function dbeta() requires alpha > 0.0 (" << EidosStringForFloat(alpha) << " supplied)." << EidosTerminate(nullptr); @@ -756,8 +756,8 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar if (!beta_singleton && (arg_beta_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rbeta): function rbeta() requires beta to be of length 1 or n." << EidosTerminate(nullptr); - double alpha0 = (arg_alpha_count ? arg_alpha->FloatAtIndex_CAST(0, nullptr) : 0.0); - double beta0 = (arg_beta_count ? arg_beta->FloatAtIndex_CAST(0, nullptr) : 0.0); + double alpha0 = (arg_alpha_count ? arg_alpha->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double beta0 = (arg_beta_count ? arg_beta->NumericAtIndex_NOCAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (alpha_singleton && beta_singleton) @@ -787,8 +787,8 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double alpha = (alpha_singleton ? alpha0 : arg_alpha->FloatAtIndex_CAST(draw_index, nullptr)); - double beta = (beta_singleton ? beta0 : arg_beta->FloatAtIndex_CAST(draw_index, nullptr)); + double alpha = (alpha_singleton ? alpha0 : arg_alpha->NumericAtIndex_NOCAST(draw_index, nullptr)); + double beta = (beta_singleton ? beta0 : arg_beta->NumericAtIndex_NOCAST(draw_index, nullptr)); if (alpha <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rbeta): function rbeta() requires alpha > 0.0 (" << EidosStringForFloat(alpha) << " supplied)." << EidosTerminate(nullptr); @@ -946,8 +946,8 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ if (!scale_singleton && (arg_scale_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rcauchy): function rcauchy() requires scale to be of length 1 or n." << EidosTerminate(nullptr); - double location0 = (arg_location_count ? arg_location->FloatAtIndex_CAST(0, nullptr) : 0.0); - double scale0 = (arg_scale_count ? arg_scale->FloatAtIndex_CAST(0, nullptr) : 1.0); + double location0 = (arg_location_count ? arg_location->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double scale0 = (arg_scale_count ? arg_scale->NumericAtIndex_NOCAST(0, nullptr) : 1.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (location_singleton && scale_singleton) @@ -975,8 +975,8 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double location = (location_singleton ? location0 : arg_location->FloatAtIndex_CAST(draw_index, nullptr)); - double scale = (scale_singleton ? scale0 : arg_scale->FloatAtIndex_CAST(draw_index, nullptr)); + double location = (location_singleton ? location0 : arg_location->NumericAtIndex_NOCAST(draw_index, nullptr)); + double scale = (scale_singleton ? scale0 : arg_scale->NumericAtIndex_NOCAST(draw_index, nullptr)); if (scale <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rcauchy): function rcauchy() requires scale > 0.0 (" << EidosStringForFloat(scale) << " supplied)." << EidosTerminate(nullptr); @@ -1121,7 +1121,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg if (mu_singleton) { - double mu0 = arg_mu->FloatAtIndex_CAST(0, nullptr); + double mu0 = arg_mu->NumericAtIndex_NOCAST(0, nullptr); if (num_quantiles == 1) { @@ -1145,7 +1145,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mu = arg_mu->FloatAtIndex_CAST(value_index, nullptr); + double mu = arg_mu->NumericAtIndex_NOCAST(value_index, nullptr); float_result->set_float_no_check(gsl_ran_exponential_pdf(float_data[value_index], mu), value_index); } @@ -1174,7 +1174,7 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg if (mu_singleton) { - double mu0 = arg_mu->FloatAtIndex_CAST(0, nullptr); + double mu0 = arg_mu->NumericAtIndex_NOCAST(0, nullptr); if (num_draws == 1) { @@ -1211,7 +1211,7 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double mu = arg_mu->FloatAtIndex_CAST((int)draw_index, nullptr); + double mu = arg_mu->NumericAtIndex_NOCAST((int)draw_index, nullptr); float_result->set_float_no_check(gsl_ran_exponential(rng, mu), draw_index); } @@ -1244,8 +1244,8 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum if (!d2_singleton && (arg_d2_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rf): function rf() requires d2 to be of length 1 or n." << EidosTerminate(nullptr); - double d1_0 = (arg_d1_count ? arg_d1->FloatAtIndex_CAST(0, nullptr) : 0.0); - double d2_0 = (arg_d2_count ? arg_d2->FloatAtIndex_CAST(0, nullptr) : 0.0); + double d1_0 = (arg_d1_count ? arg_d1->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double d2_0 = (arg_d2_count ? arg_d2->NumericAtIndex_NOCAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (d1_singleton && d2_singleton) @@ -1275,8 +1275,8 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double d1 = (d1_singleton ? d1_0 : arg_d1->FloatAtIndex_CAST(draw_index, nullptr)); - double d2 = (d2_singleton ? d2_0 : arg_d2->FloatAtIndex_CAST(draw_index, nullptr)); + double d1 = (d1_singleton ? d1_0 : arg_d1->NumericAtIndex_NOCAST(draw_index, nullptr)); + double d2 = (d2_singleton ? d2_0 : arg_d2->NumericAtIndex_NOCAST(draw_index, nullptr)); if (d1 <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rf): function rf() requires d1 > 0.0 (" << EidosStringForFloat(d1) << " supplied)." << EidosTerminate(nullptr); @@ -1311,8 +1311,8 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a if (!shape_singleton && (arg_shape_count != num_quantiles)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dgamma): function dgamma() requires shape to be of length 1 or n." << EidosTerminate(nullptr); - double mean0 = (arg_mean_count ? arg_mean->FloatAtIndex_CAST(0, nullptr) : 1.0); - double shape0 = (arg_shape_count ? arg_shape->FloatAtIndex_CAST(0, nullptr) : 0.0); + double mean0 = (arg_mean_count ? arg_mean->NumericAtIndex_NOCAST(0, nullptr) : 1.0); + double shape0 = (arg_shape_count ? arg_shape->NumericAtIndex_NOCAST(0, nullptr) : 0.0); if (mean_singleton && shape_singleton) { @@ -1343,8 +1343,8 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a for (int value_index = 0; value_index < num_quantiles; ++value_index) { - double mean = (mean_singleton ? mean0 : arg_mean->FloatAtIndex_CAST(value_index, nullptr)); - double shape = (shape_singleton ? shape0 : arg_shape->FloatAtIndex_CAST(value_index, nullptr)); + double mean = (mean_singleton ? mean0 : arg_mean->NumericAtIndex_NOCAST(value_index, nullptr)); + double shape = (shape_singleton ? shape0 : arg_shape->NumericAtIndex_NOCAST(value_index, nullptr)); if (!(shape > 0.0)) // true for NaN EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_dgamma): function dgamma() requires shape > 0.0 (" << EidosStringForFloat(shape) << " supplied)." << EidosTerminate(nullptr); @@ -1379,8 +1379,8 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a if (!shape_singleton && (arg_shape_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgamma): function rgamma() requires shape to be of length 1 or n." << EidosTerminate(nullptr); - double mean0 = (arg_mean_count ? arg_mean->FloatAtIndex_CAST(0, nullptr) : 1.0); - double shape0 = (arg_shape_count ? arg_shape->FloatAtIndex_CAST(0, nullptr) : 0.0); + double mean0 = (arg_mean_count ? arg_mean->NumericAtIndex_NOCAST(0, nullptr) : 1.0); + double shape0 = (arg_shape_count ? arg_shape->NumericAtIndex_NOCAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (mean_singleton && shape_singleton) @@ -1410,8 +1410,8 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double mean = (mean_singleton ? mean0 : arg_mean->FloatAtIndex_CAST(draw_index, nullptr)); - double shape = (shape_singleton ? shape0 : arg_shape->FloatAtIndex_CAST(draw_index, nullptr)); + double mean = (mean_singleton ? mean0 : arg_mean->NumericAtIndex_NOCAST(draw_index, nullptr)); + double shape = (shape_singleton ? shape0 : arg_shape->NumericAtIndex_NOCAST(draw_index, nullptr)); if (shape <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgamma): function rgamma() requires shape > 0.0 (" << EidosStringForFloat(shape) << " supplied)." << EidosTerminate(nullptr); @@ -1525,8 +1525,8 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a if (!sdlog_singleton && (arg_sdlog_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rlnorm): function rlnorm() requires sdlog to be of length 1 or n." << EidosTerminate(nullptr); - double meanlog0 = (arg_meanlog_count ? arg_meanlog->FloatAtIndex_CAST(0, nullptr) : 0.0); - double sdlog0 = (arg_sdlog_count ? arg_sdlog->FloatAtIndex_CAST(0, nullptr) : 1.0); + double meanlog0 = (arg_meanlog_count ? arg_meanlog->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double sdlog0 = (arg_sdlog_count ? arg_sdlog->NumericAtIndex_NOCAST(0, nullptr) : 1.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (meanlog_singleton && sdlog_singleton) @@ -1551,8 +1551,8 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double meanlog = (meanlog_singleton ? meanlog0 : arg_meanlog->FloatAtIndex_CAST(draw_index, nullptr)); - double sdlog = (sdlog_singleton ? sdlog0 : arg_sdlog->FloatAtIndex_CAST(draw_index, nullptr)); + double meanlog = (meanlog_singleton ? meanlog0 : arg_meanlog->NumericAtIndex_NOCAST(draw_index, nullptr)); + double sdlog = (sdlog_singleton ? sdlog0 : arg_sdlog->NumericAtIndex_NOCAST(draw_index, nullptr)); float_result->set_float_no_check(gsl_ran_lognormal(rng, meanlog, sdlog), draw_index); } @@ -1588,7 +1588,7 @@ EidosValue_SP Eidos_ExecuteFunction_rmvnorm(const std::vector &p_ for (int row_index = 0; row_index < d; ++row_index) for (int col_index = 0; col_index < d; ++col_index) - if (std::isnan(arg_sigma->FloatAtIndex_CAST(row_index + col_index * d, nullptr))) + if (std::isnan(arg_sigma->NumericAtIndex_NOCAST(row_index + col_index * d, nullptr))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rmvnorm): function rmvnorm() does not allow sigma to contain NANs." << EidosTerminate(nullptr); // oddly, GSL does not raise an error on this! // Set up the GSL vectors @@ -1601,11 +1601,11 @@ EidosValue_SP Eidos_ExecuteFunction_rmvnorm(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rmvnorm): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); for (int dim_index = 0; dim_index < d; ++dim_index) - gsl_vector_set(gsl_mu, dim_index, arg_mu->FloatAtIndex_CAST(dim_index, nullptr)); + gsl_vector_set(gsl_mu, dim_index, arg_mu->NumericAtIndex_NOCAST(dim_index, nullptr)); for (int row_index = 0; row_index < d; ++row_index) for (int col_index = 0; col_index < d; ++col_index) - gsl_matrix_set(gsl_Sigma, row_index, col_index, arg_sigma->FloatAtIndex_CAST(row_index + col_index * d, nullptr)); + gsl_matrix_set(gsl_Sigma, row_index, col_index, arg_sigma->NumericAtIndex_NOCAST(row_index + col_index * d, nullptr)); gsl_matrix_memcpy(gsl_L, gsl_Sigma); @@ -1695,7 +1695,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ if (!prob_singleton && (arg_prob_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnbinom): function rnbinom() requires prob to be of length 1 or n." << EidosTerminate(nullptr); - double size0 = arg_size->FloatAtIndex_CAST(0, nullptr); + double size0 = arg_size->NumericAtIndex_NOCAST(0, nullptr); double probability0 = arg_prob->FloatAtIndex_NOCAST(0, nullptr); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); @@ -1726,7 +1726,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double size = (size_singleton ? size0 : arg_size->FloatAtIndex_CAST(draw_index, nullptr)); + double size = (size_singleton ? size0 : arg_size->NumericAtIndex_NOCAST(draw_index, nullptr)); double probability = (prob_singleton ? probability0 : arg_prob->FloatAtIndex_NOCAST(draw_index, nullptr)); if ((size < 0) || std::isnan(size)) @@ -1764,8 +1764,8 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar if (!sigma_singleton && (arg_sigma_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnorm): function rnorm() requires sd to be of length 1 or n." << EidosTerminate(nullptr); - double mu0 = (arg_mu_count ? arg_mu->FloatAtIndex_CAST(0, nullptr) : 0.0); - double sigma0 = (arg_sigma_count ? arg_sigma->FloatAtIndex_CAST(0, nullptr) : 1.0); + double mu0 = (arg_mu_count ? arg_mu->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double sigma0 = (arg_sigma_count ? arg_sigma->NumericAtIndex_NOCAST(0, nullptr) : 1.0); if (sigma_singleton && (sigma0 < 0.0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rnorm): function rnorm() requires sd >= 0.0 (" << EidosStringForFloat(sigma0) << " supplied)." << EidosTerminate(nullptr); @@ -1802,7 +1802,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double mu = arg_mu->FloatAtIndex_CAST((int)draw_index, nullptr); + double mu = arg_mu->NumericAtIndex_NOCAST((int)draw_index, nullptr); float_result->set_float_no_check(gsl_ran_gaussian(rng, sigma0) + mu, draw_index); } @@ -1820,8 +1820,8 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double mu = (mu_singleton ? mu0 : arg_mu->FloatAtIndex_CAST((int)draw_index, nullptr)); - double sigma = arg_sigma->FloatAtIndex_CAST((int)draw_index, nullptr); + double mu = (mu_singleton ? mu0 : arg_mu->NumericAtIndex_NOCAST((int)draw_index, nullptr)); + double sigma = arg_sigma->NumericAtIndex_NOCAST((int)draw_index, nullptr); if (sigma < 0.0) { @@ -1864,7 +1864,7 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar if (lambda_singleton) { - double lambda0 = arg_lambda->FloatAtIndex_CAST(0, nullptr); + double lambda0 = arg_lambda->NumericAtIndex_NOCAST(0, nullptr); if ((lambda0 <= 0.0) || std::isnan(lambda0)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rpois): function rpois() requires lambda > 0.0 (" << EidosStringForFloat(lambda0) << " supplied)." << EidosTerminate(nullptr); @@ -1906,7 +1906,7 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar #pragma omp for schedule(dynamic, 1024) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double lambda = arg_lambda->FloatAtIndex_CAST((int)draw_index, nullptr); + double lambda = arg_lambda->NumericAtIndex_NOCAST((int)draw_index, nullptr); if ((lambda <= 0.0) || std::isnan(lambda)) { @@ -1948,8 +1948,8 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar if (!max_singleton && (arg_max_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_runif): function runif() requires max to be of length 1 or n." << EidosTerminate(nullptr); - double min_value0 = (arg_min_count ? arg_min->FloatAtIndex_CAST(0, nullptr) : 0.0); - double max_value0 = (arg_max_count ? arg_max->FloatAtIndex_CAST(0, nullptr) : 1.0); + double min_value0 = (arg_min_count ? arg_min->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double max_value0 = (arg_max_count ? arg_max->NumericAtIndex_NOCAST(0, nullptr) : 1.0); if (min_singleton && max_singleton && (min_value0 == 0.0) && (max_value0 == 1.0)) { @@ -2022,8 +2022,8 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar #pragma omp for schedule(static) nowait for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) { - double min_value = (min_singleton ? min_value0 : arg_min->FloatAtIndex_CAST((int)draw_index, nullptr)); - double max_value = (max_singleton ? max_value0 : arg_max->FloatAtIndex_CAST((int)draw_index, nullptr)); + double min_value = (min_singleton ? min_value0 : arg_min->NumericAtIndex_NOCAST((int)draw_index, nullptr)); + double max_value = (max_singleton ? max_value0 : arg_max->NumericAtIndex_NOCAST((int)draw_index, nullptr)); double range = max_value - min_value; if (range < 0.0) @@ -2067,8 +2067,8 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p if (!k_singleton && (arg_k_count != num_draws)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rweibull): function rweibull() requires k to be of length 1 or n." << EidosTerminate(nullptr); - double lambda0 = (arg_lambda_count ? arg_lambda->FloatAtIndex_CAST(0, nullptr) : 0.0); - double k0 = (arg_k_count ? arg_k->FloatAtIndex_CAST(0, nullptr) : 0.0); + double lambda0 = (arg_lambda_count ? arg_lambda->NumericAtIndex_NOCAST(0, nullptr) : 0.0); + double k0 = (arg_k_count ? arg_k->NumericAtIndex_NOCAST(0, nullptr) : 0.0); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); if (lambda_singleton && k_singleton) @@ -2098,8 +2098,8 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p for (int draw_index = 0; draw_index < num_draws; ++draw_index) { - double lambda = (lambda_singleton ? lambda0 : arg_lambda->FloatAtIndex_CAST(draw_index, nullptr)); - double k = (k_singleton ? k0 : arg_k->FloatAtIndex_CAST(draw_index, nullptr)); + double lambda = (lambda_singleton ? lambda0 : arg_lambda->NumericAtIndex_NOCAST(draw_index, nullptr)); + double k = (k_singleton ? k0 : arg_k->NumericAtIndex_NOCAST(draw_index, nullptr)); if (lambda <= 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rweibull): function rweibull() requires lambda > 0.0 (" << EidosStringForFloat(lambda) << " supplied)." << EidosTerminate(nullptr); diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 728253d69..7c81c0cb5 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -135,7 +135,7 @@ EidosValue_SP Eidos_ExecuteFunction_acos(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(acos(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(acos(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -143,7 +143,7 @@ EidosValue_SP Eidos_ExecuteFunction_acos(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(acos(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(acos(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -161,7 +161,7 @@ EidosValue_SP Eidos_ExecuteFunction_asin(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(asin(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(asin(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -169,7 +169,7 @@ EidosValue_SP Eidos_ExecuteFunction_asin(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(asin(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(asin(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -187,7 +187,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -195,7 +195,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(atan(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(atan(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -226,7 +226,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan2(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan2(x_value->FloatAtIndex_CAST(0, nullptr), y_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan2(x_value->NumericAtIndex_NOCAST(0, nullptr), y_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -234,7 +234,7 @@ EidosValue_SP Eidos_ExecuteFunction_atan2(const std::vector &p_ar result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(atan2(x_value->FloatAtIndex_CAST(value_index, nullptr), y_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(atan2(x_value->NumericAtIndex_NOCAST(value_index, nullptr), y_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } // Copy dimensions from whichever operand we chose at the beginning @@ -284,7 +284,7 @@ EidosValue_SP Eidos_ExecuteFunction_cos(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cos(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cos(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -292,7 +292,7 @@ EidosValue_SP Eidos_ExecuteFunction_cos(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(cos(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(cos(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -437,7 +437,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(exp(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(exp(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -445,7 +445,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(exp(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(exp(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -805,7 +805,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -813,7 +813,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(log(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(log(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -844,7 +844,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log10(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log10(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -852,7 +852,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(log10(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(log10(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -883,7 +883,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log2(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log2(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -891,7 +891,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(log2(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(log2(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -2532,7 +2532,7 @@ EidosValue_SP Eidos_ExecuteFunction_sin(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sin(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sin(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -2540,7 +2540,7 @@ EidosValue_SP Eidos_ExecuteFunction_sin(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(sin(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(sin(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); @@ -2559,7 +2559,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sqrt(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sqrt(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { @@ -2567,7 +2567,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(sqrt(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(sqrt(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } else if (x_type == EidosValueType::kValueFloat) { @@ -2733,7 +2733,7 @@ EidosValue_SP Eidos_ExecuteFunction_tan(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(tan(x_value->FloatAtIndex_CAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(tan(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { @@ -2741,7 +2741,7 @@ EidosValue_SP Eidos_ExecuteFunction_tan(const std::vector &p_argu result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) - float_result->set_float_no_check(tan(x_value->FloatAtIndex_CAST(value_index, nullptr)), value_index); + float_result->set_float_no_check(tan(x_value->NumericAtIndex_NOCAST(value_index, nullptr)), value_index); } result_SP->CopyDimensionsFromValue(x_value); diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index c1e064b33..e82c727f2 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -58,8 +58,8 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - mean_x += x_value->FloatAtIndex_CAST(value_index, nullptr); - mean_y += y_value->FloatAtIndex_CAST(value_index, nullptr); + mean_x += x_value->NumericAtIndex_NOCAST(value_index, nullptr); + mean_y += y_value->NumericAtIndex_NOCAST(value_index, nullptr); } mean_x /= count; @@ -70,8 +70,8 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - double dx = x_value->FloatAtIndex_CAST(value_index, nullptr) - mean_x; - double dy = y_value->FloatAtIndex_CAST(value_index, nullptr) - mean_y; + double dx = x_value->NumericAtIndex_NOCAST(value_index, nullptr) - mean_x; + double dy = y_value->NumericAtIndex_NOCAST(value_index, nullptr) - mean_y; ss_x += dx * dx; ss_y += dy * dy; @@ -112,8 +112,8 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - mean_x += x_value->FloatAtIndex_CAST(value_index, nullptr); - mean_y += y_value->FloatAtIndex_CAST(value_index, nullptr); + mean_x += x_value->NumericAtIndex_NOCAST(value_index, nullptr); + mean_y += y_value->NumericAtIndex_NOCAST(value_index, nullptr); } mean_x /= count; @@ -124,8 +124,8 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu for (int value_index = 0; value_index < count; ++value_index) { - double temp_x = (x_value->FloatAtIndex_CAST(value_index, nullptr) - mean_x); - double temp_y = (y_value->FloatAtIndex_CAST(value_index, nullptr) - mean_y); + double temp_x = (x_value->NumericAtIndex_NOCAST(value_index, nullptr) - mean_x); + double temp_y = (y_value->NumericAtIndex_NOCAST(value_index, nullptr) - mean_y); cov += temp_x * temp_y; } @@ -954,7 +954,7 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p if (x_count == 1) { // All quantiles of a singleton are the value of the singleton; the probabilities don't matter as long as they're in range (checked above) - double x_singleton = x_value->FloatAtIndex_CAST(0, nullptr); + double x_singleton = x_value->NumericAtIndex_NOCAST(0, nullptr); if (std::isnan(x_singleton)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_quantile): quantiles of NAN are undefined." << EidosTerminate(nullptr); @@ -993,11 +993,11 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p int64_t lo = (int64_t)std::floor(index); int64_t hi = (int64_t)std::ceil(index); - double quantile = x_value->FloatAtIndex_CAST((int)order[lo], nullptr); + double quantile = x_value->NumericAtIndex_NOCAST((int)order[lo], nullptr); if (lo != hi) { double h = index - lo; quantile *= (1.0 - h); - quantile += h * x_value->FloatAtIndex_CAST((int)order[hi], nullptr); + quantile += h * x_value->NumericAtIndex_NOCAST((int)order[hi], nullptr); } float_result->set_float_no_check(quantile, probs_index); @@ -1162,13 +1162,13 @@ EidosValue_SP Eidos_ExecuteFunction_sd(const std::vector &p_argum double sd = 0; for (int value_index = 0; value_index < x_count; ++value_index) - mean += x_value->FloatAtIndex_CAST(value_index, nullptr); + mean += x_value->NumericAtIndex_NOCAST(value_index, nullptr); mean /= x_count; for (int value_index = 0; value_index < x_count; ++value_index) { - double temp = (x_value->FloatAtIndex_CAST(value_index, nullptr) - mean); + double temp = (x_value->NumericAtIndex_NOCAST(value_index, nullptr) - mean); sd += temp * temp; } @@ -1250,7 +1250,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu double mean = 0; for (int value_index = 0; value_index < x_count; ++value_index) - mean += x_value->FloatAtIndex_CAST(value_index, nullptr); + mean += x_value->NumericAtIndex_NOCAST(value_index, nullptr); mean /= x_count; @@ -1259,7 +1259,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu for (int value_index = 0; value_index < x_count; ++value_index) { - double temp = (x_value->FloatAtIndex_CAST(value_index, nullptr) - mean); + double temp = (x_value->NumericAtIndex_NOCAST(value_index, nullptr) - mean); var += temp * temp; } diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 63e532a21..8c39ecefe 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -316,7 +316,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a if (weights_count == 1) { - double weight = weights_value->FloatAtIndex_CAST(0, nullptr); + double weight = weights_value->NumericAtIndex_NOCAST(0, nullptr); if ((weight < 0.0) || std::isnan(weight)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_sample): function sample() requires all weights to be non-negative (" << EidosStringForFloat(weight) << " supplied)." << EidosTerminate(nullptr); @@ -924,8 +924,8 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if ((from_type == EidosValueType::kValueFloat) || (to_type == EidosValueType::kValueFloat)) { // a float value was given, so we will generate a float sequence in all cases - double first_value = from_value->FloatAtIndex_CAST(0, nullptr); - double second_value = to_value->FloatAtIndex_CAST(0, nullptr); + double first_value = from_value->NumericAtIndex_NOCAST(0, nullptr); + double second_value = to_value->NumericAtIndex_NOCAST(0, nullptr); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(length); result_SP = EidosValue_SP(float_result); @@ -986,10 +986,10 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if ((from_type == EidosValueType::kValueFloat) || (to_type == EidosValueType::kValueFloat) || (by_type == EidosValueType::kValueFloat)) { // float return case - double first_value = from_value->FloatAtIndex_CAST(0, nullptr); - double second_value = to_value->FloatAtIndex_CAST(0, nullptr); + double first_value = from_value->NumericAtIndex_NOCAST(0, nullptr); + double second_value = to_value->NumericAtIndex_NOCAST(0, nullptr); double default_by = ((first_value < second_value) ? 1 : -1); - double by = ((by_type != EidosValueType::kValueNULL) ? by_value->FloatAtIndex_CAST(0, nullptr) : default_by); + double by = ((by_type != EidosValueType::kValueNULL) ? by_value->NumericAtIndex_NOCAST(0, nullptr) : default_by); if (by == 0.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() requires by != 0." << EidosTerminate(nullptr); diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 57030ecf3..68be694da 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -991,8 +991,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode } else { - double first_float = p_first_child_value.FloatAtIndex_CAST(0, operator_token); - double second_float = p_second_child_value.FloatAtIndex_CAST(0, operator_token); + double first_float = p_first_child_value.NumericAtIndex_NOCAST(0, operator_token); + double second_float = p_second_child_value.NumericAtIndex_NOCAST(0, operator_token); if (std::isnan(first_float) || std::isnan(second_float)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_Evaluate_RangeExpr_Internal): operands of the ':' operator must not be NAN." << EidosTerminate(operator_token); @@ -2153,7 +2153,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) + second_child_value->FloatAtIndex_CAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) + second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { @@ -2190,7 +2190,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2213,7 +2213,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2453,7 +2453,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) - second_child_value->FloatAtIndex_CAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) - second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { @@ -2490,7 +2490,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2513,7 +2513,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2587,7 +2587,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fmod(first_child_value->FloatAtIndex_CAST(0, operator_token), second_child_value->FloatAtIndex_CAST(0, operator_token)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fmod(first_child_value->NumericAtIndex_NOCAST(0, operator_token), second_child_value->NumericAtIndex_NOCAST(0, operator_token)))); } else { @@ -2632,7 +2632,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -2655,7 +2655,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -2769,7 +2769,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) * second_child_value->FloatAtIndex_CAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) * second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { @@ -2855,7 +2855,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) else if (any_type == EidosValueType::kValueInt) { const int64_t *any_count_data = any_count_child->IntData(); - double singleton_float = one_count_child->FloatAtIndex_CAST(0, operator_token); + double singleton_float = one_count_child->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2867,7 +2867,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) else // (any_type == EidosValueType::kValueFloat) { const double *any_count_data = any_count_child->FloatData(); - double singleton_float = one_count_child->FloatAtIndex_CAST(0, operator_token); + double singleton_float = one_count_child->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); @@ -2932,7 +2932,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->FloatAtIndex_CAST(0, operator_token) / second_child_value->FloatAtIndex_CAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) / second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { @@ -2977,7 +2977,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -3000,7 +3000,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -3109,7 +3109,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(pow(first_child_value->FloatAtIndex_CAST(0, operator_token), second_child_value->FloatAtIndex_CAST(0, operator_token)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(pow(first_child_value->NumericAtIndex_NOCAST(0, operator_token), second_child_value->NumericAtIndex_NOCAST(0, operator_token)))); } else { @@ -3154,7 +3154,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) } else if (first_child_count == 1) { - double singleton_float = first_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); @@ -3177,7 +3177,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) } else if (second_child_count == 1) { - double singleton_float = second_child_value->FloatAtIndex_CAST(0, operator_token); + double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); @@ -3865,7 +3865,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) EidosASTNode *rvalue_node = p_node->children_[1]; // the operator node EidosValue *cached_operand2 = rvalue_node->children_[1]->cached_literal_value_.get(); // the numeric constant EidosTokenType compound_operator = rvalue_node->token_->token_type_; - double operand2_value = cached_operand2->FloatAtIndex_CAST(0, nullptr); // might be an int64_t and get converted + double operand2_value = cached_operand2->NumericAtIndex_NOCAST(0, nullptr); // might be an int64_t and get converted if ((lvalue_count == 1) && lvalue->IsSingleton()) { diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 6a7533b37..1fa2102da 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1558,6 +1558,15 @@ int64_t EidosValue_Int_vector::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_ return values_[p_idx]; } +double EidosValue_Int_vector::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + // casts integer to float, otherwise does not cast; considered _NOCAST + if ((p_idx < 0) || (p_idx >= (int)count_)) + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return values_[p_idx]; +} + eidos_logical_t EidosValue_Int_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) @@ -1680,6 +1689,15 @@ int64_t EidosValue_Int_singleton::IntAtIndex_NOCAST(int p_idx, const EidosToken return value_; } +double EidosValue_Int_singleton::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + // casts integer to float, otherwise does not cast; considered _NOCAST + if (p_idx != 0) + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return value_; +} + eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) @@ -1821,6 +1839,15 @@ double EidosValue_Float_vector::FloatAtIndex_NOCAST(int p_idx, const EidosToken return values_[p_idx]; } +double EidosValue_Float_vector::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + // casts integer to float, otherwise does not cast; considered _NOCAST + if ((p_idx < 0) || (p_idx >= (int)count_)) + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return values_[p_idx]; +} + eidos_logical_t EidosValue_Float_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) @@ -1962,6 +1989,15 @@ double EidosValue_Float_singleton::FloatAtIndex_NOCAST(int p_idx, const EidosTok return value_; } +double EidosValue_Float_singleton::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +{ + // casts integer to float, otherwise does not cast; considered _NOCAST + if (p_idx != 0) + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + + return value_; +} + eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 6c526d32d..6185d7209 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -203,14 +203,26 @@ class EidosValue // basic subscript access; abstract here since we want to force subclasses to define this virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const = 0; - // fetching individual values; the CAST versions convert type if necessary, and (base class behavior) raise if impossible - // these are relatively slow convenience accessors; to get values across a large vector, the XData() methods below are preferred + // fetching individual values WITHOUT casting; the base class behavior is to raise if the type does not match + // these are convenience accessors; to get values across a large vector, the XData() methods below are preferred + // note that NumericAtIndex_NOCAST() accesses "numeric" values (integer or float), casting them to float, + // so it is technically a casting method, but "numeric" is privileged and is not considered full casting virtual eidos_logical_t LogicalAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } virtual std::string StringAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } virtual int64_t IntAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } virtual double FloatAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } // casts integer to float, otherwise does not cast; considered _NOCAST virtual EidosObject *ObjectElementAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } + // fetching individual values WITH a cast to the requested type; this is not general-purpose + // behavior for Eidos, but is limited to specific places in the language: CompareEidosValues(), + // _ProcessSubsetAssignment() to allow float indices for subsetting, _AssignRValueToLValue() to + // put a value of one type into a specific index in an existing vector, Evaluate_Subset() again + // for float subsetting indices, string + in EvaluatePlus(), Evaluate_Conditional() to cast any + // value to logical for the condition (and likewise for EvaluateIf(), Evaluate_Do(), and + // Evaluate_While()), Evaluate_And() / Evaluate_Or() / Evaluate_Not() to cast values to logical, + // and Evaluate_Eq() and the other comparison operators, == < <= > >= != + // BCH 12/21/2023: FIXME: float indices for subsetting should be reconsidered, it is a bad idea virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; @@ -730,6 +742,7 @@ class EidosValue_Int_vector final : public EidosValue_Int virtual int64_t *IntData_Mutable(void) override { return values_; } virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -793,6 +806,7 @@ class EidosValue_Int_singleton final : public EidosValue_Int inline __attribute__((always_inline)) void SetValue(int64_t p_int) { value_ = p_int; } // very dangerous; used only in Evaluate_For() virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -876,6 +890,7 @@ class EidosValue_Float_vector final : public EidosValue_Float virtual double *FloatData_Mutable(void) override { return values_; } virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -939,6 +954,7 @@ class EidosValue_Float_singleton final : public EidosValue_Float inline __attribute__((always_inline)) void SetValue(double p_float) { value_ = p_float; } // very dangerous; used only in Evaluate_For() virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; From 1260d94243ce4823a276bd65a247d5a2241a8a3d Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Thu, 21 Dec 2023 18:42:42 -0500 Subject: [PATCH 05/18] fix error attributions for EidosValue --- eidos/eidos_value.cpp | 112 +++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 1fa2102da..1b907f78b 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -342,31 +342,31 @@ EidosValue::~EidosValue(void) eidos_logical_t EidosValue::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) - EIDOS_TERMINATION << "ERROR (EidosValue::LogicalAtIndex): operand type " << this->Type() << " cannot be converted to type logical." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue::LogicalAtIndex_CAST): operand type " << this->Type() << " cannot be converted to type logical." << EidosTerminate(p_blame_token); } std::string EidosValue::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) - EIDOS_TERMINATION << "ERROR (EidosValue::StringAtIndex): operand type " << this->Type() << " cannot be converted to type string." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue::StringAtIndex_CAST): operand type " << this->Type() << " cannot be converted to type string." << EidosTerminate(p_blame_token); } int64_t EidosValue::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) - EIDOS_TERMINATION << "ERROR (EidosValue::IntAtIndex): operand type " << this->Type() << " cannot be converted to type integer." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue::IntAtIndex_CAST): operand type " << this->Type() << " cannot be converted to type integer." << EidosTerminate(p_blame_token); } double EidosValue::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) - EIDOS_TERMINATION << "ERROR (EidosValue::FloatAtIndex): operand type " << this->Type() << " cannot be converted to type float." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue::FloatAtIndex_CAST): operand type " << this->Type() << " cannot be converted to type float." << EidosTerminate(p_blame_token); } EidosObject *EidosValue::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { #pragma unused(p_idx) - EIDOS_TERMINATION << "ERROR (EidosValue::ObjectElementAtIndex): operand type " << this->Type() << " cannot be converted to type object." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue::ObjectElementAtIndex_CAST): operand type " << this->Type() << " cannot be converted to type object." << EidosTerminate(p_blame_token); } void EidosValue::RaiseForIncorrectTypeCall(void) const @@ -1051,7 +1051,7 @@ nlohmann::json EidosValue_Logical::JSONRepresentation(void) const eidos_logical_t EidosValue_Logical::LogicalAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1059,7 +1059,7 @@ eidos_logical_t EidosValue_Logical::LogicalAtIndex_NOCAST(int p_idx, const Eidos eidos_logical_t EidosValue_Logical::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Logical::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1067,7 +1067,7 @@ eidos_logical_t EidosValue_Logical::LogicalAtIndex_CAST(int p_idx, const EidosTo std::string EidosValue_Logical::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Logical::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? gEidosStr_T : gEidosStr_F); } @@ -1075,7 +1075,7 @@ std::string EidosValue_Logical::StringAtIndex_CAST(int p_idx, const EidosToken * int64_t EidosValue_Logical::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Logical::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? 1 : 0); } @@ -1083,7 +1083,7 @@ int64_t EidosValue_Logical::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame double EidosValue_Logical::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Logical::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] ? 1.0 : 0.0); } @@ -1286,7 +1286,7 @@ EidosValue_String_vector::EidosValue_String_vector(std::initializer_list= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1294,7 +1294,7 @@ std::string EidosValue_String_vector::StringAtIndex_NOCAST(int p_idx, const Eido const std::string &EidosValue_String_vector::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringRefAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringRefAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1302,7 +1302,7 @@ const std::string &EidosValue_String_vector::StringRefAtIndex_NOCAST(int p_idx, eidos_logical_t EidosValue_String_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx].length() > 0); } @@ -1310,7 +1310,7 @@ eidos_logical_t EidosValue_String_vector::LogicalAtIndex_CAST(int p_idx, const E std::string EidosValue_String_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1318,7 +1318,7 @@ std::string EidosValue_String_vector::StringAtIndex_CAST(int p_idx, const EidosT int64_t EidosValue_String_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); // We don't use IntForString because an integer has been specifically requested, so even if the string appears to contain a // float value we want to force it into being an int; the way to do that is to use FloatForString and then convert to int64_t @@ -1326,7 +1326,7 @@ int64_t EidosValue_String_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... if ((converted_value < (double)INT64_MIN) || (converted_value >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex): '" << values_[p_idx] << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex_CAST): '" << values_[p_idx] << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); return static_cast(converted_value); } @@ -1334,7 +1334,7 @@ int64_t EidosValue_String_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p double EidosValue_String_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosInterpreter::FloatForString(values_[p_idx], p_blame_token); } @@ -1373,7 +1373,7 @@ void EidosValue_String_vector::Sort(bool p_ascending) std::string EidosValue_String_singleton::StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -1381,7 +1381,7 @@ std::string EidosValue_String_singleton::StringAtIndex_NOCAST(int p_idx, const E const std::string &EidosValue_String_singleton::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringRefAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringRefAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -1389,7 +1389,7 @@ const std::string &EidosValue_String_singleton::StringRefAtIndex_NOCAST(int p_id eidos_logical_t EidosValue_String_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (value_.length() > 0); } @@ -1397,7 +1397,7 @@ eidos_logical_t EidosValue_String_singleton::LogicalAtIndex_CAST(int p_idx, cons std::string EidosValue_String_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -1405,7 +1405,7 @@ std::string EidosValue_String_singleton::StringAtIndex_CAST(int p_idx, const Eid int64_t EidosValue_String_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); // We don't use IntForString because an integer has been specifically requested, so even if the string appears to contain a // float value we want to force it into being an int; the way to do that is to use FloatForString and then convert to int64_t @@ -1413,7 +1413,7 @@ int64_t EidosValue_String_singleton::IntAtIndex_CAST(int p_idx, const EidosToken // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... if ((converted_value < (double)INT64_MIN) || (converted_value >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex): '" << value_ << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex_CAST): '" << value_ << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); return static_cast(converted_value); } @@ -1421,7 +1421,7 @@ int64_t EidosValue_String_singleton::IntAtIndex_CAST(int p_idx, const EidosToken double EidosValue_String_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosInterpreter::FloatForString(value_, p_blame_token); } @@ -1553,7 +1553,7 @@ EidosValue_Int_vector::EidosValue_Int_vector(const int64_t *p_values, size_t p_c int64_t EidosValue_Int_vector::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1570,7 +1570,7 @@ double EidosValue_Int_vector::NumericAtIndex_NOCAST(int p_idx, const EidosToken eidos_logical_t EidosValue_Int_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] == 0 ? false : true); } @@ -1578,7 +1578,7 @@ eidos_logical_t EidosValue_Int_vector::LogicalAtIndex_CAST(int p_idx, const Eido std::string EidosValue_Int_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return std::to_string(values_[p_idx]); // way faster than std::ostringstream } @@ -1586,7 +1586,7 @@ std::string EidosValue_Int_vector::StringAtIndex_CAST(int p_idx, const EidosToke int64_t EidosValue_Int_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1594,7 +1594,7 @@ int64_t EidosValue_Int_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_bl double EidosValue_Int_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1684,7 +1684,7 @@ void EidosValue_Int_vector::erase_index(size_t p_index) int64_t EidosValue_Int_singleton::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -1701,7 +1701,7 @@ double EidosValue_Int_singleton::NumericAtIndex_NOCAST(int p_idx, const EidosTok eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (value_ == 0 ? false : true); } @@ -1709,7 +1709,7 @@ eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex_CAST(int p_idx, const E std::string EidosValue_Int_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return std::to_string(value_); // way faster than std::ostringstream } @@ -1717,7 +1717,7 @@ std::string EidosValue_Int_singleton::StringAtIndex_CAST(int p_idx, const EidosT int64_t EidosValue_Int_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -1725,7 +1725,7 @@ int64_t EidosValue_Int_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p double EidosValue_Int_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -1834,7 +1834,7 @@ EidosValue_Float_vector::EidosValue_Float_vector(const double *p_values, size_t double EidosValue_Float_vector::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1851,12 +1851,12 @@ double EidosValue_Float_vector::NumericAtIndex_NOCAST(int p_idx, const EidosToke eidos_logical_t EidosValue_Float_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; if (std::isnan(value)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex_CAST): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); return (value == 0 ? false : true); } @@ -1864,7 +1864,7 @@ eidos_logical_t EidosValue_Float_vector::LogicalAtIndex_CAST(int p_idx, const Ei std::string EidosValue_Float_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosStringForFloat(values_[p_idx]); } @@ -1872,18 +1872,18 @@ std::string EidosValue_Float_vector::StringAtIndex_CAST(int p_idx, const EidosTo int64_t EidosValue_Float_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; if (std::isnan(value)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); if (std::isinf(value)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... if ((value < (double)INT64_MIN) || (value >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex): float value " << value << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): float value " << value << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); return static_cast(value); } @@ -1891,7 +1891,7 @@ int64_t EidosValue_Float_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_ double EidosValue_Float_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -1984,7 +1984,7 @@ void EidosValue_Float_vector::erase_index(size_t p_index) double EidosValue_Float_singleton::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -2001,10 +2001,10 @@ double EidosValue_Float_singleton::NumericAtIndex_NOCAST(int p_idx, const EidosT eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); if (std::isnan(value_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex_CAST): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); return (value_ == 0 ? false : true); } @@ -2012,7 +2012,7 @@ eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex_CAST(int p_idx, const std::string EidosValue_Float_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::StringAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosStringForFloat(value_); } @@ -2020,16 +2020,16 @@ std::string EidosValue_Float_singleton::StringAtIndex_CAST(int p_idx, const Eido int64_t EidosValue_Float_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); if (std::isnan(value_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); if (std::isinf(value_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... if ((value_ < (double)INT64_MIN) || (value_ >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex): float value " << value_ << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): float value " << value_ << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); return static_cast(value_); } @@ -2037,7 +2037,7 @@ int64_t EidosValue_Float_singleton::IntAtIndex_CAST(int p_idx, const EidosToken double EidosValue_Float_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -2311,7 +2311,7 @@ EidosValue_Object_vector::~EidosValue_Object_vector(void) EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -2319,7 +2319,7 @@ EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_NOCAST(int p_idx, co EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } @@ -3154,7 +3154,7 @@ EidosValue_Object_singleton::~EidosValue_Object_singleton(void) EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } @@ -3162,7 +3162,7 @@ EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST(int p_idx, EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return value_; } From 092a01c137614b303e30d6a836f66fe1f5643124 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Thu, 21 Dec 2023 22:17:56 -0500 Subject: [PATCH 06/18] remove subsetting with float indices --- VERSIONS | 3 +- eidos/eidos_functions.cpp | 217 ++++++--------------------- eidos/eidos_interpreter.cpp | 67 ++++----- eidos/eidos_test_operators_other.cpp | 32 +--- eidos/eidos_value.h | 19 ++- 5 files changed, 92 insertions(+), 246 deletions(-) diff --git a/VERSIONS b/VERSIONS index 3e9752bf1..dc6e7193c 100644 --- a/VERSIONS +++ b/VERSIONS @@ -7,7 +7,8 @@ Note that not every commit will be logged here; that is what the Github commit h development head (in the master branch): fix for #418, a crash involving null genomes in nonWF (has_null_genomes_ was not set correctly by addCloned() or takeMigrants() when putting a null genome into a subpop that previously had none) - + policy change: float indices are no longer legal for subsetting, indices must be integer (or a logical vector, as usual); this was inherited from R and is a bad idea for Eidos + version 4.1 (Eidos version 3.1): fix a minor bug with autofix when opening multiple .slim documents at once in SLiMgui diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 03d3dd05e..36099d46d 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -1031,6 +1031,10 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa EidosValue_SP result_SP; + // BCH 12/21/2023: Policy change to outlaw subsetting with float indices. It was a bad idea, inherited from R. + if (indices_type == EidosValueType::kValueFloat) + EIDOS_TERMINATION << "ERROR (SubsetEidosValue): it is no longer legal to subset with float indices; use asInteger() to coerce the indices to integer." << EidosTerminate(p_error_token); + if (indices_type == EidosValueType::kValueLogical) { // Subsetting with a logical vector means the vectors must match in length, if p_raise_range_errors is true; indices with a T value will be taken @@ -1122,13 +1126,13 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa } } } - else + else // (indices_type == EidosValueType::kValueInt) { if (indices_count == 1) { - // Subsetting with a singleton int/float vector is common and should return a singleton value for speed + // Subsetting with a singleton int vector is common and should return a singleton value for speed // This is guaranteed to return a singleton value (when available) - int index_value = (int)p_indices->IntAtIndex_CAST(0, p_error_token); + int index_value = (int)p_indices->IntAtIndex_NOCAST(0, p_error_token); if ((index_value < 0) || (index_value >= original_value_count)) { @@ -1140,30 +1144,11 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else result_SP = p_original_value->GetValueAtIndex(index_value, p_error_token); } - else if (original_value_count == 1) - { - // We can't use direct access on p_original_value if it is a singleton, so this needs to be special-cased - // Note this is identical to the general-case code below that is never hit - result_SP = p_original_value->NewMatchingType(); - - EidosValue *result = result_SP.get(); - - for (int value_idx = 0; value_idx < indices_count; value_idx++) - { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - result->PushValueFromIndexOfEidosValue((int)index_value, *p_original_value, p_error_token); - } - } else { - // Subsetting with a int/float vector can use a vector of any length; the specific indices referenced will be taken + // Subsetting with a int vector can use a vector of any length; the specific indices referenced will be taken + const int64_t *int_index_data = p_indices->IntData(); + if (original_value_type == EidosValueType::kValueFloat) { // result type is float; optimize for that @@ -1171,39 +1156,17 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); - if (indices_type == EidosValueType::kValueInt) + for (int value_idx = 0; value_idx < indices_count; value_idx++) { - // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntData(); + int64_t index_value = int_index_data[value_idx]; - for (int value_idx = 0; value_idx < indices_count; value_idx++) - { - int64_t index_value = int_index_data[value_idx]; - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - float_result->push_float_no_check(first_child_data[index_value]); - } - } - else - { - // float indices; we use IntAtIndex() since it has complex behavior - for (int value_idx = 0; value_idx < indices_count; value_idx++) + if ((index_value < 0) || (index_value >= original_value_count)) { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - float_result->push_float_no_check(first_child_data[index_value]); + if (p_raise_range_errors) + EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); } + else + float_result->push_float_no_check(first_child_data[index_value]); } result_SP = float_result_SP; @@ -1215,39 +1178,17 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); - if (indices_type == EidosValueType::kValueInt) + for (int value_idx = 0; value_idx < indices_count; value_idx++) { - // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntData(); + int64_t index_value = int_index_data[value_idx]; - for (int value_idx = 0; value_idx < indices_count; value_idx++) - { - int64_t index_value = int_index_data[value_idx]; - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - int_result->push_int_no_check(first_child_data[index_value]); - } - } - else - { - // float indices; we use IntAtIndex() since it has complex behavior - for (int value_idx = 0; value_idx < indices_count; value_idx++) + if ((index_value < 0) || (index_value >= original_value_count)) { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - int_result->push_int_no_check(first_child_data[index_value]); + if (p_raise_range_errors) + EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); } + else + int_result->push_int_no_check(first_child_data[index_value]); } result_SP = int_result_SP; @@ -1259,39 +1200,17 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); - if (indices_type == EidosValueType::kValueInt) + for (int value_idx = 0; value_idx < indices_count; value_idx++) { - // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntData(); + int64_t index_value = int_index_data[value_idx]; - for (int value_idx = 0; value_idx < indices_count; value_idx++) - { - int64_t index_value = int_index_data[value_idx]; - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - obj_result->push_object_element_no_check_CRR(first_child_vec[index_value]); - } - } - else - { - // float indices; we use IntAtIndex() since it has complex behavior - for (int value_idx = 0; value_idx < indices_count; value_idx++) + if ((index_value < 0) || (index_value >= original_value_count)) { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - obj_result->push_object_element_no_check_CRR(first_child_vec[index_value]); + if (p_raise_range_errors) + EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); } + else + obj_result->push_object_element_no_check_CRR(first_child_vec[index_value]); } result_SP = obj_result_SP; @@ -1303,39 +1222,17 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa EidosValue_Logical_SP logical_result_SP = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); EidosValue_Logical *logical_result = logical_result_SP->reserve(indices_count); - if (indices_type == EidosValueType::kValueInt) + for (int value_idx = 0; value_idx < indices_count; value_idx++) { - // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntData(); + int64_t index_value = int_index_data[value_idx]; - for (int value_idx = 0; value_idx < indices_count; value_idx++) - { - int64_t index_value = int_index_data[value_idx]; - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - logical_result->push_logical_no_check(first_child_data[index_value]); - } - } - else - { - // float indices; we use IntAtIndex() since it has complex behavior - for (int value_idx = 0; value_idx < indices_count; value_idx++) + if ((index_value < 0) || (index_value >= original_value_count)) { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - logical_result->push_logical_no_check(first_child_data[index_value]); + if (p_raise_range_errors) + EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); } + else + logical_result->push_logical_no_check(first_child_data[index_value]); } result_SP = logical_result_SP; @@ -1347,39 +1244,17 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); - if (indices_type == EidosValueType::kValueInt) + for (int value_idx = 0; value_idx < indices_count; value_idx++) { - // integer indices; we can use fast access since we know indices_count != 1 - const int64_t *int_index_data = p_indices->IntData(); + int64_t index_value = int_index_data[value_idx]; - for (int value_idx = 0; value_idx < indices_count; value_idx++) - { - int64_t index_value = int_index_data[value_idx]; - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - string_result->PushString(first_child_vec[index_value]); - } - } - else - { - // float indices; we use IntAtIndex() since it has complex behavior - for (int value_idx = 0; value_idx < indices_count; value_idx++) + if ((index_value < 0) || (index_value >= original_value_count)) { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); - - if ((index_value < 0) || (index_value >= original_value_count)) - { - if (p_raise_range_errors) - EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); - } - else - string_result->PushString(first_child_vec[index_value]); + if (p_raise_range_errors) + EIDOS_TERMINATION << "ERROR (SubsetEidosValue): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(p_error_token); } + else + string_result->PushString(first_child_vec[index_value]); } result_SP = string_result_SP; @@ -1394,7 +1269,7 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa for (int value_idx = 0; value_idx < indices_count; value_idx++) { - int64_t index_value = p_indices->IntAtIndex_CAST(value_idx, p_error_token); + int64_t index_value = int_index_data[value_idx]; if ((index_value < 0) || (index_value >= original_value_count)) { diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 68be694da..cd01989f1 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -319,7 +319,9 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, EidosValue_SP child_value = FastEvaluateNode(subset_index_node); EidosValueType child_type = child_value->Type(); - if ((child_type != EidosValueType::kValueInt) && (child_type != EidosValueType::kValueFloat) && (child_type != EidosValueType::kValueLogical) && (child_type != EidosValueType::kValueNULL)) + if (child_type == EidosValueType::kValueFloat) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): it is no longer legal to subset with float indices; use asInteger() to cast the indices to integer." << EidosTerminate(parent_token); + if ((child_type != EidosValueType::kValueInt) && (child_type != EidosValueType::kValueLogical) && (child_type != EidosValueType::kValueNULL)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): index operand type " << child_type << " is not supported by the '[]' operator." << EidosTerminate(parent_token); if (child_value->DimensionCount() != 1) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): a matrix or array index operand is not supported by the '[]' operator." << EidosTerminate(parent_token); @@ -351,8 +353,6 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, EidosValue_SP second_child_value = subset_indices[0]; EidosValueType second_child_type = second_child_value->Type(); - if ((second_child_type != EidosValueType::kValueInt) && (second_child_type != EidosValueType::kValueFloat) && (second_child_type != EidosValueType::kValueLogical)) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): index operand type " << second_child_type << " is not supported by the '[]' operator." << EidosTerminate(parent_token); if (second_child_value->DimensionCount() != 1) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): a matrix or array index operand is not supported by the '[]' operator." << EidosTerminate(parent_token); @@ -372,43 +372,26 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, p_indices_ptr->emplace_back(base_indices[value_idx]); } } - else + else // (second_child_type == EidosValueType::kValueInt) { - // A numeric vector can be of any length; each number selects the index at that index in base_indices - if (second_child_type == EidosValueType::kValueInt) + // An integer vector can be of any length; each number selects the index at that index in base_indices + if (second_child_count == 1) { - if (second_child_count == 1) - { - int64_t index_value = second_child_value->IntAtIndex_NOCAST(0, parent_token); - - if ((index_value < 0) || (index_value >= base_indices_count)) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); - else - p_indices_ptr->emplace_back(base_indices[index_value]); - } - else if (second_child_count) - { - // fast vector access for the non-singleton case - const int64_t *second_child_data = second_child_value->IntData(); - - for (int value_idx = 0; value_idx < second_child_count; value_idx++) - { - int64_t index_value = second_child_data[value_idx]; - - if ((index_value < 0) || (index_value >= base_indices_count)) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); - else - p_indices_ptr->emplace_back(base_indices[index_value]); - } - } + int64_t index_value = second_child_value->IntAtIndex_NOCAST(0, parent_token); + + if ((index_value < 0) || (index_value >= base_indices_count)) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); + else + p_indices_ptr->emplace_back(base_indices[index_value]); } - else // (second_child_type == EidosValueType::kValueFloat)) + else if (second_child_count) { - // We do not optimize the float case with direct vector access, because IntAtIndex() has complex behavior - // for EidosValue_Float that we want to get here; subsetting with float vectors is slow, don't do it. + // fast vector access for the non-singleton case + const int64_t *second_child_data = second_child_value->IntData(); + for (int value_idx = 0; value_idx < second_child_count; value_idx++) { - int64_t index_value = second_child_value->IntAtIndex_CAST(value_idx, parent_token); + int64_t index_value = second_child_data[value_idx]; if ((index_value < 0) || (index_value >= base_indices_count)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); @@ -438,7 +421,7 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, EidosTokenType left_token_type = left_token->token_type_; if (left_token_type == EidosTokenType::kTokenLBracket) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): chaining of matrix/array-style subsets in assignments is not currently supported (although it is permitted by the Eidos language definition)." << EidosTerminate(parent_token); + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): chaining of matrix/array-style subsets in assignments is not supported." << EidosTerminate(parent_token); if (left_token_type == EidosTokenType::kTokenDot) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): cannot assign into a subset of a property; not an lvalue." << EidosTerminate(parent_token); } @@ -478,12 +461,12 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, if (logical_index_data[dim_index]) indices.emplace_back(dim_index); } - else + else // (subset_type == EidosValueType::kValueInt) { - // We have a float or integer subset, which selects indices within inclusion_indices + // We have an integer subset, which selects indices within inclusion_indices for (int index_index = 0; index_index < subset_count; index_index++) { - int64_t index_value = subset_value->IntAtIndex_CAST(index_index, parent_token); + int64_t index_value = subset_value->IntAtIndex_NOCAST(index_index, parent_token); if ((index_value < 0) || (index_value >= dim_size)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(parent_token); @@ -1725,7 +1708,9 @@ EidosValue_SP EidosInterpreter::Evaluate_Subset(const EidosASTNode *p_node) return result_SP; } - if ((child_type != EidosValueType::kValueInt) && (child_type != EidosValueType::kValueFloat) && (child_type != EidosValueType::kValueLogical) && (child_type != EidosValueType::kValueNULL)) + if (child_type == EidosValueType::kValueFloat) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): it is no longer legal to subset with float indices; use asInteger() to cast the indices to integer." << EidosTerminate(operator_token); + if ((child_type != EidosValueType::kValueInt) && (child_type != EidosValueType::kValueLogical) && (child_type != EidosValueType::kValueNULL)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): index operand type " << child_type << " is not supported by the '[]' operator." << EidosTerminate(operator_token); if (child_value->DimensionCount() != 1) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): a matrix or array index operand is not supported by the '[]' operator." << EidosTerminate(operator_token); @@ -1805,10 +1790,10 @@ EidosValue_SP EidosInterpreter::Evaluate_Subset(const EidosASTNode *p_node) } else { - // We have a float or integer subset, which selects indices within inclusion_indices + // We have an integer subset, which selects indices within inclusion_indices for (int index_index = 0; index_index < subset_count; index_index++) { - int64_t index_value = subset_value->IntAtIndex_CAST(index_index, operator_token); + int64_t index_value = subset_value->IntAtIndex_NOCAST(index_index, operator_token); if ((index_value < 0) || (index_value >= dim_size)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Subset): out-of-range index " << index_value << " used with the '[]' operator." << EidosTerminate(operator_token); diff --git a/eidos/eidos_test_operators_other.cpp b/eidos/eidos_test_operators_other.cpp index 5836fd591..68299dc0f 100644 --- a/eidos/eidos_test_operators_other.cpp +++ b/eidos/eidos_test_operators_other.cpp @@ -34,18 +34,18 @@ void _RunOperatorSubsetTests(void) EidosAssertScriptSuccess_IV("x = 1:5; x[2:3];", {3, 4}); EidosAssertScriptSuccess_IV("x = 1:5; x[c(0, 2, 4)];", {1, 3, 5}); EidosAssertScriptSuccess_IV("x = 1:5; x[0:4];", {1, 2, 3, 4, 5}); - EidosAssertScriptSuccess("x = 1:5; x[float(0)];", gStaticEidosValue_Integer_ZeroVec); - EidosAssertScriptSuccess_I("x = 1:5; x[2.0];", 3); - EidosAssertScriptSuccess_IV("x = 1:5; x[2.0:3];", {3, 4}); - EidosAssertScriptSuccess_IV("x = 1:5; x[c(0.0, 2, 4)];", {1, 3, 5}); - EidosAssertScriptSuccess_IV("x = 1:5; x[0.0:4];", {1, 2, 3, 4, 5}); + EidosAssertScriptRaise("x = 1:5; x[float(0)];", 10, "float indices"); + EidosAssertScriptRaise("x = 1:5; x[2.0];", 10, "float indices"); + EidosAssertScriptRaise("x = 1:5; x[2.0:3];", 10, "float indices"); + EidosAssertScriptRaise("x = 1:5; x[c(0.0, 2, 4)];", 10, "float indices"); + EidosAssertScriptRaise("x = 1:5; x[0.0:4];", 10, "float indices"); EidosAssertScriptRaise("x = 1:5; x[c(7,8)];", 10, "out-of-range index"); EidosAssertScriptRaise("x = 1:5; x[logical(0)];", 10, "operator requires that the size()"); EidosAssertScriptRaise("x = 1:5; x[T];", 10, "operator requires that the size()"); EidosAssertScriptRaise("x = 1:5; x[c(T, T)];", 10, "operator requires that the size()"); EidosAssertScriptRaise("x = 1:5; x[c(T, F, T)];", 10, "operator requires that the size()"); - EidosAssertScriptRaise("x = 1:5; x[NAN];", 10, "cannot be converted"); - EidosAssertScriptRaise("x = 1:5; x[c(0.0, 2, NAN)];", 10, "cannot be converted"); + EidosAssertScriptRaise("x = 1:5; x[NAN];", 10, "float indices"); + EidosAssertScriptRaise("x = 1:5; x[c(0.0, 2, NAN)];", 10, "float indices"); EidosAssertScriptSuccess_IV("x = 1:5; x[c(T, F, T, F, T)];", {1, 3, 5}); EidosAssertScriptSuccess_IV("x = 1:5; x[c(T, T, T, T, T)];", {1, 2, 3, 4, 5}); EidosAssertScriptSuccess("x = 1:5; x[c(F, F, F, F, F)];", gStaticEidosValue_Integer_ZeroVec); @@ -56,28 +56,18 @@ void _RunOperatorSubsetTests(void) EidosAssertScriptSuccess_LV("x = c(T,T,F,T,F); x[c(2,3)];", {false, true}); EidosAssertScriptRaise("x = c(T,T,F,T,F); x[c(2,3,7)];", 19, "out-of-range index"); - EidosAssertScriptSuccess_LV("x = c(T,T,F,T,F); x[c(2.0,3)];", {false, true}); - EidosAssertScriptRaise("x = c(T,T,F,T,F); x[c(2.0,3,7)];", 19, "out-of-range index"); EidosAssertScriptSuccess_IV("x = 1:5; x[c(2,3)];", {3, 4}); EidosAssertScriptRaise("x = 1:5; x[c(2,3,7)];", 10, "out-of-range index"); - EidosAssertScriptSuccess_IV("x = 1:5; x[c(2.0,3)];", {3, 4}); - EidosAssertScriptRaise("x = 1:5; x[c(2.0,3,7)];", 10, "out-of-range index"); EidosAssertScriptSuccess_FV("x = 1.0:5; x[c(2,3)];", {3.0, 4.0}); EidosAssertScriptRaise("x = 1.0:5; x[c(2,3,7)];", 12, "out-of-range index"); - EidosAssertScriptSuccess_FV("x = 1.0:5; x[c(2.0,3)];", {3.0, 4.0}); - EidosAssertScriptRaise("x = 1.0:5; x[c(2.0,3,7)];", 12, "out-of-range index"); EidosAssertScriptSuccess_SV("x = c('foo', 'bar', 'foobaz', 'baz', 'xyzzy'); x[c(2,3)];", {"foobaz", "baz"}); EidosAssertScriptRaise("x = c('foo', 'bar', 'foobaz', 'baz', 'xyzzy'); x[c(2,3,7)];", 48, "out-of-range index"); - EidosAssertScriptSuccess_SV("x = c('foo', 'bar', 'foobaz', 'baz', 'xyzzy'); x[c(2.0,3)];", {"foobaz", "baz"}); - EidosAssertScriptRaise("x = c('foo', 'bar', 'foobaz', 'baz', 'xyzzy'); x[c(2.0,3,7)];", 48, "out-of-range index"); EidosAssertScriptSuccess_IV("x = c(_Test(1), _Test(2), _Test(3), _Test(4), _Test(5)); x = x[c(2,3)]; x._yolk;", {3, 4}); EidosAssertScriptRaise("x = c(_Test(1), _Test(2), _Test(3), _Test(4), _Test(5)); x = x[c(2,3,7)]; x._yolk;", 62, "out-of-range index"); - EidosAssertScriptSuccess_IV("x = c(_Test(1), _Test(2), _Test(3), _Test(4), _Test(5)); x = x[c(2.0,3)]; x._yolk;", {3, 4}); - EidosAssertScriptRaise("x = c(_Test(1), _Test(2), _Test(3), _Test(4), _Test(5)); x = x[c(2.0,3,7)]; x._yolk;", 62, "out-of-range index"); EidosAssertScriptSuccess_I("x = 5; x[T];", 5); EidosAssertScriptSuccess_IV("x = 5; x[F];", {}); @@ -86,10 +76,6 @@ void _RunOperatorSubsetTests(void) EidosAssertScriptRaise("x = 5; x[1];", 8, "out of range"); EidosAssertScriptRaise("x = 5; x[-1];", 8, "out of range"); EidosAssertScriptSuccess_IV("x = 5; x[integer(0)];", {}); - EidosAssertScriptSuccess_I("x = 5; x[0.0];", 5); - EidosAssertScriptRaise("x = 5; x[1.0];", 8, "out-of-range"); - EidosAssertScriptRaise("x = 5; x[-1.0];", 8, "out-of-range"); - EidosAssertScriptSuccess_IV("x = 5; x[float(0)];", {}); EidosAssertScriptRaise("x = 5:9; x[matrix(0)];", 10, "matrix or array index operand is not supported"); EidosAssertScriptRaise("x = 5:9; x[matrix(0:2)];", 10, "matrix or array index operand is not supported"); @@ -214,10 +200,6 @@ void _RunOperatorAssignTests(void) EidosAssertScriptRaise("x = 1:5; x[c(T,T,F,T,F,T)] = 7:9; x;", 10, "must match the size()"); EidosAssertScriptSuccess_IV("x = 1:5; x[c(2,3)] = c(9, 5); x;", {1, 2, 9, 5, 5}); EidosAssertScriptRaise("x = 1:5; x[c(7,8)] = 7; x;", 10, "out-of-range index"); - EidosAssertScriptSuccess_IV("x = 1:5; x[c(2.0,3)] = c(9, 5); x;", {1, 2, 9, 5, 5}); - EidosAssertScriptRaise("x = 1:5; x[c(7.0,8)] = 7; x;", 10, "out-of-range index"); - EidosAssertScriptRaise("x = 1:5; x[NAN] = 3;", 10, "cannot be converted"); - EidosAssertScriptRaise("x = 1:5; x[c(0.0, 2, NAN)] = c(5, 7, 3);", 10, "cannot be converted"); EidosAssertScriptSuccess_I("x = _Test(9); x = _Test(7); x._yolk;", 7); EidosAssertScriptSuccess_I("x = _Test(9); x[0] = _Test(7); x._yolk;", 7); diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 6185d7209..7511d6f63 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -215,14 +215,17 @@ class EidosValue virtual EidosObject *ObjectElementAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } // fetching individual values WITH a cast to the requested type; this is not general-purpose - // behavior for Eidos, but is limited to specific places in the language: CompareEidosValues(), - // _ProcessSubsetAssignment() to allow float indices for subsetting, _AssignRValueToLValue() to - // put a value of one type into a specific index in an existing vector, Evaluate_Subset() again - // for float subsetting indices, string + in EvaluatePlus(), Evaluate_Conditional() to cast any - // value to logical for the condition (and likewise for EvaluateIf(), Evaluate_Do(), and - // Evaluate_While()), Evaluate_And() / Evaluate_Or() / Evaluate_Not() to cast values to logical, - // and Evaluate_Eq() and the other comparison operators, == < <= > >= != - // BCH 12/21/2023: FIXME: float indices for subsetting should be reconsidered, it is a bad idea + // behavior for Eidos, but is limited to specific places in the language: + // + // -- CompareEidosValues(), which is now used only by pmax()/pmin() and only for identical types + // -- _AssignRValueToLValue() to put a value of one type into a specific index in an existing vector that might be a different type + // -- string + in EvaluatePlus(), which coerces everything that isn't a string into a string, and cat() / catn() / paste() / paste0() / print() + // -- Evaluate_Conditional() / Evaluate_If() / Evaluate_Do() / Evaluate_While() to cast their condition to logical + // -- Evaluate_And() / Evaluate_Or() / Evaluate_Not() to cast values used with operators & | ^ to logical + // -- Evaluate_Eq() and the other comparison operators, == < <= > >= !=, which compare on the basis of promoting up to a common type + // -- ConcatenateEidosValues() for c() / apply() / sapply() / AppendKeysAndValuesFrom(), and property accesses / method calls + // -- the asLogical() / asInteger() / asFloat() / asString() methods, which explicitly coerce one type into another + // virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; From fa1ade257264ab4c85928e818b324ce1c565d35a Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Fri, 22 Dec 2023 11:34:56 -0500 Subject: [PATCH 07/18] bring SLiM up to speed with EidosValue changes --- SLiMgui/slim_gui.mm | 2 +- core/chromosome.cpp | 76 +++++------ core/community.cpp | 6 +- core/community_eidos.cpp | 78 +++++------ core/genome.cpp | 128 +++++++++--------- core/genomic_element.cpp | 2 +- core/genomic_element_type.cpp | 26 ++-- core/individual.cpp | 86 ++++++------ core/interaction_type.cpp | 160 ++++++++++------------ core/log_file.cpp | 40 +++--- core/mutation.cpp | 14 +- core/mutation_type.cpp | 32 ++--- core/population.cpp | 20 +-- core/slim_eidos_block.cpp | 6 +- core/slim_functions.cpp | 70 +++++----- core/slim_globals.cpp | 30 ++--- core/spatial_kernel.cpp | 4 +- core/spatial_map.cpp | 76 +++++------ core/species.cpp | 10 +- core/species_eidos.cpp | 232 ++++++++++++++++---------------- core/subpopulation.cpp | 226 +++++++++++++++---------------- core/substitution.cpp | 8 +- eidos/eidos_functions_files.cpp | 4 +- eidos/eidos_functions_math.cpp | 2 +- eidos/eidos_interpreter.cpp | 30 ++--- eidos/eidos_value.h | 4 +- 26 files changed, 680 insertions(+), 692 deletions(-) diff --git a/SLiMgui/slim_gui.mm b/SLiMgui/slim_gui.mm index b9eaaa3fd..475fda626 100644 --- a/SLiMgui/slim_gui.mm +++ b/SLiMgui/slim_gui.mm @@ -109,7 +109,7 @@ #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue_String *filePath_value = (EidosValue_String *)p_arguments[0].get(); - std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringRefAtIndex(0, nullptr))); + std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringRefAtIndex_NOCAST(0, nullptr))); NSString *filePath = [NSString stringWithUTF8String:file_path.c_str()]; [controller_ eidos_openDocument:filePath]; diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 7d6089b78..5a6f569c3 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -912,11 +912,11 @@ Mutation *Chromosome::ApplyMutationCallbacks(Mutation *p_mut, Genome *p_genome, if ((resultType == EidosValueType::kValueLogical) && (resultCount == 1)) { - mutation_accepted = result->LogicalAtIndex(0, nullptr); + mutation_accepted = result->LogicalAtIndex_NOCAST(0, nullptr); } else if ((resultType == EidosValueType::kValueObject) && (((EidosValue_Object *)result)->Class() == gSLiM_Mutation_Class) && (resultCount == 1)) { - Mutation *replacementMutation = (Mutation *)result->ObjectElementAtIndex(0, mutation_callback->identifier_token_); + Mutation *replacementMutation = (Mutation *)result->ObjectElementAtIndex_NOCAST(0, mutation_callback->identifier_token_); if (replacementMutation == p_mut) { @@ -1823,14 +1823,14 @@ void Chromosome::SetProperty(EidosGlobalStringID p_property_id, const EidosValue { case gID_colorSubstitution: { - color_sub_ = p_value.StringAtIndex(0, nullptr); + color_sub_ = p_value.StringAtIndex_NOCAST(0, nullptr); if (!color_sub_.empty()) Eidos_GetColorComponents(color_sub_, &color_sub_red_, &color_sub_green_, &color_sub_blue_); return; } case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -1870,8 +1870,8 @@ EidosValue_SP Chromosome::ExecuteMethod_ancestralNucleotides(EidosGlobalStringID EidosValue *start_value = p_arguments[0].get(); EidosValue *end_value = p_arguments[1].get(); - int64_t start = (start_value->Type() == EidosValueType::kValueNULL) ? 0 : start_value->IntAtIndex(0, nullptr); - int64_t end = (end_value->Type() == EidosValueType::kValueNULL) ? last_position_ : end_value->IntAtIndex(0, nullptr); + int64_t start = (start_value->Type() == EidosValueType::kValueNULL) ? 0 : start_value->IntAtIndex_NOCAST(0, nullptr); + int64_t end = (end_value->Type() == EidosValueType::kValueNULL) ? last_position_ : end_value->IntAtIndex_NOCAST(0, nullptr); if ((start < 0) || (end < 0) || (start > last_position_) || (end > last_position_) || (start > end)) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_ancestralNucleotides): start and end must be within the chromosome's extent, and start must be <= end." << EidosTerminate(); @@ -1884,7 +1884,7 @@ EidosValue_SP Chromosome::ExecuteMethod_ancestralNucleotides(EidosGlobalStringID EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_ancestralNucleotides): the returned vector would exceed the maximum vector length in Eidos." << EidosTerminate(); EidosValue_String *format_value = (EidosValue_String *)p_arguments[2].get(); - const std::string &format = format_value->StringRefAtIndex(0, nullptr); + const std::string &format = format_value->StringRefAtIndex_NOCAST(0, nullptr); if (format == "codon") return sequence->NucleotidesAsCodonVector(start, end, /* p_force_vector */ false); @@ -1918,7 +1918,7 @@ EidosValue_SP Chromosome::ExecuteMethod_drawBreakpoints(EidosGlobalStringID p_me Individual *parent = nullptr; if (parent_value->Type() != EidosValueType::kValueNULL) - parent = (Individual *)parent_value->ObjectElementAtIndex(0, nullptr); + parent = (Individual *)parent_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (!parent && !single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_drawBreakpoints): drawBreakpoints() requires a non-NULL parent parameter in sexual models with sex-specific recombination maps." << EidosTerminate(); @@ -1949,7 +1949,7 @@ EidosValue_SP Chromosome::ExecuteMethod_drawBreakpoints(EidosGlobalStringID p_me num_breakpoints = DrawBreakpointCount(parent_sex); else { - int64_t n = n_value->IntAtIndex(0, nullptr); + int64_t n = n_value->IntAtIndex_NOCAST(0, nullptr); if ((n < 0) || (n > 1000000L)) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_drawBreakpoints): drawBreakpoints() requires 0 <= n <= 1000000." << EidosTerminate(); @@ -2033,7 +2033,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setAncestralNucleotides(EidosGlobalStrin if (sequence_value_count == 1) { // singleton case - int64_t int_value = sequence_value->IntAtIndex(0, nullptr); + int64_t int_value = sequence_value->IntAtIndex_NOCAST(0, nullptr); ancestral_seq_buffer_ = new NucleotideArray(1); ancestral_seq_buffer_->SetNucleotideAtIndex((std::size_t)0, (uint64_t)int_value); @@ -2152,10 +2152,10 @@ EidosValue_SP Chromosome::ExecuteMethod_setGeneConversion(EidosGlobalStringID p_ EidosValue *simpleConversionFraction_value = p_arguments[2].get(); EidosValue *bias_value = p_arguments[3].get(); - double non_crossover_fraction = nonCrossoverFraction_value->FloatAtIndex(0, nullptr); - double gene_conversion_avg_length = meanLength_value->FloatAtIndex(0, nullptr); - double simple_conversion_fraction = simpleConversionFraction_value->FloatAtIndex(0, nullptr); - double bias = bias_value->FloatAtIndex(0, nullptr); + double non_crossover_fraction = nonCrossoverFraction_value->NumericAtIndex_NOCAST(0, nullptr); + double gene_conversion_avg_length = meanLength_value->NumericAtIndex_NOCAST(0, nullptr); + double simple_conversion_fraction = simpleConversionFraction_value->NumericAtIndex_NOCAST(0, nullptr); + double bias = bias_value->NumericAtIndex_NOCAST(0, nullptr); if ((non_crossover_fraction < 0.0) || (non_crossover_fraction > 1.0) || std::isnan(non_crossover_fraction)) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setGeneConversion): setGeneConversion() nonCrossoverFraction must be between 0.0 and 1.0 inclusive (" << EidosStringForFloat(non_crossover_fraction) << " supplied)." << EidosTerminate(); @@ -2196,7 +2196,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setHotspotMap(EidosGlobalStringID p_meth // Figure out what sex we are being given a map for IndividualSex requested_sex = IndividualSex::kUnspecified; - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -2224,7 +2224,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setHotspotMap(EidosGlobalStringID p_meth if (multipliers_count != 1) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setHotspotMap): setHotspotMap() requires multipliers to be a singleton if ends is not supplied." << EidosTerminate(); - double multiplier = multipliers_value->FloatAtIndex(0, nullptr); + double multiplier = multipliers_value->NumericAtIndex_NOCAST(0, nullptr); // check values if ((multiplier < 0.0) || !std::isfinite(multiplier)) // intentionally no upper bound @@ -2248,11 +2248,11 @@ EidosValue_SP Chromosome::ExecuteMethod_setHotspotMap(EidosGlobalStringID p_meth // check values for (int value_index = 0; value_index < end_count; ++value_index) { - double multiplier = multipliers_value->FloatAtIndex(value_index, nullptr); - slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(value_index, nullptr)); + double multiplier = multipliers_value->NumericAtIndex_NOCAST(value_index, nullptr); + slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(value_index, nullptr)); if (value_index > 0) - if (mutation_end_position <= ends_value->IntAtIndex(value_index - 1, nullptr)) + if (mutation_end_position <= ends_value->IntAtIndex_NOCAST(value_index - 1, nullptr)) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setHotspotMap): setHotspotMap() requires ends to be in strictly ascending order." << EidosTerminate(); if ((multiplier < 0.0) || !std::isfinite(multiplier)) // intentionally no upper bound @@ -2262,7 +2262,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setHotspotMap(EidosGlobalStringID p_meth // The stake here is that the last position in the chromosome is not allowed to change after the chromosome is // constructed. When we call InitializeDraws() below, we recalculate the last position – and we must come up // with the same answer that we got before, otherwise our last_position_ cache is invalid. - int64_t new_last_position = ends_value->IntAtIndex(end_count - 1, nullptr); + int64_t new_last_position = ends_value->IntAtIndex_NOCAST(end_count - 1, nullptr); if (new_last_position != last_position_) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setHotspotMap): setHotspotMap() end " << new_last_position << " noncompliant; the last interval must end at the last position of the chromosome (" << last_position_ << ")." << EidosTerminate(); @@ -2273,8 +2273,8 @@ EidosValue_SP Chromosome::ExecuteMethod_setHotspotMap(EidosGlobalStringID p_meth for (int interval_index = 0; interval_index < end_count; ++interval_index) { - double multiplier = multipliers_value->FloatAtIndex(interval_index, nullptr); - slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(interval_index, nullptr)); + double multiplier = multipliers_value->NumericAtIndex_NOCAST(interval_index, nullptr); + slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(interval_index, nullptr)); multipliers.emplace_back(multiplier); positions.emplace_back(mutation_end_position); @@ -2306,7 +2306,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setMutationRate(EidosGlobalStringID p_me // Figure out what sex we are being given a map for IndividualSex requested_sex = IndividualSex::kUnspecified; - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -2334,7 +2334,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setMutationRate(EidosGlobalStringID p_me if (rate_count != 1) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setMutationRate): setMutationRate() requires rates to be a singleton if ends is not supplied." << EidosTerminate(); - double mutation_rate = rates_value->FloatAtIndex(0, nullptr); + double mutation_rate = rates_value->NumericAtIndex_NOCAST(0, nullptr); // check values if ((mutation_rate < 0.0) || !std::isfinite(mutation_rate)) // intentionally no upper bound @@ -2358,11 +2358,11 @@ EidosValue_SP Chromosome::ExecuteMethod_setMutationRate(EidosGlobalStringID p_me // check values for (int value_index = 0; value_index < end_count; ++value_index) { - double mutation_rate = rates_value->FloatAtIndex(value_index, nullptr); - slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(value_index, nullptr)); + double mutation_rate = rates_value->NumericAtIndex_NOCAST(value_index, nullptr); + slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(value_index, nullptr)); if (value_index > 0) - if (mutation_end_position <= ends_value->IntAtIndex(value_index - 1, nullptr)) + if (mutation_end_position <= ends_value->IntAtIndex_NOCAST(value_index - 1, nullptr)) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setMutationRate): setMutationRate() requires ends to be in strictly ascending order." << EidosTerminate(); if ((mutation_rate < 0.0) || !std::isfinite(mutation_rate)) // intentionally no upper bound @@ -2372,7 +2372,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setMutationRate(EidosGlobalStringID p_me // The stake here is that the last position in the chromosome is not allowed to change after the chromosome is // constructed. When we call InitializeDraws() below, we recalculate the last position – and we must come up // with the same answer that we got before, otherwise our last_position_ cache is invalid. - int64_t new_last_position = ends_value->IntAtIndex(end_count - 1, nullptr); + int64_t new_last_position = ends_value->IntAtIndex_NOCAST(end_count - 1, nullptr); if (new_last_position != last_position_) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setMutationRate): setMutationRate() end " << new_last_position << " noncompliant; the last interval must end at the last position of the chromosome (" << last_position_ << ")." << EidosTerminate(); @@ -2383,8 +2383,8 @@ EidosValue_SP Chromosome::ExecuteMethod_setMutationRate(EidosGlobalStringID p_me for (int interval_index = 0; interval_index < end_count; ++interval_index) { - double mutation_rate = rates_value->FloatAtIndex(interval_index, nullptr); - slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(interval_index, nullptr)); + double mutation_rate = rates_value->NumericAtIndex_NOCAST(interval_index, nullptr); + slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(interval_index, nullptr)); rates.emplace_back(mutation_rate); positions.emplace_back(mutation_end_position); @@ -2413,7 +2413,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setRecombinationRate(EidosGlobalStringID // Figure out what sex we are being given a map for IndividualSex requested_sex = IndividualSex::kUnspecified; - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -2441,7 +2441,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setRecombinationRate(EidosGlobalStringID if (rate_count != 1) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setRecombinationRate): setRecombinationRate() requires rates to be a singleton if ends is not supplied." << EidosTerminate(); - double recombination_rate = rates_value->FloatAtIndex(0, nullptr); + double recombination_rate = rates_value->NumericAtIndex_NOCAST(0, nullptr); // check values if ((recombination_rate < 0.0) || (recombination_rate > 0.5)) @@ -2465,11 +2465,11 @@ EidosValue_SP Chromosome::ExecuteMethod_setRecombinationRate(EidosGlobalStringID // check values for (int value_index = 0; value_index < end_count; ++value_index) { - double recombination_rate = rates_value->FloatAtIndex(value_index, nullptr); - slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(value_index, nullptr)); + double recombination_rate = rates_value->NumericAtIndex_NOCAST(value_index, nullptr); + slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(value_index, nullptr)); if (value_index > 0) - if (recombination_end_position <= ends_value->IntAtIndex(value_index - 1, nullptr)) + if (recombination_end_position <= ends_value->IntAtIndex_NOCAST(value_index - 1, nullptr)) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setRecombinationRate): setRecombinationRate() requires ends to be in strictly ascending order." << EidosTerminate(); if ((recombination_rate < 0.0) || (recombination_rate > 0.5)) @@ -2479,7 +2479,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setRecombinationRate(EidosGlobalStringID // The stake here is that the last position in the chromosome is not allowed to change after the chromosome is // constructed. When we call InitializeDraws() below, we recalculate the last position – and we must come up // with the same answer that we got before, otherwise our last_position_ cache is invalid. - int64_t new_last_position = ends_value->IntAtIndex(end_count - 1, nullptr); + int64_t new_last_position = ends_value->IntAtIndex_NOCAST(end_count - 1, nullptr); if (new_last_position != last_position_) EIDOS_TERMINATION << "ERROR (Chromosome::ExecuteMethod_setRecombinationRate): setRecombinationRate() rate " << new_last_position << " noncompliant; the last interval must end at the last position of the chromosome (" << last_position_ << ")." << EidosTerminate(); @@ -2490,8 +2490,8 @@ EidosValue_SP Chromosome::ExecuteMethod_setRecombinationRate(EidosGlobalStringID for (int interval_index = 0; interval_index < end_count; ++interval_index) { - double recombination_rate = rates_value->FloatAtIndex(interval_index, nullptr); - slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(interval_index, nullptr)); + double recombination_rate = rates_value->NumericAtIndex_NOCAST(interval_index, nullptr); + slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(interval_index, nullptr)); rates.emplace_back(recombination_rate); positions.emplace_back(recombination_end_position); diff --git a/core/community.cpp b/core/community.cpp index 30eb16275..10733c3c7 100644 --- a/core/community.cpp +++ b/core/community.cpp @@ -1324,7 +1324,7 @@ Species *Community::SpeciesForIndividuals(EidosValue *value) EIDOS_TERMINATION << "ERROR (Community::SpeciesForIndividuals): (internal error) value is not of class Individual." << EidosTerminate(); if (value_count == 1) - return &((Individual *)object_value->ObjectElementAtIndex(0, nullptr))->subpopulation_->species_; + return &((Individual *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_->species_; EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value; Individual **individuals = (Individual **)object_vector_value->data(); @@ -1369,7 +1369,7 @@ Species *Community::SpeciesForGenomes(EidosValue *value) EIDOS_TERMINATION << "ERROR (Community::SpeciesForGenomes): (internal error) value is not of class Genome." << EidosTerminate(); if (value_count == 1) - return &((Genome *)object_value->ObjectElementAtIndex(0, nullptr))->OwningIndividual()->subpopulation_->species_; + return &((Genome *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->OwningIndividual()->subpopulation_->species_; EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value; Genome **genomes = (Genome **)object_vector_value->data(); @@ -1414,7 +1414,7 @@ Species *Community::SpeciesForMutations(EidosValue *value) EIDOS_TERMINATION << "ERROR (Community::SpeciesForMutations): (internal error) value is not of class Mutation." << EidosTerminate(); if (value_count == 1) - return &((Mutation *)object_value->ObjectElementAtIndex(0, nullptr))->mutation_type_ptr_->species_; + return &((Mutation *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->mutation_type_ptr_->species_; EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value; Mutation **mutations = (Mutation **)object_vector_value->data(); diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index 93e2a2127..bafc66861 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -205,7 +205,7 @@ EidosValue_SP Community::ExecuteContextFunction_initializeSLiMModelType(const st { // string$ modelType - std::string model_type = arg_modelType_value->StringAtIndex(0, nullptr); + std::string model_type = arg_modelType_value->StringAtIndex_NOCAST(0, nullptr); if (model_type == "WF") SetModelType(SLiMModelType::kModelTypeWF); @@ -249,10 +249,10 @@ EidosValue_SP Community::ExecuteContextFunction_initializeInteractionType(const EIDOS_TERMINATION << "ERROR (Community::ExecuteContextFunction_initializeInteractionType): in multispecies models, initializeInteractionType() may only be called from a non-species-specific (`species all`) initialize() callback." << EidosTerminate(); slim_objectid_t map_identifier = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 'i'); - std::string spatiality_string = spatiality_value->StringAtIndex(0, nullptr); - bool reciprocal = reciprocal_value->LogicalAtIndex(0, nullptr); // UNUSED - double max_distance = maxDistance_value->FloatAtIndex(0, nullptr); - std::string sex_string = sexSegregation_value->StringAtIndex(0, nullptr); + std::string spatiality_string = spatiality_value->StringAtIndex_NOCAST(0, nullptr); + bool reciprocal = reciprocal_value->LogicalAtIndex_NOCAST(0, nullptr); // UNUSED + double max_distance = maxDistance_value->NumericAtIndex_NOCAST(0, nullptr); + std::string sex_string = sexSegregation_value->StringAtIndex_NOCAST(0, nullptr); IndividualSex receiver_sex = IndividualSex::kUnspecified, exerter_sex = IndividualSex::kUnspecified; if (InteractionTypeWithID(map_identifier)) @@ -454,7 +454,7 @@ void Community::SetProperty(EidosGlobalStringID p_property_id, const EidosValue { case gID_tick: { - int64_t value = p_value.IntAtIndex(0, nullptr); + int64_t value = p_value.IntAtIndex_NOCAST(0, nullptr); slim_tick_t old_tick = tick_; slim_tick_t new_tick = SLiMCastToTickTypeOrRaise(value); @@ -522,7 +522,7 @@ void Community::SetProperty(EidosGlobalStringID p_property_id, const EidosValue case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -530,7 +530,7 @@ void Community::SetProperty(EidosGlobalStringID p_property_id, const EidosValue case gID_verbosity: { - int64_t value = p_value.IntAtIndex(0, nullptr); + int64_t value = p_value.IntAtIndex_NOCAST(0, nullptr); SLiM_verbosity_level = value; // at the command line we bounds-check this, but here I see no need return; @@ -581,11 +581,11 @@ EidosValue_SP Community::ExecuteMethod_createLogFile(EidosGlobalStringID p_metho EidosValue *flushInterval_value = p_arguments[6].get(); // process parameters - const std::string &filePath = filePath_value->StringRefAtIndex(0, nullptr); + const std::string &filePath = filePath_value->StringRefAtIndex_NOCAST(0, nullptr); std::vector initialContents; - bool append = append_value->LogicalAtIndex(0, nullptr); - bool do_compress = compress_value->LogicalAtIndex(0, nullptr); - const std::string &sep = sep_value->StringRefAtIndex(0, nullptr); + bool append = append_value->LogicalAtIndex_NOCAST(0, nullptr); + bool do_compress = compress_value->LogicalAtIndex_NOCAST(0, nullptr); + const std::string &sep = sep_value->StringRefAtIndex_NOCAST(0, nullptr); bool autologging = false, explicitFlushing = false; int64_t logInterval = 0, flushInterval = 0; @@ -595,7 +595,7 @@ EidosValue_SP Community::ExecuteMethod_createLogFile(EidosGlobalStringID p_metho int ic_count = initialContents_value->Count(); for (int ic_index = 0; ic_index < ic_count; ++ic_index) - initialContents.emplace_back(&ic_string_value->StringRefAtIndex(ic_index, nullptr)); + initialContents.emplace_back(&ic_string_value->StringRefAtIndex_NOCAST(ic_index, nullptr)); } if (logInterval_value->Type() == EidosValueType::kValueNULL) @@ -607,7 +607,7 @@ EidosValue_SP Community::ExecuteMethod_createLogFile(EidosGlobalStringID p_metho else { autologging = true; - logInterval = logInterval_value->IntAtIndex(0, nullptr); + logInterval = logInterval_value->IntAtIndex_NOCAST(0, nullptr); } if (flushInterval_value->Type() == EidosValueType::kValueNULL) @@ -619,7 +619,7 @@ EidosValue_SP Community::ExecuteMethod_createLogFile(EidosGlobalStringID p_metho else { explicitFlushing = true; - flushInterval = flushInterval_value->IntAtIndex(0, nullptr); + flushInterval = flushInterval_value->IntAtIndex_NOCAST(0, nullptr); } // Create the LogFile object @@ -724,7 +724,7 @@ EidosValue_SP Community::ExecuteMethod_genomicElementTypesWithIDs(EidosGlobalStr if (ids_count == 1) { // Singleton case - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(0, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(0, nullptr)); GenomicElementType *object = GenomicElementTypeWithID(id); if (!object) @@ -739,7 +739,7 @@ EidosValue_SP Community::ExecuteMethod_genomicElementTypesWithIDs(EidosGlobalStr for (int id_index = 0; id_index < ids_count; id_index++) { - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(id_index, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(id_index, nullptr)); GenomicElementType *object = GenomicElementTypeWithID(id); if (!object) @@ -763,7 +763,7 @@ EidosValue_SP Community::ExecuteMethod_interactionTypesWithIDs(EidosGlobalString if (ids_count == 1) { // Singleton case - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(0, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(0, nullptr)); InteractionType *object = InteractionTypeWithID(id); if (!object) @@ -778,7 +778,7 @@ EidosValue_SP Community::ExecuteMethod_interactionTypesWithIDs(EidosGlobalString for (int id_index = 0; id_index < ids_count; id_index++) { - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(id_index, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(id_index, nullptr)); InteractionType *object = InteractionTypeWithID(id); if (!object) @@ -802,7 +802,7 @@ EidosValue_SP Community::ExecuteMethod_mutationTypesWithIDs(EidosGlobalStringID if (ids_count == 1) { // Singleton case - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(0, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(0, nullptr)); MutationType *object = MutationTypeWithID(id); if (!object) @@ -817,7 +817,7 @@ EidosValue_SP Community::ExecuteMethod_mutationTypesWithIDs(EidosGlobalStringID for (int id_index = 0; id_index < ids_count; id_index++) { - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(id_index, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(id_index, nullptr)); MutationType *object = MutationTypeWithID(id); if (!object) @@ -841,7 +841,7 @@ EidosValue_SP Community::ExecuteMethod_scriptBlocksWithIDs(EidosGlobalStringID p if (ids_count == 1) { // Singleton case - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(0, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(0, nullptr)); SLiMEidosBlock *object = ScriptBlockWithID(id); if (!object) @@ -856,7 +856,7 @@ EidosValue_SP Community::ExecuteMethod_scriptBlocksWithIDs(EidosGlobalStringID p for (int id_index = 0; id_index < ids_count; id_index++) { - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(id_index, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(id_index, nullptr)); SLiMEidosBlock *object = ScriptBlockWithID(id); if (!object) @@ -880,7 +880,7 @@ EidosValue_SP Community::ExecuteMethod_speciesWithIDs(EidosGlobalStringID p_meth if (ids_count == 1) { // Singleton case - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(0, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(0, nullptr)); Species *object = SpeciesWithID(id); if (!object) @@ -895,7 +895,7 @@ EidosValue_SP Community::ExecuteMethod_speciesWithIDs(EidosGlobalStringID p_meth for (int id_index = 0; id_index < ids_count; id_index++) { - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(id_index, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(id_index, nullptr)); Species *object = SpeciesWithID(id); if (!object) @@ -919,7 +919,7 @@ EidosValue_SP Community::ExecuteMethod_subpopulationsWithIDs(EidosGlobalStringID if (ids_count == 1) { // Singleton case - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(0, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(0, nullptr)); Subpopulation *object = SubpopulationWithID(id); if (!object) @@ -934,7 +934,7 @@ EidosValue_SP Community::ExecuteMethod_subpopulationsWithIDs(EidosGlobalStringID for (int id_index = 0; id_index < ids_count; id_index++) { - slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex(id_index, nullptr)); + slim_objectid_t id = SLiMCastToObjectidTypeOrRaise(ids_value->IntAtIndex_NOCAST(id_index, nullptr)); Subpopulation *object = SubpopulationWithID(id); if (!object) @@ -1083,9 +1083,9 @@ EidosValue_SP Community::ExecuteMethod_registerFirstEarlyLateEvent(EidosGlobalSt EidosValue *ticksSpec_value = p_arguments[4].get(); slim_objectid_t script_id = -1; // used if the id is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); @@ -1115,7 +1115,7 @@ EidosValue_SP Community::ExecuteMethod_registerFirstEarlyLateEvent(EidosGlobalSt else EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_registerFirstEarlyLateEvent): (internal error) unrecognized target_type." << EidosTerminate(); - Species *ticksSpec = ((ticksSpec_value->Type() != EidosValueType::kValueNULL) ? (Species *)ticksSpec_value->ObjectElementAtIndex(0, nullptr) : nullptr); + Species *ticksSpec = ((ticksSpec_value->Type() != EidosValueType::kValueNULL) ? (Species *)ticksSpec_value->ObjectElementAtIndex_NOCAST(0, nullptr) : nullptr); if (ticksSpec && !is_explicit_species_) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_registerFirstEarlyLateEvent): ticksSpec must be NULL in models without explicit species declarations." << EidosTerminate(); @@ -1142,17 +1142,17 @@ EidosValue_SP Community::ExecuteMethod_registerInteractionCallback(EidosGlobalSt EidosValue *end_value = p_arguments[5].get(); slim_objectid_t script_id = -1; // used if the id is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); - slim_objectid_t int_type_id = (intType_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(intType_value->IntAtIndex(0, nullptr)) : ((InteractionType *)intType_value->ObjectElementAtIndex(0, nullptr))->interaction_type_id_; + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); + slim_objectid_t int_type_id = (intType_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(intType_value->IntAtIndex_NOCAST(0, nullptr)) : ((InteractionType *)intType_value->ObjectElementAtIndex_NOCAST(0, nullptr))->interaction_type_id_; slim_objectid_t subpop_id = -1; - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); if (subpop_value->Type() != EidosValueType::kValueNULL) - subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex(0, nullptr))->subpopulation_id_; + subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_id_; if (start_tick > end_tick) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_registerInteractionCallback): registerInteractionCallback() requires start <= end." << EidosTerminate(); @@ -1245,8 +1245,8 @@ EidosValue_SP Community::ExecuteMethod_rescheduleScriptBlock(EidosGlobalStringID { // start/end case; this is simple - slim_tick_t start = (start_null ? 1 : SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr))); - slim_tick_t end = (end_null ? SLIM_MAX_TICK + 1 : SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr))); + slim_tick_t start = (start_null ? 1 : SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr))); + slim_tick_t end = (end_null ? SLIM_MAX_TICK + 1 : SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr))); if (start > end) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_rescheduleScriptBlock): rescheduleScriptBlock() requires start <= end." << EidosTerminate(); @@ -1281,7 +1281,7 @@ EidosValue_SP Community::ExecuteMethod_rescheduleScriptBlock(EidosGlobalStringID ticks.reserve(tick_count); for (int tick_index = 0; tick_index < tick_count; ++tick_index) - ticks.emplace_back(SLiMCastToTickTypeOrRaise(ticks_value->IntAtIndex(tick_index, nullptr))); + ticks.emplace_back(SLiMCastToTickTypeOrRaise(ticks_value->IntAtIndex_NOCAST(tick_index, nullptr))); // next, sort the tick list and check that the first scheduling it requests is not in the past std::sort(ticks.begin(), ticks.end()); diff --git a/core/genome.cpp b/core/genome.cpp index ddfaa6f0a..c03a16689 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -542,7 +542,7 @@ void Genome::SetProperty(EidosGlobalStringID p_property_id, const EidosValue &p_ { case gID_tag: // ACCELERATED { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; Individual::s_any_genome_tag_set_ = true; @@ -563,7 +563,7 @@ void Genome::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values // SLiMCastToUsertagTypeOrRaise() is a no-op at present if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Genome *)(p_values[value_index]))->tag_value_ = source_value; @@ -613,13 +613,13 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMarkerMutation(EidosObje Species &species = *genomes_species; MutationType *mutation_type_ptr = SLiM_ExtractMutationTypeFromEidosValue_io(mutType_value, 0, &species.community_, &species, "containsMarkerMutation()"); // SPECIES CONSISTENCY CHECK - slim_position_t marker_position = SLiMCastToPositionTypeOrRaise(position_value->IntAtIndex(0, nullptr)); + slim_position_t marker_position = SLiMCastToPositionTypeOrRaise(position_value->IntAtIndex_NOCAST(0, nullptr)); slim_position_t last_position = species.TheChromosome().last_position_; if (marker_position > last_position) EIDOS_TERMINATION << "ERROR (Genome::ExecuteMethod_Accelerated_containsMarkerMutation): containsMarkerMutation() position " << marker_position << " is past the end of the chromosome." << EidosTerminate(); - eidos_logical_t returnMutation = returnMutation_value->LogicalAtIndex(0, nullptr); + eidos_logical_t returnMutation = returnMutation_value->LogicalAtIndex_NOCAST(0, nullptr); if (p_elements_size == 1) { @@ -724,7 +724,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMutations(EidosObject ** if (mutations_count == 1) { - Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex(0, nullptr)); + Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(0, nullptr)); MutationIndex mut_block_index = mut->BlockIndex(); slim_position_t mutrun_length = ((Genome *)(p_elements[0]))->mutrun_length_; // assume all Genome objects have the same mutrun_length_; better be true... slim_position_t mutrun_index = mut->position_ / mutrun_length; @@ -948,8 +948,8 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, EidosValue *start_value = p_arguments[0].get(); EidosValue *end_value = p_arguments[1].get(); - int64_t start = (start_value->Type() == EidosValueType::kValueNULL) ? 0 : start_value->IntAtIndex(0, nullptr); - int64_t end = (end_value->Type() == EidosValueType::kValueNULL) ? last_position : end_value->IntAtIndex(0, nullptr); + int64_t start = (start_value->Type() == EidosValueType::kValueNULL) ? 0 : start_value->IntAtIndex_NOCAST(0, nullptr); + int64_t end = (end_value->Type() == EidosValueType::kValueNULL) ? last_position : end_value->IntAtIndex_NOCAST(0, nullptr); if ((start < 0) || (end < 0) || (start > last_position) || (end > last_position) || (start > end)) EIDOS_TERMINATION << "ERROR (Genome::ExecuteMethod_nucleotides): start and end must be within the chromosome's extent, and start must be <= end." << EidosTerminate(); @@ -962,7 +962,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, EIDOS_TERMINATION << "ERROR (Genome::ExecuteMethod_nucleotides): the returned vector would exceed the maximum vector length in Eidos." << EidosTerminate(); EidosValue_String *format_value = (EidosValue_String *)p_arguments[2].get(); - const std::string &format = format_value->StringRefAtIndex(0, nullptr); + const std::string &format = format_value->StringRefAtIndex_NOCAST(0, nullptr); if (format == "codon") { @@ -2111,7 +2111,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met Community &community = species->community_; // use the 0th genome in the target to find out what the mutation run length is, so we can calculate run indices - Genome *genome_0 = (Genome *)p_target->ObjectElementAtIndex(0, nullptr); + Genome *genome_0 = (Genome *)p_target->ObjectElementAtIndex_NOCAST(0, nullptr); slim_position_t mutrun_length = genome_0->mutrun_length_; // check that the individuals that mutations are being added to have age == 0, in nonWF models, to prevent tree sequence inconsistencies (see issue #102) @@ -2119,7 +2119,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met { for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); Individual *target_individual = target_genome->OwningIndividual(); if (target_individual->age_ > 0) @@ -2165,7 +2165,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); if ((target_genome != focal_genome_1) && (target_genome != focal_genome_2)) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addMutations): addMutations() cannot be called on the currently executing species from within a modifyChild() callback to modify any genomes except those of the focal child being generated." << EidosTerminate(); @@ -2180,7 +2180,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met // check that the same genome is not included more than once as a target, which we don't allow; we use patch_pointer as scratch for (int target_index = 0; target_index < target_size; ++target_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(target_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(target_index, nullptr); if (target_genome->IsNull()) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addMutations): addMutations() cannot be called on a null genome." << EidosTerminate(); @@ -2190,7 +2190,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met for (int target_index = 0; target_index < target_size; ++target_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(target_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(target_index, nullptr); if (target_genome->scratch_ != 1) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addMutations): addMutations() cannot be called on the same genome more than once (you must eliminate duplicates in the target vector)." << EidosTerminate(); @@ -2204,7 +2204,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met for (int value_index = 0; value_index < mutations_count; ++value_index) { - Mutation *mut_to_add = (Mutation *)mutations_value->ObjectElementAtIndex(value_index, nullptr); + Mutation *mut_to_add = (Mutation *)mutations_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); if ((mut_to_add->state_ == MutationState::kFixedAndSubstituted) || (mut_to_add->state_ == MutationState::kRemovedWithSubstitution)) @@ -2236,7 +2236,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met { for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); GenomeWalker walker(target_genome); slim_position_t last_added_pos = -1; @@ -2308,7 +2308,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addMutations(EidosGlobalStringID p_met for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); // See if WillModifyRunForBulkOperation() can short-circuit the operation for us MutationRun *target_run = target_genome->WillModifyRunForBulkOperation(operation_id, mutrun_index, mutrun_context); @@ -2399,7 +2399,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m Community &community = species->community_; // get the 0th genome in the target to find out what the mutation run length is, so we can calculate run indices - Genome *genome_0 = (Genome *)p_target->ObjectElementAtIndex(0, nullptr); + Genome *genome_0 = (Genome *)p_target->ObjectElementAtIndex_NOCAST(0, nullptr); int mutrun_count = genome_0->mutrun_count_; slim_position_t mutrun_length = genome_0->mutrun_length_; @@ -2408,7 +2408,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m { for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); Individual *target_individual = target_genome->OwningIndividual(); if (target_individual->age_ > 0) @@ -2458,7 +2458,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); if ((target_genome != focal_genome_1) && (target_genome != focal_genome_2)) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " cannot be called on the currently executing species from within a modifyChild() callback to modify any genomes except those of the focal child being generated." << EidosTerminate(); @@ -2497,12 +2497,12 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m return retval; // before proceeding, let's check that all positions supplied are valid, so we don't need to worry about it below - // would be better not to call IntAtIndex() multiple times for the same position, but that will not be the majority of our time anyway... + // would be better not to call IntAtIndex_NOCAST() multiple times for the same position, but that will not be the majority of our time anyway... slim_position_t last_position = species->TheChromosome().last_position_; for (int position_index = 0; position_index < position_count; ++position_index) { - slim_position_t position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex(position_index, nullptr)); + slim_position_t position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex_NOCAST(position_index, nullptr)); if (position > last_position) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " position " << position << " is past the end of the chromosome." << EidosTerminate(); @@ -2538,7 +2538,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m { for (int nucleotide_index = 0; nucleotide_index < nucleotide_count; ++nucleotide_index) { - int64_t nuc_int = arg_nucleotide->IntAtIndex(nucleotide_index, nullptr); + int64_t nuc_int = arg_nucleotide->IntAtIndex_NOCAST(nucleotide_index, nullptr); if ((nuc_int < 0) || (nuc_int > 3)) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " requires integer nucleotide values to be in [0,3]." << EidosTerminate(); @@ -2548,7 +2548,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m { for (int nucleotide_index = 0; nucleotide_index < nucleotide_count; ++nucleotide_index) { - uint8_t nuc = nucleotide_lookup[(unsigned char)(arg_nucleotide->StringAtIndex(nucleotide_index, nullptr)[0])]; + uint8_t nuc = nucleotide_lookup[(unsigned char)(arg_nucleotide->StringAtIndex_NOCAST(nucleotide_index, nullptr)[0])]; if (nuc > 3) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " requires string nucleotide values to be 'A', 'C', 'G', or 'T'." << EidosTerminate(); @@ -2559,7 +2559,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m // check that the same genome is not included more than once as a target, which we don't allow; we use patch_pointer as scratch for (int target_index = 0; target_index < target_size; ++target_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(target_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(target_index, nullptr); if (target_genome->IsNull()) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " cannot be called on a null genome." << EidosTerminate(); @@ -2569,7 +2569,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m for (int target_index = 0; target_index < target_size; ++target_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(target_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(target_index, nullptr); if (target_genome->scratch_ != 1) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " cannot be called on the same genome more than once (you must eliminate duplicates in the target vector)." << EidosTerminate(); @@ -2589,7 +2589,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m { for (int pos_index = 0; pos_index < position_count; ++pos_index) { - slim_position_t position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex(pos_index, nullptr)); + slim_position_t position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex_NOCAST(pos_index, nullptr)); mutrun_indexes.emplace_back((slim_mutrun_index_t)(position / mutrun_length)); } @@ -2600,9 +2600,9 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m // for the singleton case for each of the parameters, get all the info MutationType *singleton_mutation_type_ptr = SLiM_ExtractMutationTypeFromEidosValue_io(arg_muttype, 0, &community, species, method_name.c_str()); // SPECIES CONSISTENCY CHECK - double singleton_selection_coeff = (arg_selcoeff ? arg_selcoeff->FloatAtIndex(0, nullptr) : 0.0); + double singleton_selection_coeff = (arg_selcoeff ? arg_selcoeff->NumericAtIndex_NOCAST(0, nullptr) : 0.0); - slim_position_t singleton_position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex(0, nullptr)); + slim_position_t singleton_position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex_NOCAST(0, nullptr)); slim_tick_t origin_tick = community.Tick(); @@ -2615,20 +2615,20 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m // We set the origin subpopulation based on the first genome in the target if (target_size >= 1) { - Genome *first_target = (Genome *)p_target->ObjectElementAtIndex(0, nullptr); + Genome *first_target = (Genome *)p_target->ObjectElementAtIndex_NOCAST(0, nullptr); singleton_origin_subpop_id = first_target->individual_->subpopulation_->subpopulation_id_; } } else if (arg_origin_subpop->Type() == EidosValueType::kValueInt) - singleton_origin_subpop_id = SLiMCastToObjectidTypeOrRaise(arg_origin_subpop->IntAtIndex(0, nullptr)); + singleton_origin_subpop_id = SLiMCastToObjectidTypeOrRaise(arg_origin_subpop->IntAtIndex_NOCAST(0, nullptr)); else { #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // The class should be guaranteed by the method signature already - Subpopulation *origin_subpop = dynamic_cast(arg_origin_subpop->ObjectElementAtIndex(0, nullptr)); + Subpopulation *origin_subpop = dynamic_cast(arg_origin_subpop->ObjectElementAtIndex_NOCAST(0, nullptr)); #else - Subpopulation *origin_subpop = ((Subpopulation *)(arg_origin_subpop->ObjectElementAtIndex(0, nullptr))); + Subpopulation *origin_subpop = ((Subpopulation *)(arg_origin_subpop->ObjectElementAtIndex_NOCAST(0, nullptr))); #endif // SPECIES CONSISTENCY CHECK @@ -2643,9 +2643,9 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m if (arg_nucleotide->Type() == EidosValueType::kValueNULL) singleton_nucleotide = -1; else if (arg_nucleotide->Type() == EidosValueType::kValueInt) - singleton_nucleotide = arg_nucleotide->IntAtIndex(0, nullptr); + singleton_nucleotide = arg_nucleotide->IntAtIndex_NOCAST(0, nullptr); else - singleton_nucleotide = nucleotide_lookup[(unsigned char)(arg_nucleotide->StringAtIndex(0, nullptr)[0])]; + singleton_nucleotide = nucleotide_lookup[(unsigned char)(arg_nucleotide->StringAtIndex_NOCAST(0, nullptr)[0])]; // ok, now loop to add the mutations in a single bulk operation per mutation run bool recording_tree_sequence_mutations = species->RecordingTreeSequenceMutations(); @@ -2667,7 +2667,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m for (int mut_parameter_index = 0; mut_parameter_index < count_to_add; ++mut_parameter_index) { if (position_count != 1) - position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex(mut_parameter_index, nullptr)); + position = SLiMCastToPositionTypeOrRaise(arg_position->IntAtIndex_NOCAST(mut_parameter_index, nullptr)); // check that this mutation will be added to this mutation run if (position / mutrun_length == mutrun_index) @@ -2678,7 +2678,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m if (selcoeff_count != 1) { if (arg_selcoeff) - selection_coeff = arg_selcoeff->FloatAtIndex(mut_parameter_index, nullptr); + selection_coeff = arg_selcoeff->NumericAtIndex_NOCAST(mut_parameter_index, nullptr); else selection_coeff = mutation_type_ptr->DrawSelectionCoefficient(); } @@ -2686,14 +2686,14 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m if (origin_subpop_count != 1) { if (arg_origin_subpop->Type() == EidosValueType::kValueInt) - origin_subpop_id = SLiMCastToObjectidTypeOrRaise(arg_origin_subpop->IntAtIndex(mut_parameter_index, nullptr)); + origin_subpop_id = SLiMCastToObjectidTypeOrRaise(arg_origin_subpop->IntAtIndex_NOCAST(mut_parameter_index, nullptr)); else #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // The class should be guaranteed by the method signature already - origin_subpop_id = dynamic_cast(arg_origin_subpop->ObjectElementAtIndex(mut_parameter_index, nullptr))->subpopulation_id_; + origin_subpop_id = dynamic_cast(arg_origin_subpop->ObjectElementAtIndex_NOCAST(mut_parameter_index, nullptr))->subpopulation_id_; #else - origin_subpop_id = ((Subpopulation *)(arg_origin_subpop->ObjectElementAtIndex(mut_parameter_index, nullptr)))->subpopulation_id_; + origin_subpop_id = ((Subpopulation *)(arg_origin_subpop->ObjectElementAtIndex_NOCAST(mut_parameter_index, nullptr)))->subpopulation_id_; #endif } @@ -2701,9 +2701,9 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m { // Already checked for validity above if (arg_nucleotide->Type() == EidosValueType::kValueInt) - nucleotide = arg_nucleotide->IntAtIndex(mut_parameter_index, nullptr); + nucleotide = arg_nucleotide->IntAtIndex_NOCAST(mut_parameter_index, nullptr); else - nucleotide = nucleotide_lookup[(unsigned char)(arg_nucleotide->StringAtIndex(mut_parameter_index, nullptr)[0])]; + nucleotide = nucleotide_lookup[(unsigned char)(arg_nucleotide->StringAtIndex_NOCAST(mut_parameter_index, nullptr)[0])]; } MutationIndex new_mut_index = SLiM_NewMutationFromBlock(); @@ -2744,7 +2744,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m for (int target_index = 0; target_index < target_size; ++target_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(target_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(target_index, nullptr); // See if WillModifyRunForBulkOperation() can short-circuit the operation for us const MutationRun *original_run = target_genome->mutruns_[mutrun_index]; @@ -2815,7 +2815,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_mutationFreqsCountsInGenomes(EidosGlob for (int target_index = 0; target_index < target_size; ++target_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(target_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(target_index, nullptr); if (target_genome->IsNull()) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_mutationFreqsCountsInGenomes): " << EidosStringRegistry::StringForGlobalStringID(p_method_id) << "() cannot be called on a null genome." << EidosTerminate(); @@ -2869,23 +2869,23 @@ EidosValue_SP Genome_Class::ExecuteMethod_outputX(EidosGlobalStringID p_method_i bool output_multiallelics = true; if (p_method_id == gID_outputVCF) - output_multiallelics = outputMultiallelics_value->LogicalAtIndex(0, nullptr); + output_multiallelics = outputMultiallelics_value->LogicalAtIndex_NOCAST(0, nullptr); bool simplify_nucs = false; if (p_method_id == gID_outputVCF) - simplify_nucs = simplifyNucleotides_value->LogicalAtIndex(0, nullptr); + simplify_nucs = simplifyNucleotides_value->LogicalAtIndex_NOCAST(0, nullptr); bool output_nonnucs = true; if (p_method_id == gID_outputVCF) - output_nonnucs = outputNonnucleotides_value->LogicalAtIndex(0, nullptr); + output_nonnucs = outputNonnucleotides_value->LogicalAtIndex_NOCAST(0, nullptr); // figure out if we're filtering out mutations that are monomorphic within the sample (MS output only) bool filter_monomorphic = false; if (p_method_id == gID_outputMS) - filter_monomorphic = filterMonomorphic_value->LogicalAtIndex(0, nullptr); + filter_monomorphic = filterMonomorphic_value->LogicalAtIndex_NOCAST(0, nullptr); // Get all the genomes we're sampling from p_target; they must all be in the same species, which we determine here // We require at least one genome because otherwise we can't determine the species @@ -2898,7 +2898,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_outputX(EidosGlobalStringID p_method_i for (int index = 0; index < sample_size; ++index) { - Genome *genome = (Genome *)p_target->ObjectElementAtIndex(index, nullptr); + Genome *genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(index, nullptr); Species *genome_species = &genome->individual_->subpopulation_->species_; if (!species) @@ -2944,8 +2944,8 @@ EidosValue_SP Genome_Class::ExecuteMethod_outputX(EidosGlobalStringID p_method_i else { // Otherwise, output to filePath - std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex(0, nullptr)); - bool append = append_value->LogicalAtIndex(0, nullptr); + std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex_NOCAST(0, nullptr)); + bool append = append_value->LogicalAtIndex_NOCAST(0, nullptr); std::ofstream outfile; outfile.open(outfile_path.c_str(), append ? (std::ios_base::app | std::ios_base::out) : std::ios_base::out); @@ -2992,7 +2992,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromMS(EidosGlobalStringID p_metho EidosValue *mutationType_value = p_arguments[1].get(); Community &community = SLiM_GetCommunityFromInterpreter(p_interpreter); - std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex(0, nullptr))); + std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex_NOCAST(0, nullptr))); MutationType *mutation_type_ptr = nullptr; if (mutationType_value->Type() != EidosValueType::kValueNULL) @@ -3181,7 +3181,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromMS(EidosGlobalStringID p_metho for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); bool genome_started_empty = (genome->mutation_count() == 0); slim_position_t mutrun_length = genome->mutrun_length_; slim_mutrun_index_t current_run_index = -1; @@ -3259,7 +3259,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromVCF(EidosGlobalStringID p_meth slim_position_t last_position = species->TheChromosome().last_position_; bool recording_mutations = species->RecordingTreeSequenceMutations(); bool nucleotide_based = species->IsNucleotideBased(); - std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex(0, nullptr))); + std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex_NOCAST(0, nullptr))); MutationType *default_mutation_type_ptr = nullptr; if (mutationType_value->Type() != EidosValueType::kValueNULL) @@ -3372,7 +3372,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromVCF(EidosGlobalStringID p_meth for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); // null genomes are silently excluded from the target list, for convenience if (!genome->IsNull()) @@ -3842,12 +3842,12 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ Community &community = species->community_; Population &pop = species->population_; slim_tick_t tick = community.Tick(); - bool create_substitutions = substitute_value->LogicalAtIndex(0, nullptr); + bool create_substitutions = substitute_value->LogicalAtIndex_NOCAST(0, nullptr); bool recording_tree_sequence_mutations = species->RecordingTreeSequenceMutations(); bool any_nonneutral_removed = false; // Use the 0th genome in the target to find out what the mutation run length is, so we can calculate run indices - Genome *genome_0 = (Genome *)p_target->ObjectElementAtIndex(0, nullptr); + Genome *genome_0 = (Genome *)p_target->ObjectElementAtIndex_NOCAST(0, nullptr); slim_position_t mutrun_length = genome_0->mutrun_length_; // TIMING RESTRICTION @@ -3867,7 +3867,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); if ((target_genome != focal_genome_1) && (target_genome != focal_genome_2)) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_removeMutations): removeMutations() cannot be called on the currently executing species from within a modifyChild() callback to modify any genomes except those of the focal child being generated." << EidosTerminate(); @@ -3900,7 +3900,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); if (target_genome->IsNull()) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_removeMutations): removeMutations() cannot be called on a null genome. This error may be due to a break in backward compatibility in SLiM 3.7 involving addRecombinant() with haploid models; if that seems likely, please see the release notes." << EidosTerminate(); @@ -3920,7 +3920,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); if (target_genome->IsNull()) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_removeMutations): removeMutations() cannot be called on a null genome. This error may be due to a break in backward compatibility in SLiM 3.7 involving addRecombinant() with haploid models; if that seems likely, please see the release notes." << EidosTerminate(); @@ -3992,7 +3992,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ for (int value_index = 0; value_index < mutations_count; ++value_index) { - Mutation *mut = (Mutation *)mutations_value->ObjectElementAtIndex(value_index, nullptr); + Mutation *mut = (Mutation *)mutations_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); if (mut->state_ != MutationState::kInRegistry) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_removeMutations): removeMutations() cannot remove mutations that are not currently segregating (i.e., have either been fixed/substituted or lost)." << EidosTerminate(); @@ -4022,7 +4022,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ { for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); GenomeWalker walker(target_genome); slim_position_t last_added_pos = -1; @@ -4076,7 +4076,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ { for (int value_index = 0; value_index < mutations_count; ++value_index) { - Mutation *mut = (Mutation *)mutations_value->ObjectElementAtIndex(value_index, nullptr); + Mutation *mut = (Mutation *)mutations_value->ObjectElementAtIndex_NOCAST(value_index, nullptr); Substitution *sub = new Substitution(*mut, tick); // TREE SEQUENCE RECORDING @@ -4104,7 +4104,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ genome->scratch_ = (genome->IsNull() ? 0 : 1); for (int genome_index = 0; genome_index < target_size; ++genome_index) - ((Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr))->scratch_ = 0; + ((Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr))->scratch_ = 0; // Figure out the unique chromosome positions that have changed (the uniqued set of mutation positions) std::vector unique_positions; @@ -4154,7 +4154,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_removeMutations(EidosGlobalStringID p_ for (int genome_index = 0; genome_index < target_size; ++genome_index) { - Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex(genome_index, nullptr); + Genome *target_genome = (Genome *)p_target->ObjectElementAtIndex_NOCAST(genome_index, nullptr); if (target_genome->IsNull()) { diff --git a/core/genomic_element.cpp b/core/genomic_element.cpp index d52b8cabb..9312d1a16 100644 --- a/core/genomic_element.cpp +++ b/core/genomic_element.cpp @@ -167,7 +167,7 @@ void GenomicElement::SetProperty(EidosGlobalStringID p_property_id, const EidosV { case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index 8a8a9dc1f..4cb432707 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -124,17 +124,17 @@ void GenomicElementType::SetNucleotideMutationMatrix(const EidosValue_Float_vect static int required_zeros_4x4[4] = {0, 5, 10, 15}; for (int required_zeros : required_zeros_4x4) - if (mutation_matrix_->FloatAtIndex(required_zeros, nullptr) != 0.0) + if (mutation_matrix_->FloatAtIndex_NOCAST(required_zeros, nullptr) != 0.0) EIDOS_TERMINATION << "ERROR (GenomicElementType::SetNucleotideMutationMatrix): the mutationMatrix must contain 0.0 for all entries that correspond to a nucleotide mutating to itself." << EidosTerminate(); // check that each row sums to <= 1.0; in fact this has to be <= 1.0 even when multiplied by the hotspot map, but this is a preliminary sanity check // check also for no negative values, and for all values being finite for (int row = 0; row < 4; ++row) { - double row_1 = mutation_matrix_->FloatAtIndex(row, nullptr); - double row_2 = mutation_matrix_->FloatAtIndex(row + 4, nullptr); - double row_3 = mutation_matrix_->FloatAtIndex(row + 8, nullptr); - double row_4 = mutation_matrix_->FloatAtIndex(row + 12, nullptr); + double row_1 = mutation_matrix_->FloatAtIndex_NOCAST(row, nullptr); + double row_2 = mutation_matrix_->FloatAtIndex_NOCAST(row + 4, nullptr); + double row_3 = mutation_matrix_->FloatAtIndex_NOCAST(row + 8, nullptr); + double row_4 = mutation_matrix_->FloatAtIndex_NOCAST(row + 12, nullptr); if ((row_1 < 0.0) || (row_2 < 0.0) || (row_3 < 0.0) || (row_4 < 0.0) || !std::isfinite(row_1) || !std::isfinite(row_2) || !std::isfinite(row_3) || !std::isfinite(row_4)) @@ -151,17 +151,17 @@ void GenomicElementType::SetNucleotideMutationMatrix(const EidosValue_Float_vect static int required_zeros_64x4[64] = {0, 1, 2, 3, 16, 17, 18, 19, 32, 33, 34, 35, 48, 49, 50, 51, 68, 69, 70, 71, 84, 85, 86, 87, 100, 101, 102, 103, 116, 117, 118, 119, 136, 137, 138, 139, 152, 153, 154, 155, 168, 169, 170, 171, 184, 185, 186, 187, 204, 205, 206, 207, 220, 221, 222, 223, 236, 237, 238, 239, 252, 253, 254, 255}; for (int required_zeros : required_zeros_64x4) - if (mutation_matrix_->FloatAtIndex(required_zeros, nullptr) != 0.0) + if (mutation_matrix_->FloatAtIndex_NOCAST(required_zeros, nullptr) != 0.0) EIDOS_TERMINATION << "ERROR (GenomicElementType::SetNucleotideMutationMatrix): the mutationMatrix must contain 0.0 for all entries that correspond to a nucleotide mutating to itself." << EidosTerminate(); // check that each row sums to <= 1.0; in fact this has to be <= 1.0 even when multiplied by the hotspot map, but this is a preliminary sanity check // check also for no negative values for (int row = 0; row < 64; ++row) { - double row_1 = mutation_matrix_->FloatAtIndex(row, nullptr); - double row_2 = mutation_matrix_->FloatAtIndex(row + 64, nullptr); - double row_3 = mutation_matrix_->FloatAtIndex(row + 128, nullptr); - double row_4 = mutation_matrix_->FloatAtIndex(row + 192, nullptr); + double row_1 = mutation_matrix_->FloatAtIndex_NOCAST(row, nullptr); + double row_2 = mutation_matrix_->FloatAtIndex_NOCAST(row + 64, nullptr); + double row_3 = mutation_matrix_->FloatAtIndex_NOCAST(row + 128, nullptr); + double row_4 = mutation_matrix_->FloatAtIndex_NOCAST(row + 192, nullptr); if ((row_1 < 0.0) || (row_2 < 0.0) || (row_3 < 0.0) || (row_4 < 0.0) || !std::isfinite(row_1) || !std::isfinite(row_2) || !std::isfinite(row_3) || !std::isfinite(row_4)) @@ -336,7 +336,7 @@ void GenomicElementType::SetProperty(EidosGlobalStringID p_property_id, const Ei { case gEidosID_color: { - color_ = p_value.StringAtIndex(0, nullptr); + color_ = p_value.StringAtIndex_NOCAST(0, nullptr); if (!color_.empty()) Eidos_GetColorComponents(color_, &color_red_, &color_green_, &color_blue_); @@ -347,7 +347,7 @@ void GenomicElementType::SetProperty(EidosGlobalStringID p_property_id, const Ei } case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -390,7 +390,7 @@ EidosValue_SP GenomicElementType::ExecuteMethod_setMutationFractions(EidosGlobal for (int mut_type_index = 0; mut_type_index < mut_type_id_count; ++mut_type_index) { MutationType *mutation_type_ptr = SLiM_ExtractMutationTypeFromEidosValue_io(mutationTypes_value, mut_type_index, &species_.community_, &species_, "setMutationFractions()"); // SPECIES CONSISTENCY CHECK - double proportion = proportions_value->FloatAtIndex(mut_type_index, nullptr); + double proportion = proportions_value->NumericAtIndex_NOCAST(mut_type_index, nullptr); if ((proportion < 0) || !std::isfinite(proportion)) // == 0 is allowed but must be fixed before the simulation executes; see InitializeDraws() EIDOS_TERMINATION << "ERROR (GenomicElementType::ExecuteMethod_setMutationFractions): setMutationFractions() proportions must be greater than or equal to zero (" << EidosStringForFloat(proportion) << " supplied)." << EidosTerminate(); diff --git a/core/individual.cpp b/core/individual.cpp index 201fd22c4..1700cad8d 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -1119,7 +1119,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue { case gEidosID_color: // ACCELERATED { - const std::string &color_string = ((EidosValue_String &)p_value).StringRefAtIndex(0, nullptr); + const std::string &color_string = ((EidosValue_String &)p_value).StringRefAtIndex_NOCAST(0, nullptr); if (color_string.empty()) { @@ -1135,7 +1135,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tag: // ACCELERATED { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; s_any_individual_tag_set_ = true; @@ -1143,13 +1143,13 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tagF: // ACCELERATED { - tagF_value_ = p_value.FloatAtIndex(0, nullptr); + tagF_value_ = p_value.FloatAtIndex_NOCAST(0, nullptr); s_any_individual_tagF_set_ = true; return; } case gID_tagL0: // ACCELERATED { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); tagL0_set_ = true; tagL0_value_ = value; @@ -1158,7 +1158,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tagL1: // ACCELERATED { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); tagL1_set_ = true; tagL1_value_ = value; @@ -1167,7 +1167,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tagL2: // ACCELERATED { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); tagL2_set_ = true; tagL2_value_ = value; @@ -1176,7 +1176,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tagL3: // ACCELERATED { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); tagL3_set_ = true; tagL3_value_ = value; @@ -1185,7 +1185,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tagL4: // ACCELERATED { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); tagL4_set_ = true; tagL4_value_ = value; @@ -1194,7 +1194,7 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_fitnessScaling: // ACCELERATED { - fitness_scaling_ = p_value.FloatAtIndex(0, nullptr); + fitness_scaling_ = p_value.FloatAtIndex_NOCAST(0, nullptr); Individual::s_any_individual_fitness_scaling_set_ = true; if ((fitness_scaling_ < 0.0) || (std::isnan(fitness_scaling_))) @@ -1204,22 +1204,22 @@ void Individual::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gEidosID_x: // ACCELERATED { - spatial_x_ = p_value.FloatAtIndex(0, nullptr); + spatial_x_ = p_value.FloatAtIndex_NOCAST(0, nullptr); return; } case gEidosID_y: // ACCELERATED { - spatial_y_ = p_value.FloatAtIndex(0, nullptr); + spatial_y_ = p_value.FloatAtIndex_NOCAST(0, nullptr); return; } case gEidosID_z: // ACCELERATED { - spatial_z_ = p_value.FloatAtIndex(0, nullptr); + spatial_z_ = p_value.FloatAtIndex_NOCAST(0, nullptr); return; } case gID_age: // ACCELERATED { - slim_age_t value = SLiMCastToAgeTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_age_t value = SLiMCastToAgeTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); age_ = value; return; @@ -1238,7 +1238,7 @@ void Individual::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_va // SLiMCastToUsertagTypeOrRaise() is a no-op at present if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->tag_value_ = source_value; @@ -1259,7 +1259,7 @@ void Individual::SetProperty_Accelerated_tagF(EidosObject **p_values, size_t p_v // SLiMCastToUsertagTypeOrRaise() is a no-op at present if (p_source_size == 1) { - double source_value = p_source.FloatAtIndex(0, nullptr); + double source_value = p_source.FloatAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->tagF_value_ = source_value; @@ -1473,7 +1473,7 @@ void Individual::SetProperty_Accelerated_fitnessScaling(EidosObject **p_values, if (p_source_size == 1) { - double source_value = p_source.FloatAtIndex(0, nullptr); + double source_value = p_source.FloatAtIndex_NOCAST(0, nullptr); needs_raise = _SetFitnessScaling_1(source_value, p_values, p_values_size); } @@ -1492,7 +1492,7 @@ void Individual::SetProperty_Accelerated_x(EidosObject **p_values, size_t p_valu { if (p_source_size == 1) { - double source_value = p_source.FloatAtIndex(0, nullptr); + double source_value = p_source.FloatAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_x_ = source_value; @@ -1510,7 +1510,7 @@ void Individual::SetProperty_Accelerated_y(EidosObject **p_values, size_t p_valu { if (p_source_size == 1) { - double source_value = p_source.FloatAtIndex(0, nullptr); + double source_value = p_source.FloatAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_y_ = source_value; @@ -1528,7 +1528,7 @@ void Individual::SetProperty_Accelerated_z(EidosObject **p_values, size_t p_valu { if (p_source_size == 1) { - double source_value = p_source.FloatAtIndex(0, nullptr); + double source_value = p_source.FloatAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Individual *)(p_values[value_index]))->spatial_z_ = source_value; @@ -1546,7 +1546,7 @@ void Individual::SetProperty_Accelerated_color(EidosObject **p_values, size_t p_ { if (p_source_size == 1) { - const std::string &source_value = ((EidosValue_String &)p_source).StringRefAtIndex(0, nullptr); + const std::string &source_value = ((EidosValue_String &)p_source).StringRefAtIndex_NOCAST(0, nullptr); if (source_value.empty()) { @@ -1599,7 +1599,7 @@ void Individual::SetProperty_Accelerated_age(EidosObject **p_values, size_t p_va { if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); slim_age_t source_age = SLiMCastToAgeTypeOrRaise(source_value); for (size_t value_index = 0; value_index < p_values_size; ++value_index) @@ -1659,7 +1659,7 @@ EidosValue_SP Individual::ExecuteMethod_containsMutations(EidosGlobalStringID p_ if (mutations_count == 1) { - MutationIndex mut = ((Mutation *)(mutations_value->ObjectElementAtIndex(0, nullptr)))->BlockIndex(); + MutationIndex mut = ((Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(0, nullptr)))->BlockIndex(); if ((!genome1_->IsNull() && genome1_->contains_mutation(mut)) || (!genome2_->IsNull() && genome2_->contains_mutation(mut))) return gStaticEidosValue_LogicalT; @@ -1672,7 +1672,7 @@ EidosValue_SP Individual::ExecuteMethod_containsMutations(EidosGlobalStringID p_ for (int value_index = 0; value_index < mutations_count; ++value_index) { - MutationIndex mut = ((Mutation *)(mutations_value->ObjectElementAtIndex(value_index, nullptr)))->BlockIndex(); + MutationIndex mut = ((Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)))->BlockIndex(); bool contains_mut = ((!genome1_->IsNull() && genome1_->contains_mutation(mut)) || (!genome2_->IsNull() && genome2_->contains_mutation(mut))); logical_result->set_logical_no_check(contains_mut, value_index); @@ -1774,7 +1774,7 @@ EidosValue_SP Individual::ExecuteMethod_relatedness(EidosGlobalStringID p_method if (individuals_count == 1) { - Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex(0, nullptr)); + Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex_NOCAST(0, nullptr)); double relatedness; if (pedigree_tracking_enabled) @@ -1796,7 +1796,7 @@ EidosValue_SP Individual::ExecuteMethod_relatedness(EidosGlobalStringID p_method #pragma omp parallel for schedule(dynamic, 128) default(none) shared(individuals_count, individuals_value) firstprivate(float_result) if(individuals_count >= EIDOS_OMPMIN_RELATEDNESS) num_threads(thread_count) for (int value_index = 0; value_index < individuals_count; ++value_index) { - Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex(value_index, nullptr)); + Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); double relatedness = RelatednessToIndividual(*ind); float_result->set_float_no_check(relatedness, value_index); @@ -1806,7 +1806,7 @@ EidosValue_SP Individual::ExecuteMethod_relatedness(EidosGlobalStringID p_method { for (int value_index = 0; value_index < individuals_count; ++value_index) { - Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex(value_index, nullptr)); + Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); double relatedness = (ind == this) ? 1.0 : 0.0; float_result->set_float_no_check(relatedness, value_index); @@ -1840,7 +1840,7 @@ EidosValue_SP Individual::ExecuteMethod_sharedParentCount(EidosGlobalStringID p_ if (individuals_count == 1) { - Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex(0, nullptr)); + Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex_NOCAST(0, nullptr)); int shared_count; if (pedigree_tracking_enabled) @@ -1859,7 +1859,7 @@ EidosValue_SP Individual::ExecuteMethod_sharedParentCount(EidosGlobalStringID p_ // FIXME needs parallelization, see relatedness() for (int value_index = 0; value_index < individuals_count; ++value_index) { - Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex(value_index, nullptr)); + Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); int shared_count = SharedParentCountWithIndividual(*ind); int_result->set_int_no_check(shared_count, value_index); @@ -1869,7 +1869,7 @@ EidosValue_SP Individual::ExecuteMethod_sharedParentCount(EidosGlobalStringID p_ { for (int value_index = 0; value_index < individuals_count; ++value_index) { - Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex(value_index, nullptr)); + Individual *ind = (Individual *)(individuals_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); int shared_count = (ind == this) ? 2.0 : 0.0; int_result->set_int_no_check(shared_count, value_index); @@ -2277,7 +2277,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri // Determine the spatiality of the individuals involved, and make sure it is the same for all if (target_size == 1) { - Individual *target = (Individual *)p_target->ObjectElementAtIndex(0, nullptr); + Individual *target = (Individual *)p_target->ObjectElementAtIndex_NOCAST(0, nullptr); dimensionality = target->subpopulation_->species_.SpatialDimensionality(); } @@ -2310,21 +2310,21 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri if (target_size == 1) { // Handle the singleton target case separately so we can handle the vector target case faster - Individual *target = (Individual *)p_target->ObjectElementAtIndex(0, nullptr); + Individual *target = (Individual *)p_target->ObjectElementAtIndex_NOCAST(0, nullptr); switch (dimensionality) { case 1: - target->spatial_x_ = position_value->FloatAtIndex(0, nullptr); + target->spatial_x_ = position_value->FloatAtIndex_NOCAST(0, nullptr); break; case 2: - target->spatial_x_ = position_value->FloatAtIndex(0, nullptr); - target->spatial_y_ = position_value->FloatAtIndex(1, nullptr); + target->spatial_x_ = position_value->FloatAtIndex_NOCAST(0, nullptr); + target->spatial_y_ = position_value->FloatAtIndex_NOCAST(1, nullptr); break; case 3: - target->spatial_x_ = position_value->FloatAtIndex(0, nullptr); - target->spatial_y_ = position_value->FloatAtIndex(1, nullptr); - target->spatial_z_ = position_value->FloatAtIndex(2, nullptr); + target->spatial_x_ = position_value->FloatAtIndex_NOCAST(0, nullptr); + target->spatial_y_ = position_value->FloatAtIndex_NOCAST(1, nullptr); + target->spatial_z_ = position_value->FloatAtIndex_NOCAST(2, nullptr); break; default: EIDOS_TERMINATION << "ERROR (Individual_Class::ExecuteMethod_setSpatialPosition): (internal error) dimensionality out of range." << EidosTerminate(nullptr); @@ -2339,7 +2339,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri { case 1: { - double x = position_value->FloatAtIndex(0, nullptr); + double x = position_value->FloatAtIndex_NOCAST(0, nullptr); EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1_1D); #pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1_1D) num_threads(thread_count) @@ -2352,8 +2352,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri } case 2: { - double x = position_value->FloatAtIndex(0, nullptr); - double y = position_value->FloatAtIndex(1, nullptr); + double x = position_value->FloatAtIndex_NOCAST(0, nullptr); + double y = position_value->FloatAtIndex_NOCAST(1, nullptr); EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1_2D); #pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x, y) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1_2D) num_threads(thread_count) @@ -2367,9 +2367,9 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri } case 3: { - double x = position_value->FloatAtIndex(0, nullptr); - double y = position_value->FloatAtIndex(1, nullptr); - double z = position_value->FloatAtIndex(2, nullptr); + double x = position_value->FloatAtIndex_NOCAST(0, nullptr); + double y = position_value->FloatAtIndex_NOCAST(1, nullptr); + double z = position_value->FloatAtIndex_NOCAST(2, nullptr); EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1_3D); #pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x, y, z) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1_3D) num_threads(thread_count) diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 1424e7320..99752887d 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -1319,7 +1319,7 @@ double InteractionType::ApplyInteractionCallbacks(Individual *p_receiver, Indivi if ((result->Type() != EidosValueType::kValueFloat) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (InteractionType::ApplyInteractionCallbacks): interaction() callbacks must provide a float singleton return value." << EidosTerminate(interaction_callback->identifier_token_); - p_strength = result->FloatAtIndex(0, nullptr); + p_strength = result->FloatAtIndex_NOCAST(0, nullptr); // the cached value is owned by the tree, so we do not dispose of it // there is also no script output to handle @@ -1368,7 +1368,7 @@ double InteractionType::ApplyInteractionCallbacks(Individual *p_receiver, Indivi if ((result->Type() != EidosValueType::kValueFloat) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (InteractionType::ApplyInteractionCallbacks): interaction() callbacks must provide a float singleton return value." << EidosTerminate(interaction_callback->identifier_token_); - p_strength = result->FloatAtIndex(0, nullptr); + p_strength = result->FloatAtIndex_NOCAST(0, nullptr); if (std::isnan(p_strength) || std::isinf(p_strength) || (p_strength < 0.0)) EIDOS_TERMINATION << "ERROR (InteractionType::ApplyInteractionCallbacks): interaction() callbacks must return a finite value >= 0.0." << EidosTerminate(interaction_callback->identifier_token_); @@ -3552,7 +3552,7 @@ void InteractionType::SetProperty(EidosGlobalStringID p_property_id, const Eidos if (AnyEvaluated()) EIDOS_TERMINATION << "ERROR (InteractionType::SetProperty): maxDistance cannot be changed while the interaction is being evaluated; call unevaluate() first, or set maxDistance prior to evaluation of the interaction." << EidosTerminate(); - max_distance_ = p_value.FloatAtIndex(0, nullptr); + max_distance_ = p_value.FloatAtIndex_NOCAST(0, nullptr); max_distance_sq_ = max_distance_ * max_distance_; if (max_distance_ < 0.0) @@ -3571,7 +3571,7 @@ void InteractionType::SetProperty(EidosGlobalStringID p_property_id, const Eidos case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -3688,19 +3688,7 @@ EidosValue_SP InteractionType::ExecuteMethod_clippedIntegral(EidosGlobalStringID // We have a singleton or vector of receivers; we'd like to treat them both in the same way, so we set up for that here // We do not try to create a singleton return value when passed a singleton receiver; too complicated to optimize for that here - const Individual * const *receivers_data; - const Individual *receivers_singleton = nullptr; - - if (receivers_count == 1) - { - receivers_singleton = (Individual *)receivers_value->ObjectElementAtIndex(0, nullptr); - receivers_data = &receivers_singleton; - } - else - { - receivers_data = (Individual * const *)receivers_value->ObjectData(); - } - + const Individual * const *receivers_data = (Individual * const *)receivers_value->ObjectData(); InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receivers_data[0]->subpopulation_); EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(receivers_count); @@ -3946,7 +3934,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distance(EidosGlobalStringID p_meth EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_distance): distance() requires that the interaction be spatial." << EidosTerminate(); // receiver_value is guaranteed to be singleton; let's get the info on it - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -3967,7 +3955,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distance(EidosGlobalStringID p_meth if ((exerters_count == 0) && !exerters_value_NULL) return gStaticEidosValue_Float_ZeroVec; - Subpopulation *exerter_subpop = (exerters_value_NULL ? receiver_subpop : ((Individual *)exerters_value->ObjectElementAtIndex(0, nullptr))->subpopulation_); + Subpopulation *exerter_subpop = (exerters_value_NULL ? receiver_subpop : ((Individual *)exerters_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_); CheckSpeciesCompatibility_Generic(exerter_subpop->species_); CheckSpatialCompatibility(receiver_subpop, exerter_subpop); @@ -4010,7 +3998,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distance(EidosGlobalStringID p_meth for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { - Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex(exerter_index, nullptr); + Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(exerter_index, nullptr); // SPECIES CONSISTENCY CHECK if (exerter_subpop != exerter->subpopulation_) @@ -4063,10 +4051,10 @@ EidosValue_SP InteractionType::ExecuteMethod_distanceFromPoint(EidosGlobalString #endif for (int point_index = 0; point_index < spatiality_; ++point_index) - point_data[point_index] = point_value->FloatAtIndex(point_index, nullptr); + point_data[point_index] = point_value->FloatAtIndex_NOCAST(point_index, nullptr); // exerters_value is guaranteed to be of length >= 1; let's get the info on it - Individual *exerter_first = (Individual *)exerters_value->ObjectElementAtIndex(0, nullptr); + Individual *exerter_first = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(0, nullptr); Subpopulation *exerter_subpop = exerter_first->subpopulation_; Species &exerter_species = exerter_subpop->species_; @@ -4091,7 +4079,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distanceFromPoint(EidosGlobalString { for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { - Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex(exerter_index, nullptr); + Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(exerter_index, nullptr); // SPECIES CONSISTENCY CHECK if (exerter_subpop != exerter->subpopulation_) @@ -4111,7 +4099,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distanceFromPoint(EidosGlobalString { for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { - Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex(exerter_index, nullptr); + Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(exerter_index, nullptr); // SPECIES CONSISTENCY CHECK if (exerter_subpop != exerter->subpopulation_) @@ -4207,7 +4195,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID EidosValue *exerterSubpop_value = p_arguments[2].get(); EidosValue *returnDict_value = p_arguments[3].get(); - eidos_logical_t returnDict = returnDict_value->LogicalAtIndex(0, nullptr); + eidos_logical_t returnDict = returnDict_value->LogicalAtIndex_NOCAST(0, nullptr); Subpopulation *receiver_subpop = nullptr; if (!returnDict) @@ -4216,7 +4204,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID if (receiver_value->Count() != 1) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_drawByStrength): drawByStrength() requires that the receiver is singleton when returnDict is F; if you want to process multiple receivers in a single call, pass returnDict=T." << EidosTerminate(); - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); receiver_subpop = receiver->subpopulation_; } @@ -4237,7 +4225,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID return result_SP; } - receiver_subpop = ((Individual *)receiver_value->ObjectElementAtIndex(0, nullptr))->subpopulation_; + receiver_subpop = ((Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_; } // shared logic for both cases @@ -4246,7 +4234,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID CheckSpeciesCompatibility_Receiver(receiver_species); // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); CheckSpatialCompatibility(receiver_subpop, exerter_subpop); @@ -4255,7 +4243,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID InteractionsData &exerter_subpop_data = InteractionsDataForSubpop(data_, exerter_subpop); // Check the count; note that we do NOT clamp count to exerter_subpop_size, since draws are done with replacement! - int64_t count = count_value->IntAtIndex(0, nullptr); + int64_t count = count_value->IntAtIndex_NOCAST(0, nullptr); if (count < 0) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_drawByStrength): drawByStrength() requires count >= 0." << EidosTerminate(); @@ -4270,7 +4258,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -4466,7 +4454,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID #pragma omp parallel for schedule(dynamic, 16) default(none) shared(gEidos_RNG_PERTHREAD, receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_EXERTERS, optimize_fixed_interaction_strengths) firstprivate(receiver_value, result_vectors, count, exerter_subpop_size) reduction(||: saw_error_1) reduction(||: saw_error_2) reduction(||: saw_error_3) reduction(||: saw_error_4) if(!has_interaction_callbacks && (receivers_count >= EIDOS_OMPMIN_DRAWBYSTRENGTH)) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -4644,8 +4632,8 @@ EidosValue_SP InteractionType::ExecuteMethod_interactingNeighborCount(EidosGloba return gStaticEidosValue_Integer_ZeroVec; // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *receiver_subpop = ((Individual *)receivers_value->ObjectElementAtIndex(0, nullptr))->subpopulation_; - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *receiver_subpop = ((Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_; + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Receiver(receiver_subpop->species_); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); @@ -4678,7 +4666,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactingNeighborCount(EidosGloba if (receivers_count == 1) { // Just one value, so we can return a singleton and skip some work - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -4712,7 +4700,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactingNeighborCount(EidosGloba #pragma omp parallel for schedule(dynamic, 16) default(none) shared(receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_EXERTERS) firstprivate(receivers_value, result_vec) reduction(||: saw_error_1) reduction(||: saw_error_2) reduction(||: saw_error_3) if(receivers_count >= EIDOS_OMPMIN_INTNEIGHCOUNT) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -4789,11 +4777,11 @@ EidosValue_SP InteractionType::ExecuteMethod_localPopulationDensity(EidosGlobalS return gStaticEidosValue_Float_ZeroVec; // receivers_value is guaranteed to have at least one value - Individual *first_receiver = (Individual *)receivers_value->ObjectElementAtIndex(0, nullptr); + Individual *first_receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr); Subpopulation *receiver_subpop = first_receiver->subpopulation_; // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Receiver(receiver_subpop->species_); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); @@ -4897,7 +4885,7 @@ EidosValue_SP InteractionType::ExecuteMethod_localPopulationDensity(EidosGlobalS total_strength += strength_for_zero_distance; // Divide by the corresponding clipped integral to get density - total_strength /= clipped_integrals->FloatAtIndex(0, nullptr); + total_strength /= clipped_integrals->FloatAtIndex_NOCAST(0, nullptr); FreeSparseVector(sv); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(total_strength)); @@ -4912,7 +4900,7 @@ EidosValue_SP InteractionType::ExecuteMethod_localPopulationDensity(EidosGlobalS #pragma omp parallel for schedule(dynamic, 16) default(none) shared(receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_EXERTERS, strength_for_zero_distance, clipped_integrals, optimize_fixed_interaction_strengths) firstprivate(receivers_value, result_vec) reduction(||: saw_error_1) reduction(||: saw_error_2) reduction(||: saw_error_3) if(!has_interaction_callbacks && (receivers_count >= EIDOS_OMPMIN_LOCALPOPDENSITY)) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -4979,7 +4967,7 @@ EidosValue_SP InteractionType::ExecuteMethod_localPopulationDensity(EidosGlobalS total_strength += strength_for_zero_distance; // Divide by the corresponding clipped integral to get density - total_strength /= clipped_integrals->FloatAtIndex(receiver_index, nullptr); + total_strength /= clipped_integrals->FloatAtIndex_NOCAST(receiver_index, nullptr); result_vec->set_float_no_check(total_strength, receiver_index); FreeSparseVector(sv); @@ -5009,7 +4997,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactionDistance(EidosGlobalStri EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_interactionDistance): interactionDistance() requires that the interaction be spatial." << EidosTerminate(); // receiver_value is guaranteed to be singleton; let's get the info on it - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5030,7 +5018,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactionDistance(EidosGlobalStri if ((exerters_count == 0) && !exerters_value_NULL) return gStaticEidosValue_Float_ZeroVec; - Subpopulation *exerter_subpop = (exerters_value_NULL ? receiver_subpop : ((Individual *)exerters_value->ObjectElementAtIndex(0, nullptr))->subpopulation_); + Subpopulation *exerter_subpop = (exerters_value_NULL ? receiver_subpop : ((Individual *)exerters_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); CheckSpatialCompatibility(receiver_subpop, exerter_subpop); @@ -5085,7 +5073,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactionDistance(EidosGlobalStri // which would allow us to avoid this O(N^2) behavior for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { - Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex(exerter_index, nullptr); + Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(exerter_index, nullptr); // SPECIES CONSISTENCY CHECK if (exerter_subpop != exerter->subpopulation_) @@ -5133,7 +5121,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl if (spatiality_ == 0) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestInteractingNeighbors): nearestInteractingNeighbors() requires that the interaction be spatial." << EidosTerminate(); - eidos_logical_t returnDict = returnDict_value->LogicalAtIndex(0, nullptr); + eidos_logical_t returnDict = returnDict_value->LogicalAtIndex_NOCAST(0, nullptr); Subpopulation *receiver_subpop = nullptr; if (!returnDict) @@ -5142,7 +5130,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl if (receiver_value->Count() != 1) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestInteractingNeighbors): nearestInteractingNeighbors() requires that the receiver is singleton when returnDict is F; if you want to process multiple receivers in a single call, pass returnDict=T." << EidosTerminate(); - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); receiver_subpop = receiver->subpopulation_; } @@ -5163,7 +5151,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl return result_SP; } - receiver_subpop = ((Individual *)receiver_value->ObjectElementAtIndex(0, nullptr))->subpopulation_; + receiver_subpop = ((Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_; } // shared logic for both cases @@ -5174,14 +5162,14 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receiver_subpop); // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); CheckSpatialCompatibility(receiver_subpop, exerter_subpop); // Check the count slim_popsize_t exerter_subpop_size = exerter_subpop->parent_subpop_size_; - int64_t count = count_value->IntAtIndex(0, nullptr); + int64_t count = count_value->IntAtIndex_NOCAST(0, nullptr); if (count < 0) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestInteractingNeighbors): nearestInteractingNeighbors() requires count >= 0." << EidosTerminate(); @@ -5196,7 +5184,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5253,7 +5241,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl #pragma omp parallel for schedule(dynamic, 16) default(none) shared(receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_EXERTERS) firstprivate(receiver_value, result_vectors, count, exerter_subpop_size) reduction(||: saw_error_1) reduction(||: saw_error_2) reduction(||: saw_error_3) if(receivers_count >= EIDOS_OMPMIN_NEARESTINTNEIGH) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5326,7 +5314,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI if (spatiality_ == 0) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestNeighbors): nearestNeighbors() requires that the interaction be spatial." << EidosTerminate(); - eidos_logical_t returnDict = returnDict_value->LogicalAtIndex(0, nullptr); + eidos_logical_t returnDict = returnDict_value->LogicalAtIndex_NOCAST(0, nullptr); Subpopulation *receiver_subpop = nullptr; if (!returnDict) @@ -5335,7 +5323,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI if (receiver_value->Count() != 1) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestNeighbors): nearestNeighbors() requires that the receiver is singleton when returnDict is F; if you want to process multiple receivers in a single call, pass returnDict=T." << EidosTerminate(); - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); receiver_subpop = receiver->subpopulation_; } @@ -5356,7 +5344,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI return result_SP; } - receiver_subpop = ((Individual *)receiver_value->ObjectElementAtIndex(0, nullptr))->subpopulation_; + receiver_subpop = ((Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_; } // shared logic for both cases @@ -5367,14 +5355,14 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receiver_subpop); // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Generic(exerter_subpop->species_); CheckSpatialCompatibility(receiver_subpop, exerter_subpop); // Check the count slim_popsize_t exerter_subpop_size = exerter_subpop->parent_subpop_size_; - int64_t count = count_value->IntAtIndex(0, nullptr); + int64_t count = count_value->IntAtIndex_NOCAST(0, nullptr); if (count < 0) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestNeighbors): nearestNeighbors() requires count >= 0." << EidosTerminate(); @@ -5389,7 +5377,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5442,7 +5430,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI #pragma omp parallel for schedule(dynamic, 16) default(none) shared(receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_ALL) firstprivate(receiver_value, result_vectors, count, exerter_subpop_size) reduction(||: saw_error_1) reduction(||: saw_error_2) if(receivers_count >= EIDOS_OMPMIN_NEARESTNEIGH) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5508,11 +5496,11 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighborsOfPoint(EidosGlobal double point_array[SLIM_MAX_DIMENSIONALITY]; for (int point_index = 0; point_index < spatiality_; ++point_index) - point_array[point_index] = point_value->FloatAtIndex(point_index, nullptr); + point_array[point_index] = point_value->FloatAtIndex_NOCAST(point_index, nullptr); // Check the count slim_popsize_t exerter_subpop_size = exerter_subpop->parent_subpop_size_; - int64_t count = count_value->IntAtIndex(0, nullptr); + int64_t count = count_value->IntAtIndex_NOCAST(0, nullptr); if (count < 0) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_nearestNeighborsOfPoint): nearestNeighborsOfPoint() requires count >= 0." << EidosTerminate(); @@ -5551,8 +5539,8 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCount(EidosGlobalStringID p return gStaticEidosValue_Integer_ZeroVec; // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *receiver_subpop = ((Individual *)receivers_value->ObjectElementAtIndex(0, nullptr))->subpopulation_; - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *receiver_subpop = ((Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_; + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Generic(receiver_subpop->species_); CheckSpeciesCompatibility_Generic(exerter_subpop->species_); @@ -5585,7 +5573,7 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCount(EidosGlobalStringID p if (receivers_count == 1) { // Just one value, so we can return a singleton and skip some work - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5615,7 +5603,7 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCount(EidosGlobalStringID p #pragma omp parallel for schedule(dynamic, 16) default(none) shared(receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_ALL) firstprivate(receivers_value, result_vec) reduction(||: saw_error_1) reduction(||: saw_error_2) if(receivers_count >= EIDOS_OMPMIN_NEIGHCOUNT) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5687,7 +5675,7 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCountOfPoint(EidosGlobalStr double point_array[SLIM_MAX_DIMENSIONALITY]; for (int point_index = 0; point_index < spatiality_; ++point_index) - point_array[point_index] = point_value->FloatAtIndex(point_index, nullptr); + point_array[point_index] = point_value->FloatAtIndex_NOCAST(point_index, nullptr); // Find the neighbors int neighborCount; @@ -5714,7 +5702,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_setConstraints): setConstraints() cannot be called while the interaction is being evaluated; call unevaluate() first, or call setConstraints() prior to evaluation of the interaction." << EidosTerminate(); EidosValue *who_value = p_arguments[0].get(); - std::string who = who_value->StringAtIndex(0, nullptr); + std::string who = who_value->StringAtIndex_NOCAST(0, nullptr); bool set_receiver_constraints = false; bool set_exerter_constraints = false; @@ -5771,7 +5759,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *sex_value = p_arguments[1].get(); if (sex_value->Type() != EidosValueType::kValueNULL) { - std::string sex = sex_value->StringAtIndex(0, nullptr); + std::string sex = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex == "M") { constraints->sex_ = IndividualSex::kMale; constraints->has_constraints_ = true; } else if (sex == "F") { constraints->sex_ = IndividualSex::kFemale; constraints->has_constraints_ = true; } else if (sex == "*") constraints->sex_ = IndividualSex::kUnspecified; @@ -5782,7 +5770,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *tag_value = p_arguments[2].get(); if (tag_value->Type() != EidosValueType::kValueNULL) { - slim_usertag_t tag = tag_value->IntAtIndex(0, nullptr); + slim_usertag_t tag = tag_value->IntAtIndex_NOCAST(0, nullptr); constraints->tag_ = tag; constraints->has_constraints_ = true; @@ -5795,7 +5783,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID if (community_.ModelType() == SLiMModelType::kModelTypeWF) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_setConstraints): setConstraints() cannot set a minAge constraint in a WF model (since the WF model is of non-overlapping generations)." << EidosTerminate(); - slim_age_t minAge = SLiMCastToAgeTypeOrRaise(minAge_value->IntAtIndex(0, nullptr)); + slim_age_t minAge = SLiMCastToAgeTypeOrRaise(minAge_value->IntAtIndex_NOCAST(0, nullptr)); if ((minAge <= 0) || (minAge > 100000)) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_setConstraints): setConstraints() requires the parameter minAge to be >= 0 and <= 100000." << EidosTerminate(); @@ -5811,7 +5799,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID if (community_.ModelType() == SLiMModelType::kModelTypeWF) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_setConstraints): setConstraints() cannot set a maxAge constraint in a WF model (since the WF model is of non-overlapping generations)." << EidosTerminate(); - slim_age_t maxAge = SLiMCastToAgeTypeOrRaise(maxAge_value->IntAtIndex(0, nullptr)); + slim_age_t maxAge = SLiMCastToAgeTypeOrRaise(maxAge_value->IntAtIndex_NOCAST(0, nullptr)); if ((maxAge <= 0) || (maxAge > 100000)) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_setConstraints): setConstraints() requires the parameter maxAge to be >= 0 and <= 100000." << EidosTerminate(); @@ -5827,7 +5815,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *migrant_value = p_arguments[5].get(); if (migrant_value->Type() != EidosValueType::kValueNULL) { - eidos_logical_t migrant = migrant_value->LogicalAtIndex(0, nullptr); + eidos_logical_t migrant = migrant_value->LogicalAtIndex_NOCAST(0, nullptr); constraints->migrant_ = migrant; constraints->has_constraints_ = true; @@ -5837,7 +5825,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *tagL0_value = p_arguments[6].get(); if (tagL0_value->Type() != EidosValueType::kValueNULL) { - eidos_logical_t tagL0 = tagL0_value->LogicalAtIndex(0, nullptr); + eidos_logical_t tagL0 = tagL0_value->LogicalAtIndex_NOCAST(0, nullptr); constraints->tagL0_ = tagL0; constraints->has_constraints_ = true; @@ -5848,7 +5836,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *tagL1_value = p_arguments[7].get(); if (tagL1_value->Type() != EidosValueType::kValueNULL) { - eidos_logical_t tagL1 = tagL1_value->LogicalAtIndex(0, nullptr); + eidos_logical_t tagL1 = tagL1_value->LogicalAtIndex_NOCAST(0, nullptr); constraints->tagL1_ = tagL1; constraints->has_constraints_ = true; @@ -5859,7 +5847,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *tagL2_value = p_arguments[8].get(); if (tagL2_value->Type() != EidosValueType::kValueNULL) { - eidos_logical_t tagL2 = tagL2_value->LogicalAtIndex(0, nullptr); + eidos_logical_t tagL2 = tagL2_value->LogicalAtIndex_NOCAST(0, nullptr); constraints->tagL2_ = tagL2; constraints->has_constraints_ = true; @@ -5870,7 +5858,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *tagL3_value = p_arguments[9].get(); if (tagL3_value->Type() != EidosValueType::kValueNULL) { - eidos_logical_t tagL3 = tagL3_value->LogicalAtIndex(0, nullptr); + eidos_logical_t tagL3 = tagL3_value->LogicalAtIndex_NOCAST(0, nullptr); constraints->tagL3_ = tagL3; constraints->has_constraints_ = true; @@ -5881,7 +5869,7 @@ EidosValue_SP InteractionType::ExecuteMethod_setConstraints(EidosGlobalStringID EidosValue *tagL4_value = p_arguments[10].get(); if (tagL4_value->Type() != EidosValueType::kValueNULL) { - eidos_logical_t tagL4 = tagL4_value->LogicalAtIndex(0, nullptr); + eidos_logical_t tagL4 = tagL4_value->LogicalAtIndex_NOCAST(0, nullptr); constraints->tagL4_ = tagL4; constraints->has_constraints_ = true; @@ -5934,7 +5922,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth EidosValue *exerters_value = p_arguments[1].get(); // receiver_value is guaranteed to be singleton; let's get the info on it - Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -5952,7 +5940,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth if ((exerters_count == 0) && !exerters_value_NULL) return gStaticEidosValue_Float_ZeroVec; - Subpopulation *exerter_subpop = (exerters_value_NULL ? receiver_subpop : ((Individual *)exerters_value->ObjectElementAtIndex(0, nullptr))->subpopulation_); + Subpopulation *exerter_subpop = (exerters_value_NULL ? receiver_subpop : ((Individual *)exerters_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); CheckSpatialCompatibility(receiver_subpop, exerter_subpop); @@ -6016,7 +6004,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth // which would allow us to avoid this O(N^2) behavior for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { - Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex(exerter_index, nullptr); + Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(exerter_index, nullptr); // SPECIES CONSISTENCY CHECK if (exerter_subpop != exerter->subpopulation_) @@ -6090,7 +6078,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { - Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex(exerter_index, nullptr); + Individual *exerter = (Individual *)exerters_value->ObjectElementAtIndex_NOCAST(exerter_index, nullptr); if (exerter_subpop != exerter->subpopulation_) EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_strength): strength() requires that all individuals be in the same subpopulation." << EidosTerminate(); @@ -6124,7 +6112,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID int individuals_count = individuals_value->Count(); - const std::string &constraints_str = constraints_value->StringRefAtIndex(0, nullptr); + const std::string &constraints_str = constraints_value->StringRefAtIndex_NOCAST(0, nullptr); InteractionConstraints *constraints; if (constraints_str == "receiver") @@ -6134,12 +6122,12 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID else EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_testConstraints): testConstraints() requires that parameter constraints be 'receiver' or 'exerter'." << EidosTerminate(); - bool returnIndividuals = returnIndividuals_value->LogicalAtIndex(0, nullptr); + bool returnIndividuals = returnIndividuals_value->LogicalAtIndex_NOCAST(0, nullptr); if (individuals_count == 1) { // singleton case - Individual *ind = (Individual *)individuals_value->ObjectElementAtIndex(0, nullptr); + Individual *ind = (Individual *)individuals_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (CheckIndividualConstraints(ind, *constraints)) { @@ -6209,8 +6197,8 @@ EidosValue_SP InteractionType::ExecuteMethod_totalOfNeighborStrengths(EidosGloba return gStaticEidosValue_Float_ZeroVec; // the exerter subpopulation defaults to the same subpop as the receivers - Subpopulation *receiver_subpop = ((Individual *)receivers_value->ObjectElementAtIndex(0, nullptr))->subpopulation_; - Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *receiver_subpop = ((Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_; + Subpopulation *exerter_subpop = ((exerterSubpop_value->Type() == EidosValueType::kValueNULL) ? receiver_subpop : (Subpopulation *)exerterSubpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); CheckSpeciesCompatibility_Receiver(receiver_subpop->species_); CheckSpeciesCompatibility_Exerter(exerter_subpop->species_); @@ -6243,7 +6231,7 @@ EidosValue_SP InteractionType::ExecuteMethod_totalOfNeighborStrengths(EidosGloba if (receivers_count == 1) { // Just one value, so we can return a singleton and skip some work - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(0, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(0, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) @@ -6292,7 +6280,7 @@ EidosValue_SP InteractionType::ExecuteMethod_totalOfNeighborStrengths(EidosGloba #pragma omp parallel for schedule(dynamic, 16) default(none) shared(receivers_count, receiver_subpop, exerter_subpop, receiver_subpop_data, exerter_subpop_data, kd_root_EXERTERS) firstprivate(receivers_value, result_vec) reduction(||: saw_error_1) reduction(||: saw_error_2) reduction(||: saw_error_3) reduction(||: saw_error_4) if(!has_interaction_callbacks && (receivers_count >= EIDOS_OMPMIN_TOTNEIGHSTRENGTH)) num_threads(thread_count) for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex(receiver_index, nullptr); + Individual *receiver = (Individual *)receivers_value->ObjectElementAtIndex_NOCAST(receiver_index, nullptr); slim_popsize_t receiver_index_in_subpop = receiver->index_; if (receiver_index_in_subpop < 0) diff --git a/core/log_file.cpp b/core/log_file.cpp index c7182ee7c..6f89f957a 100644 --- a/core/log_file.cpp +++ b/core/log_file.cpp @@ -592,7 +592,7 @@ void LogFile::SetProperty(EidosGlobalStringID p_property_id, const EidosValue &p { case gID_precision: { - int64_t value = p_value.IntAtIndex(0, nullptr); + int64_t value = p_value.IntAtIndex_NOCAST(0, nullptr); if ((value < 1) || (value > 22)) EIDOS_TERMINATION << "ERROR (LogFile::SetProperty): property precision must be in [1,22]." << EidosTerminate(); @@ -603,7 +603,7 @@ void LogFile::SetProperty(EidosGlobalStringID p_property_id, const EidosValue &p } case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -663,8 +663,8 @@ EidosValue_SP LogFile::ExecuteMethod_addCustomColumn(EidosGlobalStringID p_metho EidosValue_String *source_value = (EidosValue_String *)p_arguments[1].get(); EidosValue_SP context_value = p_arguments[2]; - const std::string &column_name = columnName_value->StringRefAtIndex(0, nullptr); - const std::string &source = source_value->StringRefAtIndex(0, nullptr); + const std::string &column_name = columnName_value->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &source = source_value->StringRefAtIndex_NOCAST(0, nullptr); // See, e.g., Subpopulation::ApplyFitnessEffectCallbacks() for comments on parsing/running script blocks EidosErrorContext error_context_save = gEidosErrorContext; @@ -746,8 +746,8 @@ EidosValue_SP LogFile::ExecuteMethod_addMeanSDColumns(EidosGlobalStringID p_meth EidosValue_String *source_value = (EidosValue_String *)p_arguments[1].get(); EidosValue_SP context_value = p_arguments[2]; - const std::string &column_name = columnName_value->StringRefAtIndex(0, nullptr); - const std::string &source = source_value->StringRefAtIndex(0, nullptr); + const std::string &column_name = columnName_value->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &source = source_value->StringRefAtIndex_NOCAST(0, nullptr); EidosErrorContext error_context_save = gEidosErrorContext; EidosScript *source_script = new EidosScript(source, -1); @@ -845,16 +845,16 @@ EidosValue_SP LogFile::ExecuteMethod_addSubpopulationSexRatio(EidosGlobalStringI if (subpop_value->Type() == EidosValueType::kValueInt) { - subpop_id = SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)); + subpop_id = SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)); } else { #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - Subpopulation *subpop = dynamic_cast(subpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *subpop = dynamic_cast(subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); #else - Subpopulation *subpop = (Subpopulation *)(subpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *subpop = (Subpopulation *)(subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); #endif subpop_id = subpop->subpopulation_id_; @@ -879,16 +879,16 @@ EidosValue_SP LogFile::ExecuteMethod_addSubpopulationSize(EidosGlobalStringID p_ if (subpop_value->Type() == EidosValueType::kValueInt) { - subpop_id = SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)); + subpop_id = SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)); } else { #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - Subpopulation *subpop = dynamic_cast(subpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *subpop = dynamic_cast(subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); #else - Subpopulation *subpop = (Subpopulation *)(subpop_value->ObjectElementAtIndex(0, nullptr)); + Subpopulation *subpop = (Subpopulation *)(subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr)); #endif subpop_id = subpop->subpopulation_id_; @@ -908,7 +908,7 @@ EidosValue_SP LogFile::ExecuteMethod_addSuppliedColumn(EidosGlobalStringID p_met RaiseForLockedHeader("LogFile::ExecuteMethod_addSuppliedColumn"); EidosValue_String *columnName_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &column_name = columnName_value->StringRefAtIndex(0, nullptr); + const std::string &column_name = columnName_value->StringRefAtIndex_NOCAST(0, nullptr); generator_info_.emplace_back(LogFileGeneratorType::kGenerator_SuppliedColumn, nullptr, -1, EidosValue_SP()); column_names_.emplace_back(column_name); @@ -966,7 +966,7 @@ EidosValue_SP LogFile::ExecuteMethod_setLogInterval(EidosGlobalStringID p_method else { autologging = true; - logInterval = logInterval_value->IntAtIndex(0, nullptr); + logInterval = logInterval_value->IntAtIndex_NOCAST(0, nullptr); } SetLogInterval(autologging, logInterval); @@ -986,9 +986,9 @@ EidosValue_SP LogFile::ExecuteMethod_setFilePath(EidosGlobalStringID p_method_id // Note that the parameters and their interpretation is different from Community::ExecuteMethod_createLogFile(); // in particular, NULL here means "keep the existing value" - const std::string &filePath = filePath_value->StringRefAtIndex(0, nullptr); + const std::string &filePath = filePath_value->StringRefAtIndex_NOCAST(0, nullptr); std::vector initialContents; - bool append = append_value->LogicalAtIndex(0, nullptr); + bool append = append_value->LogicalAtIndex_NOCAST(0, nullptr); bool do_compress = compress_; std::string sep = sep_; @@ -998,14 +998,14 @@ EidosValue_SP LogFile::ExecuteMethod_setFilePath(EidosGlobalStringID p_method_id int ic_count = initialContents_value->Count(); for (int ic_index = 0; ic_index < ic_count; ++ic_index) - initialContents.emplace_back(&ic_string_value->StringRefAtIndex(ic_index, nullptr)); + initialContents.emplace_back(&ic_string_value->StringRefAtIndex_NOCAST(ic_index, nullptr)); } if (compress_value->Type() != EidosValueType::kValueNULL) - do_compress = compress_value->LogicalAtIndex(0, nullptr); + do_compress = compress_value->LogicalAtIndex_NOCAST(0, nullptr); if (sep_value->Type() != EidosValueType::kValueNULL) - sep = sep_value->StringRefAtIndex(0, nullptr); + sep = sep_value->StringRefAtIndex_NOCAST(0, nullptr); ConfigureFile(filePath, initialContents, append, do_compress, sep); @@ -1019,7 +1019,7 @@ EidosValue_SP LogFile::ExecuteMethod_setSuppliedValue(EidosGlobalStringID p_meth EidosValue_String *columnName_value = (EidosValue_String *)p_arguments[0].get(); EidosValue_SP value = p_arguments[1]; - const std::string &column_name = columnName_value->StringRefAtIndex(0, nullptr); + const std::string &column_name = columnName_value->StringRefAtIndex_NOCAST(0, nullptr); // check that the column name exists and is a supplied column auto col_iter = std::find(column_names_.begin(), column_names_.end(), column_name); diff --git a/core/mutation.cpp b/core/mutation.cpp index 2d9f049d3..95ac29360 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -612,7 +612,7 @@ void Mutation::SetProperty(EidosGlobalStringID p_property_id, const EidosValue & { case gID_nucleotide: { - const std::string &nucleotide = ((EidosValue_String &)p_value).StringRefAtIndex(0, nullptr); + const std::string &nucleotide = ((EidosValue_String &)p_value).StringRefAtIndex_NOCAST(0, nullptr); if (nucleotide_ == -1) EIDOS_TERMINATION << "ERROR (Mutation::SetProperty): property nucleotide is only defined for nucleotide-based mutations." << EidosTerminate(); @@ -626,7 +626,7 @@ void Mutation::SetProperty(EidosGlobalStringID p_property_id, const EidosValue & } case gID_nucleotideValue: { - int64_t nucleotide = p_value.IntAtIndex(0, nullptr); + int64_t nucleotide = p_value.IntAtIndex_NOCAST(0, nullptr); if (nucleotide_ == -1) EIDOS_TERMINATION << "ERROR (Mutation::SetProperty): property nucleotideValue is only defined for nucleotide-based mutations." << EidosTerminate(); @@ -638,14 +638,14 @@ void Mutation::SetProperty(EidosGlobalStringID p_property_id, const EidosValue & } case gID_subpopID: // ACCELERATED { - slim_objectid_t value = SLiMCastToObjectidTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_objectid_t value = SLiMCastToObjectidTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); subpop_index_ = value; return; } case gID_tag: // ACCELERATED { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -662,7 +662,7 @@ void Mutation::SetProperty_Accelerated_subpopID(EidosObject **p_values, size_t p { if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Mutation *)(p_values[value_index]))->subpop_index_ = SLiMCastToObjectidTypeOrRaise(source_value); @@ -681,7 +681,7 @@ void Mutation::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_valu // SLiMCastToUsertagTypeOrRaise() is a no-op at present if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Mutation *)(p_values[value_index]))->tag_value_ = source_value; @@ -712,7 +712,7 @@ EidosValue_SP Mutation::ExecuteMethod_setSelectionCoeff(EidosGlobalStringID p_me #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *selectionCoeff_value = p_arguments[0].get(); - double value = selectionCoeff_value->FloatAtIndex(0, nullptr); + double value = selectionCoeff_value->FloatAtIndex_NOCAST(0, nullptr); slim_selcoeff_t old_coeff = selection_coeff_; selection_coeff_ = static_cast(value); diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index f75ffc340..e719aacc3 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -170,14 +170,14 @@ void MutationType::ParseDFEParameters(std::string &p_dfe_type_string, const Eido if ((dfe_param_type != EidosValueType::kValueFloat) && (dfe_param_type != EidosValueType::kValueInt)) EIDOS_TERMINATION << "ERROR (MutationType::ParseDFEParameters): the parameters for a DFE of type '" << *p_dfe_type << "' must be of type numeric (integer or float)." << EidosTerminate(); - p_dfe_parameters->emplace_back(dfe_param_value->FloatAtIndex(0, nullptr)); + p_dfe_parameters->emplace_back(dfe_param_value->NumericAtIndex_NOCAST(0, nullptr)); } else { if (dfe_param_type != EidosValueType::kValueString) EIDOS_TERMINATION << "ERROR (MutationType::ParseDFEParameters): the parameters for a DFE of type '" << *p_dfe_type << "' must be of type string." << EidosTerminate(); - p_dfe_strings->emplace_back(dfe_param_value->StringAtIndex(0, nullptr)); + p_dfe_strings->emplace_back(dfe_param_value->StringAtIndex_NOCAST(0, nullptr)); } } @@ -325,9 +325,9 @@ double MutationType::DrawSelectionCoefficient(void) const int result_count = result->Count(); if ((result_type == EidosValueType::kValueFloat) && (result_count == 1)) - sel_coeff = result->FloatAtIndex(0, nullptr); + sel_coeff = result->FloatAtIndex_NOCAST(0, nullptr); else if ((result_type == EidosValueType::kValueInt) && (result_count == 1)) - sel_coeff = result->IntAtIndex(0, nullptr); + sel_coeff = result->IntAtIndex_NOCAST(0, nullptr); else EIDOS_TERMINATION << "ERROR (MutationType::DrawSelectionCoefficient): type 's' DFE callbacks must provide a singleton float or integer return value." << EidosTerminate(nullptr); } @@ -579,7 +579,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal { case gEidosID_color: { - color_ = p_value.StringAtIndex(0, nullptr); + color_ = p_value.StringAtIndex_NOCAST(0, nullptr); if (!color_.empty()) Eidos_GetColorComponents(color_, &color_red_, &color_green_, &color_blue_); return; @@ -587,7 +587,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_colorSubstitution: { - color_sub_ = p_value.StringAtIndex(0, nullptr); + color_sub_ = p_value.StringAtIndex_NOCAST(0, nullptr); if (!color_sub_.empty()) Eidos_GetColorComponents(color_sub_, &color_sub_red_, &color_sub_green_, &color_sub_blue_); return; @@ -595,7 +595,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_convertToSubstitution: // ACCELERATED { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); convert_to_substitution_ = value; return; @@ -603,7 +603,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_dominanceCoeff: { - double value = p_value.FloatAtIndex(0, nullptr); + double value = p_value.FloatAtIndex_NOCAST(0, nullptr); dominance_coeff_ = static_cast(value); // intentionally no bounds check @@ -617,7 +617,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_haploidDominanceCoeff: { - double value = p_value.FloatAtIndex(0, nullptr); + double value = p_value.FloatAtIndex_NOCAST(0, nullptr); haploid_dominance_coeff_ = static_cast(value); // intentionally no bounds check @@ -631,7 +631,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_mutationStackGroup: { - int64_t new_group = p_value.IntAtIndex(0, nullptr); + int64_t new_group = p_value.IntAtIndex_NOCAST(0, nullptr); if (nucleotide_based_ && (new_group != -1)) EIDOS_TERMINATION << "ERROR (MutationType::SetProperty): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " must be -1 for nucleotide-based mutation types." << EidosTerminate(); @@ -644,7 +644,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_mutationStackPolicy: { - std::string value = p_value.StringAtIndex(0, nullptr); + std::string value = p_value.StringAtIndex_NOCAST(0, nullptr); if (nucleotide_based_ && (value != gStr_l)) EIDOS_TERMINATION << "ERROR (MutationType::SetProperty): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " must be 'l' for nucleotide-based mutation types." << EidosTerminate(); @@ -664,7 +664,7 @@ void MutationType::SetProperty(EidosGlobalStringID p_property_id, const EidosVal case gID_tag: // ACCELERATED { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -681,7 +681,7 @@ void MutationType::SetProperty_Accelerated_convertToSubstitution(EidosObject **p { if (p_source_size == 1) { - eidos_logical_t source_value = p_source.LogicalAtIndex(0, nullptr); + eidos_logical_t source_value = p_source.LogicalAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((MutationType *)(p_values[value_index]))->convert_to_substitution_ = source_value; @@ -700,7 +700,7 @@ void MutationType::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p_ // SLiMCastToUsertagTypeOrRaise() is a no-op at present if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((MutationType *)(p_values[value_index]))->tag_value_ = source_value; @@ -731,7 +731,7 @@ EidosValue_SP MutationType::ExecuteMethod_drawSelectionCoefficient(EidosGlobalSt #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue_SP result_SP(nullptr); EidosValue *n_value = p_arguments[0].get(); - int64_t num_draws = n_value->IntAtIndex(0, nullptr); + int64_t num_draws = n_value->IntAtIndex_NOCAST(0, nullptr); if (num_draws < 0) EIDOS_TERMINATION << "ERROR (ExecuteMethod_drawSelectionCoefficient): drawSelectionCoefficient() requires n to be greater than or equal to 0 (" << num_draws << " supplied)." << EidosTerminate(nullptr); @@ -758,7 +758,7 @@ EidosValue_SP MutationType::ExecuteMethod_setDistribution(EidosGlobalStringID p_ { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *distributionType_value = p_arguments[0].get(); - std::string dfe_type_string = distributionType_value->StringAtIndex(0, nullptr); + std::string dfe_type_string = distributionType_value->StringAtIndex_NOCAST(0, nullptr); // Parse the DFE type and parameters, and do various sanity checks DFEType dfe_type; diff --git a/core/population.cpp b/core/population.cpp index 880a3aa51..a7cf3b7f5 100644 --- a/core/population.cpp +++ b/core/population.cpp @@ -544,7 +544,7 @@ void Population::CheckForDeferralInGenomes(EidosValue_Object *p_genomes, const s for (int element_index = 0; element_index < element_count; ++element_index) { - Genome *genome = (Genome *)p_genomes->ObjectElementAtIndex(element_index, nullptr); + Genome *genome = (Genome *)p_genomes->ObjectElementAtIndex_NOCAST(element_index, nullptr); if (genome->IsDeferred()) EIDOS_TERMINATION << "ERROR (" << p_caller << "): the mutations of deferred genomes cannot be accessed." << EidosTerminate(); @@ -791,7 +791,7 @@ slim_popsize_t Population::ApplyMateChoiceCallbacks(slim_popsize_t p_parent1_ind // A singleton vector of type Individual may be returned to choose a specific mate if ((result->Count() == 1) && (((EidosValue_Object *)result)->Class() == gSLiM_Individual_Class)) { - chosen_mate = (Individual *)result->ObjectElementAtIndex(0, mate_choice_callback->identifier_token_); + chosen_mate = (Individual *)result->ObjectElementAtIndex_NOCAST(0, mate_choice_callback->identifier_token_); weights_reflect_chosen_mate = false; // remember this callback for error attribution below @@ -1112,7 +1112,7 @@ bool Population::ApplyModifyChildCallbacks(Individual *p_child, Individual *p_pa if ((result->Type() != EidosValueType::kValueLogical) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (Population::ApplyModifyChildCallbacks): modifyChild() callbacks must provide a logical singleton return value." << EidosTerminate(modify_child_callback->identifier_token_); - eidos_logical_t generate_child = result->LogicalAtIndex(0, nullptr); + eidos_logical_t generate_child = result->LogicalAtIndex_NOCAST(0, nullptr); // If this callback told us not to generate the child, we do not call the rest of the callback chain; we're done if (!generate_child) @@ -2467,7 +2467,7 @@ bool Population::ApplyRecombinationCallbacks(slim_popsize_t p_parent_index, Geno if ((result->Type() != EidosValueType::kValueLogical) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (Population::ApplyRecombinationCallbacks): recombination() callbacks must provide a logical singleton return value." << EidosTerminate(recombination_callback->identifier_token_); - eidos_logical_t breakpoints_changed = result->LogicalAtIndex(0, nullptr); + eidos_logical_t breakpoints_changed = result->LogicalAtIndex_NOCAST(0, nullptr); // If the callback says that breakpoints were changed, check for an actual change in value for the variables referenced by the callback if (breakpoints_changed) @@ -2504,7 +2504,7 @@ bool Population::ApplyRecombinationCallbacks(slim_popsize_t p_parent_index, Geno p_crossovers.resize(count); // zero-fills only new entries at the margin, so is minimally wasteful if (count == 1) - p_crossovers[0] = (slim_position_t)local_crossovers_ptr->IntAtIndex(0, nullptr); + p_crossovers[0] = (slim_position_t)local_crossovers_ptr->IntAtIndex_NOCAST(0, nullptr); else { const int64_t *new_crossover_data = local_crossovers_ptr->IntData(); @@ -5073,7 +5073,7 @@ void Population::RecalculateFitness(slim_tick_t p_tick) if ((result->Type() == EidosValueType::kValueFloat) && (result->Count() == 1)) { - if (result->FloatAtIndex(0, nullptr) == 1.0) + if (result->FloatAtIndex_NOCAST(0, nullptr) == 1.0) { // the callback returns 1.0, so it makes the mutation types to which it applies become neutral slim_objectid_t mutation_type_id = mutationEffect_callback->mutation_type_id_; @@ -6810,7 +6810,7 @@ EidosValue_SP Population::Eidos_FrequenciesForTalliedMutations(EidosValue *mutat if (mutations_count == 1) { // Handle the one-mutation case separately so we can return a singleton - Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex(0, nullptr)); + Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(0, nullptr)); int8_t mut_state = mut->state_; double freq; @@ -6827,7 +6827,7 @@ EidosValue_SP Population::Eidos_FrequenciesForTalliedMutations(EidosValue *mutat for (int value_index = 0; value_index < mutations_count; ++value_index) { - Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex(value_index, nullptr)); + Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); int8_t mut_state = mut->state_; double freq; @@ -6898,7 +6898,7 @@ EidosValue_SP Population::Eidos_CountsForTalliedMutations(EidosValue *mutations_ if (mutations_count == 1) { // Handle the one-mutation case separately so we can return a singleton - Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex(0, nullptr)); + Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(0, nullptr)); int8_t mut_state = mut->state_; slim_refcount_t count; @@ -6915,7 +6915,7 @@ EidosValue_SP Population::Eidos_CountsForTalliedMutations(EidosValue *mutations_ for (int value_index = 0; value_index < mutations_count; ++value_index) { - Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex(value_index, nullptr)); + Mutation *mut = (Mutation *)(mutations_value->ObjectElementAtIndex_NOCAST(value_index, nullptr)); int8_t mut_state = mut->state_; slim_refcount_t count; diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 324a29585..0b1bdd937 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -1517,7 +1517,7 @@ void SLiMEidosBlock::SetProperty(EidosGlobalStringID p_property_id, const EidosV { case gID_active: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); // cannot activate a block if it has been deactivated by its association with an inactive species if (value && ((species_spec_ && !species_spec_->Active()) || (ticks_spec_ && !ticks_spec_->Active()))) @@ -1530,7 +1530,7 @@ void SLiMEidosBlock::SetProperty(EidosGlobalStringID p_property_id, const EidosV case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -1733,7 +1733,7 @@ void SLiMTypeInterpreter::_SetTypeForISArgumentOfClass(const EidosASTNode *p_arg if (cached_value && (cached_value->Type() == EidosValueType::kValueInt) && (cached_value->Count() == 1)) { - int64_t cached_int = cached_value->IntAtIndex(0, nullptr); + int64_t cached_int = cached_value->IntAtIndex_NOCAST(0, nullptr); if ((cached_int >= 0) && (cached_int <= SLIM_MAX_ID_VALUE)) { diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index beec1e433..fb2802b3b 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -571,7 +571,7 @@ static int codon2aa_int[64] = { #pragma mark Nucleotide utilities #pragma mark - -// (string)codonsToAminoAcids(integer codons, [li$ long = F]) +// (string)codonsToAminoAcids(integer codons, [li$ long = F], [l$ paste = T]) EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosValue *codons_value = p_arguments[0].get(); @@ -580,11 +580,11 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorCount(); bool integer_result = (long_value->Type() == EidosValueType::kValueInt); - eidos_logical_t long_strings = (integer_result ? false : long_value->LogicalAtIndex(0, nullptr)); + eidos_logical_t long_strings = (integer_result ? false : long_value->LogicalAtIndex_NOCAST(0, nullptr)); if (integer_result) { - int64_t long_intval = long_value->IntAtIndex(0, nullptr); + int64_t long_intval = long_value->IntAtIndex_NOCAST(0, nullptr); if (long_intval != 0) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_codonsToAminoAcids): function codonsToAminoAcids() requires 'long' to be T, F, or 0." << EidosTerminate(nullptr); @@ -592,7 +592,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorIntAtIndex(0, nullptr); + int64_t codon = codons_value->IntAtIndex_NOCAST(0, nullptr); if ((codon < 0) || (codon > 63)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_codonsToAminoAcids): function codonsToAminoAcids() requires codons to be in [0, 63]." << EidosTerminate(nullptr); @@ -631,7 +631,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorLogicalAtIndex(0, nullptr); + eidos_logical_t paste = paste_value->LogicalAtIndex_NOCAST(0, nullptr); if (paste) { @@ -831,7 +831,7 @@ static void CountNucleotides(EidosValue *sequence_value, int64_t *total_ACGT, co // Singleton case if (sequence_type == EidosValueType::kValueInt) { - uint64_t nuc = sequence_value->IntAtIndex(0, nullptr); + uint64_t nuc = sequence_value->IntAtIndex_NOCAST(0, nullptr); if (nuc > 3) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_" << function_name << "): function " << function_name << "() requires integer sequence values to be in [0,3]." << EidosTerminate(nullptr); @@ -913,7 +913,7 @@ EidosValue_SP SLiM_ExecuteFunction_mm16To256(const std::vector &p { int ancestral_nucleotide = ((i / 4) % 4); int derived_nucleotide = (i / 64); - double value = mutationMatrix16_value->FloatAtIndex(ancestral_nucleotide + derived_nucleotide * 4, nullptr); + double value = mutationMatrix16_value->FloatAtIndex_NOCAST(ancestral_nucleotide + derived_nucleotide * 4, nullptr); float_result->set_float_no_check(value, i); } @@ -928,7 +928,7 @@ EidosValue_SP SLiM_ExecuteFunction_mm16To256(const std::vector &p EidosValue_SP SLiM_ExecuteFunction_mmJukesCantor(const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosValue *alpha_value = p_arguments[0].get(); - double alpha = alpha_value->FloatAtIndex(0, nullptr); + double alpha = alpha_value->FloatAtIndex_NOCAST(0, nullptr); if (alpha < 0.0) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_mmJukesCantor): function mmJukesCantor() requires alpha >= 0.0." << EidosTerminate(nullptr); @@ -969,8 +969,8 @@ EidosValue_SP SLiM_ExecuteFunction_mmKimura(const std::vector &p_ EidosValue *alpha_value = p_arguments[0].get(); EidosValue *beta_value = p_arguments[1].get(); - double alpha = alpha_value->FloatAtIndex(0, nullptr); - double beta = beta_value->FloatAtIndex(0, nullptr); + double alpha = alpha_value->FloatAtIndex_NOCAST(0, nullptr); + double beta = beta_value->FloatAtIndex_NOCAST(0, nullptr); if ((alpha < 0.0) || (alpha > 1.0)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_mmKimura): function mmKimura() requires alpha to be in [0.0, 1.0]." << EidosTerminate(nullptr); @@ -1054,7 +1054,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorIntAtIndex(0, nullptr); + int64_t length = length_value->IntAtIndex_NOCAST(0, nullptr); if ((length < 0) || (length > 2000000000L)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_randomNucleotides): function randomNucleotides() requires length to be in [0, 2e9]." << EidosTerminate(nullptr); @@ -1067,10 +1067,10 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorCount() != 4) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_randomNucleotides): function randomNucleotides() requires basis to be either NULL, or an integer or float vector of length 4 (with relative probabilities for A/C/G/T)." << EidosTerminate(nullptr); - pA = basis_value->FloatAtIndex(0, nullptr); - pC = basis_value->FloatAtIndex(1, nullptr); - pG = basis_value->FloatAtIndex(2, nullptr); - pT = basis_value->FloatAtIndex(3, nullptr); + pA = basis_value->NumericAtIndex_NOCAST(0, nullptr); + pC = basis_value->NumericAtIndex_NOCAST(1, nullptr); + pG = basis_value->NumericAtIndex_NOCAST(2, nullptr); + pT = basis_value->NumericAtIndex_NOCAST(3, nullptr); if (!std::isfinite(pA) || !std::isfinite(pC) || !std::isfinite(pG) || !std::isfinite(pT) || (pA < 0.0) || (pC < 0.0) || (pG < 0.0) || (pT < 0.0)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_randomNucleotides): function randomNucleotides() requires basis values to be finite and >= 0.0." << EidosTerminate(nullptr); @@ -1093,7 +1093,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorStringRefAtIndex(0, nullptr); + const std::string &format = format_value->StringRefAtIndex_NOCAST(0, nullptr); if ((format != "string") && (format != "char") && (format != "integer")) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_randomNucleotides): function randomNucleotides() requires a format of 'string', 'char', or 'integer'." << EidosTerminate(); @@ -1196,7 +1196,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorCount(); int length = codons_length * 3; - const std::string &format = format_value->StringRefAtIndex(0, nullptr); + const std::string &format = format_value->StringRefAtIndex_NOCAST(0, nullptr); if (format == "char") { @@ -1205,7 +1205,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorIntAtIndex(codon_index, nullptr); + int codon = (int)codons_value->IntAtIndex_NOCAST(codon_index, nullptr); if ((codon < 0) || (codon > 63)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_codonsToNucleotides): function codonsToNucleotides() requires codon values to be in [0,63]." << EidosTerminate(); @@ -1249,7 +1249,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorIntAtIndex(codon_index, nullptr); + int codon = (int)codons_value->IntAtIndex_NOCAST(codon_index, nullptr); if ((codon < 0) || (codon > 63)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_codonsToNucleotides): function codonsToNucleotides() requires codon values to be in [0,63]." << EidosTerminate(); @@ -1277,7 +1277,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorIntAtIndex(codon_index, nullptr); + int codon = (int)codons_value->IntAtIndex_NOCAST(codon_index, nullptr); if ((codon < 0) || (codon > 63)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_codonsToNucleotides): function codonsToNucleotides() requires codon values to be in [0,63]." << EidosTerminate(); @@ -1410,7 +1410,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorObjectElementAtIndex(0, nullptr); + singleton_ind = (Individual *)individuals_value->ObjectElementAtIndex_NOCAST(0, nullptr); individuals_buffer = &singleton_ind; } else @@ -1466,7 +1466,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorStringAtIndex(0, nullptr); + std::string spatiality_string = spatiality_value->StringAtIndex_NOCAST(0, nullptr); if (spatiality_string.compare(gEidosStr_x) == 0) { spatiality = 1; required_dimensionality = 1; component0 = 0; } else if (spatiality_string.compare(gEidosStr_y) == 0) { spatiality = 1; required_dimensionality = 2; component0 = 1; } @@ -1495,22 +1495,22 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vector= 1) { - spatialBounds[0] = spatialBounds_value->FloatAtIndex(component0, nullptr); - spatialBounds[1] = spatialBounds_value->FloatAtIndex(component0 + spatiality, nullptr); + spatialBounds[0] = spatialBounds_value->NumericAtIndex_NOCAST(component0, nullptr); + spatialBounds[1] = spatialBounds_value->NumericAtIndex_NOCAST(component0 + spatiality, nullptr); if (spatialBounds[0] >= spatialBounds[1]) invalid_bounds = true; } if (spatiality >= 2) { - spatialBounds[2] = spatialBounds_value->FloatAtIndex(component1, nullptr); - spatialBounds[3] = spatialBounds_value->FloatAtIndex(component1 + spatiality, nullptr); + spatialBounds[2] = spatialBounds_value->NumericAtIndex_NOCAST(component1, nullptr); + spatialBounds[3] = spatialBounds_value->NumericAtIndex_NOCAST(component1 + spatiality, nullptr); if (spatialBounds[2] >= spatialBounds[3]) invalid_bounds = true; } if (spatiality >= 3) { - spatialBounds[4] = spatialBounds_value->FloatAtIndex(component2, nullptr); - spatialBounds[5] = spatialBounds_value->FloatAtIndex(component2 + spatiality, nullptr); + spatialBounds[4] = spatialBounds_value->NumericAtIndex_NOCAST(component2, nullptr); + spatialBounds[5] = spatialBounds_value->NumericAtIndex_NOCAST(component2 + spatiality, nullptr); if (spatialBounds[4] >= spatialBounds[5]) invalid_bounds = true; } @@ -1519,12 +1519,12 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorStringAtIndex(0, nullptr); + std::string operation_string = operation_value->StringAtIndex_NOCAST(0, nullptr); bool uses_empty = (empty_value->Type() != EidosValueType::kValueNULL); - double empty = uses_empty ? empty_value->FloatAtIndex(0, nullptr) : 0.0; // handles logical, integer, and float + double empty = uses_empty ? empty_value->FloatAtIndex_CAST(0, nullptr) : 0.0; // handles logical, integer, and float // Get the edgeScale value, which is used to postprocess vaues at the very end - bool perUnitArea = perUnitArea_value->LogicalAtIndex(0, nullptr); + bool perUnitArea = perUnitArea_value->LogicalAtIndex_NOCAST(0, nullptr); if (perUnitArea && std::isfinite(empty) && (empty != 0.0)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_summarizeIndividuals): summarizeIndividuals() requires that when perUnitArea is T, empty is F, 0, 0.0, INF, -INF, or NAN (so that the empty value does not get scaled, which presumably does not make sense)." << EidosTerminate(); @@ -1540,7 +1540,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorIntAtIndex(dim_index, nullptr); + dims[dim_index] = dim_value->IntAtIndex_NOCAST(dim_index, nullptr); if ((dims[dim_index] < 2) || (dims[dim_index] > 10000)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_summarizeIndividuals): summarizeIndividuals() requires dimensions in dim to be in the range [2, 10000]." << EidosTerminate(); @@ -1710,7 +1710,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorCount() == 1) && ((return_value_SP->Type() == EidosValueType::kValueFloat) || (return_value_SP->Type() == EidosValueType::kValueInt) || (return_value_SP->Type() == EidosValueType::kValueLogical))) { - result_data[bin_index] = return_value_SP->FloatAtIndex(0, nullptr); + result_data[bin_index] = return_value_SP->FloatAtIndex_CAST(0, nullptr); } else { @@ -1824,7 +1824,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosValue *filePath_value = p_arguments[0].get(); - std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex(0, nullptr))); + std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex_NOCAST(0, nullptr))); tsk_table_collection_t temp_tables; @@ -1874,7 +1874,7 @@ EidosValue_SP SLiM_ExecuteFunction_treeSeqMetadata(const std::vectorLogicalAtIndex(0, nullptr); + bool userData = userData_value->LogicalAtIndex_NOCAST(0, nullptr); if (userData) { diff --git a/core/slim_globals.cpp b/core/slim_globals.cpp index 9bda0d460..70327ed08 100644 --- a/core/slim_globals.cpp +++ b/core/slim_globals.cpp @@ -241,7 +241,7 @@ Community &SLiM_GetCommunityFromInterpreter(EidosInterpreter &p_interpreter) slim_objectid_t SLiM_ExtractObjectIDFromEidosValue_is(EidosValue *p_value, int p_index, char p_prefix_char) { - return (p_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex(p_index, nullptr)) : SLiMEidosScript::ExtractIDFromStringWithPrefix(p_value->StringAtIndex(p_index, nullptr), p_prefix_char, nullptr); + return (p_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex_NOCAST(p_index, nullptr)) : SLiMEidosScript::ExtractIDFromStringWithPrefix(p_value->StringAtIndex_NOCAST(p_index, nullptr), p_prefix_char, nullptr); } MutationType *SLiM_ExtractMutationTypeFromEidosValue_io(EidosValue *p_value, int p_index, Community *p_community, Species *p_species, const char *p_method_name) @@ -250,7 +250,7 @@ MutationType *SLiM_ExtractMutationTypeFromEidosValue_io(EidosValue *p_value, int if (p_value->Type() == EidosValueType::kValueInt) { - slim_objectid_t mutation_type_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex(p_index, nullptr)); + slim_objectid_t mutation_type_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex_NOCAST(p_index, nullptr)); if (p_species) { @@ -280,9 +280,9 @@ MutationType *SLiM_ExtractMutationTypeFromEidosValue_io(EidosValue *p_value, int #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - found_muttype = dynamic_cast(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_muttype = dynamic_cast(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #else - found_muttype = (MutationType *)(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_muttype = (MutationType *)(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #endif if (!found_muttype) @@ -301,7 +301,7 @@ GenomicElementType *SLiM_ExtractGenomicElementTypeFromEidosValue_io(EidosValue * if (p_value->Type() == EidosValueType::kValueInt) { - slim_objectid_t getype_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex(p_index, nullptr)); + slim_objectid_t getype_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex_NOCAST(p_index, nullptr)); if (p_species) { @@ -331,9 +331,9 @@ GenomicElementType *SLiM_ExtractGenomicElementTypeFromEidosValue_io(EidosValue * #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - found_getype = dynamic_cast(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_getype = dynamic_cast(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #else - found_getype = (GenomicElementType *)(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_getype = (GenomicElementType *)(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #endif if (!found_getype) @@ -352,7 +352,7 @@ Subpopulation *SLiM_ExtractSubpopulationFromEidosValue_io(EidosValue *p_value, i if (p_value->Type() == EidosValueType::kValueInt) { - slim_objectid_t source_subpop_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex(p_index, nullptr)); + slim_objectid_t source_subpop_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex_NOCAST(p_index, nullptr)); if (p_species) { @@ -382,9 +382,9 @@ Subpopulation *SLiM_ExtractSubpopulationFromEidosValue_io(EidosValue *p_value, i #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - found_subpop = dynamic_cast(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_subpop = dynamic_cast(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #else - found_subpop = (Subpopulation *)(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_subpop = (Subpopulation *)(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #endif if (!found_subpop) @@ -403,7 +403,7 @@ SLiMEidosBlock *SLiM_ExtractSLiMEidosBlockFromEidosValue_io(EidosValue *p_value, if (p_value->Type() == EidosValueType::kValueInt) { - slim_objectid_t block_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex(p_index, nullptr)); + slim_objectid_t block_id = SLiMCastToObjectidTypeOrRaise(p_value->IntAtIndex_NOCAST(p_index, nullptr)); std::vector &script_blocks = p_community->AllScriptBlocks(); for (SLiMEidosBlock *temp_found_block : script_blocks) @@ -421,9 +421,9 @@ SLiMEidosBlock *SLiM_ExtractSLiMEidosBlockFromEidosValue_io(EidosValue *p_value, #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - found_block = dynamic_cast(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_block = dynamic_cast(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #else - found_block = (SLiMEidosBlock *)(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_block = (SLiMEidosBlock *)(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #endif if (!found_block) @@ -455,9 +455,9 @@ Species *SLiM_ExtractSpeciesFromEidosValue_No(EidosValue *p_value, int p_index, #if DEBUG // Use dynamic_cast<> only in DEBUG since it is hella slow // the class of the object here should be guaranteed by the caller anyway - found_species = dynamic_cast(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_species = dynamic_cast(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #else - found_species = (Species *)(p_value->ObjectElementAtIndex(p_index, nullptr)); + found_species = (Species *)(p_value->ObjectElementAtIndex_NOCAST(p_index, nullptr)); #endif if (!found_species) diff --git a/core/spatial_kernel.cpp b/core/spatial_kernel.cpp index 4031ef0db..e8d9d1838 100644 --- a/core/spatial_kernel.cpp +++ b/core/spatial_kernel.cpp @@ -78,7 +78,7 @@ SpatialKernel::SpatialKernel(int p_dimensionality, double p_maxDistance, const s EidosValue_String *functionType_value = (EidosValue_String *)p_arguments[p_first_kernel_arg].get(); - const std::string &k_type_string = functionType_value->StringRefAtIndex(0, nullptr); + const std::string &k_type_string = functionType_value->StringRefAtIndex_NOCAST(0, nullptr); SpatialKernelType k_type; int expected_k_param_count = 0; std::vector k_parameters; @@ -140,7 +140,7 @@ SpatialKernel::SpatialKernel(int p_dimensionality, double p_maxDistance, const s if ((k_param_type != EidosValueType::kValueFloat) && (k_param_type != EidosValueType::kValueInt)) EIDOS_TERMINATION << "ERROR (SpatialKernel::SpatialKernel): the parameters for this spatial kernel type must be numeric (integer or float)." << EidosTerminate(); - k_parameters.emplace_back(k_param_value->FloatAtIndex(0, nullptr)); + k_parameters.emplace_back(k_param_value->NumericAtIndex_NOCAST(0, nullptr)); } // Internally, we always have a max kernel density. If one was not expected from the arguments, diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index 89e95f9b0..16274b6f3 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -262,8 +262,8 @@ void SpatialMap::TakeColorsFromEidosValues(EidosValue *p_value_range, EidosValue EIDOS_TERMINATION << "ERROR (" << p_code_name << "): " << p_eidos_name << " valueRange must be exactly length 2 (giving the min and max value permitted)." << EidosTerminate(); // valueRange and colors were provided, so use them for coloring - colors_min_ = p_value_range->FloatAtIndex(0, nullptr); - colors_max_ = p_value_range->FloatAtIndex(1, nullptr); + colors_min_ = p_value_range->NumericAtIndex_NOCAST(0, nullptr); + colors_max_ = p_value_range->NumericAtIndex_NOCAST(1, nullptr); if (!std::isfinite(colors_min_) || !std::isfinite(colors_max_) || (colors_min_ > colors_max_)) EIDOS_TERMINATION << "ERROR (" << p_code_name << "): " << p_eidos_name << " valueRange must be finite, and min <= max is required." << EidosTerminate(); @@ -1125,7 +1125,7 @@ void SpatialMap::SetProperty(EidosGlobalStringID p_property_id, const EidosValue { case gID_interpolate: { - eidos_logical_t value = p_value.LogicalAtIndex(0, nullptr); + eidos_logical_t value = p_value.LogicalAtIndex_NOCAST(0, nullptr); interpolate_ = value; @@ -1143,7 +1143,7 @@ void SpatialMap::SetProperty(EidosGlobalStringID p_property_id, const EidosValue } case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -1203,7 +1203,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_add(EidosGlobalStringID p_method_id, con if ((x_value->Type() == EidosValueType::kValueInt) || (x_value->Type() == EidosValueType::kValueFloat)) { - double add_scalar = x_value->FloatAtIndex(0, nullptr); + double add_scalar = x_value->NumericAtIndex_NOCAST(0, nullptr); // FIXME: TO BE PARALLELIZED for (int64_t i = 0; i < values_size_; ++i) @@ -1211,7 +1211,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_add(EidosGlobalStringID p_method_id, con } else { - SpatialMap *add_map = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *add_map = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); double *add_map_values = add_map->values_; if (!IsCompatibleWithMap(add_map)) @@ -1246,7 +1246,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_blend(EidosGlobalStringID p_method_id, c x_value = spatialmap_temp.get(); } - double xFraction = xFraction_value->FloatAtIndex(0, nullptr); + double xFraction = xFraction_value->FloatAtIndex_NOCAST(0, nullptr); double targetFraction = 1 - xFraction; if ((xFraction < 0.0) || (xFraction > 1.0)) @@ -1254,7 +1254,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_blend(EidosGlobalStringID p_method_id, c if ((x_value->Type() == EidosValueType::kValueInt) || (x_value->Type() == EidosValueType::kValueFloat)) { - double blend_scalar = x_value->FloatAtIndex(0, nullptr); + double blend_scalar = x_value->NumericAtIndex_NOCAST(0, nullptr); // FIXME: TO BE PARALLELIZED for (int64_t i = 0; i < values_size_; ++i) @@ -1262,7 +1262,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_blend(EidosGlobalStringID p_method_id, c } else { - SpatialMap *blend_map = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *blend_map = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); double *blend_map_values = blend_map->values_; if (!IsCompatibleWithMap(blend_map)) @@ -1298,7 +1298,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_multiply(EidosGlobalStringID p_method_id if ((x_value->Type() == EidosValueType::kValueInt) || (x_value->Type() == EidosValueType::kValueFloat)) { - double multiply_scalar = x_value->FloatAtIndex(0, nullptr); + double multiply_scalar = x_value->NumericAtIndex_NOCAST(0, nullptr); // FIXME: TO BE PARALLELIZED for (int64_t i = 0; i < values_size_; ++i) @@ -1306,7 +1306,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_multiply(EidosGlobalStringID p_method_id } else { - SpatialMap *multiply_map = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *multiply_map = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); double *multiply_map_values = multiply_map->values_; if (!IsCompatibleWithMap(multiply_map)) @@ -1342,7 +1342,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_subtract(EidosGlobalStringID p_method_id if ((x_value->Type() == EidosValueType::kValueInt) || (x_value->Type() == EidosValueType::kValueFloat)) { - double subtract_scalar = x_value->FloatAtIndex(0, nullptr); + double subtract_scalar = x_value->NumericAtIndex_NOCAST(0, nullptr); // FIXME: TO BE PARALLELIZED for (int64_t i = 0; i < values_size_; ++i) @@ -1350,7 +1350,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_subtract(EidosGlobalStringID p_method_id } else { - SpatialMap *subtract_map = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *subtract_map = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); double *subtract_map_values = subtract_map->values_; if (!IsCompatibleWithMap(subtract_map)) @@ -1386,7 +1386,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_divide(EidosGlobalStringID p_method_id, if ((x_value->Type() == EidosValueType::kValueInt) || (x_value->Type() == EidosValueType::kValueFloat)) { - double divide_scalar = x_value->FloatAtIndex(0, nullptr); + double divide_scalar = x_value->NumericAtIndex_NOCAST(0, nullptr); // FIXME: TO BE PARALLELIZED for (int64_t i = 0; i < values_size_; ++i) @@ -1394,7 +1394,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_divide(EidosGlobalStringID p_method_id, } else { - SpatialMap *divide_map = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *divide_map = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); double *divide_map_values = divide_map->values_; if (!IsCompatibleWithMap(divide_map)) @@ -1430,7 +1430,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_power(EidosGlobalStringID p_method_id, c if ((x_value->Type() == EidosValueType::kValueInt) || (x_value->Type() == EidosValueType::kValueFloat)) { - double power_scalar = x_value->FloatAtIndex(0, nullptr); + double power_scalar = x_value->NumericAtIndex_NOCAST(0, nullptr); // FIXME: TO BE PARALLELIZED for (int64_t i = 0; i < values_size_; ++i) @@ -1438,7 +1438,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_power(EidosGlobalStringID p_method_id, c } else { - SpatialMap *power_map = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *power_map = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); double *power_map_values = power_map->values_; if (!IsCompatibleWithMap(power_map)) @@ -1494,7 +1494,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_changeValues(EidosGlobalStringID p_metho EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_changeValues): changeValues() requires that if x is of type object, it must be a singleton SpatialMap." << EidosTerminate(); // If passed a SpatialMap object, we copy its values directly - SpatialMap *x = (SpatialMap *)x_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *x = (SpatialMap *)x_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (IsCompatibleWithMapValues(x)) { @@ -1562,14 +1562,14 @@ EidosValue_SP SpatialMap::ExecuteMethod_interpolate(EidosGlobalStringID p_method { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *factor_value = p_arguments[0].get(); - int64_t factor = factor_value->IntAtIndex(0, nullptr); + int64_t factor = factor_value->IntAtIndex_NOCAST(0, nullptr); // the upper limit here is arbitrary, but the goal is to prevent users from blowing up their memory usage unintentionally if ((factor < 2) || (factor > 10001)) EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_interpolate): interpolate() requires factor to be in [2, 10001], rather arbitrarily." << EidosTerminate(); EidosValue_String *method_value = (EidosValue_String *)p_arguments[1].get(); - const std::string &method_string = method_value->StringRefAtIndex(0, nullptr); + const std::string &method_string = method_value->StringRefAtIndex_NOCAST(0, nullptr); int method; if (method_string == "nearest") @@ -1862,7 +1862,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapColor(EidosGlobalStringID p_method_id for (slim_popsize_t value_index = 0; value_index < value_count; value_index++) { - double value = values->FloatAtIndex(value_index, nullptr); + double value = values->NumericAtIndex_NOCAST(value_index, nullptr); double rgb[3]; char hex_chars[8]; @@ -1890,15 +1890,15 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapImage(EidosGlobalStringID p_method_id int64_t image_width = grid_size_[0], image_height = grid_size_[1]; if (width_value->Type() != EidosValueType::kValueNULL) - image_width = width_value->IntAtIndex(0, nullptr); + image_width = width_value->IntAtIndex_NOCAST(0, nullptr); if (height_value->Type() != EidosValueType::kValueNULL) - image_height = height_value->IntAtIndex(0, nullptr); + image_height = height_value->IntAtIndex_NOCAST(0, nullptr); if ((image_width <= 0) || (image_width > 100000) || (image_height <= 0) || (image_height > 100000)) EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_mapImage): mapImage() requires width and height values to be in [1, 100000]." << EidosTerminate(); - bool color = color_value->LogicalAtIndex(0, nullptr); + bool color = color_value->LogicalAtIndex_NOCAST(0, nullptr); if (color && (n_colors_ == 0)) EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_mapImage): mapImage() requires a defined color map for the spatial map with color=T; use color=F to get a grayscale image, or define a color map in SpatialMap()." << EidosTerminate(); @@ -1906,7 +1906,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapImage(EidosGlobalStringID p_method_id EidosImage *image = new EidosImage(image_width, image_height, !color); unsigned char * const data = image->Data(); unsigned char *data_ptr = data; - bool centers = centers_value->LogicalAtIndex(0, nullptr); + bool centers = centers_value->LogicalAtIndex_NOCAST(0, nullptr); if (centers) { @@ -2027,7 +2027,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id double point_vec[1]; int value_offset = value_index; - double a = (point->FloatAtIndex(0 + value_offset, nullptr) - bounds_a0_) / (bounds_a1_ - bounds_a0_); + double a = (point->FloatAtIndex_NOCAST(0 + value_offset, nullptr) - bounds_a0_) / (bounds_a1_ - bounds_a0_); point_vec[0] = SLiMClampCoordinate(a); map_value = ValueAtPoint_S1(point_vec); @@ -2038,10 +2038,10 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id double point_vec[2]; int value_offset = value_index * 2; - double a = (point->FloatAtIndex(0 + value_offset, nullptr) - bounds_a0_) / (bounds_a1_ - bounds_a0_); + double a = (point->FloatAtIndex_NOCAST(0 + value_offset, nullptr) - bounds_a0_) / (bounds_a1_ - bounds_a0_); point_vec[0] = SLiMClampCoordinate(a); - double b = (point->FloatAtIndex(1 + value_offset, nullptr) - bounds_b0_) / (bounds_b1_ - bounds_b0_); + double b = (point->FloatAtIndex_NOCAST(1 + value_offset, nullptr) - bounds_b0_) / (bounds_b1_ - bounds_b0_); point_vec[1] = SLiMClampCoordinate(b); map_value = ValueAtPoint_S2(point_vec); @@ -2052,13 +2052,13 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id double point_vec[3]; int value_offset = value_index * 3; - double a = (point->FloatAtIndex(0 + value_offset, nullptr) - bounds_a0_) / (bounds_a1_ - bounds_a0_); + double a = (point->FloatAtIndex_NOCAST(0 + value_offset, nullptr) - bounds_a0_) / (bounds_a1_ - bounds_a0_); point_vec[0] = SLiMClampCoordinate(a); - double b = (point->FloatAtIndex(1 + value_offset, nullptr) - bounds_b0_) / (bounds_b1_ - bounds_b0_); + double b = (point->FloatAtIndex_NOCAST(1 + value_offset, nullptr) - bounds_b0_) / (bounds_b1_ - bounds_b0_); point_vec[1] = SLiMClampCoordinate(b); - double c = (point->FloatAtIndex(2 + value_offset, nullptr) - bounds_c0_) / (bounds_c1_ - bounds_c0_); + double c = (point->FloatAtIndex_NOCAST(2 + value_offset, nullptr) - bounds_c0_) / (bounds_c1_ - bounds_c0_); point_vec[2] = SLiMClampCoordinate(c); map_value = ValueAtPoint_S3(point_vec); @@ -2099,8 +2099,8 @@ EidosValue_SP SpatialMap::ExecuteMethod_rescale(EidosGlobalStringID p_method_id, EidosValue *min_value = p_arguments[0].get(); EidosValue *max_value = p_arguments[1].get(); - double min = min_value->FloatAtIndex(0, nullptr); - double max = max_value->FloatAtIndex(0, nullptr); + double min = min_value->NumericAtIndex_NOCAST(0, nullptr); + double max = max_value->NumericAtIndex_NOCAST(0, nullptr); if (!std::isfinite(min) || !std::isfinite(max) || (min >= max)) EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_rescale): rescale() requires that min and max are finite, and that min < max." << EidosTerminate(nullptr); @@ -2131,7 +2131,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleImprovedNearbyPoint(EidosGlobalStr size_t point_count = point_value->Count(); EidosValue *maxDistance_value = p_arguments[1].get(); - double max_distance = maxDistance_value->FloatAtIndex(0, nullptr); + double max_distance = maxDistance_value->FloatAtIndex_NOCAST(0, nullptr); SpatialKernel kernel(spatiality_, max_distance, p_arguments, 2, /* p_expect_max_density */ false); // uses our arguments starting at index 2 @@ -2362,7 +2362,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleNearbyPoint(EidosGlobalStringID p_ size_t point_count = point_value->Count(); EidosValue *maxDistance_value = p_arguments[1].get(); - double max_distance = maxDistance_value->FloatAtIndex(0, nullptr); + double max_distance = maxDistance_value->FloatAtIndex_NOCAST(0, nullptr); SpatialKernel kernel(spatiality_, max_distance, p_arguments, 2, /* p_expect_max_density */ false); // uses our arguments starting at index 2 @@ -2577,7 +2577,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_smooth(EidosGlobalStringID p_method_id, #pragma unused (p_method_id, p_arguments, p_interpreter) // Our arguments go to SpatialKernel::SpatialKernel(), which creates the kernel object that we use EidosValue *maxDistance_value = p_arguments[0].get(); - double max_distance = maxDistance_value->FloatAtIndex(0, nullptr); + double max_distance = maxDistance_value->FloatAtIndex_NOCAST(0, nullptr); SpatialKernel kernel(spatiality_, max_distance, p_arguments, 1, /* p_expect_max_density */ false); // uses our arguments starting at index 1 @@ -2640,10 +2640,10 @@ EidosValue_SP SpatialMap::_DeriveTemporarySpatialMapWithEidosValue(EidosValue *p static EidosValue_SP SLiM_Instantiate_SpatialMap(const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosValue_String *name_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &name = name_value->StringRefAtIndex(0, nullptr); + const std::string &name = name_value->StringRefAtIndex_NOCAST(0, nullptr); EidosValue *map_value = p_arguments[1].get(); - SpatialMap *map = (SpatialMap *)map_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *map = (SpatialMap *)map_value->ObjectElementAtIndex_NOCAST(0, nullptr); SpatialMap *objectElement = new SpatialMap(name, *map); EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gSLiM_SpatialMap_Class)); diff --git a/core/species.cpp b/core/species.cpp index 7d177c34d..0a53f5c40 100644 --- a/core/species.cpp +++ b/core/species.cpp @@ -320,7 +320,7 @@ void Species::_CleanAllReferencesToSpecies(EidosInterpreter *p_interpreter) { for (int i = 0; i < symbol_object->Count(); ++i) { - Subpopulation *element = (Subpopulation *)symbol_object->ObjectElementAtIndex(i, nullptr); + Subpopulation *element = (Subpopulation *)symbol_object->ObjectElementAtIndex_NOCAST(i, nullptr); if (&element->species_ == this) { @@ -333,7 +333,7 @@ void Species::_CleanAllReferencesToSpecies(EidosInterpreter *p_interpreter) { for (int i = 0; i < symbol_object->Count(); ++i) { - Genome *element = (Genome *)symbol_object->ObjectElementAtIndex(i, nullptr); + Genome *element = (Genome *)symbol_object->ObjectElementAtIndex_NOCAST(i, nullptr); if (&element->individual_->subpopulation_->species_ == this) { @@ -346,7 +346,7 @@ void Species::_CleanAllReferencesToSpecies(EidosInterpreter *p_interpreter) { for (int i = 0; i < symbol_object->Count(); ++i) { - Individual *element = (Individual *)symbol_object->ObjectElementAtIndex(i, nullptr); + Individual *element = (Individual *)symbol_object->ObjectElementAtIndex_NOCAST(i, nullptr); if (&element->subpopulation_->species_ == this) { @@ -359,7 +359,7 @@ void Species::_CleanAllReferencesToSpecies(EidosInterpreter *p_interpreter) { for (int i = 0; i < symbol_object->Count(); ++i) { - Mutation *element = (Mutation *)symbol_object->ObjectElementAtIndex(i, nullptr); + Mutation *element = (Mutation *)symbol_object->ObjectElementAtIndex_NOCAST(i, nullptr); if (&element->mutation_type_ptr_->species_ == this) { @@ -372,7 +372,7 @@ void Species::_CleanAllReferencesToSpecies(EidosInterpreter *p_interpreter) { for (int i = 0; i < symbol_object->Count(); ++i) { - Substitution *element = (Substitution *)symbol_object->ObjectElementAtIndex(i, nullptr); + Substitution *element = (Substitution *)symbol_object->ObjectElementAtIndex_NOCAST(i, nullptr); if (&element->mutation_type_ptr_->species_ == this) { diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index f86015b31..7d367d8ff 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -74,7 +74,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeAncestralNucleotides(con if (sequence_value_count == 1) { // singleton case - int64_t int_value = sequence_value->IntAtIndex(0, nullptr); + int64_t int_value = sequence_value->IntAtIndex_NOCAST(0, nullptr); chromosome_->ancestral_seq_buffer_ = new NucleotideArray(1); chromosome_->ancestral_seq_buffer_->SetNucleotideAtIndex((std::size_t)0, (uint64_t)int_value); @@ -217,8 +217,8 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGenomicElement(const std for (int element_index = 0; element_index < element_count; ++element_index) { genomic_element_type_ptr = ((type_count == 1) ? genomic_element_type_ptr_0 : SLiM_ExtractGenomicElementTypeFromEidosValue_io(genomicElementType_value, element_index, &community_, this, "initializeGenomicElement()")); // SPECIES CONSISTENCY CHECK - start_position = SLiMCastToPositionTypeOrRaise(start_value->IntAtIndex(element_index, nullptr)); - end_position = SLiMCastToPositionTypeOrRaise(end_value->IntAtIndex(element_index, nullptr)); + start_position = SLiMCastToPositionTypeOrRaise(start_value->IntAtIndex_NOCAST(element_index, nullptr)); + end_position = SLiMCastToPositionTypeOrRaise(end_value->IntAtIndex_NOCAST(element_index, nullptr)); if (end_position < start_position) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeGenomicElement): initializeGenomicElement() end position " << end_position << " is less than start position " << start_position << "." << EidosTerminate(); @@ -296,7 +296,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGenomicElementType(const for (int mut_type_index = 0; mut_type_index < mut_type_id_count; ++mut_type_index) { MutationType *mutation_type_ptr = SLiM_ExtractMutationTypeFromEidosValue_io(mutationTypes_value, mut_type_index, &community_, this, "initializeGenomicElementType()"); // SPECIES CONSISTENCY CHECK - double proportion = proportions_value->FloatAtIndex(mut_type_index, nullptr); + double proportion = proportions_value->NumericAtIndex_NOCAST(mut_type_index, nullptr); if ((proportion < 0) || !std::isfinite(proportion)) // == 0 is allowed but must be fixed before the simulation executes; see InitializeDraws() EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeGenomicElementType): initializeGenomicElementType() proportions must be greater than or equal to zero (" << EidosStringForFloat(proportion) << " supplied)." << EidosTerminate(); @@ -358,7 +358,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGenomicElementType(const output_stream << ((mut_type_id_count > 1) ? ", c(" : ", "); for (int mut_type_index = 0; mut_type_index < mut_type_id_count; ++mut_type_index) - output_stream << (mut_type_index > 0 ? ", " : "") << proportions_value->FloatAtIndex(mut_type_index, nullptr); + output_stream << (mut_type_index > 0 ? ", " : "") << proportions_value->NumericAtIndex_NOCAST(mut_type_index, nullptr); output_stream << ((mut_type_id_count > 1) ? ")" : ""); output_stream << ");" << std::endl; @@ -387,8 +387,8 @@ EidosValue_SP Species::ExecuteContextFunction_initializeMutationType(const std:: std::ostream &output_stream = p_interpreter.ExecutionOutputStream(); slim_objectid_t map_identifier = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 'm'); - double dominance_coeff = dominanceCoeff_value->FloatAtIndex(0, nullptr); - std::string dfe_type_string = distributionType_value->StringAtIndex(0, nullptr); + double dominance_coeff = dominanceCoeff_value->NumericAtIndex_NOCAST(0, nullptr); + std::string dfe_type_string = distributionType_value->StringAtIndex_NOCAST(0, nullptr); if (community_.MutationTypeWithID(map_identifier)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeMutationType): " << p_function_name << "() mutation type m" << map_identifier << " already defined." << EidosTerminate(); @@ -466,7 +466,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeRecombinationRate(const // Figure out what sex we are being given a map for IndividualSex requested_sex; - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -500,7 +500,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeRecombinationRate(const if (rate_count != 1) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeRecombinationRate): initializeRecombinationRate() requires rates to be a singleton if ends is not supplied." << EidosTerminate(); - double recombination_rate = rates_value->FloatAtIndex(0, nullptr); + double recombination_rate = rates_value->NumericAtIndex_NOCAST(0, nullptr); // check values if ((recombination_rate < 0.0) || (recombination_rate > 0.5) || std::isnan(recombination_rate)) @@ -523,11 +523,11 @@ EidosValue_SP Species::ExecuteContextFunction_initializeRecombinationRate(const // check values for (int value_index = 0; value_index < end_count; ++value_index) { - double recombination_rate = rates_value->FloatAtIndex(value_index, nullptr); - slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(value_index, nullptr)); + double recombination_rate = rates_value->NumericAtIndex_NOCAST(value_index, nullptr); + slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(value_index, nullptr)); if (value_index > 0) - if (recombination_end_position <= ends_value->IntAtIndex(value_index - 1, nullptr)) + if (recombination_end_position <= ends_value->IntAtIndex_NOCAST(value_index - 1, nullptr)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeRecombinationRate): initializeRecombinationRate() requires ends to be in strictly ascending order." << EidosTerminate(); if ((recombination_rate < 0.0) || (recombination_rate > 0.5) || std::isnan(recombination_rate)) @@ -540,8 +540,8 @@ EidosValue_SP Species::ExecuteContextFunction_initializeRecombinationRate(const for (int interval_index = 0; interval_index < end_count; ++interval_index) { - double recombination_rate = rates_value->FloatAtIndex(interval_index, nullptr); - slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(interval_index, nullptr)); + double recombination_rate = rates_value->NumericAtIndex_NOCAST(interval_index, nullptr); + slim_position_t recombination_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(interval_index, nullptr)); rates.emplace_back(recombination_rate); positions.emplace_back(recombination_end_position); @@ -615,11 +615,11 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGeneConversion(const std if (num_gene_conversions_ > 0) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeGeneConversion): initializeGeneConversion() may be called only once." << EidosTerminate(); - double non_crossover_fraction = nonCrossoverFraction_value->FloatAtIndex(0, nullptr); - double gene_conversion_avg_length = meanLength_value->FloatAtIndex(0, nullptr); - double simple_conversion_fraction = simpleConversionFraction_value->FloatAtIndex(0, nullptr); - double bias = bias_value->FloatAtIndex(0, nullptr); - bool redraw_lengths_on_failure = redrawLengthsOnFailure_value->LogicalAtIndex(0, nullptr); + double non_crossover_fraction = nonCrossoverFraction_value->NumericAtIndex_NOCAST(0, nullptr); + double gene_conversion_avg_length = meanLength_value->NumericAtIndex_NOCAST(0, nullptr); + double simple_conversion_fraction = simpleConversionFraction_value->NumericAtIndex_NOCAST(0, nullptr); + double bias = bias_value->NumericAtIndex_NOCAST(0, nullptr); + bool redraw_lengths_on_failure = redrawLengthsOnFailure_value->LogicalAtIndex_NOCAST(0, nullptr); if ((non_crossover_fraction < 0.0) || (non_crossover_fraction > 1.0) || std::isnan(non_crossover_fraction)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeGeneConversion): initializeGeneConversion() nonCrossoverFraction must be between 0.0 and 1.0 inclusive (" << EidosStringForFloat(non_crossover_fraction) << " supplied)." << EidosTerminate(); @@ -672,7 +672,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeHotspotMap(const std::st // Figure out what sex we are being given a map for IndividualSex requested_sex; - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -705,7 +705,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeHotspotMap(const std::st if (multipliers_count != 1) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeHotspotMap): initializeHotspotMap() requires multipliers to be a singleton if ends is not supplied." << EidosTerminate(); - double multiplier = multipliers_value->FloatAtIndex(0, nullptr); + double multiplier = multipliers_value->NumericAtIndex_NOCAST(0, nullptr); // check values if ((multiplier < 0.0) || !std::isfinite(multiplier)) // intentionally no upper bound @@ -728,11 +728,11 @@ EidosValue_SP Species::ExecuteContextFunction_initializeHotspotMap(const std::st // check values for (int value_index = 0; value_index < end_count; ++value_index) { - double multiplier = multipliers_value->FloatAtIndex(value_index, nullptr); - slim_position_t multiplier_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(value_index, nullptr)); + double multiplier = multipliers_value->NumericAtIndex_NOCAST(value_index, nullptr); + slim_position_t multiplier_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(value_index, nullptr)); if (value_index > 0) - if (multiplier_end_position <= ends_value->IntAtIndex(value_index - 1, nullptr)) + if (multiplier_end_position <= ends_value->IntAtIndex_NOCAST(value_index - 1, nullptr)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeHotspotMap): initializeHotspotMap() requires ends to be in strictly ascending order." << EidosTerminate(); if ((multiplier < 0.0) || !std::isfinite(multiplier)) // intentionally no upper bound @@ -745,8 +745,8 @@ EidosValue_SP Species::ExecuteContextFunction_initializeHotspotMap(const std::st for (int interval_index = 0; interval_index < end_count; ++interval_index) { - double multiplier = multipliers_value->FloatAtIndex(interval_index, nullptr); - slim_position_t multiplier_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(interval_index, nullptr)); + double multiplier = multipliers_value->NumericAtIndex_NOCAST(interval_index, nullptr); + slim_position_t multiplier_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(interval_index, nullptr)); multipliers.emplace_back(multiplier); positions.emplace_back(multiplier_end_position); @@ -822,7 +822,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeMutationRate(const std:: // Figure out what sex we are being given a map for IndividualSex requested_sex; - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -856,7 +856,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeMutationRate(const std:: if (rate_count != 1) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeMutationRate): initializeMutationRate() requires rates to be a singleton if ends is not supplied." << EidosTerminate(); - double mutation_rate = rates_value->FloatAtIndex(0, nullptr); + double mutation_rate = rates_value->NumericAtIndex_NOCAST(0, nullptr); // check values if ((mutation_rate < 0.0) || (mutation_rate >= 1.0) || !std::isfinite(mutation_rate)) @@ -879,11 +879,11 @@ EidosValue_SP Species::ExecuteContextFunction_initializeMutationRate(const std:: // check values for (int value_index = 0; value_index < end_count; ++value_index) { - double mutation_rate = rates_value->FloatAtIndex(value_index, nullptr); - slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(value_index, nullptr)); + double mutation_rate = rates_value->NumericAtIndex_NOCAST(value_index, nullptr); + slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(value_index, nullptr)); if (value_index > 0) - if (mutation_end_position <= ends_value->IntAtIndex(value_index - 1, nullptr)) + if (mutation_end_position <= ends_value->IntAtIndex_NOCAST(value_index - 1, nullptr)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeMutationRate): initializeMutationRate() requires ends to be in strictly ascending order." << EidosTerminate(); if ((mutation_rate < 0.0) || (mutation_rate >= 1.0) || !std::isfinite(mutation_rate)) // intentionally no upper bound @@ -896,8 +896,8 @@ EidosValue_SP Species::ExecuteContextFunction_initializeMutationRate(const std:: for (int interval_index = 0; interval_index < end_count; ++interval_index) { - double mutation_rate = rates_value->FloatAtIndex(interval_index, nullptr); - slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex(interval_index, nullptr)); + double mutation_rate = rates_value->NumericAtIndex_NOCAST(interval_index, nullptr); + slim_position_t mutation_end_position = SLiMCastToPositionTypeOrRaise(ends_value->IntAtIndex_NOCAST(interval_index, nullptr)); rates.emplace_back(mutation_rate); positions.emplace_back(mutation_end_position); @@ -967,7 +967,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSex(const std::string &p if (num_sex_declarations_ > 0) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeSex): initializeSex() may be called only once." << EidosTerminate(); - std::string chromosome_type = chromosomeType_value->StringAtIndex(0, nullptr); + std::string chromosome_type = chromosomeType_value->StringAtIndex_NOCAST(0, nullptr); if (chromosome_type.compare(gStr_A) == 0) modeled_chromosome_type_ = GenomeType::kAutosome; @@ -1013,7 +1013,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSLiMOptions(const std::s { // [logical$ keepPedigrees = F] - bool keep_pedigrees = arg_keepPedigrees_value->LogicalAtIndex(0, nullptr); + bool keep_pedigrees = arg_keepPedigrees_value->LogicalAtIndex_NOCAST(0, nullptr); if (keep_pedigrees) { @@ -1039,7 +1039,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSLiMOptions(const std::s { // [string$ dimensionality = ""] - std::string space = arg_dimensionality_value->StringAtIndex(0, nullptr); + std::string space = arg_dimensionality_value->StringAtIndex_NOCAST(0, nullptr); if (space.length() != 0) { @@ -1056,7 +1056,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSLiMOptions(const std::s { // [string$ periodicity = ""] - std::string periodicity = arg_periodicity_value->StringAtIndex(0, nullptr); + std::string periodicity = arg_periodicity_value->StringAtIndex_NOCAST(0, nullptr); if (periodicity.length() != 0) { @@ -1087,7 +1087,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSLiMOptions(const std::s { // [integer$ mutationRuns = 0] - int64_t mutrun_count = arg_mutationRuns_value->IntAtIndex(0, nullptr); + int64_t mutrun_count = arg_mutationRuns_value->IntAtIndex_NOCAST(0, nullptr); if (mutrun_count != 0) { @@ -1100,21 +1100,21 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSLiMOptions(const std::s { // [logical$ preventIncidentalSelfing = F] - bool prevent_selfing = arg_preventIncidentalSelfing_value->LogicalAtIndex(0, nullptr); + bool prevent_selfing = arg_preventIncidentalSelfing_value->LogicalAtIndex_NOCAST(0, nullptr); prevent_incidental_selfing_ = prevent_selfing; } { // [logical$ nucleotideBased = F] - bool nucleotide_based = arg_nucleotideBased_value->LogicalAtIndex(0, nullptr); + bool nucleotide_based = arg_nucleotideBased_value->LogicalAtIndex_NOCAST(0, nullptr); nucleotide_based_ = nucleotide_based; } { // [logical$ randomizeCallbacks = T] - bool randomize_callbacks = arg_randomizeCallbacks_value->LogicalAtIndex(0, nullptr); + bool randomize_callbacks = arg_randomizeCallbacks_value->LogicalAtIndex_NOCAST(0, nullptr); shuffle_buf_is_enabled_ = randomize_callbacks; } @@ -1214,23 +1214,23 @@ EidosValue_SP Species::ExecuteContextFunction_initializeSpecies(const std::strin if (num_species_declarations_ > 0) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeSpecies): initializeSpecies() may be called only once per species." << EidosTerminate(); - int64_t tickModulo = arg_tickModulo_value->IntAtIndex(0, nullptr); + int64_t tickModulo = arg_tickModulo_value->IntAtIndex_NOCAST(0, nullptr); if ((tickModulo < 1) || (tickModulo >= SLIM_MAX_TICK)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeSpecies): initializeSpecies() requires a tickModulo value >= 1." << EidosTerminate(); tick_modulo_ = (slim_tick_t)tickModulo; - int64_t tickPhase = arg_tickPhase_value->IntAtIndex(0, nullptr); + int64_t tickPhase = arg_tickPhase_value->IntAtIndex_NOCAST(0, nullptr); if ((tickPhase < 1) || (tickModulo >= SLIM_MAX_TICK)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeSpecies): initializeSpecies() requires a tickPhase value >= 1." << EidosTerminate(); tick_phase_ = (slim_tick_t)tickPhase; - avatar_ = arg_avatar_value->StringAtIndex(0, nullptr); + avatar_ = arg_avatar_value->StringAtIndex_NOCAST(0, nullptr); - color_ = arg_color_value->StringAtIndex(0, nullptr); + color_ = arg_color_value->StringAtIndex_NOCAST(0, nullptr); if (!color_.empty()) Eidos_GetColorComponents(color_, &color_red_, &color_green_, &color_blue_); @@ -1299,10 +1299,10 @@ EidosValue_SP Species::ExecuteContextFunction_initializeTreeSeq(const std::strin // if the code here changes, that method should probably be updated too. recording_tree_ = true; - recording_mutations_ = arg_recordMutations_value->LogicalAtIndex(0, nullptr); - running_coalescence_checks_ = arg_checkCoalescence_value->LogicalAtIndex(0, nullptr); - running_treeseq_crosschecks_ = arg_runCrosschecks_value->LogicalAtIndex(0, nullptr); - retain_coalescent_only_ = arg_retainCoalescentOnly_value->LogicalAtIndex(0, nullptr); + recording_mutations_ = arg_recordMutations_value->LogicalAtIndex_NOCAST(0, nullptr); + running_coalescence_checks_ = arg_checkCoalescence_value->LogicalAtIndex_NOCAST(0, nullptr); + running_treeseq_crosschecks_ = arg_runCrosschecks_value->LogicalAtIndex_NOCAST(0, nullptr); + retain_coalescent_only_ = arg_retainCoalescentOnly_value->LogicalAtIndex_NOCAST(0, nullptr); treeseq_crosschecks_interval_ = 1; // this interval is presently not exposed in the Eidos API if ((arg_simplificationRatio_value->Type() == EidosValueType::kValueNULL) && (arg_simplificationInterval_value->Type() == EidosValueType::kValueNULL)) @@ -1315,7 +1315,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeTreeSeq(const std::strin else if (arg_simplificationRatio_value->Type() != EidosValueType::kValueNULL) { // The ratio is non-NULL; using the specified ratio - simplification_ratio_ = arg_simplificationRatio_value->FloatAtIndex(0, nullptr); + simplification_ratio_ = arg_simplificationRatio_value->NumericAtIndex_NOCAST(0, nullptr); simplification_interval_ = -1; if (std::isnan(simplification_ratio_) || (simplification_ratio_ < 0)) @@ -1325,7 +1325,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeTreeSeq(const std::strin if (arg_simplificationInterval_value->Type() != EidosValueType::kValueNULL) { // Both ratio and interval are non-NULL; the interval is thus interpreted as the *initial* interval - simplify_interval_ = arg_simplificationInterval_value->IntAtIndex(0, nullptr); + simplify_interval_ = arg_simplificationInterval_value->IntAtIndex_NOCAST(0, nullptr); if (simplify_interval_ <= 0) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeTreeSeq): initializeTreeSeq() requires simplificationInterval to be > 0." << EidosTerminate(); @@ -1343,7 +1343,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeTreeSeq(const std::strin { // The ratio is NULL, interval is not; using the specified interval simplification_ratio_ = 0.0; - simplification_interval_ = arg_simplificationInterval_value->IntAtIndex(0, nullptr); + simplification_interval_ = arg_simplificationInterval_value->IntAtIndex_NOCAST(0, nullptr); if (simplification_interval_ <= 0) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeTreeSeq): initializeTreeSeq() requires simplificationInterval to be > 0." << EidosTerminate(); @@ -1365,7 +1365,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeTreeSeq(const std::strin } else { - community_.treeseq_time_unit_ = arg_timeUnit_value->StringAtIndex(0, nullptr); + community_.treeseq_time_unit_ = arg_timeUnit_value->StringAtIndex_NOCAST(0, nullptr); if ((community_.treeseq_time_unit_.length() == 0) || (community_.treeseq_time_unit_.find('"') != std::string::npos) || (community_.treeseq_time_unit_.find('\'') != std::string::npos)) EIDOS_TERMINATION << "ERROR (Species::ExecuteContextFunction_initializeTreeSeq): initializeTreeSeq() requires the timeUnit to be non-zero length, and it may not contain a quote character." << EidosTerminate(); @@ -1394,7 +1394,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeTreeSeq(const std::strin if (arg_simplificationInterval_value->Type() != EidosValueType::kValueNULL) { if (previous_params) output_stream << ", "; - output_stream << "simplificationInterval = " << arg_simplificationInterval_value->IntAtIndex(0, nullptr); + output_stream << "simplificationInterval = " << arg_simplificationInterval_value->IntAtIndex_NOCAST(0, nullptr); previous_params = true; } @@ -1651,7 +1651,7 @@ void Species::SetProperty(EidosGlobalStringID p_property_id, const EidosValue &p { case gID_description: { - std::string description = p_value.StringAtIndex(0, nullptr); + std::string description = p_value.StringAtIndex_NOCAST(0, nullptr); // there are no restrictions on descriptions at all @@ -1660,7 +1660,7 @@ void Species::SetProperty(EidosGlobalStringID p_property_id, const EidosValue &p } case gID_cycle: { - int64_t value = p_value.IntAtIndex(0, nullptr); + int64_t value = p_value.IntAtIndex_NOCAST(0, nullptr); slim_tick_t old_cycle = cycle_; slim_tick_t new_cycle = SLiMCastToTickTypeOrRaise(value); @@ -1671,7 +1671,7 @@ void Species::SetProperty(EidosGlobalStringID p_property_id, const EidosValue &p case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; @@ -1741,14 +1741,14 @@ EidosValue_SP Species::ExecuteMethod_addSubpop(EidosGlobalStringID p_method_id, EidosValue *haploid_value = p_arguments[3].get(); slim_objectid_t subpop_id = SLiM_ExtractObjectIDFromEidosValue_is(subpopID_value, 0, 'p'); - slim_popsize_t subpop_size = SLiMCastToPopsizeTypeOrRaise(size_value->IntAtIndex(0, nullptr)); + slim_popsize_t subpop_size = SLiMCastToPopsizeTypeOrRaise(size_value->IntAtIndex_NOCAST(0, nullptr)); - double sex_ratio = sexRatio_value->FloatAtIndex(0, nullptr); + double sex_ratio = sexRatio_value->FloatAtIndex_NOCAST(0, nullptr); if ((sex_ratio != 0.5) && !sex_enabled_) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_addSubpop): addSubpop() sex ratio supplied in non-sexual simulation." << EidosTerminate(); - bool haploid = haploid_value->LogicalAtIndex(0, nullptr); + bool haploid = haploid_value->LogicalAtIndex_NOCAST(0, nullptr); if (haploid) { @@ -1796,10 +1796,10 @@ EidosValue_SP Species::ExecuteMethod_addSubpopSplit(EidosGlobalStringID p_method EidosValue *sexRatio_value = p_arguments[3].get(); slim_objectid_t subpop_id = SLiM_ExtractObjectIDFromEidosValue_is(subpopID_value, 0, 'p'); - slim_popsize_t subpop_size = SLiMCastToPopsizeTypeOrRaise(size_value->IntAtIndex(0, nullptr)); + slim_popsize_t subpop_size = SLiMCastToPopsizeTypeOrRaise(size_value->IntAtIndex_NOCAST(0, nullptr)); Subpopulation *source_subpop = SLiM_ExtractSubpopulationFromEidosValue_io(sourceSubpop_value, 0, &community_, this, "addSubpopSplit()"); // SPECIES CONSISTENCY CHECK - double sex_ratio = sexRatio_value->FloatAtIndex(0, nullptr); + double sex_ratio = sexRatio_value->FloatAtIndex_NOCAST(0, nullptr); if ((sex_ratio != 0.5) && !sex_enabled_) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_addSubpopSplit): addSubpopSplit() sex ratio supplied in non-sexual simulation." << EidosTerminate(); @@ -1859,7 +1859,7 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin if (pedigreeIDs_count == 1) { // Singleton case, to allow efficiency in the non-singleton case - slim_pedigreeid_t pedigree_id = pedigreeIDs_value->IntAtIndex(0, nullptr); + slim_pedigreeid_t pedigree_id = pedigreeIDs_value->IntAtIndex_NOCAST(0, nullptr); for (Subpopulation *subpop : subpops_to_search) { @@ -2027,7 +2027,7 @@ EidosValue_SP Species::ExecuteMethod_killIndividuals(EidosGlobalStringID p_metho // free the objects now, so we move them to a temporary "graveyard" which we dispose of between tick cycle stages for (int individual_index = 0; individual_index < individuals_count; ++individual_index) { - Individual *doomed = (Individual *)individuals_value->ObjectElementAtIndex(individual_index, nullptr); + Individual *doomed = (Individual *)individuals_value->ObjectElementAtIndex_NOCAST(individual_index, nullptr); slim_popsize_t source_subpop_index = doomed->index_; if (source_subpop_index < 0) @@ -2384,8 +2384,8 @@ EidosValue_SP Species::ExecuteMethod_outputFixedMutations(EidosGlobalStringID p_ if (filePath_value->Type() != EidosValueType::kValueNULL) { - outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex(0, nullptr)); - bool append = append_value->LogicalAtIndex(0, nullptr); + outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex_NOCAST(0, nullptr)); + bool append = append_value->LogicalAtIndex_NOCAST(0, nullptr); outfile.open(outfile_path.c_str(), append ? (std::ios_base::app | std::ios_base::out) : std::ios_base::out); has_file = true; @@ -2467,11 +2467,11 @@ EidosValue_SP Species::ExecuteMethod_outputFull(EidosGlobalStringID p_method_id, } } - bool use_binary = binary_value->LogicalAtIndex(0, nullptr); - bool output_spatial_positions = spatialPositions_value->LogicalAtIndex(0, nullptr); - bool output_ages = ages_value->LogicalAtIndex(0, nullptr); - bool output_ancestral_nucs = ancestralNucleotides_value->LogicalAtIndex(0, nullptr); - bool output_pedigree_ids = pedigreeIDs_value->LogicalAtIndex(0, nullptr); + bool use_binary = binary_value->LogicalAtIndex_NOCAST(0, nullptr); + bool output_spatial_positions = spatialPositions_value->LogicalAtIndex_NOCAST(0, nullptr); + bool output_ages = ages_value->LogicalAtIndex_NOCAST(0, nullptr); + bool output_ancestral_nucs = ancestralNucleotides_value->LogicalAtIndex_NOCAST(0, nullptr); + bool output_pedigree_ids = pedigreeIDs_value->LogicalAtIndex_NOCAST(0, nullptr); if (output_pedigree_ids && !PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_outputFull): outputFull() cannot output pedigree IDs, because pedigree recording has not been enabled." << EidosTerminate(); @@ -2493,8 +2493,8 @@ EidosValue_SP Species::ExecuteMethod_outputFull(EidosGlobalStringID p_method_id, } else { - std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex(0, nullptr)); - bool append = append_value->LogicalAtIndex(0, nullptr); + std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex_NOCAST(0, nullptr)); + bool append = append_value->LogicalAtIndex_NOCAST(0, nullptr); std::ofstream outfile; if (use_binary && append) @@ -2564,8 +2564,8 @@ EidosValue_SP Species::ExecuteMethod_outputMutations(EidosGlobalStringID p_metho if (filePath_value->Type() != EidosValueType::kValueNULL) { - std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex(0, nullptr)); - bool append = append_value->LogicalAtIndex(0, nullptr); + std::string outfile_path = Eidos_ResolvedPath(filePath_value->StringAtIndex_NOCAST(0, nullptr)); + bool append = append_value->LogicalAtIndex_NOCAST(0, nullptr); outfile.open(outfile_path.c_str(), append ? (std::ios_base::app | std::ios_base::out) : std::ios_base::out); has_file = true; @@ -2604,7 +2604,7 @@ EidosValue_SP Species::ExecuteMethod_outputMutations(EidosGlobalStringID p_metho for (int mut_index = 0; mut_index < mutations_count; mut_index++) { - Mutation *mut = (Mutation *)(mutations_object->ObjectElementAtIndex(mut_index, nullptr)); + Mutation *mut = (Mutation *)(mutations_object->ObjectElementAtIndex_NOCAST(mut_index, nullptr)); mut->scratch_ = 1; } @@ -2693,7 +2693,7 @@ EidosValue_SP Species::ExecuteMethod_readFromPopulationFile(EidosGlobalStringID } EidosValue *filePath_value = p_arguments[0].get(); - std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex(0, nullptr))); + std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex_NOCAST(0, nullptr))); EidosValue *subpopMap_value = p_arguments[1].get(); SUBPOP_REMAP_HASH subpopRemap; @@ -2702,7 +2702,7 @@ EidosValue_SP Species::ExecuteMethod_readFromPopulationFile(EidosGlobalStringID { // This is not type-checked by Eidos, because we would have to declare the parameter as being of type "DictionaryBase", // which is an implementation detail that we try to hide. So we just declare it as No$ and type-check it here. - EidosObject *subpopMap_element = subpopMap_value->ObjectElementAtIndex(0, nullptr); + EidosObject *subpopMap_element = subpopMap_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (!subpopMap_element->IsKindOfClass(gEidosDictionaryUnretained_Class)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_readFromPopulationFile): readFromPopulationFile() requires that subpopMap be a Dictionary or a subclass of Dictionary." << EidosTerminate(); @@ -2726,7 +2726,7 @@ EidosValue_SP Species::ExecuteMethod_readFromPopulationFile(EidosGlobalStringID if ((table_id_value->Type() != EidosValueType::kValueInt) || (table_id_value->Count() != 1)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_readFromPopulationFile): subpopMap values must be singleton integers." << EidosTerminate(); - int64_t table_id = table_id_value->IntAtIndex(0, nullptr); + int64_t table_id = table_id_value->IntAtIndex_NOCAST(0, nullptr); if ((table_id < 0) || (table_id > SLIM_MAX_ID_VALUE)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_readFromPopulationFile): subpopMap value (" << table_id << ") is out of range." << EidosTerminate(); @@ -2766,7 +2766,7 @@ EidosValue_SP Species::ExecuteMethod_recalculateFitness(EidosGlobalStringID p_me // Trigger a fitness recalculation. This is suggested after making a change that would modify fitness values, such as altering // a selection coefficient or dominance coefficient, changing the mutation type for a mutation, etc. It will have the side // effect of calling mutationEffect() callbacks, so this is quite a heavyweight operation. - slim_tick_t tick = (tick_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(tick_value->IntAtIndex(0, nullptr)) : community_.Tick(); + slim_tick_t tick = (tick_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(tick_value->IntAtIndex_NOCAST(0, nullptr)) : community_.Tick(); population_.RecalculateFitness(tick); @@ -2788,16 +2788,16 @@ EidosValue_SP Species::ExecuteMethod_registerFitnessEffectCallback(EidosGlobalSt EidosValue *end_value = p_arguments[4].get(); slim_objectid_t script_id = -1; // used if id_value is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); slim_objectid_t subpop_id = -1; // used if subpop_value is NULL, to indicate applicability to all subpops - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); if (subpop_value->Type() != EidosValueType::kValueNULL) - subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex(0, nullptr))->subpopulation_id_; + subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_id_; if (start_tick > end_tick) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_registerFitnessEffectCallback): registerFitnessEffectCallback() requires start <= end." << EidosTerminate(); @@ -2837,16 +2837,16 @@ EidosValue_SP Species::ExecuteMethod_registerMateModifyRecSurvCallback(EidosGlob EidosValue *end_value = p_arguments[4].get(); slim_objectid_t script_id = -1; // used if the id is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); slim_objectid_t subpop_id = -1; - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); if (subpop_value->Type() != EidosValueType::kValueNULL) - subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex(0, nullptr))->subpopulation_id_; + subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_id_; if (start_tick > end_tick) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_registerMateModifyRecSurvCallback): " << EidosStringRegistry::StringForGlobalStringID(p_method_id) << "() requires start <= end." << EidosTerminate(); @@ -2885,20 +2885,20 @@ EidosValue_SP Species::ExecuteMethod_registerMutationCallback(EidosGlobalStringI EidosValue *end_value = p_arguments[5].get(); slim_objectid_t script_id = -1; // used if id_value is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); slim_objectid_t mut_type_id = -1; // used if mutType_value is NULL, to indicate applicability to all mutation types slim_objectid_t subpop_id = -1; // used if subpop_value is NULL, to indicate applicability to all subpops - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); if (mutType_value->Type() != EidosValueType::kValueNULL) - mut_type_id = (mutType_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(mutType_value->IntAtIndex(0, nullptr)) : ((MutationType *)mutType_value->ObjectElementAtIndex(0, nullptr))->mutation_type_id_; + mut_type_id = (mutType_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(mutType_value->IntAtIndex_NOCAST(0, nullptr)) : ((MutationType *)mutType_value->ObjectElementAtIndex_NOCAST(0, nullptr))->mutation_type_id_; if (subpop_value->Type() != EidosValueType::kValueNULL) - subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex(0, nullptr))->subpopulation_id_; + subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_id_; if (start_tick > end_tick) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_registerMutationCallback): registerMutationCallback() requires start <= end." << EidosTerminate(); @@ -2929,19 +2929,19 @@ EidosValue_SP Species::ExecuteMethod_registerMutationEffectCallback(EidosGlobalS EidosValue *end_value = p_arguments[5].get(); slim_objectid_t script_id = -1; // used if id_value is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); slim_objectid_t mut_type_id = -1; slim_objectid_t subpop_id = -1; // used if subpop_value is NULL, to indicate applicability to all subpops - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); - mut_type_id = (mutType_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(mutType_value->IntAtIndex(0, nullptr)) : ((MutationType *)mutType_value->ObjectElementAtIndex(0, nullptr))->mutation_type_id_; + mut_type_id = (mutType_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(mutType_value->IntAtIndex_NOCAST(0, nullptr)) : ((MutationType *)mutType_value->ObjectElementAtIndex_NOCAST(0, nullptr))->mutation_type_id_; if (subpop_value->Type() != EidosValueType::kValueNULL) - subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex(0, nullptr))->subpopulation_id_; + subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_id_; if (start_tick > end_tick) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_registerMutationEffectCallback): registerMutationEffectCallback() requires start <= end." << EidosTerminate(); @@ -2976,21 +2976,21 @@ EidosValue_SP Species::ExecuteMethod_registerReproductionCallback(EidosGlobalStr EidosValue *end_value = p_arguments[5].get(); slim_objectid_t script_id = -1; // used if the id is NULL, to indicate an anonymous block - std::string script_string = source_value->StringAtIndex(0, nullptr); + std::string script_string = source_value->StringAtIndex_NOCAST(0, nullptr); slim_objectid_t subpop_id = -1; IndividualSex sex_specificity = IndividualSex::kUnspecified; - slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex(0, nullptr)) : 1); - slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex(0, nullptr)) : SLIM_MAX_TICK + 1); + slim_tick_t start_tick = ((start_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(start_value->IntAtIndex_NOCAST(0, nullptr)) : 1); + slim_tick_t end_tick = ((end_value->Type() != EidosValueType::kValueNULL) ? SLiMCastToTickTypeOrRaise(end_value->IntAtIndex_NOCAST(0, nullptr)) : SLIM_MAX_TICK + 1); if (id_value->Type() != EidosValueType::kValueNULL) script_id = SLiM_ExtractObjectIDFromEidosValue_is(id_value, 0, 's'); if (subpop_value->Type() != EidosValueType::kValueNULL) - subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex(0, nullptr))->subpopulation_id_; + subpop_id = (subpop_value->Type() == EidosValueType::kValueInt) ? SLiMCastToObjectidTypeOrRaise(subpop_value->IntAtIndex_NOCAST(0, nullptr)) : ((Subpopulation *)subpop_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_id_; if (sex_value->Type() != EidosValueType::kValueNULL) { - std::string sex_string = sex_value->StringAtIndex(0, nullptr); + std::string sex_string = sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string == "M") sex_specificity = IndividualSex::kMale; else if (sex_string == "F") sex_specificity = IndividualSex::kFemale; @@ -3076,14 +3076,14 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho EidosValue *id_value = p_arguments[5].get(); // parse our arguments - Mutation *exclude = (exclude_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Mutation *)exclude_value->ObjectElementAtIndex(0, nullptr); + Mutation *exclude = (exclude_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Mutation *)exclude_value->ObjectElementAtIndex_NOCAST(0, nullptr); MutationType *mutation_type_ptr = (mutType_value->Type() == EidosValueType::kValueNULL) ? nullptr : SLiM_ExtractMutationTypeFromEidosValue_io(mutType_value, 0, &community_, this, "subsetMutations()"); // SPECIES CONSISTENCY CHECK - slim_position_t position = (position_value->Type() == EidosValueType::kValueNULL) ? -1 : SLiMCastToPositionTypeOrRaise(position_value->IntAtIndex(0, nullptr)); + slim_position_t position = (position_value->Type() == EidosValueType::kValueNULL) ? -1 : SLiMCastToPositionTypeOrRaise(position_value->IntAtIndex_NOCAST(0, nullptr)); int8_t nucleotide = -1; bool has_tag = !(tag_value->Type() == EidosValueType::kValueNULL); - slim_usertag_t tag = (has_tag ? tag_value->IntAtIndex(0, nullptr) : 0); + slim_usertag_t tag = (has_tag ? tag_value->IntAtIndex_NOCAST(0, nullptr) : 0); bool has_id = !(id_value->Type() == EidosValueType::kValueNULL); - slim_mutationid_t id = (has_id ? id_value->IntAtIndex(0, nullptr) : 0); + slim_mutationid_t id = (has_id ? id_value->IntAtIndex_NOCAST(0, nullptr) : 0); // SPECIES CONSISTENCY CHECK if (exclude && (&exclude->mutation_type_ptr_->species_ != this)) @@ -3091,7 +3091,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho if (nucleotide_value->Type() == EidosValueType::kValueInt) { - int64_t nuc_int = nucleotide_value->IntAtIndex(0, nullptr); + int64_t nuc_int = nucleotide_value->IntAtIndex_NOCAST(0, nullptr); if ((nuc_int < 0) || (nuc_int > 3)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_subsetMutations): subsetMutations() requires integer nucleotide values to be in [0,3]." << EidosTerminate(); @@ -3100,7 +3100,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (nucleotide_value->Type() == EidosValueType::kValueString) { - const std::string &nuc_string = ((EidosValue_String *)nucleotide_value)->StringRefAtIndex(0, nullptr); + const std::string &nuc_string = ((EidosValue_String *)nucleotide_value)->StringRefAtIndex_NOCAST(0, nullptr); if (nuc_string == "A") nucleotide = 0; else if (nuc_string == "C") nucleotide = 1; @@ -3274,7 +3274,7 @@ EidosValue_SP Species::ExecuteMethod_treeSeqRememberIndividuals(EidosGlobalStrin if ((community_.executing_block_type_ == SLiMEidosBlockType::SLiMEidosMateChoiceCallback) || (community_.executing_block_type_ == SLiMEidosBlockType::SLiMEidosModifyChildCallback) || (community_.executing_block_type_ == SLiMEidosBlockType::SLiMEidosRecombinationCallback)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_treeSeqRememberIndividuals): treeSeqRememberIndividuals() may not be called from inside a mateChoice(), modifyChild(), or recombination() callback for the currently executing species." << EidosTerminate(); - bool permanent = permanent_value->LogicalAtIndex(0, nullptr); + bool permanent = permanent_value->LogicalAtIndex_NOCAST(0, nullptr); uint32_t flag = permanent ? SLIM_TSK_INDIVIDUAL_REMEMBERED : SLIM_TSK_INDIVIDUAL_RETAINED; if (ind_count == 0) @@ -3288,7 +3288,7 @@ EidosValue_SP Species::ExecuteMethod_treeSeqRememberIndividuals(EidosGlobalStrin if (ind_count == 1) { - Individual *ind = (Individual *)individuals_value->ObjectElementAtIndex(0, nullptr); + Individual *ind = (Individual *)individuals_value->ObjectElementAtIndex_NOCAST(0, nullptr); AddIndividualsToTable(&ind, 1, &tables_, &tabled_individuals_hash_, flag); } else @@ -3327,18 +3327,18 @@ EidosValue_SP Species::ExecuteMethod_treeSeqOutput(EidosGlobalStringID p_method_ (community_.executing_block_type_ != SLiMEidosBlockType::SLiMEidosEventLate)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_treeSeqOutput): treeSeqOutput() may not be called from inside a callback." << EidosTerminate(); - std::string path_string = path_value->StringAtIndex(0, nullptr); - bool binary = binary_value->LogicalAtIndex(0, nullptr); - bool simplify = simplify_value->LogicalAtIndex(0, nullptr); + std::string path_string = path_value->StringAtIndex_NOCAST(0, nullptr); + bool binary = binary_value->LogicalAtIndex_NOCAST(0, nullptr); + bool simplify = simplify_value->LogicalAtIndex_NOCAST(0, nullptr); EidosDictionaryUnretained *metadata_dict = nullptr; - bool includeModel = includeModel_value->LogicalAtIndex(0, nullptr); + bool includeModel = includeModel_value->LogicalAtIndex_NOCAST(0, nullptr); if (metadata_value->Type() == EidosValueType::kValueObject) { // This is not type-checked by Eidos, because we would have to declare the parameter as being of type "DictionaryBase", // which is an implementation detail that we try to hide. So we just declare it as No$ and type-check it here. // The JSON serialization would raise anyway, I think, but this gives a better error message. - EidosObject *metadata_object = metadata_value->ObjectElementAtIndex(0, nullptr); + EidosObject *metadata_object = metadata_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (!metadata_object->IsKindOfClass(gEidosDictionaryUnretained_Class)) EIDOS_TERMINATION << "ERROR (Species::ExecuteMethod_treeSeqOutput): treeSeqOutput() requires that the metadata parameter be a Dictionary or a subclass of Dictionary." << EidosTerminate(); diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index d202b7d16..3184670b9 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -1153,7 +1153,7 @@ void Subpopulation::UpdateFitness(std::vector &p_mutationEffect if ((result->Type() == EidosValueType::kValueFloat) || (result->Count() == 1)) { - if (result->FloatAtIndex(0, nullptr) == 1.0) + if (result->FloatAtIndex_NOCAST(0, nullptr) == 1.0) { // we have a mutationEffect() callback that is neutral-making, so it could conceivably work; // change our minds but keep checking @@ -1193,7 +1193,7 @@ void Subpopulation::UpdateFitness(std::vector &p_mutationEffect if ((result->Type() == EidosValueType::kValueFloat) && (result->Count() == 1)) { - if (result->FloatAtIndex(0, nullptr) == 1.0) + if (result->FloatAtIndex_NOCAST(0, nullptr) == 1.0) { // the callback returns 1.0, so it makes the mutation types to which it applies become neutral slim_objectid_t mutation_type_id = mutationEffect_callback->mutation_type_id_; @@ -2168,7 +2168,7 @@ double Subpopulation::ApplyMutationEffectCallbacks(MutationIndex p_mutation, int if ((result->Type() != EidosValueType::kValueFloat) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (Subpopulation::ApplyMutationEffectCallbacks): mutationEffect() callbacks must provide a float singleton return value." << EidosTerminate(mutationEffect_callback->identifier_token_); - p_computed_fitness = result->FloatAtIndex(0, nullptr); + p_computed_fitness = result->FloatAtIndex_NOCAST(0, nullptr); // the cached value is owned by the tree, so we do not dispose of it // there is also no script output to handle @@ -2245,7 +2245,7 @@ double Subpopulation::ApplyMutationEffectCallbacks(MutationIndex p_mutation, int if ((result->Type() != EidosValueType::kValueFloat) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (Subpopulation::ApplyMutationEffectCallbacks): mutationEffect() callbacks must provide a float singleton return value." << EidosTerminate(mutationEffect_callback->identifier_token_); - p_computed_fitness = result->FloatAtIndex(0, nullptr); + p_computed_fitness = result->FloatAtIndex_NOCAST(0, nullptr); } catch (...) { @@ -2320,7 +2320,7 @@ double Subpopulation::ApplyFitnessEffectCallbacks(std::vector & if ((result->Type() != EidosValueType::kValueFloat) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (Subpopulation::ApplyFitnessEffectCallbacks): fitnessEffect() callbacks must provide a float singleton return value." << EidosTerminate(fitnessEffect_callback->identifier_token_); - computed_fitness *= result->FloatAtIndex(0, nullptr); + computed_fitness *= result->FloatAtIndex_NOCAST(0, nullptr); // the cached value is owned by the tree, so we do not dispose of it // there is also no script output to handle @@ -2376,7 +2376,7 @@ double Subpopulation::ApplyFitnessEffectCallbacks(std::vector & if ((result->Type() != EidosValueType::kValueFloat) || (result->Count() != 1)) EIDOS_TERMINATION << "ERROR (Subpopulation::ApplyFitnessEffectCallbacks): fitnessEffect() callbacks must provide a float singleton return value." << EidosTerminate(fitnessEffect_callback->identifier_token_); - computed_fitness *= result->FloatAtIndex(0, nullptr); + computed_fitness *= result->FloatAtIndex_NOCAST(0, nullptr); } catch (...) { @@ -3610,7 +3610,7 @@ bool Subpopulation::ApplySurvivalCallbacks(std::vector &p_survi (result->Count() == 1)) { // T or F means change the existing decision to that value - p_surviving = result->LogicalAtIndex(0, nullptr); + p_surviving = result->LogicalAtIndex_NOCAST(0, nullptr); move_destination = nullptr; // cancel a previously made move decision; T/F says "do not move" } else if ((result_type == EidosValueType::kValueObject) && @@ -3621,7 +3621,7 @@ bool Subpopulation::ApplySurvivalCallbacks(std::vector &p_survi // moving to one's current subpopulation is not-moving; it is equivalent to returning T (i.e., forces survival) p_surviving = true; - Subpopulation *destination = (Subpopulation *)result->ObjectElementAtIndex(0, survival_callback->identifier_token_); + Subpopulation *destination = (Subpopulation *)result->ObjectElementAtIndex_NOCAST(0, survival_callback->identifier_token_); if (destination != this) move_destination = destination; } @@ -4246,14 +4246,14 @@ void Subpopulation::SetProperty(EidosGlobalStringID p_property_id, const EidosVa { case gID_tag: // ACCELERATED { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; } case gID_fitnessScaling: // ACCELERATED { - subpop_fitness_scaling_ = p_value.FloatAtIndex(0, nullptr); + subpop_fitness_scaling_ = p_value.FloatAtIndex_NOCAST(0, nullptr); if ((subpop_fitness_scaling_ < 0.0) || std::isnan(subpop_fitness_scaling_)) EIDOS_TERMINATION << "ERROR (Subpopulation::SetProperty): property fitnessScaling must be >= 0.0." << EidosTerminate(); @@ -4262,12 +4262,12 @@ void Subpopulation::SetProperty(EidosGlobalStringID p_property_id, const EidosVa } case gID_name: { - SetName(p_value.StringAtIndex(0, nullptr)); + SetName(p_value.StringAtIndex_NOCAST(0, nullptr)); return; } case gID_description: { - std::string description = p_value.StringAtIndex(0, nullptr); + std::string description = p_value.StringAtIndex_NOCAST(0, nullptr); // there are no restrictions on descriptions at all @@ -4287,7 +4287,7 @@ void Subpopulation::SetProperty_Accelerated_tag(EidosObject **p_values, size_t p // SLiMCastToUsertagTypeOrRaise() is a no-op at present if (p_source_size == 1) { - int64_t source_value = p_source.IntAtIndex(0, nullptr); + int64_t source_value = p_source.IntAtIndex_NOCAST(0, nullptr); for (size_t value_index = 0; value_index < p_values_size; ++value_index) ((Subpopulation *)(p_values[value_index]))->tag_value_ = source_value; @@ -4305,7 +4305,7 @@ void Subpopulation::SetProperty_Accelerated_fitnessScaling(EidosObject **p_value { if (p_source_size == 1) { - double source_value = p_source.FloatAtIndex(0, nullptr); + double source_value = p_source.FloatAtIndex_NOCAST(0, nullptr); if ((source_value < 0.0) || std::isnan(source_value)) EIDOS_TERMINATION << "ERROR (Subpopulation::SetProperty_Accelerated_fitnessScaling): property fitnessScaling must be >= 0.0." << EidosTerminate(); @@ -4392,7 +4392,7 @@ IndividualSex Subpopulation::_GenomeConfigurationForSex(EidosValue *p_sex_value, else if (sex_value_type == EidosValueType::kValueString) { // if a string is provided, it must be either "M" or "F" - std::string sex_string = p_sex_value->StringAtIndex(0, nullptr); + std::string sex_string = p_sex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string == "M") sex = IndividualSex::kMale; @@ -4403,7 +4403,7 @@ IndividualSex Subpopulation::_GenomeConfigurationForSex(EidosValue *p_sex_value, } else // if (sex_value_type == EidosValueType::kValueFloat) { - double sex_prob = p_sex_value->FloatAtIndex(0, nullptr); + double sex_prob = p_sex_value->FloatAtIndex_NOCAST(0, nullptr); if ((sex_prob >= 0.0) && (sex_prob <= 1.0)) { @@ -4468,7 +4468,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCloned(EidosGlobalStringID p_metho // Get and check the first parent (the mother) EidosValue *parent_value = p_arguments[0].get(); - Individual *parent = (Individual *)parent_value->ObjectElementAtIndex(0, nullptr); + Individual *parent = (Individual *)parent_value->ObjectElementAtIndex_NOCAST(0, nullptr); IndividualSex parent_sex = parent->sex_; Subpopulation &parent_subpop = *parent->subpopulation_; @@ -4482,7 +4482,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCloned(EidosGlobalStringID p_metho // Check the count and short-circuit if it is zero EidosValue *count_value = p_arguments[1].get(); - int64_t child_count = count_value->IntAtIndex(0, nullptr); + int64_t child_count = count_value->IntAtIndex_NOCAST(0, nullptr); if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCloned): addCloned() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); @@ -4514,7 +4514,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCloned(EidosGlobalStringID p_metho bool pedigrees_enabled = species_.PedigreesEnabled(); EidosValue *defer_value = p_arguments[2].get(); - bool defer = defer_value->LogicalAtIndex(0, nullptr); + bool defer = defer_value->LogicalAtIndex_NOCAST(0, nullptr); if (defer && parent_mutation_callbacks) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCloned): deferred reproduction cannot be used when mutation() callbacks are enabled." << EidosTerminate(); @@ -4603,7 +4603,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCrossed(EidosGlobalStringID p_meth // Get and check the first parent (the mother) EidosValue *parent1_value = p_arguments[0].get(); - Individual *parent1 = (Individual *)parent1_value->ObjectElementAtIndex(0, nullptr); + Individual *parent1 = (Individual *)parent1_value->ObjectElementAtIndex_NOCAST(0, nullptr); IndividualSex parent1_sex = parent1->sex_; Subpopulation &parent1_subpop = *parent1->subpopulation_; @@ -4612,7 +4612,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCrossed(EidosGlobalStringID p_meth // Get and check the second parent (the father) EidosValue *parent2_value = p_arguments[1].get(); - Individual *parent2 = (Individual *)parent2_value->ObjectElementAtIndex(0, nullptr); + Individual *parent2 = (Individual *)parent2_value->ObjectElementAtIndex_NOCAST(0, nullptr); IndividualSex parent2_sex = parent2->sex_; Subpopulation &parent2_subpop = *parent2->subpopulation_; @@ -4632,7 +4632,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCrossed(EidosGlobalStringID p_meth // Check the count and short-circuit if it is zero EidosValue *count_value = p_arguments[3].get(); - int64_t child_count = count_value->IntAtIndex(0, nullptr); + int64_t child_count = count_value->IntAtIndex_NOCAST(0, nullptr); if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCrossed): addCrossed() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); @@ -4661,7 +4661,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCrossed(EidosGlobalStringID p_meth bool pedigrees_enabled = species_.PedigreesEnabled(); EidosValue *defer_value = p_arguments[4].get(); - bool defer = defer_value->LogicalAtIndex(0, nullptr); + bool defer = defer_value->LogicalAtIndex_NOCAST(0, nullptr); if (defer && (parent1_recombination_callbacks || parent2_recombination_callbacks || parent1_mutation_callbacks || parent2_mutation_callbacks)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCrossed): deferred reproduction cannot be used when recombination() or mutation() callbacks are enabled." << EidosTerminate(); @@ -4765,7 +4765,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addEmpty(EidosGlobalStringID p_method // Check the count and short-circuit if it is zero EidosValue *count_value = p_arguments[3].get(); - int64_t child_count = count_value->IntAtIndex(0, nullptr); + int64_t child_count = count_value->IntAtIndex_NOCAST(0, nullptr); if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addEmpty): addEmpty() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); @@ -4795,15 +4795,15 @@ EidosValue_SP Subpopulation::ExecuteMethod_addEmpty(EidosGlobalStringID p_method genome2_null = true; has_null_genomes_ = true; - if (((genome1Null_value->Type() != EidosValueType::kValueNULL) && !genome1Null_value->LogicalAtIndex(0, nullptr)) || - ((genome2Null_value->Type() != EidosValueType::kValueNULL) && !genome2Null_value->LogicalAtIndex(0, nullptr))) + if (((genome1Null_value->Type() != EidosValueType::kValueNULL) && !genome1Null_value->LogicalAtIndex_NOCAST(0, nullptr)) || + ((genome2Null_value->Type() != EidosValueType::kValueNULL) && !genome2Null_value->LogicalAtIndex_NOCAST(0, nullptr))) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addEmpty): in a no-genetics species, null genomes are required." << EidosTerminate(); } else { if (genome1Null_value->Type() != EidosValueType::kValueNULL) { - bool requestedNull = genome1Null_value->LogicalAtIndex(0, nullptr); + bool requestedNull = genome1Null_value->LogicalAtIndex_NOCAST(0, nullptr); if ((requestedNull != genome1_null) && sex_enabled_ && (modeled_chromosome_type_ != GenomeType::kAutosome)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addEmpty): when simulating sex chromosomes, which genomes are null is dictated by sex and cannot be changed." << EidosTerminate(); @@ -4813,7 +4813,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addEmpty(EidosGlobalStringID p_method if (genome2Null_value->Type() != EidosValueType::kValueNULL) { - bool requestedNull = genome2Null_value->LogicalAtIndex(0, nullptr); + bool requestedNull = genome2Null_value->LogicalAtIndex_NOCAST(0, nullptr); if ((requestedNull != genome2_null) && sex_enabled_ && (modeled_chromosome_type_ != GenomeType::kAutosome)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addEmpty): when simulating sex chromosomes, which genomes are null is dictated by sex and cannot be changed." << EidosTerminate(); @@ -4921,7 +4921,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ // Check the count and short-circuit if it is zero EidosValue *count_value = p_arguments[10].get(); - int64_t child_count = count_value->IntAtIndex(0, nullptr); + int64_t child_count = count_value->IntAtIndex_NOCAST(0, nullptr); if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addRecombinant): addRecombinant() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); @@ -4949,10 +4949,10 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ EidosValue *sex_value = p_arguments[6].get(); // Get the genomes for the supplied strands, or nullptr for NULL - Genome *strand1 = ((strand1_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand1_value->ObjectElementAtIndex(0, nullptr)); - Genome *strand2 = ((strand2_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand2_value->ObjectElementAtIndex(0, nullptr)); - Genome *strand3 = ((strand3_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand3_value->ObjectElementAtIndex(0, nullptr)); - Genome *strand4 = ((strand4_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand4_value->ObjectElementAtIndex(0, nullptr)); + Genome *strand1 = ((strand1_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand1_value->ObjectElementAtIndex_NOCAST(0, nullptr)); + Genome *strand2 = ((strand2_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand2_value->ObjectElementAtIndex_NOCAST(0, nullptr)); + Genome *strand3 = ((strand3_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand3_value->ObjectElementAtIndex_NOCAST(0, nullptr)); + Genome *strand4 = ((strand4_value->Type() == EidosValueType::kValueNULL) ? nullptr : (Genome *)strand4_value->ObjectElementAtIndex_NOCAST(0, nullptr)); // The parental strands must be visible in the subpopulation, and we need to be able to find them to check their sex Individual *strand1_parent = (strand1 ? strand1->individual_ : nullptr); @@ -5022,9 +5022,9 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ EidosValue *parent2_value = p_arguments[8].get(); if (parent1_value->Type() != EidosValueType::kValueNULL) - pedigree_parent1 = (Individual *)parent1_value->ObjectElementAtIndex(0, nullptr); + pedigree_parent1 = (Individual *)parent1_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (parent2_value->Type() != EidosValueType::kValueNULL) - pedigree_parent2 = (Individual *)parent2_value->ObjectElementAtIndex(0, nullptr); + pedigree_parent2 = (Individual *)parent2_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (pedigree_parent1 && !pedigree_parent2) pedigree_parent2 = pedigree_parent1; @@ -5041,10 +5041,10 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ mutation_callbacks = nullptr; EidosValue *randomizeStrands_value = p_arguments[9].get(); - bool randomizeStrands = randomizeStrands_value->LogicalAtIndex(0, nullptr); + bool randomizeStrands = randomizeStrands_value->LogicalAtIndex_NOCAST(0, nullptr); EidosValue *defer_value = p_arguments[11].get(); - bool defer = defer_value->LogicalAtIndex(0, nullptr); + bool defer = defer_value->LogicalAtIndex_NOCAST(0, nullptr); if (defer && mutation_callbacks) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addRecombinant): deferred reproduction cannot be used when mutation() callbacks are enabled." << EidosTerminate(); @@ -5134,7 +5134,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ if (breaks1count) { for (int break_index = 0; break_index < breaks1count; ++break_index) - breakvec1.emplace_back(SLiMCastToPositionTypeOrRaise(breaks1_value->IntAtIndex(break_index, nullptr))); + breakvec1.emplace_back(SLiMCastToPositionTypeOrRaise(breaks1_value->IntAtIndex_NOCAST(break_index, nullptr))); std::sort(breakvec1.begin(), breakvec1.end()); breakvec1.erase(unique(breakvec1.begin(), breakvec1.end()), breakvec1.end()); @@ -5155,7 +5155,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ if (breaks2count) { for (int break_index = 0; break_index < breaks2count; ++break_index) - breakvec2.emplace_back(SLiMCastToPositionTypeOrRaise(breaks2_value->IntAtIndex(break_index, nullptr))); + breakvec2.emplace_back(SLiMCastToPositionTypeOrRaise(breaks2_value->IntAtIndex_NOCAST(break_index, nullptr))); std::sort(breakvec2.begin(), breakvec2.end()); breakvec2.erase(unique(breakvec2.begin(), breakvec2.end()), breakvec2.end()); @@ -5491,7 +5491,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addSelfed(EidosGlobalStringID p_metho // Get and check the first parent (the mother) EidosValue *parent_value = p_arguments[0].get(); - Individual *parent = (Individual *)parent_value->ObjectElementAtIndex(0, nullptr); + Individual *parent = (Individual *)parent_value->ObjectElementAtIndex_NOCAST(0, nullptr); IndividualSex parent_sex = parent->sex_; Subpopulation &parent_subpop = *parent->subpopulation_; @@ -5508,7 +5508,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addSelfed(EidosGlobalStringID p_metho // Check the count and short-circuit if it is zero EidosValue *count_value = p_arguments[1].get(); - int64_t child_count = count_value->IntAtIndex(0, nullptr); + int64_t child_count = count_value->IntAtIndex_NOCAST(0, nullptr); if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addSelfed): addSelfed() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); @@ -5549,7 +5549,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addSelfed(EidosGlobalStringID p_metho bool pedigrees_enabled = species_.PedigreesEnabled(); EidosValue *defer_value = p_arguments[2].get(); - bool defer = defer_value->LogicalAtIndex(0, nullptr); + bool defer = defer_value->LogicalAtIndex_NOCAST(0, nullptr); if (defer && (parent_recombination_callbacks || parent_mutation_callbacks)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addSelfed): deferred reproduction cannot be used when recombination() or mutation() callbacks are enabled." << EidosTerminate(); @@ -5647,7 +5647,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_takeMigrants(EidosGlobalStringID p_me // Loop over the migrants and move them one by one for (int migrant_index = 0; migrant_index < migrant_count; ++migrant_index) { - Individual *migrant = (Individual *)migrants_value->ObjectElementAtIndex(migrant_index, nullptr); + Individual *migrant = (Individual *)migrants_value->ObjectElementAtIndex_NOCAST(migrant_index, nullptr); Subpopulation *source_subpop = migrant->subpopulation_; if (source_subpop != this) @@ -5821,7 +5821,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_setMigrationRates(EidosGlobalStringID if (std::find(subpops_seen.begin(), subpops_seen.end(), source_subpop_id) != subpops_seen.end()) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setMigrationRates): setMigrationRates() two rates set for subpopulation p" << source_subpop_id << "." << EidosTerminate(); - double migrant_fraction = rates_value->FloatAtIndex(value_index, nullptr); + double migrant_fraction = rates_value->NumericAtIndex_NOCAST(value_index, nullptr); population_.SetMigration(*this, source_subpop_id, migrant_fraction); subpops_seen.emplace_back(source_subpop_id); @@ -5842,7 +5842,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointDeviated(EidosGlobalStringID p_m EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_pointDeviated): pointDeviated() cannot be called in non-spatial simulations." << EidosTerminate(); EidosValue *n_value = p_arguments[0].get(); - int64_t n = n_value->IntAtIndex(0, nullptr); + int64_t n = n_value->IntAtIndex_NOCAST(0, nullptr); if (n < 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_pointDeviated): pointDeviated() requires n >= 0." << EidosTerminate(); @@ -5868,7 +5868,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointDeviated(EidosGlobalStringID p_m EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_pointDeviated): pointDeviated() requires point to be contain either a single spatial point (to be deviated n times) or n spatial points (each to be deviated once)." << EidosTerminate(); EidosValue_String *boundary_value = (EidosValue_String *)p_arguments[2].get(); - const std::string &boundary_str = boundary_value->StringRefAtIndex(0, nullptr); + const std::string &boundary_str = boundary_value->StringRefAtIndex_NOCAST(0, nullptr); BoundaryCondition boundary; if (boundary_str.compare("none") == 0) @@ -5898,7 +5898,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointDeviated(EidosGlobalStringID p_m } EidosValue *maxDistance_value = p_arguments[3].get(); - double max_distance = maxDistance_value->FloatAtIndex(0, nullptr); + double max_distance = maxDistance_value->NumericAtIndex_NOCAST(0, nullptr); SpatialKernel kernel(dimensionality, max_distance, p_arguments, 4, /* p_expect_max_density */ false); // uses our arguments starting at index 3 @@ -6212,7 +6212,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointInBounds(EidosGlobalStringID p_m if ((point_count == 1) && (dimensionality == 1)) { // singleton case, get it out of the way - double x = point_value->FloatAtIndex(0, nullptr); + double x = point_value->FloatAtIndex_NOCAST(0, nullptr); return ((x >= bounds_x0_) && (x <= bounds_x1_)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF; } @@ -6333,7 +6333,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointReflected(EidosGlobalStringID p_ if ((point_count == 1) && (dimensionality == 1)) { // Handle the singleton separately, so we can handle the non-singleton case more quickly - double x = point_value->FloatAtIndex(0, nullptr); + double x = point_value->FloatAtIndex_NOCAST(0, nullptr); while (true) { @@ -6466,7 +6466,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointStopped(EidosGlobalStringID p_me if ((point_count == 1) && (dimensionality == 1)) { // Handle the singleton separately, so we can handle the non-singleton case more quickly - double x = point_value->FloatAtIndex(0, nullptr); + double x = point_value->FloatAtIndex_NOCAST(0, nullptr); return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::max(bounds_x0_, std::min(bounds_x1_, x)))); } @@ -6564,7 +6564,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointPeriodic(EidosGlobalStringID p_m if ((point_count == 1) && (dimensionality == 1)) { // Handle the singleton separately, so we can handle the non-singleton case more quickly - double x = point_value->FloatAtIndex(0, nullptr); + double x = point_value->FloatAtIndex_NOCAST(0, nullptr); if (periodic_x) { @@ -6684,7 +6684,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointUniform(EidosGlobalStringID p_me EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_pointUniform): pointUniform() cannot be called in non-spatial simulations." << EidosTerminate(); EidosValue *n_value = p_arguments[0].get(); - int64_t point_count = n_value->IntAtIndex(0, nullptr); + int64_t point_count = n_value->IntAtIndex_NOCAST(0, nullptr); if (point_count < 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_pointUniform): pointUniform() requires n >= 0." << EidosTerminate(); @@ -6778,8 +6778,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_setCloningRate(EidosGlobalStringID p_ if ((value_count < 1) || (value_count > 2)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setCloningRate): setCloningRate() requires a rate vector containing either one or two values, in sexual simulations." << EidosTerminate(); - double female_cloning_fraction = rate_value->FloatAtIndex(0, nullptr); - double male_cloning_fraction = (value_count == 2) ? rate_value->FloatAtIndex(1, nullptr) : female_cloning_fraction; + double female_cloning_fraction = rate_value->NumericAtIndex_NOCAST(0, nullptr); + double male_cloning_fraction = (value_count == 2) ? rate_value->NumericAtIndex_NOCAST(1, nullptr) : female_cloning_fraction; if ((female_cloning_fraction < 0.0) || (female_cloning_fraction > 1.0) || std::isnan(female_cloning_fraction)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setCloningRate): setCloningRate() requires cloning fractions within [0,1] (" << EidosStringForFloat(female_cloning_fraction) << " supplied)." << EidosTerminate(); @@ -6795,7 +6795,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_setCloningRate(EidosGlobalStringID p_ if (value_count != 1) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setCloningRate): setCloningRate() requires a rate vector containing exactly one value, in asexual simulations.." << EidosTerminate(); - double cloning_fraction = rate_value->FloatAtIndex(0, nullptr); + double cloning_fraction = rate_value->NumericAtIndex_NOCAST(0, nullptr); if ((cloning_fraction < 0.0) || (cloning_fraction > 1.0) || std::isnan(cloning_fraction)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setCloningRate): setCloningRate() requires cloning fractions within [0,1] (" << EidosStringForFloat(cloning_fraction) << " supplied)." << EidosTerminate(); @@ -6818,7 +6818,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_setSelfingRate(EidosGlobalStringID p_ EidosValue *rate_value = p_arguments[0].get(); - double selfing_fraction = rate_value->FloatAtIndex(0, nullptr); + double selfing_fraction = rate_value->NumericAtIndex_NOCAST(0, nullptr); if ((selfing_fraction != 0.0) && sex_enabled_) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setSelfingRate): setSelfingRate() is limited to the hermaphroditic case, and cannot be called in sexual simulations." << EidosTerminate(); @@ -6851,7 +6851,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_setSexRatio(EidosGlobalStringID p_met if (!sex_enabled_) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setSexRatio): setSexRatio() is limited to the sexual case, and cannot be called in asexual simulations." << EidosTerminate(); - double sex_ratio = sexRatio_value->FloatAtIndex(0, nullptr); + double sex_ratio = sexRatio_value->FloatAtIndex_NOCAST(0, nullptr); if ((sex_ratio < 0.0) || (sex_ratio > 1.0) || std::isnan(sex_ratio)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_setSexRatio): setSexRatio() requires a sex ratio within [0,1] (" << EidosStringForFloat(sex_ratio) << " supplied)." << EidosTerminate(); @@ -6887,7 +6887,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_setSpatialBounds(EidosGlobalStringID switch (dimensionality) { case 1: - bounds_x0_ = position_value->FloatAtIndex(0, nullptr); bounds_x1_ = position_value->FloatAtIndex(1, nullptr); + bounds_x0_ = position_value->NumericAtIndex_NOCAST(0, nullptr); bounds_x1_ = position_value->NumericAtIndex_NOCAST(1, nullptr); if (bounds_x1_ <= bounds_x0_) bad_bounds = true; @@ -6896,8 +6896,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_setSpatialBounds(EidosGlobalStringID break; case 2: - bounds_x0_ = position_value->FloatAtIndex(0, nullptr); bounds_x1_ = position_value->FloatAtIndex(2, nullptr); - bounds_y0_ = position_value->FloatAtIndex(1, nullptr); bounds_y1_ = position_value->FloatAtIndex(3, nullptr); + bounds_x0_ = position_value->NumericAtIndex_NOCAST(0, nullptr); bounds_x1_ = position_value->NumericAtIndex_NOCAST(2, nullptr); + bounds_y0_ = position_value->NumericAtIndex_NOCAST(1, nullptr); bounds_y1_ = position_value->NumericAtIndex_NOCAST(3, nullptr); if ((bounds_x1_ <= bounds_x0_) || (bounds_y1_ <= bounds_y0_)) bad_bounds = true; @@ -6906,9 +6906,9 @@ EidosValue_SP Subpopulation::ExecuteMethod_setSpatialBounds(EidosGlobalStringID break; case 3: - bounds_x0_ = position_value->FloatAtIndex(0, nullptr); bounds_x1_ = position_value->FloatAtIndex(3, nullptr); - bounds_y0_ = position_value->FloatAtIndex(1, nullptr); bounds_y1_ = position_value->FloatAtIndex(4, nullptr); - bounds_z0_ = position_value->FloatAtIndex(2, nullptr); bounds_z1_ = position_value->FloatAtIndex(5, nullptr); + bounds_x0_ = position_value->NumericAtIndex_NOCAST(0, nullptr); bounds_x1_ = position_value->NumericAtIndex_NOCAST(3, nullptr); + bounds_y0_ = position_value->NumericAtIndex_NOCAST(1, nullptr); bounds_y1_ = position_value->NumericAtIndex_NOCAST(4, nullptr); + bounds_z0_ = position_value->NumericAtIndex_NOCAST(2, nullptr); bounds_z1_ = position_value->NumericAtIndex_NOCAST(5, nullptr); if ((bounds_x1_ <= bounds_x0_) || (bounds_y1_ <= bounds_y0_) || (bounds_z1_ <= bounds_z0_)) bad_bounds = true; @@ -6951,7 +6951,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_setSubpopulationSize(EidosGlobalStrin EidosValue *size_value = p_arguments[0].get(); - slim_popsize_t subpop_size = SLiMCastToPopsizeTypeOrRaise(size_value->IntAtIndex(0, nullptr)); + slim_popsize_t subpop_size = SLiMCastToPopsizeTypeOrRaise(size_value->IntAtIndex_NOCAST(0, nullptr)); population_.SetSize(*this, subpop_size); @@ -7019,7 +7019,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_cachedFitness(EidosGlobalStringID p_m if (!do_all_indices) { - index = SLiMCastToPopsizeTypeOrRaise(indices_value->IntAtIndex(0, nullptr)); + index = SLiMCastToPopsizeTypeOrRaise(indices_value->IntAtIndex_NOCAST(0, nullptr)); if (index >= parent_subpop_size_) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_cachedFitness): cachedFitness() index " << index << " out of range." << EidosTerminate(); @@ -7040,7 +7040,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_cachedFitness(EidosGlobalStringID p_m if (!do_all_indices) { - index = SLiMCastToPopsizeTypeOrRaise(indices_value->IntAtIndex(value_index, nullptr)); + index = SLiMCastToPopsizeTypeOrRaise(indices_value->IntAtIndex_NOCAST(value_index, nullptr)); if (index >= parent_subpop_size_) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_cachedFitness): cachedFitness() index " << index << " out of range." << EidosTerminate(); @@ -7063,8 +7063,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID // This method is patterned closely upon Eidos_ExecuteFunction_sample(), but with no weights vector, and with various ways to narrow down the candidate pool EidosValue_SP result_SP(nullptr); - int64_t sample_size = p_arguments[0]->IntAtIndex(0, nullptr); - bool replace = p_arguments[1]->LogicalAtIndex(0, nullptr); + int64_t sample_size = p_arguments[0]->IntAtIndex_NOCAST(0, nullptr); + bool replace = p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr); int x_count = parent_subpop_size_; if (sample_size < 0) @@ -7078,7 +7078,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID slim_popsize_t excluded_index = -1; if (exclude_value->Type() != EidosValueType::kValueNULL) - excluded_individual = (Individual *)exclude_value->ObjectElementAtIndex(0, nullptr); + excluded_individual = (Individual *)exclude_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (excluded_individual) { @@ -7098,7 +7098,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID if (sex_value->Type() != EidosValueType::kValueNULL) { - const std::string &sex_string = ((EidosValue_String *)sex_value)->StringRefAtIndex(0, nullptr); + const std::string &sex_string = ((EidosValue_String *)sex_value)->StringRefAtIndex_NOCAST(0, nullptr); if (sex_string == "M") sex = IndividualSex::kMale; else if (sex_string == "F") sex = IndividualSex::kFemale; @@ -7112,15 +7112,15 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID // a tag value may be specified; if so, tag values must be defined for all individuals EidosValue *tag_value = p_arguments[4].get(); bool tag_specified = (tag_value->Type() != EidosValueType::kValueNULL); - slim_usertag_t tag = (tag_specified ? tag_value->IntAtIndex(0, nullptr) : 0); + slim_usertag_t tag = (tag_specified ? tag_value->IntAtIndex_NOCAST(0, nullptr) : 0); // an age min or max may be specified in nonWF models EidosValue *ageMin_value = p_arguments[5].get(); EidosValue *ageMax_value = p_arguments[6].get(); bool ageMin_specified = (ageMin_value->Type() != EidosValueType::kValueNULL); bool ageMax_specified = (ageMax_value->Type() != EidosValueType::kValueNULL); - int64_t ageMin = (ageMin_specified ? ageMin_value->IntAtIndex(0, nullptr) : -1); - int64_t ageMax = (ageMax_specified ? ageMax_value->IntAtIndex(0, nullptr) : INT64_MAX); + int64_t ageMin = (ageMin_specified ? ageMin_value->IntAtIndex_NOCAST(0, nullptr) : -1); + int64_t ageMax = (ageMax_specified ? ageMax_value->IntAtIndex_NOCAST(0, nullptr) : INT64_MAX); if ((ageMin_specified || ageMax_specified) && (model_type_ != SLiMModelType::kModelTypeNonWF)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_sampleIndividuals): ageMin and ageMax may only be specified in nonWF models." << EidosTerminate(nullptr); @@ -7128,24 +7128,24 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID // a migrant value may be specified EidosValue *migrant_value = p_arguments[7].get(); bool migrant_specified = (migrant_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t migrant = (migrant_specified ? migrant_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t migrant = (migrant_specified ? migrant_value->LogicalAtIndex_NOCAST(0, nullptr) : false); // logical tag values, tagL0 - tagL4, may be specified; if so, those tagL values must be defined for all individuals EidosValue *tagL0_value = p_arguments[8].get(); bool tagL0_specified = (tagL0_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL0 = (tagL0_specified ? tagL0_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL0 = (tagL0_specified ? tagL0_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL1_value = p_arguments[9].get(); bool tagL1_specified = (tagL1_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL1 = (tagL1_specified ? tagL1_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL1 = (tagL1_specified ? tagL1_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL2_value = p_arguments[10].get(); bool tagL2_specified = (tagL2_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL2 = (tagL2_specified ? tagL2_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL2 = (tagL2_specified ? tagL2_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL3_value = p_arguments[11].get(); bool tagL3_specified = (tagL3_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL3 = (tagL3_specified ? tagL3_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL3 = (tagL3_specified ? tagL3_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL4_value = p_arguments[12].get(); bool tagL4_specified = (tagL4_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL4 = (tagL4_specified ? tagL4_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL4 = (tagL4_specified ? tagL4_value->LogicalAtIndex_NOCAST(0, nullptr) : false); bool any_tagL_specified = (tagL0_specified || tagL1_specified || tagL2_specified || tagL3_specified || tagL4_specified); // determine the range the sample will be drawn from; this does not take into account tag, tagLX, or ageMin/ageMax @@ -7530,7 +7530,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID slim_popsize_t excluded_index = -1; if (exclude_value->Type() != EidosValueType::kValueNULL) - excluded_individual = (Individual *)exclude_value->ObjectElementAtIndex(0, nullptr); + excluded_individual = (Individual *)exclude_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (excluded_individual) { @@ -7550,7 +7550,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID if (sex_value->Type() != EidosValueType::kValueNULL) { - const std::string &sex_string = ((EidosValue_String *)sex_value)->StringRefAtIndex(0, nullptr); + const std::string &sex_string = ((EidosValue_String *)sex_value)->StringRefAtIndex_NOCAST(0, nullptr); if (sex_string == "M") sex = IndividualSex::kMale; else if (sex_string == "F") sex = IndividualSex::kFemale; @@ -7564,15 +7564,15 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID // a tag value may be specified; if so, tag values must be defined for all individuals EidosValue *tag_value = p_arguments[2].get(); bool tag_specified = (tag_value->Type() != EidosValueType::kValueNULL); - slim_usertag_t tag = (tag_specified ? tag_value->IntAtIndex(0, nullptr) : 0); + slim_usertag_t tag = (tag_specified ? tag_value->IntAtIndex_NOCAST(0, nullptr) : 0); // an age min or max may be specified in nonWF models EidosValue *ageMin_value = p_arguments[3].get(); EidosValue *ageMax_value = p_arguments[4].get(); bool ageMin_specified = (ageMin_value->Type() != EidosValueType::kValueNULL); bool ageMax_specified = (ageMax_value->Type() != EidosValueType::kValueNULL); - int64_t ageMin = (ageMin_specified ? ageMin_value->IntAtIndex(0, nullptr) : -1); - int64_t ageMax = (ageMax_specified ? ageMax_value->IntAtIndex(0, nullptr) : INT64_MAX); + int64_t ageMin = (ageMin_specified ? ageMin_value->IntAtIndex_NOCAST(0, nullptr) : -1); + int64_t ageMax = (ageMax_specified ? ageMax_value->IntAtIndex_NOCAST(0, nullptr) : INT64_MAX); if ((ageMin_specified || ageMax_specified) && (model_type_ != SLiMModelType::kModelTypeNonWF)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_subsetIndividuals): ageMin and ageMax may only be specified in nonWF models." << EidosTerminate(nullptr); @@ -7580,24 +7580,24 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID // a migrant value may be specified EidosValue *migrant_value = p_arguments[5].get(); bool migrant_specified = (migrant_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t migrant = (migrant_specified ? migrant_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t migrant = (migrant_specified ? migrant_value->LogicalAtIndex_NOCAST(0, nullptr) : false); // logical tag values, tagL0 - tagL4, may be specified; if so, those tagL values must be defined for all individuals EidosValue *tagL0_value = p_arguments[6].get(); bool tagL0_specified = (tagL0_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL0 = (tagL0_specified ? tagL0_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL0 = (tagL0_specified ? tagL0_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL1_value = p_arguments[7].get(); bool tagL1_specified = (tagL1_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL1 = (tagL1_specified ? tagL1_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL1 = (tagL1_specified ? tagL1_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL2_value = p_arguments[8].get(); bool tagL2_specified = (tagL2_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL2 = (tagL2_specified ? tagL2_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL2 = (tagL2_specified ? tagL2_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL3_value = p_arguments[9].get(); bool tagL3_specified = (tagL3_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL3 = (tagL3_specified ? tagL3_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL3 = (tagL3_specified ? tagL3_value->LogicalAtIndex_NOCAST(0, nullptr) : false); EidosValue *tagL4_value = p_arguments[10].get(); bool tagL4_specified = (tagL4_value->Type() != EidosValueType::kValueNULL); - eidos_logical_t tagL4 = (tagL4_specified ? tagL4_value->LogicalAtIndex(0, nullptr) : false); + eidos_logical_t tagL4 = (tagL4_specified ? tagL4_value->LogicalAtIndex_NOCAST(0, nullptr) : false); bool any_tagL_specified = (tagL0_specified || tagL1_specified || tagL2_specified || tagL3_specified || tagL4_specified); // determine the range the sample will be drawn from; this does not take into account tag, tagLX, or ageMin/ageMax @@ -7734,13 +7734,13 @@ EidosValue_SP Subpopulation::ExecuteMethod_defineSpatialMap(EidosGlobalStringID EidosValue *value_range = p_arguments[4].get(); EidosValue *colors = p_arguments[5].get(); - const std::string &map_name = name_value->StringRefAtIndex(0, nullptr); + const std::string &map_name = name_value->StringRefAtIndex_NOCAST(0, nullptr); if (map_name.length() == 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_defineSpatialMap): defineSpatialMap() map name must not be zero-length." << EidosTerminate(); - const std::string &spatiality_string = spatiality_value->StringRefAtIndex(0, nullptr); - bool interpolate = interpolate_value->LogicalAtIndex(0, nullptr); + const std::string &spatiality_string = spatiality_value->StringRefAtIndex_NOCAST(0, nullptr); + bool interpolate = interpolate_value->LogicalAtIndex_NOCAST(0, nullptr); // Make our SpatialMap object and populate it with the values provided SpatialMap *spatial_map = new SpatialMap(map_name, spatiality_string, this, values, interpolate, value_range, colors); @@ -7774,7 +7774,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addSpatialMap(EidosGlobalStringID p_m { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *map_value = (EidosValue *)p_arguments[0].get(); - SpatialMap *spatial_map = (SpatialMap *)map_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *spatial_map = (SpatialMap *)map_value->ObjectElementAtIndex_NOCAST(0, nullptr); std::string map_name = spatial_map->name_; // Check for an existing entry under this name; that is an error, unless it is the same spatial map object @@ -7810,7 +7810,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_removeSpatialMap(EidosGlobalStringID if (map_value->Type() == EidosValueType::kValueString) { - std::string map_name = map_value->StringAtIndex(0, nullptr); + std::string map_name = map_value->StringAtIndex_NOCAST(0, nullptr); auto map_iter = spatial_maps_.find(map_name); @@ -7827,7 +7827,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_removeSpatialMap(EidosGlobalStringID } else { - SpatialMap *map = (SpatialMap *)map_value->ObjectElementAtIndex(0, nullptr); + SpatialMap *map = (SpatialMap *)map_value->ObjectElementAtIndex_NOCAST(0, nullptr); std::string map_name = map->name_; auto map_iter = spatial_maps_.find(map_name); @@ -7859,7 +7859,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_spatialMapColor(EidosGlobalStringID p { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue_String *name_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &map_name = name_value->StringRefAtIndex(0, nullptr); + const std::string &map_name = name_value->StringRefAtIndex_NOCAST(0, nullptr); if (map_name.length() == 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_spatialMapColor): spatialMapColor() map name must not be zero-length." << EidosTerminate(); @@ -7892,7 +7892,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_spatialMapImage(EidosGlobalStringID p { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue_String *name_value = (EidosValue_String *)p_arguments[0].get(); - const std::string &map_name = name_value->StringRefAtIndex(0, nullptr); + const std::string &map_name = name_value->StringRefAtIndex_NOCAST(0, nullptr); if (map_name.length() == 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_spatialMapImage): spatialMapImage() map name must not be zero-length." << EidosTerminate(); @@ -7938,14 +7938,14 @@ EidosValue_SP Subpopulation::ExecuteMethod_spatialMapValue(EidosGlobalStringID p if (map_value->Type() == EidosValueType::kValueString) { - map_name = ((EidosValue_String *)map_value)->StringRefAtIndex(0, nullptr); + map_name = ((EidosValue_String *)map_value)->StringRefAtIndex_NOCAST(0, nullptr); if (map_name.length() == 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_spatialMapValue): spatialMapValue() map name must not be zero-length." << EidosTerminate(); } else { - map = (SpatialMap *)map_value->ObjectElementAtIndex(0, nullptr); + map = (SpatialMap *)map_value->ObjectElementAtIndex_NOCAST(0, nullptr); map_name = map->name_; } @@ -8003,13 +8003,13 @@ EidosValue_SP Subpopulation::ExecuteMethod_outputXSample(EidosGlobalStringID p_m } } - slim_popsize_t sample_size = SLiMCastToPopsizeTypeOrRaise(sampleSize_value->IntAtIndex(0, nullptr)); + slim_popsize_t sample_size = SLiMCastToPopsizeTypeOrRaise(sampleSize_value->IntAtIndex_NOCAST(0, nullptr)); - bool replace = replace_value->LogicalAtIndex(0, nullptr); + bool replace = replace_value->LogicalAtIndex_NOCAST(0, nullptr); IndividualSex requested_sex; - std::string sex_string = requestedSex_value->StringAtIndex(0, nullptr); + std::string sex_string = requestedSex_value->StringAtIndex_NOCAST(0, nullptr); if (sex_string.compare("M") == 0) requested_sex = IndividualSex::kMale; @@ -8026,22 +8026,22 @@ EidosValue_SP Subpopulation::ExecuteMethod_outputXSample(EidosGlobalStringID p_m bool output_multiallelics = true; if (p_method_id == gID_outputVCFSample) - output_multiallelics = outputMultiallelics_arg->LogicalAtIndex(0, nullptr); + output_multiallelics = outputMultiallelics_arg->LogicalAtIndex_NOCAST(0, nullptr); bool simplify_nucs = false; if (p_method_id == gID_outputVCFSample) - simplify_nucs = simplifyNucleotides_arg->LogicalAtIndex(0, nullptr); + simplify_nucs = simplifyNucleotides_arg->LogicalAtIndex_NOCAST(0, nullptr); bool output_nonnucs = true; if (p_method_id == gID_outputVCFSample) - output_nonnucs = outputNonnucleotides_arg->LogicalAtIndex(0, nullptr); + output_nonnucs = outputNonnucleotides_arg->LogicalAtIndex_NOCAST(0, nullptr); bool filter_monomorphic = false; if (p_method_id == gID_outputMSSample) - filter_monomorphic = filterMonomorphic_arg->LogicalAtIndex(0, nullptr); + filter_monomorphic = filterMonomorphic_arg->LogicalAtIndex_NOCAST(0, nullptr); // Figure out the right output stream std::ofstream outfile; @@ -8050,8 +8050,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_outputXSample(EidosGlobalStringID p_m if (filePath_arg->Type() != EidosValueType::kValueNULL) { - outfile_path = Eidos_ResolvedPath(filePath_arg->StringAtIndex(0, nullptr)); - bool append = append_arg->LogicalAtIndex(0, nullptr); + outfile_path = Eidos_ResolvedPath(filePath_arg->StringAtIndex_NOCAST(0, nullptr)); + bool append = append_arg->LogicalAtIndex_NOCAST(0, nullptr); outfile.open(outfile_path.c_str(), append ? (std::ios_base::app | std::ios_base::out) : std::ios_base::out); has_file = true; @@ -8124,8 +8124,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_configureDisplay(EidosGlobalStringID if (center_count != 2) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_configureDisplay): configureDisplay() requires that center be of exactly size 2 (x and y)." << EidosTerminate(); - double x = center_value->FloatAtIndex(0, nullptr); - double y = center_value->FloatAtIndex(1, nullptr); + double x = center_value->FloatAtIndex_NOCAST(0, nullptr); + double y = center_value->FloatAtIndex_NOCAST(1, nullptr); if ((x < 0.0) || (x > 1.0) || (y < 0.0) || (y > 1.0)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_configureDisplay): configureDisplay() requires that the specified center be within [0,1] for both x and y." << EidosTerminate(); @@ -8145,7 +8145,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_configureDisplay(EidosGlobalStringID } else { - double scale = scale_value->FloatAtIndex(0, nullptr); + double scale = scale_value->FloatAtIndex_NOCAST(0, nullptr); if ((scale <= 0.0) || (scale > 5.0)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_configureDisplay): configureDisplay() requires that the specified scale be within (0,5]." << EidosTerminate(); @@ -8164,7 +8164,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_configureDisplay(EidosGlobalStringID } else { - std::string &&color = color_value->StringAtIndex(0, nullptr); + std::string &&color = color_value->StringAtIndex_NOCAST(0, nullptr); if (color.empty()) { diff --git a/core/substitution.cpp b/core/substitution.cpp index 08c0d6d15..633fbabaf 100644 --- a/core/substitution.cpp +++ b/core/substitution.cpp @@ -309,7 +309,7 @@ void Substitution::SetProperty(EidosGlobalStringID p_property_id, const EidosVal { case gID_nucleotide: { - const std::string &nucleotide = ((EidosValue_String &)p_value).StringRefAtIndex(0, nullptr); + const std::string &nucleotide = ((EidosValue_String &)p_value).StringRefAtIndex_NOCAST(0, nullptr); if (nucleotide_ == -1) EIDOS_TERMINATION << "ERROR (Substitution::SetProperty): property nucleotide is only defined for nucleotide-based substitutions." << EidosTerminate(); @@ -323,7 +323,7 @@ void Substitution::SetProperty(EidosGlobalStringID p_property_id, const EidosVal } case gID_nucleotideValue: { - int64_t nucleotide = p_value.IntAtIndex(0, nullptr); + int64_t nucleotide = p_value.IntAtIndex_NOCAST(0, nullptr); if (nucleotide_ == -1) EIDOS_TERMINATION << "ERROR (Substitution::SetProperty): property nucleotideValue is only defined for nucleotide-based substitutions." << EidosTerminate(); @@ -335,14 +335,14 @@ void Substitution::SetProperty(EidosGlobalStringID p_property_id, const EidosVal } case gID_subpopID: { - slim_objectid_t value = SLiMCastToObjectidTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_objectid_t value = SLiMCastToObjectidTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); subpop_index_ = value; return; } case gID_tag: { - slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex(0, nullptr)); + slim_usertag_t value = SLiMCastToUsertagTypeOrRaise(p_value.IntAtIndex_NOCAST(0, nullptr)); tag_value_ = value; return; diff --git a/eidos/eidos_functions_files.cpp b/eidos/eidos_functions_files.cpp index d03b3838f..07fb74e80 100644 --- a/eidos/eidos_functions_files.cpp +++ b/eidos/eidos_functions_files.cpp @@ -302,7 +302,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeFile(const std::vector & slimgui_buffer.reserve(contents_count); for (int value_index = 0; value_index < contents_count; ++value_index) - slimgui_buffer.emplace_back(contents_value->StringRefAtIndex(value_index, nullptr)); + slimgui_buffer.emplace_back(contents_value->StringRefAtIndex_NOCAST(value_index, nullptr)); if (context) context->FileWriteNotification(file_path, std::move(slimgui_buffer), append); @@ -367,7 +367,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vectorStringRefAtIndex(value_index, nullptr)); + slimgui_buffer.emplace_back(contents_value->StringRefAtIndex_NOCAST(value_index, nullptr)); if (context) context->FileWriteNotification(file_path, std::move(slimgui_buffer), false); diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 7c81c0cb5..b4abed603 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -63,7 +63,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu if (x_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(llabs(x_value->IntAtIndex(0, nullptr))); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(llabs(x_value->IntAtIndex_NOCAST(0, nullptr))); int64_t operand = x_value->IntAtIndex_NOCAST(0, nullptr); diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index cd01989f1..8bc8d1d02 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -2037,7 +2037,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex(0, operator_token) + second_child_value->IntAtIndex(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex_NOCAST(0, operator_token) + second_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); @@ -2059,7 +2059,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) for (int value_index = 0; value_index < first_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->set_int_no_check(first_child_value->IntAtIndex(value_index, operator_token) + second_child_value->IntAtIndex(value_index, operator_token)); + //int_result->set_int_no_check(first_child_value->IntAtIndex_NOCAST(value_index, operator_token) + second_child_value->IntAtIndex_NOCAST(value_index, operator_token)); int64_t first_operand = first_child_data[value_index]; int64_t second_operand = second_child_data[value_index]; @@ -2085,7 +2085,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) for (int value_index = 0; value_index < second_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->PushInt(singleton_int + second_child_value->IntAtIndex(value_index, operator_token)); + //int_result->PushInt(singleton_int + second_child_value->IntAtIndex_NOCAST(value_index, operator_token)); int64_t second_operand = second_child_data[value_index]; int64_t add_result; @@ -2109,7 +2109,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) for (int value_index = 0; value_index < first_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->PushInt(first_child_value->IntAtIndex(value_index, operator_token) + singleton_int); + //int_result->PushInt(first_child_value->IntAtIndex_NOCAST(value_index, operator_token) + singleton_int); int64_t first_operand = first_child_data[value_index]; int64_t add_result; @@ -2257,7 +2257,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-first_child_value->IntAtIndex(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-first_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t subtract_result; @@ -2277,7 +2277,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) for (int value_index = 0; value_index < first_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->set_int_no_check(-first_child_value->IntAtIndex(value_index, operator_token), value_index); + //int_result->set_int_no_check(-first_child_value->IntAtIndex_NOCAST(value_index, operator_token), value_index); int64_t operand = first_child_data[value_index]; int64_t subtract_result; @@ -2340,7 +2340,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex(0, operator_token) - second_child_value->IntAtIndex(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex_NOCAST(0, operator_token) - second_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); @@ -2362,7 +2362,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) for (int value_index = 0; value_index < first_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->set_int_no_check(first_child_value->IntAtIndex(value_index, operator_token) - second_child_value->IntAtIndex(value_index, operator_token)); + //int_result->set_int_no_check(first_child_value->IntAtIndex_NOCAST(value_index, operator_token) - second_child_value->IntAtIndex_NOCAST(value_index, operator_token)); int64_t first_operand = first_child_data[value_index]; int64_t second_operand = second_child_data[value_index]; @@ -2388,7 +2388,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) for (int value_index = 0; value_index < second_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->set_int_no_check(singleton_int - second_child_value->IntAtIndex(value_index, operator_token)); + //int_result->set_int_no_check(singleton_int - second_child_value->IntAtIndex_NOCAST(value_index, operator_token)); int64_t second_operand = second_child_data[value_index]; int64_t subtract_result; @@ -2412,7 +2412,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) for (int value_index = 0; value_index < first_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->set_int_no_check(first_child_value->IntAtIndex(value_index, operator_token) - singleton_int); + //int_result->set_int_no_check(first_child_value->IntAtIndex_NOCAST(value_index, operator_token) - singleton_int); int64_t first_operand = first_child_data[value_index]; int64_t subtract_result; @@ -2712,7 +2712,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex(0, operator_token) * second_child_value->IntAtIndex(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex_NOCAST(0, operator_token) * second_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); @@ -2734,7 +2734,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) for (int value_index = 0; value_index < first_child_count; ++value_index) { // This is an overflow-safe version of: - //int_result->set_int_no_check(first_child_value->IntAtIndex(value_index, operator_token) * second_child_value->IntAtIndex(value_index, operator_token)); + //int_result->set_int_no_check(first_child_value->IntAtIndex_NOCAST(value_index, operator_token) * second_child_value->IntAtIndex_NOCAST(value_index, operator_token)); int64_t first_operand = first_child_data[value_index]; int64_t second_operand = second_child_data[value_index]; @@ -5266,7 +5266,7 @@ EidosValue_SP EidosInterpreter::Evaluate_If(const EidosASTNode *p_node) (debug_points_->set.find(operator_token->token_line_) != debug_points_->set.end()) && (condition_result->Count() == 1)) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); // the above might raise, but if it does, it will be the same error as produced below ErrorOutputStream() << EidosDebugPointIndent::Indent() << "#DEBUG IF (line " << (operator_token->token_line_ + 1) << eidos_context_->DebugPointInfo() << "): condition == " << @@ -5430,7 +5430,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Do(const EidosASTNode *p_node) (debug_points_->set.find(operator_token->token_line_) != debug_points_->set.end()) && (condition_result->Count() == 1)) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); // the above might raise, but if it does, it will be the same error as produced below indenter.outdent(); @@ -5492,7 +5492,7 @@ EidosValue_SP EidosInterpreter::Evaluate_While(const EidosASTNode *p_node) (debug_points_->set.find(operator_token->token_line_) != debug_points_->set.end()) && (condition_result->Count() == 1)) { - eidos_logical_t condition_logical = condition_result->LogicalAtIndex(0, operator_token); + eidos_logical_t condition_logical = condition_result->LogicalAtIndex_CAST(0, operator_token); // the above might raise, but if it does, it will be the same error as produced below ErrorOutputStream() << EidosDebugPointIndent::Indent() << "#DEBUG WHILE (line " << (operator_token->token_line_ + 1) << eidos_context_->DebugPointInfo() << "): condition == " << diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 7511d6f63..c2c0fc133 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -211,7 +211,7 @@ class EidosValue virtual std::string StringAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } virtual int64_t IntAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } virtual double FloatAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } - virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } // casts integer to float, otherwise does not cast; considered _NOCAST + virtual double NumericAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } // casts integer to float, otherwise does not cast; considered _NOCAST virtual EidosObject *ObjectElementAtIndex_NOCAST(__attribute__((unused)) int p_idx, __attribute__((unused)) const EidosToken *p_blame_token) const { RaiseForIncorrectTypeCall(); } // fetching individual values WITH a cast to the requested type; this is not general-purpose @@ -1361,7 +1361,7 @@ class EidosValue_Object_singleton final : public EidosValue_Object void set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index); // checks for retain/release }; -inline __attribute__((always_inline)) void EidosValue_Object_singleton::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object_singleton::set_object_element_no_check_CRR(EidosObject *p_object, __attribute__((unused)) size_t p_index) { #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors From 6cfa23c735fdd5dec8244d10b47b08b928d2ef27 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Fri, 22 Dec 2023 12:45:41 -0500 Subject: [PATCH 08/18] property assignment now requires an exact type match --- VERSIONS | 1 + core/slim_test_core.cpp | 28 +++++++++++++++++----------- core/slim_test_other.cpp | 26 +++++++++++++------------- eidos/eidos_property_signature.cpp | 17 +++++++++-------- eidos/eidos_property_signature.h | 2 +- eidos/eidos_value.cpp | 28 +++++++++++----------------- 6 files changed, 52 insertions(+), 50 deletions(-) diff --git a/VERSIONS b/VERSIONS index dc6e7193c..5caa2fa37 100644 --- a/VERSIONS +++ b/VERSIONS @@ -8,6 +8,7 @@ Note that not every commit will be logged here; that is what the Github commit h development head (in the master branch): fix for #418, a crash involving null genomes in nonWF (has_null_genomes_ was not set correctly by addCloned() or takeMigrants() when putting a null genome into a subpop that previously had none) policy change: float indices are no longer legal for subsetting, indices must be integer (or a logical vector, as usual); this was inherited from R and is a bad idea for Eidos + policy change: assignment into object properties must match the type of the property; no more promotion to integer/float from lower types version 4.1 (Eidos version 3.1): diff --git a/core/slim_test_core.cpp b/core/slim_test_core.cpp index 1143ed348..ae627c640 100644 --- a/core/slim_test_core.cpp +++ b/core/slim_test_core.cpp @@ -1923,22 +1923,28 @@ void _RunIndividualTests(void) SLiMAssertScriptStop(gen1_setup_i1xyz + "1 early() { i = p1.individuals; i.setSpatialPosition(1.0:30); if (identical(i.z, (1.0:10)*3)) stop(); }", __LINE__); // Some specific testing for setting of accelerated properties - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = (seqAlong(i) % 2 == 0); if (all(i.tag == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__); + SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = asInteger(seqAlong(i) % 2 == 0); if (all(i.tag == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tag = seqAlong(i); if (all(i.tag == seqAlong(i))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = (seqAlong(i) % 2 == 0); if (all(i.tagF == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = seqAlong(i); if (all(i.tagF == seqAlong(i))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__); + SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = asFloat(seqAlong(i) % 2 == 0); if (all(i.tagF == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = seqAlong(i); }", "cannot be type integer", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.tagF = asFloat(seqAlong(i)); if (all(i.tagF == seqAlong(i))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = (seqAlong(i) % 2 == 0); if (all(i.fitnessScaling == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = seqAlong(i); if (all(i.fitnessScaling == seqAlong(i))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__); + SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = asFloat(seqAlong(i) % 2 == 0); if (all(i.fitnessScaling == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = seqAlong(i); }", "cannot be type integer", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.fitnessScaling = asFloat(seqAlong(i)); if (all(i.fitnessScaling == seqAlong(i))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = (seqAlong(i) % 2 == 0); if (all(i.x == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = seqAlong(i); if (all(i.x == seqAlong(i))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__); + SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = asFloat(seqAlong(i) % 2 == 0); if (all(i.x == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = seqAlong(i); if (all(i.x == seqAlong(i))) stop(); }", "cannot be type integer", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.x = asFloat(seqAlong(i)); if (all(i.x == seqAlong(i))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = (seqAlong(i) % 2 == 0); if (all(i.y == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = seqAlong(i); if (all(i.y == seqAlong(i))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__); + SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = asFloat(seqAlong(i) % 2 == 0); if (all(i.y == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = seqAlong(i); if (all(i.y == seqAlong(i))) stop(); }", "cannot be type integer", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.y = asFloat(seqAlong(i)); if (all(i.y == seqAlong(i))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = (seqAlong(i) % 2 == 0); if (all(i.z == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); - SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = seqAlong(i); if (all(i.z == seqAlong(i))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = (seqAlong(i) % 2 == 0); }", "cannot be type logical", __LINE__); + SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = asFloat(seqAlong(i) % 2 == 0); if (all(i.z == (seqAlong(i) % 2 == 0))) stop(); }", __LINE__); + SLiMAssertScriptRaise(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = seqAlong(i); if (all(i.z == seqAlong(i))) stop(); }", "cannot be type integer", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.z = asFloat(seqAlong(i)); if (all(i.z == seqAlong(i))) stop(); }", __LINE__); SLiMAssertScriptStop(gen1_setup_p1 + "1 early() { i = p1.individuals; i.color = format('#%.6X', seqAlong(i)); if (all(i.color == format('#%.6X', seqAlong(i)))) stop(); }", __LINE__); diff --git a/core/slim_test_other.cpp b/core/slim_test_other.cpp index 5188bfb7d..e3ba757de 100644 --- a/core/slim_test_other.cpp +++ b/core/slim_test_other.cpp @@ -408,32 +408,32 @@ void _RunInteractionTypeTests_Spatial(const std::string &p_max_distance, bool p_ if (i == 0) { spatiality = "xy"; - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0.0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } else if (i == 1) { spatiality = "xz"; - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0.0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } else if (i == 2) { spatiality = "yz"; - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0.0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } else if (i == 3) { spatiality = "xy"; - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0.0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } else if (i == 4) { spatiality = "xz"; - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0.0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } else // if (i == 5) { spatiality = "yz"; - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0.0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } // Test InteractionType – (float)distance(object individuals1, [No individuals2 = NULL]) @@ -623,7 +623,7 @@ void _RunInteractionTypeTests_Spatial(const std::string &p_max_distance, bool p_ } // *** 3D with y and z zero - std::string gen1_setup_i1xyz_pop("initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xyz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0; p1.individuals.z = 0; i1.evaluate(p1); ind = p1.individuals; "); + std::string gen1_setup_i1xyz_pop("initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xyz', maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0.0; p1.individuals.z = 0.0; i1.evaluate(p1); ind = p1.individuals; "); // Test InteractionType – (float)distance(object individuals1, [No individuals2 = NULL]) SLiMAssertScriptStop(gen1_setup_i1xyz_pop + "if (i1.distance(ind[0], ind[2]) == 11.0) stop(); }", __LINE__); @@ -1142,17 +1142,17 @@ void _RunInteractionTypeTests_LocalPopDensity() bool use_first_coordinate = (i < 3); if (i == 0) - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0.0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; else if (i == 1) - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.x = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0.0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; else if (i == 2) - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.z = 0.0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; else if (i == 3) - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xy', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.y = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0.0; p1.individuals.z = runif(10); i1.evaluate(p1); ind = p1.individuals; "; else if (i == 4) - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'xz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.x = 0.0; p1.individuals.y = runif(10); i1.evaluate(p1); ind = p1.individuals; "; else // if (i == 5) - gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; + gen1_setup_i1xy_pop = "initialize() { initializeSLiMOptions(dimensionality='xyz'); " + sex_string + "initializeMutationRate(1e-5); initializeMutationType('m1', 0.5, 'f', 0.0); initializeGenomicElementType('g1', m1, 1.0); initializeGenomicElement(g1, 0, 99999); initializeRecombinationRate(1e-8); initializeInteractionType('i1', 'yz', " + reciprocal_string + ", maxDistance=" + p_max_distance + ", sexSegregation='" + p_sex_segregation + "'); } 1 early() { sim.addSubpop('p1', 10); p1.individuals.z = c(-10.0, 0, 1, 2, 3, 5, 7, 8, 20, 25); p1.individuals.y = 0.0; p1.individuals.x = runif(10); i1.evaluate(p1); ind = p1.individuals; "; } */ diff --git a/eidos/eidos_property_signature.cpp b/eidos/eidos_property_signature.cpp index 9b96abdfb..a38f04648 100644 --- a/eidos/eidos_property_signature.cpp +++ b/eidos/eidos_property_signature.cpp @@ -50,11 +50,14 @@ EidosPropertySignature::~EidosPropertySignature(void) { } -bool EidosPropertySignature::CheckAssignedValue(const EidosValue &p_value) const +void EidosPropertySignature::CheckAssignedValue(const EidosValue &p_value) const { uint32_t retmask = value_mask_; bool value_type_ok = true; - bool value_exact_match = true; + + // BCH 12/22/2023: We used to allow type promotion when assigning into properties. I think we ought to be + // strict about that; this comes from the days when Eidos was much more oriented towards automatic type + // promotion, but it's bug-prone and provides little value. switch (p_value.Type()) { @@ -73,12 +76,12 @@ bool EidosPropertySignature::CheckAssignedValue(const EidosValue &p_value) const value_type_ok = false; break; case EidosValueType::kValueLogical: - value_type_ok = !!(retmask & (kEidosValueMaskLogical | kEidosValueMaskInt | kEidosValueMaskFloat)); // can give logical to an int or float property - value_exact_match = !!(retmask & kEidosValueMaskLogical); + //value_type_ok = !!(retmask & (kEidosValueMaskLogical | kEidosValueMaskInt | kEidosValueMaskFloat)); // can give logical to an int or float property + value_type_ok = !!(retmask & kEidosValueMaskLogical); break; case EidosValueType::kValueInt: - value_type_ok = !!(retmask & (kEidosValueMaskInt | kEidosValueMaskFloat)); // can give int to a float property - value_exact_match = !!(retmask & kEidosValueMaskInt); + //value_type_ok = !!(retmask & (kEidosValueMaskInt | kEidosValueMaskFloat)); // can give int to a float property + value_type_ok = !!(retmask & kEidosValueMaskInt); break; case EidosValueType::kValueFloat: value_type_ok = !!(retmask & kEidosValueMaskFloat); @@ -103,8 +106,6 @@ bool EidosPropertySignature::CheckAssignedValue(const EidosValue &p_value) const EIDOS_TERMINATION << "ERROR (EidosPropertySignature::CheckAssignedValue): value cannot be type " << p_value.Type() << " for " << PropertyType() << " property " << property_name_ << "." << EidosTerminate(nullptr); // No check for size, because we're checking a whole vector being assigned into an object; EidosValue_Object will check the sizes - - return value_exact_match; } void EidosPropertySignature::CheckResultValue(const EidosValue &p_value) const diff --git a/eidos/eidos_property_signature.h b/eidos/eidos_property_signature.h index 400fe7380..40d8cfc6b 100644 --- a/eidos/eidos_property_signature.h +++ b/eidos/eidos_property_signature.h @@ -74,7 +74,7 @@ class EidosPropertySignature EidosPropertySignature(const std::string &p_property_name, bool p_read_only, EidosValueMask p_value_mask, const EidosClass *p_value_class); // check arguments and returns - bool CheckAssignedValue(const EidosValue &p_value) const; // checks a vector being assigned into a whole object; true is exact match, false is implicit type conversion + void CheckAssignedValue(const EidosValue &p_value) const; // checks a vector being assigned into a whole object; raises on mismatch void CheckResultValue(const EidosValue &p_value) const; // checks the result from a single element void CheckAggregateResultValue(const EidosValue &p_value, size_t p_expected_size) const; // checks the result from a vector diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 1b907f78b..469719ce4 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -2647,7 +2647,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope if (!signature) EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); - bool exact_match = signature->CheckAssignedValue(p_value); + signature->CheckAssignedValue(p_value); // will raise if the type being assigned in is not an exact match // We have to check the count ourselves; the signature does not do that for us size_t p_value_count = p_value.Count(); @@ -2659,8 +2659,6 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope if (signature->accelerated_set_) { // Accelerated property writing is enabled for this property, so we call the setter directly - // Unlike the vector case below, this should work with implicit promotion, because accelerated - // setters will get the singleton value safely, not by direct vector access signature->accelerated_setter(values_, values_size, p_value, p_value_count); } else @@ -2676,21 +2674,17 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope if (signature->accelerated_set_) { // Accelerated property writing is enabled for this property, so we call the setter directly - // However, accelerated setting of vectors requires that the value type matches the property - // type, without promotion, so we check that condition first and fall through if not - if (exact_match) - { - signature->accelerated_setter(values_, values_size, p_value, p_value_count); - return; - } + signature->accelerated_setter(values_, values_size, p_value, p_value_count); } - - // we have a one-to-one assignment of values to elements: x.foo = 1:5 (where x has 5 elements) - for (size_t value_idx = 0; value_idx < p_value_count; value_idx++) + else { - EidosValue_SP temp_rvalue = p_value.GetValueAtIndex((int)value_idx, nullptr); - - values_[value_idx]->SetProperty(p_property_id, *temp_rvalue); + // we have a one-to-one assignment of values to elements: x.foo = 1:5 (where x has 5 elements) + for (size_t value_idx = 0; value_idx < p_value_count; value_idx++) + { + EidosValue_SP temp_rvalue = p_value.GetValueAtIndex((int)value_idx, nullptr); + + values_[value_idx]->SetProperty(p_property_id, *temp_rvalue); + } } } } @@ -3243,7 +3237,7 @@ void EidosValue_Object_singleton::SetPropertyOfElements(EidosGlobalStringID p_pr if (!signature) EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); - signature->CheckAssignedValue(p_value); + signature->CheckAssignedValue(p_value); // will raise if the type being assigned in is not an exact match // We have to check the count ourselves; the signature does not do that for us if (p_value.Count() == 1) From 2c6d0690f29913636468caab2944e2e1f1713ffa Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Fri, 22 Dec 2023 13:17:19 -0500 Subject: [PATCH 09/18] fix QtSLiM issues with the new changes --- QtSLiM/QtSLiMVariableBrowser.cpp | 2 +- QtSLiM/QtSLiM_SLiMgui.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/QtSLiM/QtSLiMVariableBrowser.cpp b/QtSLiM/QtSLiMVariableBrowser.cpp index 3dff9386b..1c6b2543e 100644 --- a/QtSLiM/QtSLiMVariableBrowser.cpp +++ b/QtSLiM/QtSLiMVariableBrowser.cpp @@ -535,7 +535,7 @@ void QtSLiMVariableBrowser::itemExpanded(QTreeWidgetItem *item) // we used to display zero-length property values for zero-length object vectors, but don't any more int display_index = (element_index != -1) ? element_index : 0; EidosValue_Object *eidos_object_vector = static_cast(eidos_value); - EidosObject *eidos_object = eidos_object_vector->ObjectElementAtIndex(display_index, nullptr); + EidosObject *eidos_object = eidos_object_vector->ObjectElementAtIndex_NOCAST(display_index, nullptr); const EidosClass *object_class = eidos_object->Class(); const std::vector *properties = object_class->Properties(); size_t propertyCount = properties->size(); diff --git a/QtSLiM/QtSLiM_SLiMgui.cpp b/QtSLiM/QtSLiM_SLiMgui.cpp index 156a6b13c..3f56b7167 100644 --- a/QtSLiM/QtSLiM_SLiMgui.cpp +++ b/QtSLiM/QtSLiM_SLiMgui.cpp @@ -113,7 +113,7 @@ EidosValue_SP SLiMgui::ExecuteMethod_openDocument(EidosGlobalStringID p_method_i #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *filePath_value = p_arguments[0].get(); - std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex(0, nullptr))); + std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex_NOCAST(0, nullptr))); QString filePath = QString::fromStdString(file_path); controller_->eidos_openDocument(filePath); From 0c8e4de8924eabb56ab581f6309fb0de5a762ced Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Fri, 22 Dec 2023 20:53:59 -0500 Subject: [PATCH 10/18] add an (internal) constness property to EidosValue --- core/community.cpp | 3 + core/genomic_element_type.cpp | 3 + core/interaction_type.cpp | 3 + core/mutation_type.cpp | 3 + core/slim_eidos_block.cpp | 8 ++ core/species.cpp | 3 + core/subpopulation.cpp | 6 ++ eidos/eidos_ast_node.cpp | 9 ++ eidos/eidos_call_signature.cpp | 8 ++ eidos/eidos_class_Object.cpp | 2 +- eidos/eidos_globals.cpp | 61 +++++++++-- eidos/eidos_globals.h | 2 - eidos/eidos_interpreter.cpp | 15 ++- eidos/eidos_script.cpp | 1 + eidos/eidos_symbol_table.cpp | 9 ++ eidos/eidos_symbol_table.h | 16 ++- eidos/eidos_value.cpp | 183 +++++++++++++++++++++++---------- eidos/eidos_value.h | 156 +++++++++++++++++----------- 18 files changed, 362 insertions(+), 129 deletions(-) diff --git a/core/community.cpp b/core/community.cpp index 10733c3c7..c920c14b1 100644 --- a/core/community.cpp +++ b/core/community.cpp @@ -83,6 +83,9 @@ extern "C" { Community::Community(void) : self_symbol_(gID_community, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Community_Class))) { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + // BCH 3/16/2022: We used to allocate the Species object here, as the first thing we did. In SLiM 4 there can // be multiple species and they can have names other than "sim", so we delay species creation until parse time. diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index 4cb432707..f7c193d27 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -39,6 +39,9 @@ GenomicElementType::GenomicElementType(Species &p_species, slim_objectid_t p_gen self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('g', p_genomic_element_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_GenomicElementType_Class))), species_(p_species), genomic_element_type_id_(p_genomic_element_type_id), mutation_type_ptrs_(std::move(p_mutation_type_ptrs)), mutation_fractions_(std::move(p_mutation_fractions)), mutation_matrix_(nullptr) { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + InitializeDraws(); } diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 99752887d..5e91630cb 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -80,6 +80,9 @@ InteractionType::InteractionType(Community &p_community, slim_objectid_t p_inter spatiality_string_(std::move(p_spatiality_string)), reciprocal_(p_reciprocal), max_distance_(p_max_distance), max_distance_sq_(p_max_distance * p_max_distance), if_type_(SpatialKernelType::kFixed), if_param1_(1.0), if_param2_(0.0), community_(p_community), interaction_type_id_(p_interaction_type_id) { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + // Figure out our spatiality, which is the number of spatial dimensions we actively use for distances if (spatiality_string_ == "") { spatiality_ = 0; required_dimensionality_ = 0; } else if (spatiality_string_ == "x") { spatiality_ = 1; required_dimensionality_ = 1; } diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index e719aacc3..18a0cb701 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -69,6 +69,9 @@ self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStr , mutation_type_index_(p_mutation_type_index) #endif { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + // In WF models, convertToSubstitution defaults to T; in nonWF models it defaults to F as specified above if (species_.community_.ModelType() == SLiMModelType::kModelTypeWF) convert_to_substitution_ = true; diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 0b1bdd937..6f84be522 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -788,6 +788,10 @@ SLiMEidosBlock::SLiMEidosBlock(EidosASTNode *p_root_node) : script_block_symbol_(gEidosID_none, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), root_node_(p_root_node), user_script_line_offset_(p_root_node->token_->token_line_) { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + script_block_symbol_.second->MarkAsConstant(); + // NOTE: SLiMEidosBlock::BlockTypeForRootNode() above must be maintained in parallel with this method! const std::vector &block_children = root_node_->children_; int child_index = 0, n_children = (int)block_children.size(); @@ -1118,6 +1122,10 @@ SLiMEidosBlock::SLiMEidosBlock(slim_objectid_t p_id, const std::string &p_script script_block_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('s', p_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), type_(p_type), block_id_(p_id), start_tick_(p_start), end_tick_(p_end), species_spec_(p_species_spec), ticks_spec_(p_ticks_spec), user_script_line_offset_(p_user_script_line_offset) { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + script_block_symbol_.second->MarkAsConstant(); + script_ = new EidosScript(p_script_string, p_user_script_line_offset); // the caller should now call TokenizeAndParse() to complete initialization } diff --git a/core/species.cpp b/core/species.cpp index 0a53f5c40..2288335ff 100644 --- a/core/species.cpp +++ b/core/species.cpp @@ -103,6 +103,9 @@ Species::Species(Community &p_community, slim_objectid_t p_species_id, const std self_symbol_(EidosStringRegistry::GlobalStringIDForString(p_name), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Species_Class))), x_experiments_enabled_(false), model_type_(p_community.model_type_), community_(p_community), population_(*this), name_(p_name), species_id_(p_species_id) { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + #ifdef SLIMGUI // Pedigree recording is always enabled when running under SLiMgui, so that the various graphs all work // However, as with tree-sequence recording, the fact that it is enabled is not user-visible unless the user enables it diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 3184670b9..7318ca289 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -841,6 +841,9 @@ Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopu , gui_premigration_size_(p_subpop_size) #endif { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + if (model_type_ == SLiMModelType::kModelTypeWF) { GenerateParentsToFit(/* p_initial_age */ -1, /* p_sex_ratio */ 0.0, /* p_allow_zero_size */ false, /* p_require_both_sexes */ true, /* p_record_in_treeseq */ p_record_in_treeseq, p_haploid, /* p_mean_parent_age */ -1.0F); @@ -881,6 +884,9 @@ Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopu , gui_premigration_size_(p_subpop_size) #endif { + // self_symbol_ is always a constant, but can't be marked as such on construction + self_symbol_.second->MarkAsConstant(); + if (model_type_ == SLiMModelType::kModelTypeWF) { GenerateParentsToFit(/* p_initial_age */ -1, /* p_sex_ratio */ p_sex_ratio, /* p_allow_zero_size */ false, /* p_require_both_sexes */ true, /* p_record_in_treeseq */ p_record_in_treeseq, p_haploid, /* p_mean_parent_age */ -1.0F); diff --git a/eidos/eidos_ast_node.cpp b/eidos/eidos_ast_node.cpp index b8fd69c85..2909179e8 100644 --- a/eidos/eidos_ast_node.cpp +++ b/eidos/eidos_ast_node.cpp @@ -93,6 +93,7 @@ void EidosASTNode::_OptimizeConstants(void) const { try { cached_literal_value_ = EidosInterpreter::NumericValueForString(token_->token_string_, token_); + cached_literal_value_->MarkAsConstant(); } catch (...) { // NOLINT(*-empty-catch) : intentional empty catch // if EidosInterpreter::NumericValueForString() raises, we just don't cache the value @@ -102,11 +103,13 @@ void EidosASTNode::_OptimizeConstants(void) const { // This is taken from EidosInterpreter::Evaluate_String and needs to match exactly! cached_literal_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(token_->token_string_)); + cached_literal_value_->MarkAsConstant(); } else if (token_type == EidosTokenType::kTokenIdentifier) { // Cache values for built-in constants; these can't be changed, so this should be safe, and // should be much faster than having to scan up through all the symbol tables recursively + // Note that these values are all constants already, so MarkAsConstant() is not needed. if (token_->token_string_ == gEidosStr_F) cached_literal_value_ = gStaticEidosValue_LogicalF; else if (token_->token_string_ == gEidosStr_T) @@ -135,7 +138,10 @@ void EidosASTNode::_OptimizeConstants(void) const const EidosASTNode *child = children_[0]; if (child->cached_literal_value_) + { cached_return_value_ = child->cached_literal_value_; + cached_return_value_->MarkAsConstant(); // should already be marked constant, actually + } } } else if (token_type == EidosTokenType::kTokenLBrace) @@ -150,7 +156,10 @@ void EidosASTNode::_OptimizeConstants(void) const const EidosASTNode *child = children_[0]; if (child->cached_return_value_ && (child->token_->token_type_ == EidosTokenType::kTokenReturn)) + { cached_return_value_ = child->cached_return_value_; + cached_return_value_->MarkAsConstant(); // should already be marked constant, actually + } } } } diff --git a/eidos/eidos_call_signature.cpp b/eidos/eidos_call_signature.cpp index 29d0e29c5..0b217e7be 100644 --- a/eidos/eidos_call_signature.cpp +++ b/eidos/eidos_call_signature.cpp @@ -78,6 +78,14 @@ EidosCallSignature *EidosCallSignature::AddArgWithDefault(EidosValueMask p_arg_m EIDOS_TERMINATION << "ERROR (EidosCallSignature::AddArgWithDefault): (internal error) an object element type may only be supplied for an argument of object type." << EidosTerminate(nullptr); } + // Default values should be marked constant, just to be safe. We just make a copy here; + // it's not worth trying to avoid that, since this is just startup overhead. + if (p_default_value) + { + p_default_value = p_default_value->CopyValues(); + p_default_value->MarkAsConstant(); + } + arg_masks_.emplace_back(p_arg_mask); arg_names_.emplace_back(p_argument_name); arg_name_IDs_.emplace_back(EidosStringRegistry::GlobalStringIDForString(p_argument_name)); diff --git a/eidos/eidos_class_Object.cpp b/eidos/eidos_class_Object.cpp index 877b25646..022802bff 100644 --- a/eidos/eidos_class_Object.cpp +++ b/eidos/eidos_class_Object.cpp @@ -104,7 +104,7 @@ void EidosObject::SetProperty(EidosGlobalStringID p_property_id, const EidosValu bool readonly = signature->read_only_; - // Check whether setting a constant was attempted; we can do this on behalf of all our subclasses + // Check whether setting a read-only property was attempted; we can do this on behalf of all our subclasses if (readonly) EIDOS_TERMINATION << "ERROR (EidosObject::SetProperty for " << Class()->ClassName() << "): attempt to set a new value for read-only property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << "." << EidosTerminate(nullptr); else diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index e50391d6f..50e33b716 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1080,7 +1080,6 @@ void Eidos_WarmUp(void) // Make the shared EidosValue pool size_t maxEidosValueSize = sizeof(EidosValue_NULL); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Logical)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Logical_const)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String_vector)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String_singleton)); @@ -1097,7 +1096,6 @@ void Eidos_WarmUp(void) // std::cout << "sizeof(EidosValue) == " << sizeof(EidosValue) << std::endl; // std::cout << "sizeof(EidosValue_NULL) == " << sizeof(EidosValue_NULL) << std::endl; // std::cout << "sizeof(EidosValue_Logical) == " << sizeof(EidosValue_Logical) << std::endl; -// std::cout << "sizeof(EidosValue_Logical_const) == " << sizeof(EidosValue_Logical_const) << std::endl; // std::cout << "sizeof(EidosValue_String) == " << sizeof(EidosValue_String) << std::endl; // std::cout << "sizeof(EidosValue_String_vector) == " << sizeof(EidosValue_String_vector) << std::endl; // std::cout << "sizeof(EidosValue_String_singleton) == " << sizeof(EidosValue_String_singleton) << std::endl; @@ -1117,44 +1115,91 @@ void Eidos_WarmUp(void) // Make the shared EidosASTNode pool gEidosASTNodePool = new EidosObjectPool("EidosObjectPool(EidosASTNode)", sizeof(EidosASTNode)); - // Allocate global permanents + // Allocate global permanents; the first five are fundamental, and get created as statics very early. + // The other constants are all created here, and should all be marked as constant here. gStaticEidosValueVOID = EidosValue_VOID::Static_EidosValue_VOID(); - gStaticEidosValueNULL = EidosValue_NULL::Static_EidosValue_NULL(); gStaticEidosValueNULLInvisible = EidosValue_NULL::Static_EidosValue_NULL_Invisible(); + gStaticEidosValue_LogicalT = EidosValue_Logical::Static_EidosValue_Logical_T(); + gStaticEidosValue_LogicalF = EidosValue_Logical::Static_EidosValue_Logical_F(); gStaticEidosValue_Logical_ZeroVec = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); + gStaticEidosValue_Logical_ZeroVec->MarkAsConstant(); + gStaticEidosValue_Integer_ZeroVec = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); + gStaticEidosValue_Integer_ZeroVec->MarkAsConstant(); + gStaticEidosValue_Float_ZeroVec = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - gStaticEidosValue_String_ZeroVec = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); + gStaticEidosValue_Float_ZeroVec->MarkAsConstant(); - gStaticEidosValue_LogicalT = EidosValue_Logical_const::Static_EidosValue_Logical_T(); - gStaticEidosValue_LogicalF = EidosValue_Logical_const::Static_EidosValue_Logical_F(); + gStaticEidosValue_String_ZeroVec = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); + gStaticEidosValue_String_ZeroVec->MarkAsConstant(); gStaticEidosValue_Integer0 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); + gStaticEidosValue_Integer0->MarkAsConstant(); + gStaticEidosValue_Integer1 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(1)); + gStaticEidosValue_Integer1->MarkAsConstant(); + gStaticEidosValue_Integer2 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(2)); + gStaticEidosValue_Integer2->MarkAsConstant(); + gStaticEidosValue_Integer3 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(3)); + gStaticEidosValue_Integer3->MarkAsConstant(); gStaticEidosValue_Float0 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0.0)); + gStaticEidosValue_Float0->MarkAsConstant(); + gStaticEidosValue_Float0Point5 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0.5)); + gStaticEidosValue_Float0Point5->MarkAsConstant(); + gStaticEidosValue_Float1 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(1.0)); + gStaticEidosValue_Float1->MarkAsConstant(); + gStaticEidosValue_Float10 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(10.0)); + gStaticEidosValue_Float10->MarkAsConstant(); + gStaticEidosValue_FloatINF = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::infinity())); + gStaticEidosValue_FloatINF->MarkAsConstant(); + gStaticEidosValue_FloatNAN = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::quiet_NaN())); + gStaticEidosValue_FloatNAN->MarkAsConstant(); + gStaticEidosValue_FloatE = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_E)); + gStaticEidosValue_FloatE->MarkAsConstant(); + gStaticEidosValue_FloatPI = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_PI)); + gStaticEidosValue_FloatPI->MarkAsConstant(); gStaticEidosValue_StringEmpty = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("")); + gStaticEidosValue_StringEmpty->MarkAsConstant(); + gStaticEidosValue_StringSpace = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(" ")); + gStaticEidosValue_StringSpace->MarkAsConstant(); + gStaticEidosValue_StringAsterisk = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("*")); + gStaticEidosValue_StringAsterisk->MarkAsConstant(); + gStaticEidosValue_StringDoubleAsterisk = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("**")); + gStaticEidosValue_StringDoubleAsterisk->MarkAsConstant(); + gStaticEidosValue_StringComma = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(",")); + gStaticEidosValue_StringComma->MarkAsConstant(); + gStaticEidosValue_StringPeriod = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(".")); + gStaticEidosValue_StringPeriod->MarkAsConstant(); + gStaticEidosValue_StringDoubleQuote = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("\"")); + gStaticEidosValue_StringDoubleQuote->MarkAsConstant(); + gStaticEidosValue_String_ECMAScript = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("ECMAScript")); + gStaticEidosValue_String_ECMAScript->MarkAsConstant(); + gStaticEidosValue_String_indices = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("indices")); + gStaticEidosValue_String_indices->MarkAsConstant(); + gStaticEidosValue_String_average = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("average")); + gStaticEidosValue_String_average->MarkAsConstant(); // Create the global class objects for all Eidos classes, from superclass to subclass // This breaks encapsulation, kind of, but it needs to be done here, in order, so that superclass objects exist, @@ -1170,6 +1215,7 @@ void Eidos_WarmUp(void) // This has to be allocated after gEidosObject_Class has been initialized above; the other global permanents must be initialized // before that point, however, since properties and method signatures may use some of those global permanent values gStaticEidosValue_Object_ZeroVec = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosObject_Class)); + gStaticEidosValue_Object_ZeroVec->MarkAsConstant(); // Set up the built-in function map, which is immutable EidosInterpreter::CacheBuiltInFunctionMap(); @@ -1287,6 +1333,7 @@ EidosValue_SP Eidos_ValueForCommandLineExpression(std::string &p_value_expressio EidosInterpreter interpreter(script, symbol_table, function_map, nullptr, std::cout, std::cerr); // we're at the command line, so we assume we're using stdout/stderr value = interpreter.EvaluateInterpreterBlock(false, true); // do not print output, return the last statement value + value->MarkAsConstant(); return value; } diff --git a/eidos/eidos_globals.h b/eidos/eidos_globals.h index 34e354929..ea2d37b43 100644 --- a/eidos/eidos_globals.h +++ b/eidos/eidos_globals.h @@ -1186,7 +1186,6 @@ class EidosValue; class EidosValue_VOID; class EidosValue_NULL; class EidosValue_Logical; -class EidosValue_Logical_const; class EidosValue_Int; class EidosValue_Int_singleton; class EidosValue_Int_vector; @@ -1228,7 +1227,6 @@ typedef Eidos_intrusive_ptr EidosValue_SP; typedef Eidos_intrusive_ptr EidosValue_VOID_SP; typedef Eidos_intrusive_ptr EidosValue_NULL_SP; typedef Eidos_intrusive_ptr EidosValue_Logical_SP; -typedef Eidos_intrusive_ptr EidosValue_Logical_const_SP; typedef Eidos_intrusive_ptr EidosValue_Int_SP; typedef Eidos_intrusive_ptr EidosValue_Int_singleton_SP; typedef Eidos_intrusive_ptr EidosValue_Int_vector_SP; diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 8bc8d1d02..d2bf7fbe5 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -577,6 +577,8 @@ void EidosInterpreter::_ProcessSubsetAssignment(EidosValue_SP *p_base_value_ptr, EidosValue_SP identifier_value_SP = global_symbols_->GetValueOrRaiseForASTNode_IsConst(p_parent_node, &identifier_is_const); EidosValue *identifier_value = identifier_value_SP.get(); + // Check for a constant symbol table. Note that _AssignRValueToLValue() will check for a constant EidosValue. + // The work of checking constness is divided between these methods for historical reasons. if (identifier_is_const) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_ProcessSubsetAssignment): identifier '" << EidosStringRegistry::StringForGlobalStringID(p_parent_node->cached_stringID_) << "' cannot be redefined because it is a constant." << EidosTerminate(nullptr); @@ -666,6 +668,11 @@ void EidosInterpreter::_AssignRValueToLValue(EidosValue_SP p_rvalue, const Eidos if (index_count == 0) return; + // Check for a constant value. Note that ProcessSubsetAssignment() already checked for a constant symbol table. + // The work of checking constness is divided between these methods for historical reasons. + if (base_value->IsConstant()) + EIDOS_TERMINATION << "ERROR (EidosInterpreter::_AssignRValueToLValue): value cannot be redefined because it is a constant." << EidosTerminate(nullptr); + // At this point, we have either a multiplex assignment of one value to (maybe) more than one index in a symbol host: x[5:10] = 10, when // (rvalue_count == 1), or a one-to-one assignment of values to indices in a symbol host: x[5:10] = 5:10, when (rvalue_count == index_count) // We handle them both together, as far as we can. BCH 12/21/2023: This used to be done with SetValueAtIndex(); that method has been removed. @@ -1064,7 +1071,10 @@ EidosValue_SP EidosInterpreter::Evaluate_RangeExpr(const EidosASTNode *p_node) // cache our range as a constant in the tree if we can if (cacheable) + { p_node->cached_range_value_ = result_SP; + p_node->cached_range_value_->MarkAsConstant(); + } } EIDOS_EXIT_EXECUTION_LOG("Evaluate_RangeExpr()"); @@ -3734,7 +3744,10 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) bool is_const; EidosValue_SP lvalue_SP = global_symbols_->GetValueOrRaiseForASTNode_IsConst(lvalue_node, &is_const); - if (is_const) + // Check for a constant value. If either the EidosValue or the table it comes from is constant, there is an error. + // (I'm not sure the check on constness of the EidosValue itself is correct, but I can't think of a way that that + // could be true here without the table also being a constants table anyway... being cautious until proved wrong...) + if (is_const || lvalue_SP->IsConstant()) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): identifier '" << lvalue_node->token_->token_string_ << "' cannot be redefined because it is a constant." << EidosTerminate(p_node->token_); EidosValue *lvalue = lvalue_SP.get(); diff --git a/eidos/eidos_script.cpp b/eidos/eidos_script.cpp index 7a48b69e2..477cc6545 100644 --- a/eidos/eidos_script.cpp +++ b/eidos/eidos_script.cpp @@ -2433,6 +2433,7 @@ EidosASTNode *EidosScript::Parse_DefaultValue(void) node->AddChild(numeric_node); node->cached_literal_value_ = negated_value; // cache the negated value for fast default argument processing + node->cached_literal_value_->MarkAsConstant(); } else { diff --git a/eidos/eidos_symbol_table.cpp b/eidos/eidos_symbol_table.cpp index 399fb7579..da779f63b 100644 --- a/eidos/eidos_symbol_table.cpp +++ b/eidos/eidos_symbol_table.cpp @@ -157,6 +157,12 @@ EidosSymbolTable::EidosSymbolTable(EidosSymbolTableType p_table_type, EidosSymbo eConstant = new EidosSymbolTableEntry(gEidosID_E, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_E))); infConstant = new EidosSymbolTableEntry(gEidosID_INF, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::infinity()))); nanConstant = new EidosSymbolTableEntry(gEidosID_NAN, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::quiet_NaN()))); + + // ensure that the constant_ flag is set on all of these values, to prevent modification in all code paths + piConstant->second->MarkAsConstant(); + eConstant->second->MarkAsConstant(); + infConstant->second->MarkAsConstant(); + nanConstant->second->MarkAsConstant(); } // We can use InitializeConstantSymbolEntry() here since we obey its requirements (see header) @@ -551,6 +557,9 @@ void EidosSymbolTable::DefineConstantForSymbol(EidosGlobalStringID p_symbol_name if ((p_value->UseCount() != 1) || p_value->Invisible()) p_value = p_value->CopyValues(); + // Now we have a private value, which we can mark as constant + p_value->MarkAsConstant(); + // Then ask the defined constants table to add the constant definedConstantsTable->InitializeConstantSymbolEntry(p_symbol_name, std::move(p_value)); } diff --git a/eidos/eidos_symbol_table.h b/eidos/eidos_symbol_table.h index 1efc268de..f71564651 100644 --- a/eidos/eidos_symbol_table.h +++ b/eidos/eidos_symbol_table.h @@ -60,7 +60,7 @@ class EidosTypeTable; extern EidosSymbolTable *gEidosConstantsSymbolTable; -// This is used by InitializeConstantSymbolEntry / ReinitializeConstantSymbolEntry for fast setup / teardown +// This is used by InitializeConstantSymbolEntry() for fast setup / teardown typedef std::pair EidosSymbolTableEntry; @@ -172,7 +172,8 @@ class EidosSymbolTable // Set as a global (raises if already defined as a constant); adds to the kGlobalVariablesTable, or raises if that does not exist void DefineGlobalForSymbol(EidosGlobalStringID p_symbol_name, EidosValue_SP p_value); - // Remove symbols; RemoveValueForSymbol() will raise if the symbol is a constant + // Remove symbols; RemoveValueForSymbol() will raise if the symbol is a constant. RemoveConstantForSymbol() is + // not used in Eidos itself, but SLiM uses it when script blocks, subpopulations, species, etc. cease to exist. inline __attribute__((always_inline)) void RemoveValueForSymbol(EidosGlobalStringID p_symbol_name) { _RemoveSymbol(p_symbol_name, false); } inline __attribute__((always_inline)) void RemoveConstantForSymbol(EidosGlobalStringID p_symbol_name) { _RemoveSymbol(p_symbol_name, true); } @@ -195,6 +196,17 @@ class EidosSymbolTable // has infinite lifespan, and (2) that the EidosValue passed in is not invisible and is thus suitable for // direct use in the symbol table; no copy will be made of the value. These are not general-purpose methods, // they are specifically for the very specialized init case of setting up a table with standard entries. + // + // Note that this method does *not* require that the value itself is marked as a constant, nor does this + // method mark it as such; this mechanism relies upon the table's designation as a constants table to + // enforce constness. This provides a small window through which the user could potentially modify a value + // in a constants table, if (a) the value is not marked as a constant, and (b) it is set directly in the + // table through these methods, rather than through DefineConstantForSymbol(). If it is possible to do, + // I have not yet found the way to do it, though, because assignment and subset-assignment both check that + // the symbol table for the variable being modified is not a constants table. If new methods are added + // that are also capable of modifying values in place, however, they will need to check the table type, + // not just the IsConstant() property of the value, which is not guaranteed to be set in all cases! See + // eidos_value.h for further discussion of how EidosValue constness is managed internally. inline __attribute__((always_inline)) void InitializeConstantSymbolEntry(EidosSymbolTableEntry &p_new_entry) { _InitializeConstantSymbolEntry(p_new_entry.first, p_new_entry.second); } inline __attribute__((always_inline)) void InitializeConstantSymbolEntry(EidosGlobalStringID p_symbol_name, EidosValue_SP p_value) { _InitializeConstantSymbolEntry(p_symbol_name, std::move(p_value)); } diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 469719ce4..1f30c0e51 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -321,7 +321,7 @@ int EidosValue::valueTrackingCount; std::vector EidosValue::valueTrackingVector; #endif -EidosValue::EidosValue(EidosValueType p_value_type, bool p_singleton) : intrusive_ref_count_(0), cached_type_(p_value_type), invisible_(false), is_singleton_(p_singleton), dim_(nullptr) +EidosValue::EidosValue(EidosValueType p_value_type, bool p_singleton) : intrusive_ref_count_(0), cached_type_(p_value_type), constant_(false), invisible_(false), is_singleton_(p_singleton), dim_(nullptr) { #ifdef EIDOS_TRACK_VALUE_ALLOCATION valueTrackingCount++; @@ -396,6 +396,7 @@ void EidosValue::RaiseForRetainReleaseViolation(void) const EidosValue_SP EidosValue::VectorBasedCopy(void) const { + // note that constness, invisibility, etc. do not get copied return CopyValues(); } @@ -425,6 +426,8 @@ bool EidosValue::MatchingDimensions(const EidosValue *p_value1, const EidosValue void EidosValue::_CopyDimensionsFromValue(const EidosValue *p_value) { + WILL_MODIFY(this); + int64_t *source_dims = p_value->dim_; // First check that the source's dimensions will work for us; we assume they work for the source, so rather than @@ -460,6 +463,8 @@ void EidosValue::_CopyDimensionsFromValue(const EidosValue *p_value) void EidosValue::SetDimensions(int64_t p_dim_count, const int64_t *p_dim_buffer) { + WILL_MODIFY(this); + if ((p_dim_count == 1) && !p_dim_buffer) { // Make the value a plain vector; throw out any dimensions we have. @@ -861,7 +866,9 @@ void EidosValue::PrintStructure(std::ostream &p_ostream, int max_values) const // this is a truly permanent constant object static EidosValue_VOID_SP static_void = EidosValue_VOID_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_VOID()); - static_void->invisible_ = true; // set every time, since we don't have a constructor to set invisibility + // set every time, since we don't have a constructor to set invisibility + static_void->SetInvisible(true); + static_void->MarkAsConstant(); return static_void; } @@ -923,6 +930,9 @@ void EidosValue_VOID::Sort(bool p_ascending) // this is a truly permanent constant object static EidosValue_NULL_SP static_null = EidosValue_NULL_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_NULL()); + // set every time, since we don't have a constructor to set invisibility + static_null->MarkAsConstant(); + return static_null; } @@ -931,7 +941,9 @@ void EidosValue_VOID::Sort(bool p_ascending) // this is a truly permanent constant object static EidosValue_NULL_SP static_null = EidosValue_NULL_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_NULL()); - static_null->invisible_ = true; // set every time, since we don't have a constructor to set invisibility + // set every time, since we don't have a constructor to set invisibility + static_null->SetInvisible(true); + static_null->MarkAsConstant(); return static_null; } @@ -973,6 +985,8 @@ EidosValue_SP EidosValue_NULL::NewMatchingType(void) const void EidosValue_NULL::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx) + WILL_MODIFY(this); + if (p_source_script_value.Type() == EidosValueType::kValueNULL) ; // NULL doesn't have values or indices, so this is a no-op else @@ -982,6 +996,8 @@ void EidosValue_NULL::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue void EidosValue_NULL::Sort(bool p_ascending) { #pragma unused(p_ascending) + WILL_MODIFY(this); + // nothing to do } @@ -1025,6 +1041,28 @@ EidosValue_Logical::EidosValue_Logical(const eidos_logical_t *p_values, size_t p set_logical_no_check(p_values[index], index); } +/* static */ EidosValue_Logical_SP EidosValue_Logical::Static_EidosValue_Logical_T(void) +{ + // this is a truly permanent constant object + static EidosValue_Logical_SP static_T = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(true)); + + // set every time, since we don't have a constructor to set invisibility + static_T->MarkAsConstant(); + + return static_T; +} + +/* static */ EidosValue_Logical_SP EidosValue_Logical::Static_EidosValue_Logical_F(void) +{ + // this is a truly permanent constant object + static EidosValue_Logical_SP static_F = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(false)); + + // set every time, since we don't have a constructor to set invisibility + static_F->MarkAsConstant(); + + return static_F; +} + const std::string &EidosValue_Logical::ElementType(void) const { return gEidosStr_logical; @@ -1098,6 +1136,7 @@ EidosValue_SP EidosValue_Logical::GetValueAtIndex(const int p_idx, const EidosTo EidosValue_SP EidosValue_Logical::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(values_, count_))->CopyDimensionsFromValue(this)); } @@ -1108,6 +1147,8 @@ EidosValue_SP EidosValue_Logical::NewMatchingType(void) const void EidosValue_Logical::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { + WILL_MODIFY(this); + if (p_source_script_value.Type() == EidosValueType::kValueLogical) push_logical(p_source_script_value.LogicalAtIndex_NOCAST(p_idx, p_blame_token)); else @@ -1116,6 +1157,8 @@ void EidosValue_Logical::PushValueFromIndexOfEidosValue(int p_idx, const EidosVa void EidosValue_Logical::Sort(bool p_ascending) { + WILL_MODIFY(this); + if (p_ascending) std::sort(values_, values_ + count_); else @@ -1124,6 +1167,8 @@ void EidosValue_Logical::Sort(bool p_ascending) EidosValue_Logical *EidosValue_Logical::reserve(size_t p_reserved_size) { + WILL_MODIFY(this); + if (p_reserved_size > capacity_) { values_ = (eidos_logical_t *)realloc(values_, p_reserved_size * sizeof(eidos_logical_t)); @@ -1138,6 +1183,8 @@ EidosValue_Logical *EidosValue_Logical::reserve(size_t p_reserved_size) EidosValue_Logical *EidosValue_Logical::resize_no_initialize(size_t p_new_size) { + WILL_MODIFY(this); + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size @@ -1146,6 +1193,8 @@ EidosValue_Logical *EidosValue_Logical::resize_no_initialize(size_t p_new_size) void EidosValue_Logical::expand(void) { + WILL_MODIFY(this); + if (capacity_ == 0) reserve(16); // if no reserve() call was made, start out with a bit of room else @@ -1154,6 +1203,8 @@ void EidosValue_Logical::expand(void) void EidosValue_Logical::erase_index(size_t p_index) { + WILL_MODIFY(this); + if (p_index >= count_) RaiseForRangeViolation(); @@ -1172,60 +1223,6 @@ void EidosValue_Logical::erase_index(size_t p_index) } } -// EidosValue_Logical_const -#pragma mark EidosValue_Logical_const - -EidosValue_Logical_const::EidosValue_Logical_const(eidos_logical_t p_bool1) : EidosValue_Logical(p_bool1) -{ - is_singleton_ = true; // because EidosValue_Logical has a different class structure from the other types, this has to be patched after construction; no harm done... -} - -EidosValue_Logical_const::~EidosValue_Logical_const(void) -{ - EIDOS_TERMINATION << "ERROR (EidosValue_Logical_const::~EidosValue_Logical_const): (internal error) global constant deallocated." << EidosTerminate(nullptr); -} - -/* static */ EidosValue_Logical_SP EidosValue_Logical_const::Static_EidosValue_Logical_T(void) -{ - // this is a truly permanent constant object - static EidosValue_Logical_const_SP static_T = EidosValue_Logical_const_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical_const(true)); - - return static_T; -} - -/* static */ EidosValue_Logical_SP EidosValue_Logical_const::Static_EidosValue_Logical_F(void) -{ - // this is a truly permanent constant object - static EidosValue_Logical_const_SP static_F = EidosValue_Logical_const_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical_const(false)); - - return static_F; -} - -EidosValue_SP EidosValue_Logical_const::VectorBasedCopy(void) const -{ - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(values_, count_))->CopyDimensionsFromValue(this)); // same as EidosValue_Logical::, but let's not rely on that -} - -void EidosValue_Logical_const::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_source_script_value) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical_const::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Logical_const is not modifiable." << EidosTerminate(p_blame_token); -} - -void EidosValue_Logical_const::Sort(bool p_ascending) -{ -#pragma unused(p_ascending) - EIDOS_TERMINATION << "ERROR (EidosValue_Logical_const::Sort): (internal error) EidosValue_Logical_const is not modifiable." << EidosTerminate(nullptr); -} - -void EidosValue_Logical_const::_CopyDimensionsFromValue(const EidosValue *p_value) -{ - if (p_value->DimensionCount() != 1) - { - EIDOS_TERMINATION << "ERROR (EidosValue_Logical_const::_CopyDimensionsFromValue): (internal error) EidosValue_Logical_const is not modifiable." << EidosTerminate(nullptr); - } -} - // // EidosValue_String @@ -1349,11 +1346,14 @@ EidosValue_SP EidosValue_String_vector::GetValueAtIndex(const int p_idx, const E EidosValue_SP EidosValue_String_vector::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(values_))->CopyDimensionsFromValue(this)); } void EidosValue_String_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { + WILL_MODIFY(this); + if (p_source_script_value.Type() == EidosValueType::kValueString) values_.emplace_back(p_source_script_value.StringAtIndex_NOCAST(p_idx, p_blame_token)); else @@ -1362,6 +1362,8 @@ void EidosValue_String_vector::PushValueFromIndexOfEidosValue(int p_idx, const E void EidosValue_String_vector::Sort(bool p_ascending) { + WILL_MODIFY(this); + // This will sort in parallel if the task is large enough (and we're running parallel) Eidos_ParallelSort(values_.data(), values_.size(), p_ascending); } @@ -1436,11 +1438,13 @@ EidosValue_SP EidosValue_String_singleton::GetValueAtIndex(const int p_idx, cons EidosValue_SP EidosValue_String_singleton::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(value_))->CopyDimensionsFromValue(this)); } EidosValue_SP EidosValue_String_singleton::VectorBasedCopy(void) const { + // note that constness, invisibility, etc. do not get copied EidosValue_String_vector_SP new_vec = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); new_vec->PushString(value_); @@ -1452,12 +1456,16 @@ EidosValue_SP EidosValue_String_singleton::VectorBasedCopy(void) const void EidosValue_String_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_String_singleton is not modifiable." << EidosTerminate(p_blame_token); } void EidosValue_String_singleton::Sort(bool p_ascending) { #pragma unused(p_ascending) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::Sort): (internal error) EidosValue_String_singleton is not modifiable." << EidosTerminate(nullptr); } @@ -1609,11 +1617,14 @@ EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const Eido EidosValue_SP EidosValue_Int_vector::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(values_, count_))->CopyDimensionsFromValue(this)); } void EidosValue_Int_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { + WILL_MODIFY(this); + if (p_source_script_value.Type() == EidosValueType::kValueInt) push_int(p_source_script_value.IntAtIndex_NOCAST(p_idx, p_blame_token)); else @@ -1622,12 +1633,16 @@ void EidosValue_Int_vector::PushValueFromIndexOfEidosValue(int p_idx, const Eido void EidosValue_Int_vector::Sort(bool p_ascending) { + WILL_MODIFY(this); + // This will sort in parallel if the task is large enough (and we're running parallel) Eidos_ParallelSort(values_, count_, p_ascending); } EidosValue_Int_vector *EidosValue_Int_vector::reserve(size_t p_reserved_size) { + WILL_MODIFY(this); + if (p_reserved_size > capacity_) { values_ = (int64_t *)realloc(values_, p_reserved_size * sizeof(int64_t)); @@ -1642,6 +1657,8 @@ EidosValue_Int_vector *EidosValue_Int_vector::reserve(size_t p_reserved_size) EidosValue_Int_vector *EidosValue_Int_vector::resize_no_initialize(size_t p_new_size) { + WILL_MODIFY(this); + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size @@ -1650,6 +1667,8 @@ EidosValue_Int_vector *EidosValue_Int_vector::resize_no_initialize(size_t p_new_ void EidosValue_Int_vector::expand(void) { + WILL_MODIFY(this); + if (capacity_ == 0) reserve(16); // if no reserve() call was made, start out with a bit of room else @@ -1658,6 +1677,8 @@ void EidosValue_Int_vector::expand(void) void EidosValue_Int_vector::erase_index(size_t p_index) { + WILL_MODIFY(this); + if (p_index >= count_) RaiseForRangeViolation(); @@ -1740,12 +1761,14 @@ EidosValue_SP EidosValue_Int_singleton::GetValueAtIndex(const int p_idx, const E EidosValue_SP EidosValue_Int_singleton::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(value_))->CopyDimensionsFromValue(this)); } EidosValue_SP EidosValue_Int_singleton::VectorBasedCopy(void) const { // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added + // note that constness, invisibility, etc. do not get copied EidosValue_Int_vector_SP new_vec = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); new_vec->push_int(value_); @@ -1757,12 +1780,16 @@ EidosValue_SP EidosValue_Int_singleton::VectorBasedCopy(void) const void EidosValue_Int_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(p_blame_token); } void EidosValue_Int_singleton::Sort(bool p_ascending) { #pragma unused(p_ascending) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::Sort): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(nullptr); } @@ -1906,11 +1933,14 @@ EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const Ei EidosValue_SP EidosValue_Float_vector::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(values_, count_))->CopyDimensionsFromValue(this)); } void EidosValue_Float_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { + WILL_MODIFY(this); + if (p_source_script_value.Type() == EidosValueType::kValueFloat) push_float(p_source_script_value.FloatAtIndex_NOCAST(p_idx, p_blame_token)); else @@ -1919,6 +1949,8 @@ void EidosValue_Float_vector::PushValueFromIndexOfEidosValue(int p_idx, const Ei void EidosValue_Float_vector::Sort(bool p_ascending) { + WILL_MODIFY(this); + // Unfortunately a custom comparator is needed to make the sort order with NANs match that of R if (p_ascending) Eidos_ParallelSort_Comparator(values_, count_, [](const double& a, const double& b) { return std::isnan(b) || (a < b); }); @@ -1928,6 +1960,8 @@ void EidosValue_Float_vector::Sort(bool p_ascending) EidosValue_Float_vector *EidosValue_Float_vector::reserve(size_t p_reserved_size) { + WILL_MODIFY(this); + if (p_reserved_size > capacity_) { values_ = (double *)realloc(values_, p_reserved_size * sizeof(double)); @@ -1942,6 +1976,8 @@ EidosValue_Float_vector *EidosValue_Float_vector::reserve(size_t p_reserved_size EidosValue_Float_vector *EidosValue_Float_vector::resize_no_initialize(size_t p_new_size) { + WILL_MODIFY(this); + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size @@ -1950,6 +1986,8 @@ EidosValue_Float_vector *EidosValue_Float_vector::resize_no_initialize(size_t p_ void EidosValue_Float_vector::expand(void) { + WILL_MODIFY(this); + if (capacity_ == 0) reserve(16); // if no reserve() call was made, start out with a bit of room else @@ -1958,6 +1996,8 @@ void EidosValue_Float_vector::expand(void) void EidosValue_Float_vector::erase_index(size_t p_index) { + WILL_MODIFY(this); + if (p_index >= count_) RaiseForRangeViolation(); @@ -2052,12 +2092,14 @@ EidosValue_SP EidosValue_Float_singleton::GetValueAtIndex(const int p_idx, const EidosValue_SP EidosValue_Float_singleton::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(value_))->CopyDimensionsFromValue(this)); } EidosValue_SP EidosValue_Float_singleton::VectorBasedCopy(void) const { // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added + // note that constness, invisibility, etc. do not get copied EidosValue_Float_vector_SP new_vec = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); new_vec->push_float(value_); @@ -2069,12 +2111,16 @@ EidosValue_SP EidosValue_Float_singleton::VectorBasedCopy(void) const void EidosValue_Float_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(p_blame_token); } void EidosValue_Float_singleton::Sort(bool p_ascending) { #pragma unused(p_ascending) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::Sort): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(nullptr); } @@ -2334,11 +2380,14 @@ EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const E EidosValue_SP EidosValue_Object_vector::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(*this))->CopyDimensionsFromValue(this)); } void EidosValue_Object_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { + WILL_MODIFY(this); + if (p_source_script_value.Type() == EidosValueType::kValueObject) push_object_element_CRR(p_source_script_value.ObjectElementAtIndex_NOCAST(p_idx, p_blame_token)); else @@ -2359,6 +2408,8 @@ static bool CompareStringObjectSortPairsDescending(const std::pair capacity_) { values_ = (EidosObject **)realloc(values_, p_reserved_size * sizeof(EidosObject *)); @@ -3052,6 +3107,8 @@ EidosValue_Object_vector *EidosValue_Object_vector::reserve(size_t p_reserved_si EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize(size_t p_new_size) { + WILL_MODIFY(this); + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees // deal with retain/release @@ -3083,6 +3140,8 @@ EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize(size_t EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize_RR(size_t p_new_size) { + WILL_MODIFY(this); + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size @@ -3092,6 +3151,8 @@ EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize_RR(size void EidosValue_Object_vector::expand(void) { + WILL_MODIFY(this); + if (capacity_ == 0) reserve(16); // if no reserve() call was made, start out with a bit of room else @@ -3100,6 +3161,8 @@ void EidosValue_Object_vector::expand(void) void EidosValue_Object_vector::erase_index(size_t p_index) { + WILL_MODIFY(this); + if (p_index >= count_) RaiseForRangeViolation(); @@ -3171,6 +3234,8 @@ EidosValue_SP EidosValue_Object_singleton::GetValueAtIndex(const int p_idx, cons void EidosValue_Object_singleton::SetValue(EidosObject *p_element) { + WILL_MODIFY(this); + DeclareClassFromElement(p_element); if (class_uses_retain_release_) @@ -3187,12 +3252,14 @@ void EidosValue_Object_singleton::SetValue(EidosObject *p_element) EidosValue_SP EidosValue_Object_singleton::CopyValues(void) const { + // note that constness, invisibility, etc. do not get copied return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(value_, Class()))->CopyDimensionsFromValue(this)); } EidosValue_SP EidosValue_Object_singleton::VectorBasedCopy(void) const { // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added + // note that constness, invisibility, etc. do not get copied EidosValue_Object_vector_SP new_vec = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(Class())); new_vec->push_object_element_CRR(value_); @@ -3204,6 +3271,8 @@ EidosValue_SP EidosValue_Object_singleton::VectorBasedCopy(void) const void EidosValue_Object_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { #pragma unused(p_idx, p_source_script_value) + WILL_MODIFY(this); + EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Object_singleton is not modifiable." << EidosTerminate(p_blame_token); } diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index c2c0fc133..544ff6639 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -150,6 +150,28 @@ bool CompareEidosValues(const EidosValue &p_value1, int p_index1, const EidosVal // this means that we see a significant speedup compared to std::vector when running an unoptimized // debugging build, which is a nice benefit for me, albeit with no impact for end users. + +// BCH 12/22/2023: Adding "constness" as a property of EidosValue, in preparation for other work that will +// need this. Note that the internal state of object elements is NOT const, just the EidosValue containing +// the object elements! There is no concept of "constness" for object elements themselves. Also, note that +// EidosSymbolTable has its own concept of "constness", in the form of tables that are considered constant; +// that is distinct from the constness of EidosValues, although there is often overlap. Yes, this is a bit +// confusing. We want to be able to set up things like pseudo-parameters as rapidly as possible (thus the +// concept of a "constants table"), but we also want EidosValue itself to have a concept of constness so +// that constant values like T, F, NULL, NAN, etc. are blocked from modification even if those values are +// found in a "variables table". Basically, if *either* condition is met - living in a constants table, or +// being marked as constant in the EidosValue - modification should be blocked in all code paths. +// +// This macro checks for modification of a constant EidosValue. It is active only in DEBUG builds, because +// it represents an internal error -- modification of a constant value should be blocked prior to this check +// in all code paths, so this is like an assert(), not the front-line defense. +#if DEBUG +#define WILL_MODIFY(x) if ((x)->constant_) RaiseForImmutabilityCall(); +#else +#define WILL_MODIFY(x) if ((x)->constant_) RaiseForImmutabilityCall(); +#endif + + class EidosValue { // This class has its assignment operator disabled, to prevent accidental copying. @@ -157,10 +179,11 @@ class EidosValue mutable uint32_t intrusive_ref_count_; // used by Eidos_intrusive_ptr - const EidosValueType cached_type_; // allows Type() to be an inline function; cached at construction - uint8_t invisible_; // as in R; if true, the value will not normally be printed to the console - uint8_t is_singleton_; // allows Count() and IsSingleton() to be inline; cached at construction - uint8_t registered_for_patching_; // used by EidosValue_Object, otherwise UNINITIALIZED; declared here for reasons of memory packing + const EidosValueType cached_type_; // allows Type() to be an inline function; cached at construction (uint8_t) + unsigned int constant_ : 1; // if set, this EidosValue is a constant and cannot be modified + unsigned int invisible_ : 1; // as in R; if true, the value will not normally be printed to the console + unsigned int is_singleton_ : 1; // allows Count() and IsSingleton() to be inline; cached at construction + unsigned int registered_for_patching_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; declared here for reasons of memory packing int64_t *dim_; // nullptr for vectors; points to a malloced, OWNED array of dimensions for matrices and arrays // when allocated, the first value in the buffer is a count of the dimensions that follow @@ -190,6 +213,10 @@ class EidosValue inline __attribute__((always_inline)) bool IsSingleton(void) const { return is_singleton_; } // true is the subclass is a singleton subclass (not just if Count()==1) inline __attribute__((always_inline)) int Count(void) const { return (is_singleton_ ? 1 : Count_Virtual()); } // avoid the virtual function call for singletons + // constness; note that the internal state of object elements is NOT const, just the EidosValue containing the object elements + inline __attribute__((always_inline)) void MarkAsConstant(void) { constant_ = true; } + inline __attribute__((always_inline)) bool IsConstant(void) const { return constant_; } + virtual const std::string &ElementType(void) const = 0; // the type of the elements contained by the vector void Print(std::ostream &p_ostream, const std::string &p_indent = std::string()) const; // standard printing; same as operator<< void PrintStructure(std::ostream &p_ostream, int max_values) const; // print structure; no newline @@ -198,7 +225,7 @@ class EidosValue // object invisibility; note invisibility should only be changed on uniquely owned objects, to avoid side effects inline __attribute__((always_inline)) bool Invisible(void) const { return invisible_; } - inline __attribute__((always_inline)) void SetInvisible(bool p_invisible) { invisible_ = p_invisible; } + inline __attribute__((always_inline)) void SetInvisible(bool p_invisible) { WILL_MODIFY(this); invisible_ = p_invisible; } // basic subscript access; abstract here since we want to force subclasses to define this virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const = 0; @@ -433,14 +460,9 @@ class EidosValue_NULL final : public EidosValue // // EidosValue_Logical represents logical (bool) values in Eidos. Unlike other EidosValue types, for // logical the EidosValue_Logical class itself is a non-abstract class that models a vector of logical -// values; there is no singleton version. There is a subclass, EidosValue_Logical_const, that is used -// by the two shared T and F EidosValues, gStaticEidosValue_LogicalT and gStaticEidosValue_LogicalF; -// it tries to enforce constness on those globals by making the virtual function LogicalData_Mutable(), -// which is used to get a mutable pointer to the eidos_logical_t data, raise, and by making other virtual -// functions that would modify the value raise as well. This is not entirely bullet-proof, since one -// could cast to EidosValue_Logical instead of using LogicalData_Mutable(), but you're not supposed -// to do that. EidosValue_Logical_const pretends to be a singleton class, by setting is_singleton_, -// but that is probably non-essential. +// values; there is no singleton version. This is because there are only two possible singleton values, +// T and F, represented by the global constants gStaticEidosValue_LogicalT and gStaticEidosValue_LogicalF; +// those should be used for singleton values when possible. // class EidosValue_Logical : public EidosValue @@ -453,7 +475,8 @@ class EidosValue_Logical : public EidosValue size_t count_ = 0, capacity_ = 0; protected: - explicit EidosValue_Logical(eidos_logical_t p_logical1); // protected to encourage use of EidosValue_Logical_const for this + // protected to encourage use of gStaticEidosValue_LogicalT / gStaticEidosValue_LogicalF + explicit EidosValue_Logical(eidos_logical_t p_logical1); virtual int Count_Virtual(void) const override { return (int)count_; } @@ -467,12 +490,15 @@ class EidosValue_Logical : public EidosValue explicit EidosValue_Logical(const eidos_logical_t *p_values, size_t p_count); inline virtual ~EidosValue_Logical(void) override { free(values_); } + static EidosValue_Logical_SP Static_EidosValue_Logical_T(void); + static EidosValue_Logical_SP Static_EidosValue_Logical_F(void); + virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; virtual const eidos_logical_t *LogicalData(void) const override { return values_; } - virtual eidos_logical_t *LogicalData_Mutable(void) override { return values_; } + virtual eidos_logical_t *LogicalData_Mutable(void) override { WILL_MODIFY(this); return values_; } virtual eidos_logical_t LogicalAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -494,14 +520,16 @@ class EidosValue_Logical : public EidosValue void expand(void); // expand to fit (at least) one new value void erase_index(size_t p_index); // a weak substitute for erase() - inline __attribute__((always_inline)) eidos_logical_t *data(void) { return values_; } + inline __attribute__((always_inline)) eidos_logical_t *data(void) { WILL_MODIFY(this); return values_; } inline __attribute__((always_inline)) const eidos_logical_t *data(void) const { return values_; } inline __attribute__((always_inline)) void push_logical(eidos_logical_t p_logical) { + WILL_MODIFY(this); if (count_ == capacity_) expand(); values_[count_++] = p_logical; } inline __attribute__((always_inline)) void push_logical_no_check(eidos_logical_t p_logical) { + WILL_MODIFY(this); #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -509,6 +537,7 @@ class EidosValue_Logical : public EidosValue values_[count_++] = p_logical; } inline __attribute__((always_inline)) void set_logical_no_check(eidos_logical_t p_logical, size_t p_index) { + WILL_MODIFY(this); #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -517,31 +546,6 @@ class EidosValue_Logical : public EidosValue } }; -class EidosValue_Logical_const final : public EidosValue_Logical -{ -private: - typedef EidosValue_Logical super; - -protected: - virtual void _CopyDimensionsFromValue(const EidosValue *p_value) override; -public: - EidosValue_Logical_const(const EidosValue_Logical_const &p_original) = delete; // no copy-construct - EidosValue_Logical_const(void) = delete; // no default constructor - EidosValue_Logical_const& operator=(const EidosValue_Logical_const&) = delete; // no copying - explicit EidosValue_Logical_const(eidos_logical_t p_logical1); - virtual ~EidosValue_Logical_const(void) override; // calls EidosTerminate() - - static EidosValue_Logical_SP Static_EidosValue_Logical_T(void); - static EidosValue_Logical_SP Static_EidosValue_Logical_F(void); - - virtual EidosValue_SP VectorBasedCopy(void) const override; - - // prohibited actions because this subclass represents only truly immutable objects - virtual eidos_logical_t *LogicalData_Mutable(void) override { RaiseForImmutabilityCall(); } - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; - virtual void Sort(bool p_ascending) override; -}; - #pragma mark - #pragma mark EidosValue_String @@ -609,11 +613,11 @@ class EidosValue_String_vector final : public EidosValue_String inline virtual ~EidosValue_String_vector(void) override { } virtual const std::string *StringData(void) const override { return values_.data(); } - virtual std::string *StringData_Mutable(void) override { return values_.data(); } - std::vector &StringVectorData(void) { return values_; } // to get the std::vector for direct modification + virtual std::string *StringData_Mutable(void) override { WILL_MODIFY(this); return values_.data(); } + std::vector &StringVectorData(void) { WILL_MODIFY(this); return values_; } // to get the std::vector for direct modification - inline __attribute__((always_inline)) void PushString(const std::string &p_string) { values_.emplace_back(p_string); } - inline __attribute__((always_inline)) EidosValue_String_vector *Reserve(int p_reserved_size) { values_.reserve(p_reserved_size); return this; } + inline __attribute__((always_inline)) void PushString(const std::string &p_string) { WILL_MODIFY(this); values_.emplace_back(p_string); } + inline __attribute__((always_inline)) EidosValue_String_vector *Reserve(int p_reserved_size) { WILL_MODIFY(this); values_.reserve(p_reserved_size); return this; } virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -648,11 +652,11 @@ class EidosValue_String_singleton final : public EidosValue_String explicit inline EidosValue_String_singleton(const std::string &p_string1) : EidosValue_String(true), value_(p_string1) { } inline virtual ~EidosValue_String_singleton(void) override { delete cached_script_; } - inline __attribute__((always_inline)) std::string &StringValue_Mutable(void) { delete cached_script_; cached_script_ = nullptr; return value_; } // very dangerous; do not use + inline __attribute__((always_inline)) std::string &StringValue_Mutable(void) { WILL_MODIFY(this); delete cached_script_; cached_script_ = nullptr; return value_; } // very dangerous; do not use virtual const std::string *StringData(void) const override { return &value_; } - virtual std::string *StringData_Mutable(void) override { delete cached_script_; cached_script_ = nullptr; return &value_; } // very dangerous; do not use - inline __attribute__((always_inline)) void SetValue(const std::string &p_string) { delete cached_script_; cached_script_ = nullptr; value_ = p_string; } // very dangerous; used only in Evaluate_For() + virtual std::string *StringData_Mutable(void) override { WILL_MODIFY(this); delete cached_script_; cached_script_ = nullptr; return &value_; } // very dangerous; do not use + inline __attribute__((always_inline)) void SetValue(const std::string &p_string) { WILL_MODIFY(this); delete cached_script_; cached_script_ = nullptr; value_ = p_string; } // very dangerous; used only in Evaluate_For() virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -742,7 +746,7 @@ class EidosValue_Int_vector final : public EidosValue_Int inline virtual ~EidosValue_Int_vector(void) override { free(values_); } virtual const int64_t *IntData(void) const override { return values_; } - virtual int64_t *IntData_Mutable(void) override { return values_; } + virtual int64_t *IntData_Mutable(void) override { WILL_MODIFY(this); return values_; } virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast @@ -764,14 +768,16 @@ class EidosValue_Int_vector final : public EidosValue_Int void expand(void); // expand to fit (at least) one new value void erase_index(size_t p_index); // a weak substitute for erase() - inline __attribute__((always_inline)) int64_t *data(void) { return values_; } + inline __attribute__((always_inline)) int64_t *data(void) { WILL_MODIFY(this); return values_; } inline __attribute__((always_inline)) const int64_t *data(void) const { return values_; } inline __attribute__((always_inline)) void push_int(int64_t p_int) { + WILL_MODIFY(this); if (count_ == capacity_) expand(); values_[count_++] = p_int; } inline __attribute__((always_inline)) void push_int_no_check(int64_t p_int) { + WILL_MODIFY(this); #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -779,6 +785,7 @@ class EidosValue_Int_vector final : public EidosValue_Int values_[count_++] = p_int; } inline __attribute__((always_inline)) void set_int_no_check(int64_t p_int, size_t p_index) { + WILL_MODIFY(this); #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -805,8 +812,8 @@ class EidosValue_Int_singleton final : public EidosValue_Int inline virtual ~EidosValue_Int_singleton(void) override { } virtual const int64_t *IntData(void) const override { return &value_; } - virtual int64_t *IntData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() - inline __attribute__((always_inline)) void SetValue(int64_t p_int) { value_ = p_int; } // very dangerous; used only in Evaluate_For() + virtual int64_t *IntData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; used only in Evaluate_Assign() + inline __attribute__((always_inline)) void SetValue(int64_t p_int) { WILL_MODIFY(this); value_ = p_int; } // very dangerous; used only in Evaluate_For() virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast @@ -890,7 +897,7 @@ class EidosValue_Float_vector final : public EidosValue_Float inline virtual ~EidosValue_Float_vector(void) override { free(values_); } virtual const double *FloatData(void) const override { return values_; } - virtual double *FloatData_Mutable(void) override { return values_; } + virtual double *FloatData_Mutable(void) override { WILL_MODIFY(this); return values_; } virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast @@ -912,14 +919,16 @@ class EidosValue_Float_vector final : public EidosValue_Float void expand(void); // expand to fit (at least) one new value void erase_index(size_t p_index); // a weak substitute for erase() - inline __attribute__((always_inline)) double *data(void) { return values_; } + inline __attribute__((always_inline)) double *data(void) { WILL_MODIFY(this); return values_; } inline __attribute__((always_inline)) const double *data(void) const { return values_; } inline __attribute__((always_inline)) void push_float(double p_float) { + WILL_MODIFY(this); if (count_ == capacity_) expand(); values_[count_++] = p_float; } inline __attribute__((always_inline)) void push_float_no_check(double p_float) { + WILL_MODIFY(this); #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -927,6 +936,7 @@ class EidosValue_Float_vector final : public EidosValue_Float values_[count_++] = p_float; } inline __attribute__((always_inline)) void set_float_no_check(double p_float, size_t p_index) { + WILL_MODIFY(this); #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -953,8 +963,8 @@ class EidosValue_Float_singleton final : public EidosValue_Float inline virtual ~EidosValue_Float_singleton(void) override { } virtual const double *FloatData(void) const override { return &value_; } - virtual double *FloatData_Mutable(void) override { return &value_; } // very dangerous; used only in Evaluate_Assign() - inline __attribute__((always_inline)) void SetValue(double p_float) { value_ = p_float; } // very dangerous; used only in Evaluate_For() + virtual double *FloatData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; used only in Evaluate_Assign() + inline __attribute__((always_inline)) void SetValue(double p_float) { WILL_MODIFY(this); value_ = p_float; } // very dangerous; used only in Evaluate_For() virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast @@ -1016,6 +1026,8 @@ class EidosValue_Object : public EidosValue // check the type of a new element being added to an EidosValue_Object, and update class_uses_retain_release_ inline __attribute__((always_inline)) void DeclareClassFromElement(const EidosObject *p_element, bool p_undeclared_is_error = false) { + WILL_MODIFY(this); + // no check that p_element is non-null; that should always be the case, and we don't // want to waste the time - a crash is fine if this invariant is not satisfied const EidosClass *element_class = p_element->Class(); @@ -1087,7 +1099,7 @@ class EidosValue_Object_vector final : public EidosValue_Object virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosObject * const *ObjectData(void) const override { return values_; } - virtual EidosObject **ObjectData_Mutable(void) override { return values_; } + virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return values_; } virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; @@ -1114,7 +1126,7 @@ class EidosValue_Object_vector final : public EidosValue_Object void expand(void); // expand to fit (at least) one new value void erase_index(size_t p_index); // a weak substitute for erase() - inline __attribute__((always_inline)) EidosObject **data(void) { return values_; } // the accessors below should be used to modify, since they handle Retain()/Release() + inline __attribute__((always_inline)) EidosObject **data(void) { WILL_MODIFY(this); return values_; } // the accessors below should be used to modify, since they handle Retain()/Release() inline __attribute__((always_inline)) EidosObject * const *data(void) const { return values_; } // fast accessors; you can use the _RR or _NORR versions in a tight loop to avoid overhead, when you know @@ -1139,6 +1151,8 @@ class EidosValue_Object_vector final : public EidosValue_Object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_CRR(EidosObject *p_object) { + WILL_MODIFY(this); + if (count_ == capacity_) expand(); @@ -1152,6 +1166,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_RR(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (!class_uses_retain_release_) RaiseForRetainReleaseViolation(); @@ -1169,6 +1185,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_NORR(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (class_uses_retain_release_) RaiseForRetainReleaseViolation(); @@ -1184,6 +1202,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_capcheck_NORR(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors DeclareClassFromElement(p_object, true); // require a prior matching declaration @@ -1198,6 +1218,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_CRR(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -1212,6 +1234,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_RR(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -1226,6 +1250,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_NORR(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -1238,6 +1264,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_already_retained(EidosObject *p_object) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (count_ == capacity_) RaiseForCapacityViolation(); @@ -1250,6 +1278,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -1269,6 +1299,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_RR(EidosObject *p_object, size_t p_index) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -1286,6 +1318,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -1301,6 +1335,8 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= count_) RaiseForRangeViolation(); @@ -1335,7 +1371,7 @@ class EidosValue_Object_singleton final : public EidosValue_Object virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosObject * const *ObjectData(void) const override { return &value_; } - virtual EidosObject **ObjectData_Mutable(void) override { return &value_; } // very dangerous; do not use + virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; do not use void SetValue(EidosObject *p_element); // very dangerous; used only in Evaluate_For() virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; @@ -1363,6 +1399,8 @@ class EidosValue_Object_singleton final : public EidosValue_Object inline __attribute__((always_inline)) void EidosValue_Object_singleton::set_object_element_no_check_CRR(EidosObject *p_object, __attribute__((unused)) size_t p_index) { + WILL_MODIFY(this); + #if DEBUG // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors if (p_index >= 1) RaiseForRangeViolation(); From af4c97bd462ce0629ec786b3a759475add74be9b Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Fri, 22 Dec 2023 21:19:51 -0500 Subject: [PATCH 11/18] standardize EidosValue constant creation --- eidos/eidos_globals.cpp | 24 ++++++++++++----- eidos/eidos_value.cpp | 57 ----------------------------------------- eidos/eidos_value.h | 8 ------ 3 files changed, 17 insertions(+), 72 deletions(-) diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index 50e33b716..be217314f 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1115,13 +1115,23 @@ void Eidos_WarmUp(void) // Make the shared EidosASTNode pool gEidosASTNodePool = new EidosObjectPool("EidosObjectPool(EidosASTNode)", sizeof(EidosASTNode)); - // Allocate global permanents; the first five are fundamental, and get created as statics very early. - // The other constants are all created here, and should all be marked as constant here. - gStaticEidosValueVOID = EidosValue_VOID::Static_EidosValue_VOID(); - gStaticEidosValueNULL = EidosValue_NULL::Static_EidosValue_NULL(); - gStaticEidosValueNULLInvisible = EidosValue_NULL::Static_EidosValue_NULL_Invisible(); - gStaticEidosValue_LogicalT = EidosValue_Logical::Static_EidosValue_Logical_T(); - gStaticEidosValue_LogicalF = EidosValue_Logical::Static_EidosValue_Logical_F(); + // Allocate global permanents. All of these constants should be marked as constant here. + gStaticEidosValueVOID = EidosValue_VOID_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_VOID()); + gStaticEidosValueVOID->SetInvisible(true); + gStaticEidosValueVOID->MarkAsConstant(); + + gStaticEidosValueNULL = EidosValue_NULL_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_NULL()); + gStaticEidosValueNULL->MarkAsConstant(); + + gStaticEidosValueNULLInvisible = EidosValue_NULL_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_NULL()); + gStaticEidosValueNULLInvisible->SetInvisible(true); + gStaticEidosValueNULLInvisible->MarkAsConstant(); + + gStaticEidosValue_LogicalT = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical({true})); + gStaticEidosValue_LogicalT->MarkAsConstant(); + + gStaticEidosValue_LogicalF = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical({false})); + gStaticEidosValue_LogicalF->MarkAsConstant(); gStaticEidosValue_Logical_ZeroVec = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); gStaticEidosValue_Logical_ZeroVec->MarkAsConstant(); diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 1f30c0e51..bf8d04d54 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -861,18 +861,6 @@ void EidosValue::PrintStructure(std::ostream &p_ostream, int max_values) const #pragma mark EidosValue_VOID #pragma mark - -/* static */ EidosValue_VOID_SP EidosValue_VOID::Static_EidosValue_VOID(void) -{ - // this is a truly permanent constant object - static EidosValue_VOID_SP static_void = EidosValue_VOID_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_VOID()); - - // set every time, since we don't have a constructor to set invisibility - static_void->SetInvisible(true); - static_void->MarkAsConstant(); - - return static_void; -} - const std::string &EidosValue_VOID::ElementType(void) const { return gEidosStr_void; @@ -925,29 +913,6 @@ void EidosValue_VOID::Sort(bool p_ascending) #pragma mark EidosValue_NULL #pragma mark - -/* static */ EidosValue_NULL_SP EidosValue_NULL::Static_EidosValue_NULL(void) -{ - // this is a truly permanent constant object - static EidosValue_NULL_SP static_null = EidosValue_NULL_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_NULL()); - - // set every time, since we don't have a constructor to set invisibility - static_null->MarkAsConstant(); - - return static_null; -} - -/* static */ EidosValue_NULL_SP EidosValue_NULL::Static_EidosValue_NULL_Invisible(void) -{ - // this is a truly permanent constant object - static EidosValue_NULL_SP static_null = EidosValue_NULL_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_NULL()); - - // set every time, since we don't have a constructor to set invisibility - static_null->SetInvisible(true); - static_null->MarkAsConstant(); - - return static_null; -} - const std::string &EidosValue_NULL::ElementType(void) const { return gEidosStr_NULL; @@ -1041,28 +1006,6 @@ EidosValue_Logical::EidosValue_Logical(const eidos_logical_t *p_values, size_t p set_logical_no_check(p_values[index], index); } -/* static */ EidosValue_Logical_SP EidosValue_Logical::Static_EidosValue_Logical_T(void) -{ - // this is a truly permanent constant object - static EidosValue_Logical_SP static_T = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(true)); - - // set every time, since we don't have a constructor to set invisibility - static_T->MarkAsConstant(); - - return static_T; -} - -/* static */ EidosValue_Logical_SP EidosValue_Logical::Static_EidosValue_Logical_F(void) -{ - // this is a truly permanent constant object - static EidosValue_Logical_SP static_F = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical(false)); - - // set every time, since we don't have a constructor to set invisibility - static_F->MarkAsConstant(); - - return static_F; -} - const std::string &EidosValue_Logical::ElementType(void) const { return gEidosStr_logical; diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 544ff6639..f2f3e0bd6 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -396,8 +396,6 @@ class EidosValue_VOID final : public EidosValue inline EidosValue_VOID(void) : EidosValue(EidosValueType::kValueVOID, false) { } inline virtual ~EidosValue_VOID(void) override { } - static EidosValue_VOID_SP Static_EidosValue_VOID(void); - virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; @@ -436,9 +434,6 @@ class EidosValue_NULL final : public EidosValue inline EidosValue_NULL(void) : EidosValue(EidosValueType::kValueNULL, false) { } inline virtual ~EidosValue_NULL(void) override { } - static EidosValue_NULL_SP Static_EidosValue_NULL(void); - static EidosValue_NULL_SP Static_EidosValue_NULL_Invisible(void); - virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; @@ -490,9 +485,6 @@ class EidosValue_Logical : public EidosValue explicit EidosValue_Logical(const eidos_logical_t *p_values, size_t p_count); inline virtual ~EidosValue_Logical(void) override { free(values_); } - static EidosValue_Logical_SP Static_EidosValue_Logical_T(void); - static EidosValue_Logical_SP Static_EidosValue_Logical_F(void); - virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; From b85248c84a352e9b78e87c1ee0d0b2664336691f Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 10:59:19 -0500 Subject: [PATCH 12/18] abolish the singleton/vector distinction for EidosValue_Float --- core/chromosome.cpp | 40 ++-- core/community_eidos.cpp | 2 +- core/genome.cpp | 2 +- core/genomic_element_type.cpp | 6 +- core/genomic_element_type.h | 4 +- core/individual.cpp | 48 ++--- core/interaction_type.cpp | 38 ++-- core/log_file.cpp | 4 +- core/mutation.cpp | 4 +- core/mutation_type.cpp | 12 +- core/population.cpp | 10 +- core/slim_functions.cpp | 10 +- core/spatial_map.cpp | 31 ++- core/species.cpp | 4 +- core/species_eidos.cpp | 2 +- core/subpopulation.cpp | 46 ++-- core/substitution.cpp | 4 +- eidos/eidos_class_DataFrame.cpp | 2 +- eidos/eidos_class_Dictionary.cpp | 4 +- eidos/eidos_class_Image.cpp | 4 +- eidos/eidos_functions.cpp | 14 +- eidos/eidos_functions_colors.cpp | 8 +- eidos/eidos_functions_distributions.cpp | 96 ++++----- eidos/eidos_functions_math.cpp | 128 +++++------ eidos/eidos_functions_matrices.cpp | 12 +- eidos/eidos_functions_other.cpp | 10 +- eidos/eidos_functions_stats.cpp | 30 +-- eidos/eidos_functions_values.cpp | 28 +-- eidos/eidos_globals.cpp | 22 +- eidos/eidos_globals.h | 4 - eidos/eidos_interpreter.cpp | 108 +++++----- eidos/eidos_script.cpp | 2 +- eidos/eidos_symbol_table.cpp | 8 +- eidos/eidos_test.cpp | 4 +- eidos/eidos_value.cpp | 276 ++++++++---------------- eidos/eidos_value.h | 132 ++++-------- 36 files changed, 497 insertions(+), 662 deletions(-) diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 5a6f569c3..daa470df2 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -1013,7 +1013,7 @@ MutationIndex Chromosome::DrawNewMutationExtended(std::pairCount(); if (mm_count == 16) @@ -1615,7 +1615,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliers is only defined in nucleotide-based models." << EidosTerminate(); if (!single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliers is not defined since sex-specific hotspot maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(hotspot_multipliers_H_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(hotspot_multipliers_H_)); } case gID_hotspotMultipliersM: { @@ -1623,7 +1623,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersM is only defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersM is not defined since sex-specific hotspot maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(hotspot_multipliers_M_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(hotspot_multipliers_M_)); } case gID_hotspotMultipliersF: { @@ -1631,7 +1631,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersF is only defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersF is not defined since sex-specific hotspot maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(hotspot_multipliers_F_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(hotspot_multipliers_F_)); } case gID_mutationEndPositions: @@ -1665,7 +1665,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRates is not defined in nucleotide-based models." << EidosTerminate(); if (!single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRates is not defined since sex-specific mutation rate maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_rates_H_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_rates_H_)); } case gID_mutationRatesM: { @@ -1673,7 +1673,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesM is not defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesM is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_rates_M_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_rates_M_)); } case gID_mutationRatesF: { @@ -1681,7 +1681,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesF is not defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesF is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_rates_F_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_rates_F_)); } case gID_overallMutationRate: @@ -1690,7 +1690,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRate is not defined in nucleotide-based models." << EidosTerminate(); if (!single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRate is not defined since sex-specific mutation rate maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_mutation_rate_H_userlevel_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_mutation_rate_H_userlevel_)); } case gID_overallMutationRateM: { @@ -1698,7 +1698,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateM is not defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateM is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_mutation_rate_M_userlevel_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_mutation_rate_M_userlevel_)); } case gID_overallMutationRateF: { @@ -1706,26 +1706,26 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateF is not defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateF is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_mutation_rate_F_userlevel_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_mutation_rate_F_userlevel_)); } case gID_overallRecombinationRate: { if (!single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallRecombinationRate is not defined since sex-specific recombination rate maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_recombination_rate_H_userlevel_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_recombination_rate_H_userlevel_)); } case gID_overallRecombinationRateM: { if (single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallRecombinationRateM is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_recombination_rate_M_userlevel_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_recombination_rate_M_userlevel_)); } case gID_overallRecombinationRateF: { if (single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallRecombinationRateF is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_recombination_rate_F_userlevel_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_recombination_rate_F_userlevel_)); } case gID_recombinationEndPositions: @@ -1751,19 +1751,19 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) { if (!single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationRates is not defined since sex-specific recombination rate maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(recombination_rates_H_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(recombination_rates_H_)); } case gID_recombinationRatesM: { if (single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationRatesM is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(recombination_rates_M_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(recombination_rates_M_)); } case gID_recombinationRatesF: { if (single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationRatesF is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(recombination_rates_F_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(recombination_rates_F_)); } case gID_species: @@ -1780,25 +1780,25 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) { if (!using_DSB_model_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionGCBias is not defined since the DSB recombination model is not being used." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(mismatch_repair_bias_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mismatch_repair_bias_)); } case gID_geneConversionNonCrossoverFraction: { if (!using_DSB_model_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionNonCrossoverFraction is not defined since the DSB recombination model is not being used." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(non_crossover_fraction_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(non_crossover_fraction_)); } case gID_geneConversionMeanLength: { if (!using_DSB_model_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionMeanLength is not defined since the DSB recombination model is not being used." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gene_conversion_avg_length_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gene_conversion_avg_length_)); } case gID_geneConversionSimpleConversionFraction: { if (!using_DSB_model_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionSimpleConversionFraction is not defined since the DSB recombination model is not being used." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(simple_conversion_fraction_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(simple_conversion_fraction_)); } case gID_tag: { diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index bafc66861..fcbe7a8c9 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -1412,7 +1412,7 @@ EidosValue_SP Community::ExecuteMethod_usage(EidosGlobalStringID p_method_id, co size_t usage = usage_community.totalMemoryUsage + usage_all_species.totalMemoryUsage; double usage_MB = usage / (1024.0 * 1024.0); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(usage_MB)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(usage_MB)); return result_SP; } diff --git a/core/genome.cpp b/core/genome.cpp index c03a16689..a310a56e6 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -1282,7 +1282,7 @@ EidosValue_SP Genome::ExecuteMethod_sumOfMutationsOfType(EidosGlobalStringID p_m } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(selcoeff_sum)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selcoeff_sum)); } // print the sample represented by genomes, using SLiM's own format diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index f7c193d27..88726292b 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -109,7 +109,7 @@ MutationType *GenomicElementType::DrawMutationType(void) const return mutation_type_ptrs_[gsl_ran_discrete(rng, lookup_mutation_type_)]; } -void GenomicElementType::SetNucleotideMutationMatrix(const EidosValue_Float_vector_SP &p_mutation_matrix) +void GenomicElementType::SetNucleotideMutationMatrix(const EidosValue_Float_SP &p_mutation_matrix) { mutation_matrix_ = p_mutation_matrix; @@ -269,7 +269,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) } case gID_mutationFractions: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_fractions_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_fractions_)); } case gID_mutationMatrix: { @@ -432,7 +432,7 @@ EidosValue_SP GenomicElementType::ExecuteMethod_setMutationMatrix(EidosGlobalStr EidosValue *mutationMatrix_value = p_arguments[0].get(); - SetNucleotideMutationMatrix(EidosValue_Float_vector_SP((EidosValue_Float_vector *)(mutationMatrix_value))); + SetNucleotideMutationMatrix(EidosValue_Float_SP((EidosValue_Float *)(mutationMatrix_value))); // the change to the mutation matrix means everything downstream has to be recached species_.CacheNucleotideMatrices(); diff --git a/core/genomic_element_type.h b/core/genomic_element_type.h index 3b3d6522f..7605c6f2d 100644 --- a/core/genomic_element_type.h +++ b/core/genomic_element_type.h @@ -71,7 +71,7 @@ class GenomicElementType : public EidosDictionaryUnretained slim_usertag_t tag_value_ = SLIM_TAG_UNSET_VALUE; // a user-defined tag value - EidosValue_Float_vector_SP mutation_matrix_; // in nucleotide-based models only, the 4x4 or 64x4 float mutation matrix + EidosValue_Float_SP mutation_matrix_; // in nucleotide-based models only, the 4x4 or 64x4 float mutation matrix double *mm_thresholds = nullptr; // mutation matrix threshold values for determining derived nucleotides; cached in CacheNucleotideMatrices() GenomicElementType(const GenomicElementType&) = delete; // no copying @@ -83,7 +83,7 @@ class GenomicElementType : public EidosDictionaryUnretained void InitializeDraws(void); // reinitialize our mutation-type lookup after changing our mutation type or proportions MutationType *DrawMutationType(void) const; // draw a mutation type from the distribution for this genomic element type - void SetNucleotideMutationMatrix(const EidosValue_Float_vector_SP &p_mutation_matrix); + void SetNucleotideMutationMatrix(const EidosValue_Float_SP &p_mutation_matrix); // diff --git a/core/individual.cpp b/core/individual.cpp index 1700cad8d..2738de857 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -428,7 +428,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (mean_parent_age_ == -1) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property meanParentAge is not available in WF models." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(mean_parent_age_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mean_parent_age_)); } case gID_pedigreeID: // ACCELERATED { @@ -479,11 +479,11 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) case 0: EIDOS_TERMINATION << "ERROR (Individual::GetProperty): position cannot be accessed in non-spatial simulations." << EidosTerminate(); case 1: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(spatial_x_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(spatial_x_)); case 2: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{spatial_x_, spatial_y_}); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{spatial_x_, spatial_y_}); case 3: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{spatial_x_, spatial_y_, spatial_z_}); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{spatial_x_, spatial_y_, spatial_z_}); default: return gStaticEidosValueNULL; // never hit; here to make the compiler happy } @@ -640,7 +640,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (tagF_value == SLIM_TAGF_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property tagF accessed on individual before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(tagF_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(tagF_value)); } case gID_tagL0: // ACCELERATED { @@ -678,38 +678,38 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) } case gID_fitnessScaling: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fitness_scaling_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(fitness_scaling_)); } case gEidosID_x: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(spatial_x_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(spatial_x_)); } case gEidosID_y: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(spatial_y_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(spatial_y_)); } case gEidosID_z: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(spatial_z_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(spatial_z_)); } // These properties are presently undocumented, used for testing purposes, but maybe they are useful to others? // They provide x/y/z as pairs or a triplet, whether the model is spatial or not, regardless of dimensionality case gEidosID_xy: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector({spatial_x_, spatial_y_})); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float({spatial_x_, spatial_y_})); } case gEidosID_xz: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector({spatial_x_, spatial_z_})); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float({spatial_x_, spatial_z_})); } case gEidosID_yz: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector({spatial_y_, spatial_z_})); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float({spatial_y_, spatial_z_})); } case gEidosID_xyz: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector({spatial_x_, spatial_y_, spatial_z_})); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float({spatial_x_, spatial_y_, spatial_z_})); } // all others, including gID_none @@ -813,7 +813,7 @@ EidosValue *Individual::GetProperty_Accelerated_reproductiveOutput(EidosObject * EidosValue *Individual::GetProperty_Accelerated_tagF(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -930,7 +930,7 @@ EidosValue *Individual::GetProperty_Accelerated_migrant(EidosObject **p_values, EidosValue *Individual::GetProperty_Accelerated_fitnessScaling(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -944,7 +944,7 @@ EidosValue *Individual::GetProperty_Accelerated_fitnessScaling(EidosObject **p_v EidosValue *Individual::GetProperty_Accelerated_x(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -958,7 +958,7 @@ EidosValue *Individual::GetProperty_Accelerated_x(EidosObject **p_values, size_t EidosValue *Individual::GetProperty_Accelerated_y(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -972,7 +972,7 @@ EidosValue *Individual::GetProperty_Accelerated_y(EidosObject **p_values, size_t EidosValue *Individual::GetProperty_Accelerated_z(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -987,7 +987,7 @@ EidosValue *Individual::GetProperty_Accelerated_z(EidosObject **p_values, size_t EidosValue *Individual::GetProperty_Accelerated_spatialPosition(EidosObject **p_values, size_t p_values_size) { Species *consensus_species = Community::SpeciesForIndividualsVector((Individual **)p_values, (int)p_values_size); - EidosValue_Float_vector *float_result; + EidosValue_Float *float_result; if (consensus_species) { @@ -997,7 +997,7 @@ EidosValue *Individual::GetProperty_Accelerated_spatialPosition(EidosObject **p_ if (dimensionality == 0) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): position cannot be accessed in non-spatial simulations." << EidosTerminate(); - float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size * dimensionality); + float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size * dimensionality); if (dimensionality == 1) { @@ -1035,7 +1035,7 @@ EidosValue *Individual::GetProperty_Accelerated_spatialPosition(EidosObject **p_ { // Mixed-species group, so we have to figure out the dimensionality for each individual separately // FIXME: Do we really want to allow this? seems crazy - how would the user actually use this? - float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); + float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1782,11 +1782,11 @@ EidosValue_SP Individual::ExecuteMethod_relatedness(EidosGlobalStringID p_method else relatedness = (ind == this) ? 1.0 : 0.0; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(relatedness)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(relatedness)); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(individuals_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(individuals_count); if (pedigree_tracking_enabled) { @@ -1903,7 +1903,7 @@ EidosValue_SP Individual::ExecuteMethod_Accelerated_sumOfMutationsOfType(EidosOb // Count the number of mutations of the given type Mutation *mut_block_ptr = gSLiM_Mutation_Block; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_elements_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_elements_size); EIDOS_THREAD_COUNT(gEidos_OMP_threads_SUM_OF_MUTS_OF_TYPE); #pragma omp parallel for schedule(dynamic, 1) default(none) shared(p_elements_size) firstprivate(p_elements, mut_block_ptr, mutation_type_ptr, float_result) if(p_elements_size >= EIDOS_OMPMIN_SUM_OF_MUTS_OF_TYPE) num_threads(thread_count) diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 5e91630cb..660248454 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -1330,8 +1330,8 @@ double InteractionType::ApplyInteractionCallbacks(Individual *p_receiver, Indivi else { // local variables for the callback parameters that we might need to allocate here, and thus need to free below - EidosValue_Float_singleton local_distance(p_distance); - EidosValue_Float_singleton local_strength(p_strength); + EidosValue_Float local_distance(p_distance); + EidosValue_Float local_strength(p_strength); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table { @@ -3496,7 +3496,7 @@ EidosValue_SP InteractionType::GetProperty(EidosGlobalStringID p_property_id) // variables case gID_maxDistance: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(max_distance_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(max_distance_)); case gID_tag: // ACCELERATED { slim_usertag_t tag_value = tag_value_; @@ -3669,7 +3669,7 @@ EidosValue_SP InteractionType::ExecuteMethod_clippedIntegral(EidosGlobalStringID else // (spatiality_ == 3) integral = 0.0; // FIXME - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(integral)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(integral)); } else { @@ -3693,7 +3693,7 @@ EidosValue_SP InteractionType::ExecuteMethod_clippedIntegral(EidosGlobalStringID // We do not try to create a singleton return value when passed a singleton receiver; too complicated to optimize for that here const Individual * const *receivers_data = (Individual * const *)receivers_value->ObjectData(); InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receivers_data[0]->subpopulation_); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(receivers_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(receivers_count); // Now treat cases according to spatiality bool saw_error1 = false, saw_error2 = false; @@ -3971,7 +3971,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distance(EidosGlobalStringID p_meth if (exerters_value_NULL) { // NULL means return distances from receiver (which must be singleton) to all individuals in its subpopulation - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerter_subpop_size); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerter_subpop_size); if (periodicity_enabled) { @@ -3997,7 +3997,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distance(EidosGlobalStringID p_meth else { // Otherwise, individuals1 is singleton, and individuals2 is any length, so we loop over individuals2 - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerters_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerters_count); for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { @@ -4076,7 +4076,7 @@ EidosValue_SP InteractionType::ExecuteMethod_distanceFromPoint(EidosGlobalString EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_distanceFromPoint): distanceFromPoint() requires that coordinates for periodic spatial dimensions fall inside spatial bounaries; use pointPeriodic() to ensure this if necessary." << EidosTerminate(); } - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerters_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerters_count); if (periodicity_enabled) { @@ -4810,7 +4810,7 @@ EidosValue_SP InteractionType::ExecuteMethod_localPopulationDensity(EidosGlobalS } else { - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(receivers_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(receivers_count); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) result_vec->set_float_no_check(0, receiver_index); @@ -4891,12 +4891,12 @@ EidosValue_SP InteractionType::ExecuteMethod_localPopulationDensity(EidosGlobalS total_strength /= clipped_integrals->FloatAtIndex_NOCAST(0, nullptr); FreeSparseVector(sv); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(total_strength)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(total_strength)); } else { // Loop over the requested individuals and get the totals - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(receivers_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(receivers_count); bool saw_error_1 = false, saw_error_2 = false, saw_error_3 = false; EIDOS_THREAD_COUNT(gEidos_OMP_threads_LOCALPOPDENSITY); @@ -5034,7 +5034,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactionDistance(EidosGlobalStri if (exerters_value_NULL) exerters_count = exerter_subpop_size; - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerters_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerters_count); // Check constraints the receiver; if the individual is disqualified, the distance to each exerter is zero // The same applies if the k-d tree has no qualifying exerters; below this, we can assume the kd root is non-nullptr @@ -5961,7 +5961,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth if (!CheckIndividualConstraints(receiver, receiver_constraints_) || // potentially raises (!kd_root_EXERTERS && spatiality_)) { - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerters_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerters_count); EIDOS_BZERO(result_vec->data(), exerter_subpop_size * sizeof(double)); @@ -5977,7 +5977,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; SparseVector *sv = InteractionType::NewSparseVectorForExerterSubpop(exerter_subpop, SparseVectorDataType::kStrengths); - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerters_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerters_count); EidosValue_SP result_SP(result_vec); try { @@ -6055,7 +6055,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth if (exerters_value->Type() == EidosValueType::kValueNULL) { // NULL means return strengths to individuals1 (which must be singleton) from all individuals in the subpopulation - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerter_subpop_size); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerter_subpop_size); for (int exerter_index = 0; exerter_index < exerter_subpop_size; ++exerter_index) { @@ -6077,7 +6077,7 @@ EidosValue_SP InteractionType::ExecuteMethod_strength(EidosGlobalStringID p_meth else { // Otherwise, individuals1 is singleton, and exerters_value is any length, so we loop over exerters_value - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(exerters_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(exerters_count); for (int exerter_index = 0; exerter_index < exerters_count; ++exerter_index) { @@ -6220,7 +6220,7 @@ EidosValue_SP InteractionType::ExecuteMethod_totalOfNeighborStrengths(EidosGloba } else { - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(receivers_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(receivers_count); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) result_vec->set_float_no_check(0, receiver_index); @@ -6267,12 +6267,12 @@ EidosValue_SP InteractionType::ExecuteMethod_totalOfNeighborStrengths(EidosGloba total_strength += strengths[col_index]; InteractionType::FreeSparseVector(sv); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(total_strength)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(total_strength)); } else { // Loop over the requested individuals and get the totals - EidosValue_Float_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(receivers_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(receivers_count); EidosValue_SP result_SP(result_vec); #ifdef _OPENMP bool has_interaction_callbacks = (exerter_subpop_data.evaluation_interaction_callbacks_.size() != 0); diff --git a/core/log_file.cpp b/core/log_file.cpp index 6f89f957a..9d3dd09d9 100644 --- a/core/log_file.cpp +++ b/core/log_file.cpp @@ -162,7 +162,7 @@ EidosValue_SP LogFile::_GeneratedValue_PopulationSexRatio(const LogFileGenerator } double sex_ratio = (total_individuals == 0) ? 0.0 : (total_males / (double)total_individuals); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sex_ratio)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sex_ratio)); } else { @@ -193,7 +193,7 @@ EidosValue_SP LogFile::_GeneratedValue_SubpopulationSexRatio(const LogFileGenera slim_popsize_t subpop_size = subpop->CurrentSubpopSize(); slim_popsize_t first_male_index = subpop->CurrentFirstMaleIndex(); double sex_ratio = (subpop_size == 0) ? 0.0 : ((subpop_size - first_male_index) / (double)subpop_size); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sex_ratio)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sex_ratio)); } else { diff --git a/core/mutation.cpp b/core/mutation.cpp index 95ac29360..c54937800 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -381,7 +381,7 @@ EidosValue_SP Mutation::GetProperty(EidosGlobalStringID p_property_id) case gID_position: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(position_)); case gID_selectionCoeff: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(selection_coeff_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selection_coeff_)); // variables case gID_nucleotide: // ACCELERATED @@ -579,7 +579,7 @@ EidosValue *Mutation::GetProperty_Accelerated_tag(EidosObject **p_values, size_t EidosValue *Mutation::GetProperty_Accelerated_selectionCoeff(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index 18a0cb701..58a19b09e 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -463,7 +463,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) case gID_distributionParams: { if (dfe_parameters_.size() > 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(dfe_parameters_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(dfe_parameters_)); else return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(dfe_strings_)); } @@ -480,9 +480,9 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) case gID_convertToSubstitution: return (convert_to_substitution_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gID_dominanceCoeff: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(dominance_coeff_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(dominance_coeff_)); case gID_haploidDominanceCoeff: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(haploid_dominance_coeff_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(haploid_dominance_coeff_)); case gID_mutationStackGroup: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(stack_group_)); case gID_nucleotideBased: @@ -563,7 +563,7 @@ EidosValue *MutationType::GetProperty_Accelerated_tag(EidosObject **p_values, si EidosValue *MutationType::GetProperty_Accelerated_dominanceCoeff(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -741,11 +741,11 @@ EidosValue_SP MutationType::ExecuteMethod_drawSelectionCoefficient(EidosGlobalSt if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(DrawSelectionCoefficient())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(DrawSelectionCoefficient())); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) diff --git a/core/population.cpp b/core/population.cpp index a7cf3b7f5..4e10a260d 100644 --- a/core/population.cpp +++ b/core/population.cpp @@ -769,7 +769,7 @@ slim_popsize_t Population::ApplyMateChoiceCallbacks(slim_popsize_t p_parent1_ind if (mate_choice_callback->contains_weights_) { - local_weights_ptr = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(current_weights, weights_length)); + local_weights_ptr = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(current_weights, weights_length)); callback_symbols.InitializeConstantSymbolEntry(gEidosID_weights, local_weights_ptr); } @@ -6818,11 +6818,11 @@ EidosValue_SP Population::Eidos_FrequenciesForTalliedMutations(EidosValue *mutat else if (mut_state == MutationState::kLostAndRemoved) freq = 0.0; else freq = 1.0; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(freq)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(freq)); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(mutations_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(mutations_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < mutations_count; ++value_index) @@ -6847,7 +6847,7 @@ EidosValue_SP Population::Eidos_FrequenciesForTalliedMutations(EidosValue *mutat const MutationIndex *registry = MutationRegistry(®istry_size); Mutation *mutation_block_ptr = gSLiM_Mutation_Block; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(registry_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(registry_size); result_SP = EidosValue_SP(float_result); for (int registry_index = 0; registry_index < registry_size; registry_index++) @@ -6868,7 +6868,7 @@ EidosValue_SP Population::Eidos_FrequenciesForTalliedMutations(EidosValue *mutat int registry_size; const MutationIndex *registry = MutationRegistry(®istry_size); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(registry_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(registry_size); result_SP = EidosValue_SP(float_result); for (int registry_index = 0; registry_index < registry_size; registry_index++) diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index fb2802b3b..ee993fe1d 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -907,7 +907,7 @@ EidosValue_SP SLiM_ExecuteFunction_mm16To256(const std::vector &p if ((mutationMatrix16_value->DimensionCount() != 2) || (mutationMatrix16_value->Dimensions()[0] != 4) || (mutationMatrix16_value->Dimensions()[1] != 4)) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_mm16To256): function mm16To256() requires mutationMatrix16 to be a 4x4 matrix." << EidosTerminate(nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(256); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(256); for (int i = 0; i < 256; ++i) { @@ -935,7 +935,7 @@ EidosValue_SP SLiM_ExecuteFunction_mmJukesCantor(const std::vector 1.0) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_mmJukesCantor): function mmJukesCantor() requires 3 * alpha <= 1.0." << EidosTerminate(nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(16); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(16); float_result->set_float_no_check(0.0, 0); float_result->set_float_no_check(alpha, 1); @@ -979,7 +979,7 @@ EidosValue_SP SLiM_ExecuteFunction_mmKimura(const std::vector &p_ if (alpha + 2 * beta > 1.0) EIDOS_TERMINATION << "ERROR (SLiM_ExecuteFunction_mmKimura): function mmKimura() requires alpha + 2 * beta to be <= 1.0." << EidosTerminate(nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(16); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(16); float_result->set_float_no_check(0.0, 0); float_result->set_float_no_check(beta, 1); @@ -1033,7 +1033,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotideFrequencies(const std::vectorAllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(4); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(4); double total = total_ACGT[0] + total_ACGT[1] + total_ACGT[2] + total_ACGT[3]; float_result->set_float_no_check(total_ACGT[0] / total, 0); @@ -1552,7 +1552,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorAllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_count); + EidosValue_Float *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(result_count); double *result_data = result_vec->data(); if (dim_count > 1) diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index 16274b6f3..916299b51 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -1086,9 +1086,9 @@ EidosValue_SP SpatialMap::GetProperty(EidosGlobalStringID p_property_id) { switch (spatiality_) { - case 1: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{bounds_a0_, bounds_a1_}); - case 2: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{bounds_a0_, bounds_b0_, bounds_a1_, bounds_b1_}); - case 3: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{bounds_a0_, bounds_b0_, bounds_c0_, bounds_a1_, bounds_b1_, bounds_c1_}); + case 1: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{bounds_a0_, bounds_a1_}); + case 2: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{bounds_a0_, bounds_b0_, bounds_a1_, bounds_b1_}); + case 3: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{bounds_a0_, bounds_b0_, bounds_c0_, bounds_a1_, bounds_b1_, bounds_c1_}); default: return gStaticEidosValueNULL; // never hit; here to make the compiler happy } } @@ -1525,7 +1525,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_changeValues(EidosGlobalStringID p_metho EidosValue_SP SpatialMap::ExecuteMethod_gridValues(EidosGlobalStringID p_method_id, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { #pragma unused (p_method_id, p_arguments, p_interpreter) - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(values_size_); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(values_size_); if (spatiality_ == 1) { @@ -1992,8 +1992,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id #pragma unused (p_method_id, p_arguments, p_interpreter) EidosValue *point = p_arguments[0].get(); - EidosValue_Float_vector *float_result = nullptr; - EidosValue_Float_singleton *float_singleton_result = nullptr; + EidosValue_Float *float_result = nullptr; // Note that point is required to already be in terms of our spatiality; if we are an "xz" map, it must contain "xz" values int x_count; @@ -2001,12 +2000,12 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id if (point->Count() == spatiality_) { x_count = 1; - float_singleton_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0.0)); + float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float(0.0)); } else if (point->Count() % spatiality_ == 0) { x_count = point->Count() / spatiality_; - float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); } else EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_mapValue): mapValue() length of point must match spatiality of map " << name_ << ", or be a multiple thereof." << EidosTerminate(); @@ -2066,16 +2065,10 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id } } - if (float_result) - float_result->set_float_no_check(map_value, value_index); - else - float_singleton_result->SetValue(map_value); + float_result->set_float_no_check(map_value, value_index); } - if (float_result) - return EidosValue_SP(float_result); - else - return EidosValue_SP(float_singleton_result); + return EidosValue_SP(float_result); } // ********************* - (float)range(void) @@ -2083,7 +2076,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapValue(EidosGlobalStringID p_method_id EidosValue_SP SpatialMap::ExecuteMethod_range(EidosGlobalStringID p_method_id, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { #pragma unused (p_method_id, p_arguments, p_interpreter) - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(2); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(2); float_result->set_float_no_check(values_min_, 0); float_result->set_float_no_check(values_max_, 1); @@ -2151,7 +2144,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleImprovedNearbyPoint(EidosGlobalStr const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(point_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(point_count); double *result_ptr = float_result->data(); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); @@ -2379,7 +2372,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_sampleNearbyPoint(EidosGlobalStringID p_ const double *point_buf = point_value->FloatData(); const double *point_buf_ptr = point_buf; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(point_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(point_count); double *result_ptr = float_result->data(); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); diff --git a/core/species.cpp b/core/species.cpp index 2288335ff..810729dbd 100644 --- a/core/species.cpp +++ b/core/species.cpp @@ -2701,7 +2701,7 @@ void Species::CacheNucleotideMatrices(void) if (ge_type->mutation_matrix_) { - EidosValue_Float_vector *mm = ge_type->mutation_matrix_.get(); + EidosValue_Float *mm = ge_type->mutation_matrix_.get(); double *mm_data = mm->data(); if (mm->Count() == 16) @@ -2745,7 +2745,7 @@ void Species::CacheNucleotideMatrices(void) if (ge_type->mutation_matrix_) { - EidosValue_Float_vector *mm = ge_type->mutation_matrix_.get(); + EidosValue_Float *mm = ge_type->mutation_matrix_.get(); double *mm_data = mm->data(); if (mm->Count() == 16) diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index 7d367d8ff..4789996eb 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -327,7 +327,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGenomicElementType(const GenomicElementType *new_genomic_element_type = new GenomicElementType(*this, map_identifier, mutation_types, mutation_fractions); if (nucleotide_based_) - new_genomic_element_type->SetNucleotideMutationMatrix(EidosValue_Float_vector_SP((EidosValue_Float_vector *)(mutationMatrix_value))); + new_genomic_element_type->SetNucleotideMutationMatrix(EidosValue_Float_SP((EidosValue_Float *)(mutationMatrix_value))); genomic_element_types_.emplace(map_identifier, new_genomic_element_type); community_.genomic_element_types_changed_ = true; diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 7318ca289..111010a04 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -2201,7 +2201,7 @@ double Subpopulation::ApplyMutationEffectCallbacks(MutationIndex p_mutation, int { // local variables for the callback parameters that we might need to allocate here, and thus need to free below EidosValue_Object_singleton local_mut(gSLiM_Mutation_Block + p_mutation, gSLiM_Mutation_Class); - EidosValue_Float_singleton local_effect(p_computed_fitness); + EidosValue_Float local_effect(p_computed_fitness); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table { @@ -3567,8 +3567,8 @@ bool Subpopulation::ApplySurvivalCallbacks(std::vector &p_survi // This code is similar to Population::ExecuteScript, but we set up an additional symbol table, and we use the return value { // local variables for the callback parameters that we might need to allocate here, and thus need to free below - EidosValue_Float_singleton local_fitness(p_fitness); - EidosValue_Float_singleton local_draw(p_draw); + EidosValue_Float local_fitness(p_fitness); + EidosValue_Float local_draw(p_draw); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table { @@ -4034,7 +4034,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (model_type_ == SLiMModelType::kModelTypeNonWF) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): property immigrantSubpopFractions is not available in nonWF models." << EidosTerminate(); - EidosValue_Float_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); + EidosValue_Float *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Float(); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto migrant_pair : migrant_fractions_) @@ -4105,7 +4105,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (model_type_ == SLiMModelType::kModelTypeNonWF) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): property selfingRate is not available in nonWF models." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(selfing_fraction_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selfing_fraction_)); } case gID_cloningRate: { @@ -4113,16 +4113,16 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): property cloningRate is not available in nonWF models." << EidosTerminate(); if (sex_enabled_) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{female_clone_fraction_, male_clone_fraction_}); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{female_clone_fraction_, male_clone_fraction_}); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(female_clone_fraction_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(female_clone_fraction_)); } case gID_sexRatio: { if (model_type_ == SLiMModelType::kModelTypeNonWF) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): property sexRatio is not available in nonWF models." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(child_generation_valid_ ? child_sex_ratio_ : parent_sex_ratio_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(child_generation_valid_ ? child_sex_ratio_ : parent_sex_ratio_)); } case gID_spatialBounds: { @@ -4131,9 +4131,9 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) switch (dimensionality) { case 0: return gStaticEidosValue_Float_ZeroVec; - case 1: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{bounds_x0_, bounds_x1_}); - case 2: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{bounds_x0_, bounds_y0_, bounds_x1_, bounds_y1_}); - case 3: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{bounds_x0_, bounds_y0_, bounds_z0_, bounds_x1_, bounds_y1_, bounds_z1_}); + case 1: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{bounds_x0_, bounds_x1_}); + case 2: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{bounds_x0_, bounds_y0_, bounds_x1_, bounds_y1_}); + case 3: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{bounds_x0_, bounds_y0_, bounds_z0_, bounds_x1_, bounds_y1_, bounds_z1_}); default: return gStaticEidosValueNULL; // never hit; here to make the compiler happy } } @@ -4164,7 +4164,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); } case gID_fitnessScaling: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(subpop_fitness_scaling_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(subpop_fitness_scaling_)); // all others, including gID_none default: @@ -4234,7 +4234,7 @@ EidosValue *Subpopulation::GetProperty_Accelerated_tag(EidosObject **p_values, s EidosValue *Subpopulation::GetProperty_Accelerated_fitnessScaling(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -5856,7 +5856,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointDeviated(EidosGlobalStringID p_m return gStaticEidosValue_Float_ZeroVec; int64_t length_out = n * dimensionality; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(length_out); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(length_out); double *float_result_data = float_result->data(); double *float_result_ptr = float_result_data; @@ -6348,12 +6348,12 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointReflected(EidosGlobalStringID p_ else break; } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x)); } // non-singleton general case const double *point_buf = point_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); switch (dimensionality) @@ -6474,12 +6474,12 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointStopped(EidosGlobalStringID p_me // Handle the singleton separately, so we can handle the non-singleton case more quickly double x = point_value->FloatAtIndex_NOCAST(0, nullptr); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::max(bounds_x0_, std::min(bounds_x1_, x)))); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(std::max(bounds_x0_, std::min(bounds_x1_, x)))); } // non-singleton general case const double *point_buf = point_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); switch (dimensionality) @@ -6578,12 +6578,12 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointPeriodic(EidosGlobalStringID p_m while (x > bounds_x1_) x -= bounds_x1_; } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x)); } // non-singleton general case const double *point_buf = point_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(value_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(value_count); double *float_result_data = float_result->data(); // Wrap coordinates; note that we assume here that bounds_x0_ == bounds_y0_ == bounds_z0_ == 0, @@ -6698,7 +6698,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_pointUniform(EidosGlobalStringID p_me return gStaticEidosValue_Float_ZeroVec; int64_t length_out = point_count * dimensionality; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(length_out); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(length_out); double *float_result_data = float_result->data(); EidosValue_SP result_SP = EidosValue_SP(float_result); @@ -7033,11 +7033,11 @@ EidosValue_SP Subpopulation::ExecuteMethod_cachedFitness(EidosGlobalStringID p_m double fitness = (individual_cached_fitness_OVERRIDE_ ? individual_cached_fitness_OVERRIDE_value_ : parent_individuals_[index]->cached_fitness_UNSAFE_); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fitness)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(fitness)); } else { - EidosValue_Float_vector *float_return = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(index_count); + EidosValue_Float *float_return = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(index_count); EidosValue_SP result_SP = EidosValue_SP(float_return); for (slim_popsize_t value_index = 0; value_index < index_count; value_index++) diff --git a/core/substitution.cpp b/core/substitution.cpp index 633fbabaf..e4557cf8a 100644 --- a/core/substitution.cpp +++ b/core/substitution.cpp @@ -88,7 +88,7 @@ EidosValue_SP Substitution::GetProperty(EidosGlobalStringID p_property_id) case gID_position: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(position_)); case gID_selectionCoeff: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(selection_coeff_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selection_coeff_)); case gID_originTick: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(origin_tick_)); case gID_fixationTick: // ACCELERATED @@ -276,7 +276,7 @@ EidosValue *Substitution::GetProperty_Accelerated_tag(EidosObject **p_values, si EidosValue *Substitution::GetProperty_Accelerated_selectionCoeff(EidosObject **p_values, size_t p_values_size) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(p_values_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/eidos/eidos_class_DataFrame.cpp b/eidos/eidos_class_DataFrame.cpp index 3aa42dc6e..84ce3f66a 100644 --- a/eidos/eidos_class_DataFrame.cpp +++ b/eidos/eidos_class_DataFrame.cpp @@ -1191,7 +1191,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorAllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(nrows); + EidosValue_Float *float_column = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(nrows); column_values = EidosValue_SP(float_column); for (int row_index = 0; row_index < nrows; ++row_index) diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index f3e2308d3..234da8bfb 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -883,7 +883,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) else if (value.is_number_float()) { double float_value = value; - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(float_value)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(float_value)); } else if (value.is_object()) { @@ -939,7 +939,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) } else if (array_type == nlohmann::json::value_t::number_float) { - EidosValue_Float_vector *float_value = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(array_count); + EidosValue_Float *float_value = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(array_count); for (size_t element_index = 0; element_index < array_count; ++element_index) { diff --git a/eidos/eidos_class_Image.cpp b/eidos/eidos_class_Image.cpp index 80cce4e40..9b07151d3 100644 --- a/eidos/eidos_class_Image.cpp +++ b/eidos/eidos_class_Image.cpp @@ -158,7 +158,7 @@ EidosValue_SP EidosImage::ValueForFloatChannel(EidosValue_SP &p_channel_cache, C return p_channel_cache; int64_t pixel_stride = 0, pixel_suboffset = 0; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(height_ * width_); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(height_ * width_); p_channel_cache = EidosValue_SP(float_result); GetChannelMetrics(p_channel, pixel_stride, pixel_suboffset); @@ -337,7 +337,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorData(); - EidosValue_Float_vector *float_values = (EidosValue_Float_vector *)p_arguments[0].get(); + EidosValue_Float *float_values = (EidosValue_Float *)p_arguments[0].get(); const double *float_data = float_values->data(); // translate the data from by-column to by-row, to match the in-memory format of images diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 36099d46d..c1d50b8a9 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -654,8 +654,8 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (highest_type == EidosValueType::kValueFloat) { - EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(reserve_size); - EidosValue_Float_vector_SP result_SP = EidosValue_Float_vector_SP(result); + EidosValue_Float *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(reserve_size); + EidosValue_Float_SP result_SP = EidosValue_Float_SP(result); int result_set_index = 0; for (int arg_index = 0; arg_index < argument_count; ++arg_index) @@ -885,7 +885,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); + EidosValue_Float *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float(); result_SP = EidosValue_SP(float_result); if (p_preserve_order) @@ -1091,8 +1091,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueFloat) { const double *first_child_data = p_original_value->FloatData(); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) if (logical_index_data[value_idx]) @@ -1153,8 +1153,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa { // result type is float; optimize for that const double *first_child_data = p_original_value->FloatData(); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->reserve(indices_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_colors.cpp b/eidos/eidos_functions_colors.cpp index 6eee38792..8d657ff35 100644 --- a/eidos/eidos_functions_colors.cpp +++ b/eidos/eidos_functions_colors.cpp @@ -148,11 +148,11 @@ EidosValue_SP Eidos_ExecuteFunction_color2rgb(const std::vector & { Eidos_GetColorComponents(color_value->StringRefAtIndex_NOCAST(0, nullptr), &r, &g, &b); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{r, g, b}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{r, g, b}); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((size_t)color_count * 3); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((size_t)color_count * 3); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -214,7 +214,7 @@ EidosValue_SP Eidos_ExecuteFunction_hsv2rgb(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_hsv2rgb): in function hsv2rgb(), hsv must contain exactly three elements, or be a matrix with exactly three columns." << EidosTerminate(nullptr); int color_count = hsv_count / 3; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((size_t)color_count * 3); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((size_t)color_count * 3); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -368,7 +368,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgb2hsv(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rgb2hsv): in function rgb2hsv(), rgb must contain exactly three elements, or be a matrix with exactly three columns." << EidosTerminate(nullptr); int color_count = rgb_count / 3; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((size_t)color_count * 3); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((size_t)color_count * 3); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < color_count; ++value_index) diff --git a/eidos/eidos_functions_distributions.cpp b/eidos/eidos_functions_distributions.cpp index d65278588..6ef2f821e 100644 --- a/eidos/eidos_functions_distributions.cpp +++ b/eidos/eidos_functions_distributions.cpp @@ -413,7 +413,7 @@ EidosValue_SP Eidos_ExecuteFunction_dmvnorm(const std::vector &p_ } const double *float_data = arg_x->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int64_t value_index = 0; value_index < num_quantiles; ++value_index) @@ -482,12 +482,12 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gaussian_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr) - mu0, sigma0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_gaussian_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr) - mu0, sigma0))); } else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); EIDOS_THREAD_COUNT(gEidos_OMP_threads_DNORM_1); @@ -499,7 +499,7 @@ EidosValue_SP Eidos_ExecuteFunction_dnorm(const std::vector &p_ar else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); bool saw_error = false; @@ -562,12 +562,12 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar if (float_prob < 0.0 || float_prob > 1.0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_qnorm): function qnorm() requires 0.0 <= p <= 1.0 (" << EidosStringForFloat(float_prob) << " supplied)." << EidosTerminate(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_cdf_gaussian_Pinv(float_prob, sigma0) + mu0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_cdf_gaussian_Pinv(float_prob, sigma0) + mu0)); } else { const double *float_data = arg_prob->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_probs); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_probs); result_SP = EidosValue_SP(float_result); for (int64_t value_index = 0; value_index < num_probs; ++value_index) { @@ -580,7 +580,7 @@ EidosValue_SP Eidos_ExecuteFunction_qnorm(const std::vector &p_ar else { const double *float_data = arg_prob->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_probs); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_probs); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_probs; ++value_index) @@ -632,12 +632,12 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_cdf_gaussian_P(arg_quantile->FloatAtIndex_NOCAST(0, nullptr) - mu0, sigma0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_cdf_gaussian_P(arg_quantile->FloatAtIndex_NOCAST(0, nullptr) - mu0, sigma0))); } else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int64_t value_index = 0; value_index < num_quantiles; ++value_index) @@ -647,7 +647,7 @@ EidosValue_SP Eidos_ExecuteFunction_pnorm(const std::vector &p_ar else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_quantiles); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_quantiles; ++value_index) @@ -698,12 +698,12 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_beta_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), alpha0, beta0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_beta_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), alpha0, beta0))); } else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_quantiles; ++value_index) @@ -713,7 +713,7 @@ EidosValue_SP Eidos_ExecuteFunction_dbeta(const std::vector &p_ar else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_quantiles; ++value_index) @@ -769,11 +769,11 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_beta(rng, alpha0, beta0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_beta(rng, alpha0, beta0))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) @@ -782,7 +782,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbeta(const std::vector &p_ar } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -957,11 +957,11 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_cauchy(rng, scale0) + location0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_cauchy(rng, scale0) + location0)); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) @@ -970,7 +970,7 @@ EidosValue_SP Eidos_ExecuteFunction_rcauchy(const std::vector &p_ } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1125,12 +1125,12 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_exponential_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), mu0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_exponential_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), mu0))); } else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_quantiles; ++value_index) @@ -1140,7 +1140,7 @@ EidosValue_SP Eidos_ExecuteFunction_dexp(const std::vector &p_arg else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_quantiles; ++value_index) @@ -1180,11 +1180,11 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg { gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_exponential(rng, mu0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_exponential(rng, mu0))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); EIDOS_THREAD_COUNT(gEidos_OMP_threads_REXP_1); @@ -1200,7 +1200,7 @@ EidosValue_SP Eidos_ExecuteFunction_rexp(const std::vector &p_arg } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); EIDOS_THREAD_COUNT(gEidos_OMP_threads_REXP_2); @@ -1257,11 +1257,11 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_fdist(rng, d1_0, d2_0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_fdist(rng, d1_0, d2_0))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1270,7 +1270,7 @@ EidosValue_SP Eidos_ExecuteFunction_rf(const std::vector &p_argum } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1321,12 +1321,12 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a if (num_quantiles == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gamma_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), shape0, mean0/shape0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_gamma_pdf(arg_quantile->FloatAtIndex_NOCAST(0, nullptr), shape0, mean0/shape0))); } else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); double scale = mean0 / shape0; @@ -1338,7 +1338,7 @@ EidosValue_SP Eidos_ExecuteFunction_dgamma(const std::vector &p_a else { const double *float_data = arg_quantile->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_quantiles); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_quantiles); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < num_quantiles; ++value_index) @@ -1390,11 +1390,11 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gamma(rng, shape0, mean0/shape0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_gamma(rng, shape0, mean0/shape0))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); double scale = mean0 / shape0; @@ -1405,7 +1405,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgamma(const std::vector &p_a } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1533,11 +1533,11 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a { if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_lognormal(rng, meanlog0, sdlog0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_lognormal(rng, meanlog0, sdlog0))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1546,7 +1546,7 @@ EidosValue_SP Eidos_ExecuteFunction_rlnorm(const std::vector &p_a } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1637,7 +1637,7 @@ EidosValue_SP Eidos_ExecuteFunction_rmvnorm(const std::vector &p_ EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_rmvnorm): (internal error) an unknown error with code " << gsl_err << " occurred inside the GNU Scientific Library's gsl_linalg_cholesky_decomp1() function." << EidosTerminate(nullptr); } - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws * d); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws * d); result_SP = EidosValue_SP(float_result); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); @@ -1774,10 +1774,10 @@ EidosValue_SP Eidos_ExecuteFunction_rnorm(const std::vector &p_ar { gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_gaussian(rng, sigma0) + mu0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_gaussian(rng, sigma0) + mu0)); } - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); if (mu_singleton && sigma_singleton) @@ -1958,11 +1958,11 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar { gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(Eidos_rng_uniform(rng))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(Eidos_rng_uniform(rng))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); EIDOS_THREAD_COUNT(gEidos_OMP_threads_RUNIF_1); @@ -1989,11 +1989,11 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar { gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(Eidos_rng_uniform(rng) * range0 + min_value0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(Eidos_rng_uniform(rng) * range0 + min_value0)); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); EIDOS_THREAD_COUNT(gEidos_OMP_threads_RUNIF_2); @@ -2009,7 +2009,7 @@ EidosValue_SP Eidos_ExecuteFunction_runif(const std::vector &p_ar } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); bool saw_error = false; @@ -2080,11 +2080,11 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gsl_ran_weibull(rng, lambda0, k0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gsl_ran_weibull(rng, lambda0, k0))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(float_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) @@ -2093,7 +2093,7 @@ EidosValue_SP Eidos_ExecuteFunction_rweibull(const std::vector &p } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize((int)num_draws); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(float_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index b4abed603..17fe479f9 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -103,13 +103,13 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fabs(x_value->FloatAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(fabs(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -135,11 +135,11 @@ EidosValue_SP Eidos_ExecuteFunction_acos(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(acos(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(acos(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -161,11 +161,11 @@ EidosValue_SP Eidos_ExecuteFunction_asin(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(asin(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(asin(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -187,11 +187,11 @@ EidosValue_SP Eidos_ExecuteFunction_atan(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(atan(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -226,11 +226,11 @@ EidosValue_SP Eidos_ExecuteFunction_atan2(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(atan2(x_value->NumericAtIndex_NOCAST(0, nullptr), y_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(atan2(x_value->NumericAtIndex_NOCAST(0, nullptr), y_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -253,13 +253,13 @@ EidosValue_SP Eidos_ExecuteFunction_ceil(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(ceil(x_value->FloatAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(ceil(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -284,11 +284,11 @@ EidosValue_SP Eidos_ExecuteFunction_cos(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cos(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(cos(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -340,14 +340,14 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API const double *float_data = x_value->FloatData(); double product = 1.0; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -403,14 +403,14 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { // We have x_count != 1, so the type of x_value must be EidosValue_Float_vector; we can use the fast API const double *float_data = x_value->FloatData(); double sum = 0.0; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -437,11 +437,11 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(exp(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(exp(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -450,7 +450,7 @@ EidosValue_SP Eidos_ExecuteFunction_exp(const std::vector &p_argu else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -475,13 +475,13 @@ EidosValue_SP Eidos_ExecuteFunction_floor(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(floor(x_value->FloatAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(floor(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -805,11 +805,11 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(log(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -818,7 +818,7 @@ EidosValue_SP Eidos_ExecuteFunction_log(const std::vector &p_argu else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -844,11 +844,11 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log10(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(log10(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -857,7 +857,7 @@ EidosValue_SP Eidos_ExecuteFunction_log10(const std::vector &p_ar else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -883,11 +883,11 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(log2(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(log2(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -896,7 +896,7 @@ EidosValue_SP Eidos_ExecuteFunction_log2(const std::vector &p_arg else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -959,14 +959,14 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ if (fits_in_integer) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(product)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(product_d)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(product_d)); } } else if (x_type == EidosValueType::kValueFloat) { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -977,7 +977,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ for (int value_index = 0; value_index < x_count; ++value_index) product *= float_data[value_index]; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(product)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(product)); } } @@ -994,13 +994,13 @@ EidosValue_SP Eidos_ExecuteFunction_round(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(round(x_value->FloatAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(round(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -1151,7 +1151,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorAllocateChunk()) EidosValue_Float_singleton(float0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(float0)); } else if (arg_type == EidosValueType::kValueString) { @@ -1200,7 +1200,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorAllocateChunk()) EidosValue_Float_singleton(float0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(float0)); } else if (arg_type == EidosValueType::kValueString) { @@ -1248,7 +1248,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + EidosValue_Float *float_vec = dynamic_cast(result_SP.get()); double *float_data = float_vec->FloatData_Mutable(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1327,7 +1327,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorFloatData(); const double *float_data1 = y_value->FloatData(); - EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); + EidosValue_Float *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float(); result_SP = EidosValue_SP(float_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1553,7 +1553,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatAtIndex_NOCAST(0, nullptr), float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); if ((std::isnan(float0) && std::isnan(float1)) || (float0 == float1)) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(float0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(float0)); else result_SP = gStaticEidosValue_Float_ZeroVec; } @@ -1684,7 +1684,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorFloatData(); const double *float_data1 = y_value->FloatData(); - EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); + EidosValue_Float *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float(); result_SP = EidosValue_SP(float_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1922,7 +1922,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorAllocateChunk()) EidosValue_Float_vector{float0, float1}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{float0, float1}); } else if (arg_type == EidosValueType::kValueString) { @@ -1980,7 +1980,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + EidosValue_Float *float_vec = dynamic_cast(result_SP.get()); double *float_data = float_vec->FloatData_Mutable(); int value_index; @@ -2089,7 +2089,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorFloatData(); const double *float_vec1 = y_value->FloatData(); - EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); + EidosValue_Float *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float(); result_SP = EidosValue_SP(float_result); for (value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -2389,9 +2389,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p double float0 = x_value->FloatAtIndex_NOCAST(0, nullptr), float1 = y_value->FloatAtIndex_NOCAST(0, nullptr); if ((std::isnan(float0) && std::isnan(float1)) || (float0 == float1)) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(float0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(float0)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector{float0, float1}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float{float0, float1}); } else if (arg_type == EidosValueType::kValueString) { @@ -2464,7 +2464,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (scan_index == result_count) { - EidosValue_Float_vector *float_vec = dynamic_cast(result_SP.get()); + EidosValue_Float *float_vec = dynamic_cast(result_SP.get()); float_vec->push_float(value1); } @@ -2532,11 +2532,11 @@ EidosValue_SP Eidos_ExecuteFunction_sin(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sin(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sin(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -2559,11 +2559,11 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sqrt(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sqrt(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else if (x_type == EidosValueType::kValueInt) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -2572,7 +2572,7 @@ EidosValue_SP Eidos_ExecuteFunction_sqrt(const std::vector &p_arg else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -2637,7 +2637,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu if (fits_in_integer) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(sum)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum_d)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum_d)); } #else { @@ -2658,7 +2658,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu if (fits_in_integer) result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(sum)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum_d)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum_d)); } #endif } @@ -2666,7 +2666,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -2679,7 +2679,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu for (int value_index = 0; value_index < x_count; ++value_index) sum += float_data[value_index]; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum)); } } else if (x_type == EidosValueType::kValueLogical) @@ -2709,7 +2709,7 @@ EidosValue_SP Eidos_ExecuteFunction_sumExact(const std::vector &p if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_NOCAST(0, nullptr))); } else { @@ -2717,7 +2717,7 @@ EidosValue_SP Eidos_ExecuteFunction_sumExact(const std::vector &p const double *float_data = x_value->FloatData(); double sum = Eidos_ExactSum(float_data, x_count); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum)); } return result_SP; @@ -2733,11 +2733,11 @@ EidosValue_SP Eidos_ExecuteFunction_tan(const std::vector &p_argu if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(tan(x_value->NumericAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(tan(x_value->NumericAtIndex_NOCAST(0, nullptr)))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -2759,13 +2759,13 @@ EidosValue_SP Eidos_ExecuteFunction_trunc(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(trunc(x_value->FloatAtIndex_NOCAST(0, nullptr)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(trunc(x_value->FloatAtIndex_NOCAST(0, nullptr)))); } else { // We have x_count != 1 and x_value is guaranteed to be an EidosValue_Float, so we can use the fast API const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index d54945c7f..33b8d293f 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -395,7 +395,7 @@ EidosValue_SP Eidos_ExecuteFunction_cbind(const std::vector &p_ar case EidosValueType::kValueNULL: break; // never hit case EidosValueType::kValueLogical: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->reserve(result_length)); break; case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve(result_length)); break; - case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->reserve(result_length)); break; + case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; } @@ -650,7 +650,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector double x_singleton = x_value->FloatAtIndex_NOCAST(0, nullptr); double y_singleton = y_value->FloatAtIndex_NOCAST(0, nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_singleton * y_singleton)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_singleton * y_singleton)); } } else if (x_length == 1) @@ -679,7 +679,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector { double x_singleton = x_value->FloatAtIndex_NOCAST(0, nullptr); const double *y_data = y_value->FloatData(); - EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); + EidosValue_Float *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); for (int64_t y_index = 0; y_index < y_length; ++y_index) @@ -712,7 +712,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector { const double *x_data = x_value->FloatData(); double y_singleton = y_value->FloatAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); + EidosValue_Float *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); for (int64_t x_index = 0; x_index < x_length; ++x_index) @@ -769,7 +769,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector { const double *x_data = x_value->FloatData(); const double *y_data = y_value->FloatData(); - EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(result_length); + EidosValue_Float *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); for (int64_t result_col_index = 0; result_col_index < result_cols; ++result_col_index) @@ -913,7 +913,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbind(const std::vector &p_ar case EidosValueType::kValueNULL: break; // never hit case EidosValueType::kValueLogical: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->reserve(result_length)); break; case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve(result_length)); break; - case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->reserve(result_length)); break; + case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; } diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 039149ace..4ff98cdd6 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -152,7 +152,7 @@ EidosValue_SP Eidos_ExecuteFunction_clock(__attribute__((unused)) const std::vec std::clock_t cpu_time = std::clock(); double cpu_time_d = static_cast(cpu_time) / CLOCKS_PER_SEC; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cpu_time_d)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(cpu_time_d)); } else if (type_name == "mono") { @@ -161,7 +161,7 @@ EidosValue_SP Eidos_ExecuteFunction_clock(__attribute__((unused)) const std::vec std::chrono::steady_clock::duration clock_duration = ts - timebase; double seconds = std::chrono::duration(clock_duration).count(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(seconds)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(seconds)); } else { @@ -1597,7 +1597,7 @@ EidosValue_SP Eidos_ExecuteFunction_usage(__attribute__((unused)) const std::vec } double usage_MB = usage / (1024.0 * 1024.0); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(usage_MB)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(usage_MB)); return result_SP; } @@ -1622,7 +1622,7 @@ EidosValue_SP Eidos_ExecuteFunction_version(__attribute__((unused)) const std::v } // Return the versions as floats - EidosValue_Float_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->reserve(2); + EidosValue_Float *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(2); result_SP = EidosValue_SP(result); result->push_float_no_check(EIDOS_VERSION_FLOAT); @@ -1686,7 +1686,7 @@ EidosValue_SP SLiM_ExecuteFunction__stopBenchmark(__attribute__((unused)) const double benchmark_time = Eidos_ElapsedProfileTime(gEidosBenchmarkAccumulator); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(benchmark_time)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(benchmark_time)); // reset so a new benchmark can be started gEidosBenchmarkType = EidosBenchmarkType::kNone; diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index e82c727f2..8f3a41130 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -81,7 +81,7 @@ EidosValue_SP Eidos_ExecuteFunction_cor(const std::vector &p_argu // calculate correlation double cor = diff_prod / (sqrt(ss_x) * sqrt(ss_y)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cor)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(cor)); } else { @@ -130,7 +130,7 @@ EidosValue_SP Eidos_ExecuteFunction_cov(const std::vector &p_argu } cov = cov / (count - 1); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(cov)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(cov)); } else { @@ -279,7 +279,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(max)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(max)); } else if (x_type == EidosValueType::kValueString) { @@ -331,7 +331,7 @@ EidosValue_SP Eidos_ExecuteFunction_mean(const std::vector &p_arg } else if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_CAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_CAST(0, nullptr))); } else { @@ -340,7 +340,7 @@ EidosValue_SP Eidos_ExecuteFunction_mean(const std::vector &p_arg EidosValue_SP sum_value = Eidos_ExecuteFunction_sum(p_arguments, p_interpreter); double sum = sum_value->FloatAtIndex_CAST(0, nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sum / x_count)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum / x_count)); } return result_SP; @@ -485,7 +485,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(min)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(min)); } else if (x_type == EidosValueType::kValueString) { @@ -622,7 +622,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg { const double * __restrict__ float0_data = x_value->FloatData(); double y_singleton_value = y_value->FloatAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -683,7 +683,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg { const double * __restrict__ float0_data = x_value->FloatData(); const double * __restrict__ float1_data = y_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -810,7 +810,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg { const double * __restrict__ float0_data = x_value->FloatData(); double y_singleton_value = y_value->FloatAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -871,7 +871,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg { const double * __restrict__ float0_data = x_value->FloatData(); const double * __restrict__ float1_data = y_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); double * __restrict__ float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -948,7 +948,7 @@ EidosValue_SP Eidos_ExecuteFunction_quantile(const std::vector &p } } - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(probs_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(probs_count); result_SP = EidosValue_SP(float_result); if (x_count == 1) @@ -1087,7 +1087,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar } else if (x_type == EidosValueType::kValueFloat) { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(2); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(2); result_SP = EidosValue_SP(float_result); double max = p_arguments[first_nonempty_argument]->FloatAtIndex_NOCAST(0, nullptr); @@ -1173,7 +1173,7 @@ EidosValue_SP Eidos_ExecuteFunction_sd(const std::vector &p_argum } sd = sqrt(sd / (x_count - 1)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(sd)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sd)); } else { @@ -1228,7 +1228,7 @@ EidosValue_SP Eidos_ExecuteFunction_ttest(const std::vector &p_ar pvalue = Eidos_TTest_OneSample(vec1, x_count, mu, nullptr); } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(pvalue)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(pvalue)); return result_SP; } @@ -1264,7 +1264,7 @@ EidosValue_SP Eidos_ExecuteFunction_var(const std::vector &p_argu } var = var / (x_count - 1); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(var)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(var)); } else { diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 8c39ecefe..145f00d93 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -92,7 +92,7 @@ EidosValue_SP Eidos_ExecuteFunction_float(const std::vector &p_ar if (element_count == 0) return gStaticEidosValue_Float_ZeroVec; - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(element_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(element_count); result_SP = EidosValue_SP(float_result); for (int64_t value_index = 0; value_index < element_count; ++value_index) @@ -483,7 +483,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(sample_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(sample_size); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -799,7 +799,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a else if (x_type == EidosValueType::kValueFloat) { const double *float_data = x_value->FloatData(); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(sample_size); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(sample_size); double *float_result_data = float_result->data(); result_SP = EidosValue_SP(float_result); @@ -927,7 +927,7 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu double first_value = from_value->NumericAtIndex_NOCAST(0, nullptr); double second_value = to_value->NumericAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(length); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(length); result_SP = EidosValue_SP(float_result); for (int64_t seq_index = 0; seq_index < length; ++seq_index) @@ -965,7 +965,7 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu { // length does not divide evenly, so generate a float sequence double by = (second_value - first_value) / (double)(length - 1); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(length); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(length); result_SP = EidosValue_SP(float_result); for (int64_t seq_index = 0; seq_index < length; ++seq_index) @@ -998,7 +998,7 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if (((first_value < second_value) && (by < 0)) || ((first_value > second_value) && (by > 0))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() by has incorrect sign." << EidosTerminate(nullptr); - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->reserve(int(1 + ceil((second_value - first_value) / by))); // take a stab at a reserve size; might not be quite right, but no harm + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(int(1 + ceil((second_value - first_value) / by))); // take a stab at a reserve size; might not be quite right, but no harm result_SP = EidosValue_SP(float_result); if (by > 0) @@ -1528,8 +1528,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a { const double *true_data = trueValues_value->FloatData(); const double *false_data = falseValues_value->FloatData(); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(test_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(test_count); for (int value_index = 0; value_index < test_count; ++value_index) float_result->set_float_no_check(logical_vec[value_index] ? true_data[value_index] : false_data[value_index], value_index); @@ -1625,8 +1625,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a { double true_value = trueValues_value->FloatAtIndex_NOCAST(0, nullptr); double false_value = falseValues_value->FloatAtIndex_NOCAST(0, nullptr); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(test_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(test_count); for (int value_index = 0; value_index < test_count; ++value_index) float_result->set_float_no_check(logical_vec[value_index] ? true_value : false_value, value_index); @@ -2315,13 +2315,13 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg else { // Here we handle the vector cases, which can be done with direct access - EidosValue_Float_vector *float_result = nullptr; + EidosValue_Float *float_result = nullptr; EidosValue_Int_vector *int_result = nullptr; EidosValueType x_type = x_value->Type(); if (tiesMethod == TiesMethod::kTiesAverage) { - float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); } else @@ -2918,11 +2918,11 @@ EidosValue_SP Eidos_ExecuteFunction_asFloat(const std::vector &p_ if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(x_value->FloatAtIndex_CAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(x_value->FloatAtIndex_CAST(0, nullptr))); } else { - EidosValue_Float_vector *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector())->resize_no_initialize(x_count); + EidosValue_Float *float_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->resize_no_initialize(x_count); result_SP = EidosValue_SP(float_result); for (int value_index = 0; value_index < x_count; ++value_index) diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index be217314f..6252bd67f 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1087,8 +1087,6 @@ void Eidos_WarmUp(void) maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int_vector)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int_singleton)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float_vector)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float_singleton)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_vector)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_singleton)); @@ -1103,8 +1101,6 @@ void Eidos_WarmUp(void) // std::cout << "sizeof(EidosValue_Int_vector) == " << sizeof(EidosValue_Int_vector) << std::endl; // std::cout << "sizeof(EidosValue_Int_singleton) == " << sizeof(EidosValue_Int_singleton) << std::endl; // std::cout << "sizeof(EidosValue_Float) == " << sizeof(EidosValue_Float) << std::endl; -// std::cout << "sizeof(EidosValue_Float_vector) == " << sizeof(EidosValue_Float_vector) << std::endl; -// std::cout << "sizeof(EidosValue_Float_singleton) == " << sizeof(EidosValue_Float_singleton) << std::endl; // std::cout << "sizeof(EidosValue_Object) == " << sizeof(EidosValue_Object) << std::endl; // std::cout << "sizeof(EidosValue_Object_vector) == " << sizeof(EidosValue_Object_vector) << std::endl; // std::cout << "sizeof(EidosValue_Object_singleton) == " << sizeof(EidosValue_Object_singleton) << std::endl; @@ -1139,7 +1135,7 @@ void Eidos_WarmUp(void) gStaticEidosValue_Integer_ZeroVec = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); gStaticEidosValue_Integer_ZeroVec->MarkAsConstant(); - gStaticEidosValue_Float_ZeroVec = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); + gStaticEidosValue_Float_ZeroVec = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); gStaticEidosValue_Float_ZeroVec->MarkAsConstant(); gStaticEidosValue_String_ZeroVec = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); @@ -1157,28 +1153,28 @@ void Eidos_WarmUp(void) gStaticEidosValue_Integer3 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(3)); gStaticEidosValue_Integer3->MarkAsConstant(); - gStaticEidosValue_Float0 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0.0)); + gStaticEidosValue_Float0 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(0.0)); gStaticEidosValue_Float0->MarkAsConstant(); - gStaticEidosValue_Float0Point5 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0.5)); + gStaticEidosValue_Float0Point5 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(0.5)); gStaticEidosValue_Float0Point5->MarkAsConstant(); - gStaticEidosValue_Float1 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(1.0)); + gStaticEidosValue_Float1 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(1.0)); gStaticEidosValue_Float1->MarkAsConstant(); - gStaticEidosValue_Float10 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(10.0)); + gStaticEidosValue_Float10 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(10.0)); gStaticEidosValue_Float10->MarkAsConstant(); - gStaticEidosValue_FloatINF = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::infinity())); + gStaticEidosValue_FloatINF = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(std::numeric_limits::infinity())); gStaticEidosValue_FloatINF->MarkAsConstant(); - gStaticEidosValue_FloatNAN = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::quiet_NaN())); + gStaticEidosValue_FloatNAN = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(std::numeric_limits::quiet_NaN())); gStaticEidosValue_FloatNAN->MarkAsConstant(); - gStaticEidosValue_FloatE = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_E)); + gStaticEidosValue_FloatE = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(M_E)); gStaticEidosValue_FloatE->MarkAsConstant(); - gStaticEidosValue_FloatPI = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_PI)); + gStaticEidosValue_FloatPI = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(M_PI)); gStaticEidosValue_FloatPI->MarkAsConstant(); gStaticEidosValue_StringEmpty = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("")); diff --git a/eidos/eidos_globals.h b/eidos/eidos_globals.h index ea2d37b43..24dd3aa4e 100644 --- a/eidos/eidos_globals.h +++ b/eidos/eidos_globals.h @@ -1190,8 +1190,6 @@ class EidosValue_Int; class EidosValue_Int_singleton; class EidosValue_Int_vector; class EidosValue_Float; -class EidosValue_Float_singleton; -class EidosValue_Float_vector; class EidosValue_String; class EidosValue_String_singleton; class EidosValue_String_vector; @@ -1231,8 +1229,6 @@ typedef Eidos_intrusive_ptr EidosValue_Int_SP; typedef Eidos_intrusive_ptr EidosValue_Int_singleton_SP; typedef Eidos_intrusive_ptr EidosValue_Int_vector_SP; typedef Eidos_intrusive_ptr EidosValue_Float_SP; -typedef Eidos_intrusive_ptr EidosValue_Float_singleton_SP; -typedef Eidos_intrusive_ptr EidosValue_Float_vector_SP; typedef Eidos_intrusive_ptr EidosValue_String_SP; typedef Eidos_intrusive_ptr EidosValue_String_singleton_SP; typedef Eidos_intrusive_ptr EidosValue_String_vector_SP; diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index d2bf7fbe5..f75d5f28f 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -992,8 +992,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode if (second_float - first_float + 1 > 100000000) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_Evaluate_RangeExpr_Internal): a range with more than 100000000 entries cannot be constructed." << EidosTerminate(operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->reserve((int)(second_float - first_float + 1)); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->reserve((int)(second_float - first_float + 1)); for (double range_index = first_float; range_index <= second_float; ) { @@ -1019,8 +1019,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode if (first_float - second_float + 1 > 100000000) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_Evaluate_RangeExpr_Internal): a range with more than 100000000 entries cannot be constructed." << EidosTerminate(operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->reserve((int)(first_float - second_float + 1)); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->reserve((int)(first_float - second_float + 1)); for (double range_index = first_float; range_index >= second_float; ) { @@ -2148,12 +2148,12 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) + second_child_value->NumericAtIndex_NOCAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(first_child_value->NumericAtIndex_NOCAST(0, operator_token) + second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { @@ -2186,8 +2186,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (first_child_count == 1) { double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(second_child_count); if (second_child_type == EidosValueType::kValueInt) { @@ -2209,8 +2209,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (second_child_count == 1) { double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if (first_child_type == EidosValueType::kValueInt) { @@ -2306,13 +2306,13 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(-first_child_value->FloatAtIndex_NOCAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(-first_child_value->FloatAtIndex_NOCAST(0, operator_token))); } else { const double *first_child_data = first_child_value->FloatData(); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) float_result->set_float_no_check(-first_child_data[value_index], value_index); @@ -2448,12 +2448,12 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) - second_child_value->NumericAtIndex_NOCAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(first_child_value->NumericAtIndex_NOCAST(0, operator_token) - second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { @@ -2486,8 +2486,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) else if (first_child_count == 1) { double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(second_child_count); if (second_child_type == EidosValueType::kValueInt) { @@ -2509,8 +2509,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) else if (second_child_count == 1) { double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if (first_child_type == EidosValueType::kValueInt) { @@ -2582,12 +2582,12 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(fmod(first_child_value->NumericAtIndex_NOCAST(0, operator_token), second_child_value->NumericAtIndex_NOCAST(0, operator_token)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(fmod(first_child_value->NumericAtIndex_NOCAST(0, operator_token), second_child_value->NumericAtIndex_NOCAST(0, operator_token)))); } else { - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { @@ -2628,8 +2628,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) else if (first_child_count == 1) { double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(second_child_count); if (second_child_type == EidosValueType::kValueInt) { @@ -2651,8 +2651,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mod(const EidosASTNode *p_node) else if (second_child_count == 1) { double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if (first_child_type == EidosValueType::kValueInt) { @@ -2764,12 +2764,12 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) * second_child_value->NumericAtIndex_NOCAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(first_child_value->NumericAtIndex_NOCAST(0, operator_token) * second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { @@ -2851,8 +2851,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) { const int64_t *any_count_data = any_count_child->IntData(); double singleton_float = one_count_child->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(any_count); for (int value_index = 0; value_index < any_count; ++value_index) float_result->set_float_no_check(any_count_data[value_index] * singleton_float, value_index); @@ -2863,8 +2863,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) { const double *any_count_data = any_count_child->FloatData(); double singleton_float = one_count_child->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(any_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(any_count); for (int value_index = 0; value_index < any_count; ++value_index) float_result->set_float_no_check(any_count_data[value_index] * singleton_float, value_index); @@ -2927,12 +2927,12 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(first_child_value->NumericAtIndex_NOCAST(0, operator_token) / second_child_value->NumericAtIndex_NOCAST(0, operator_token))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(first_child_value->NumericAtIndex_NOCAST(0, operator_token) / second_child_value->NumericAtIndex_NOCAST(0, operator_token))); } else { - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { @@ -2973,8 +2973,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) else if (first_child_count == 1) { double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(second_child_count); if (second_child_type == EidosValueType::kValueInt) { @@ -2996,8 +2996,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Div(const EidosASTNode *p_node) else if (second_child_count == 1) { double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if (first_child_type == EidosValueType::kValueInt) { @@ -3104,12 +3104,12 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) { if (first_child_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(pow(first_child_value->NumericAtIndex_NOCAST(0, operator_token), second_child_value->NumericAtIndex_NOCAST(0, operator_token)))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(pow(first_child_value->NumericAtIndex_NOCAST(0, operator_token), second_child_value->NumericAtIndex_NOCAST(0, operator_token)))); } else { - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if ((first_child_type == EidosValueType::kValueFloat) && (second_child_type == EidosValueType::kValueFloat)) { @@ -3150,8 +3150,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) else if (first_child_count == 1) { double singleton_float = first_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(second_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(second_child_count); if (second_child_type == EidosValueType::kValueInt) { @@ -3173,8 +3173,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Exp(const EidosASTNode *p_node) else if (second_child_count == 1) { double singleton_float = second_child_value->NumericAtIndex_NOCAST(0, operator_token); - EidosValue_Float_vector_SP float_result_SP = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - EidosValue_Float_vector *float_result = float_result_SP->resize_no_initialize(first_child_count); + EidosValue_Float_SP float_result_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); + EidosValue_Float *float_result = float_result_SP->resize_no_initialize(first_child_count); if (first_child_type == EidosValueType::kValueInt) { @@ -3867,7 +3867,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) if ((lvalue_count == 1) && lvalue->IsSingleton()) { - EidosValue_Float_singleton *float_singleton = static_cast(lvalue); + EidosValue_Float *float_singleton = static_cast(lvalue); switch (compound_operator) { @@ -5179,7 +5179,7 @@ EidosValue_SP EidosInterpreter::NumericValueForString(const std::string &p_numbe if (errno || (last_used_char == c_str)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::NumericValueForString): '" << p_number_string << "' could not be represented as a float (strtod conversion error)." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(converted_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(converted_value)); } else if ((p_number_string.find('e') != std::string::npos) || (p_number_string.find('E') != std::string::npos)) // has an exponent { @@ -5888,14 +5888,14 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) else if (range_type == EidosValueType::kValueFloat) { const double *range_data = range_value->FloatData(); - EidosValue_Float_singleton_SP index_value_SP = EidosValue_Float_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(0)); - EidosValue_Float_singleton *index_value = index_value_SP.get(); + EidosValue_Float_SP index_value_SP = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(0)); + EidosValue_Float *index_value = index_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(identifier_name, index_value_SP); for (int range_index = 0; range_index < range_count; ++range_index) { - index_value->SetValue(range_data[range_index]); + index_value->data()[0] = range_data[range_index]; EidosASTNode *statement_node = p_node->children_[2]; diff --git a/eidos/eidos_script.cpp b/eidos/eidos_script.cpp index 477cc6545..cc78b4b48 100644 --- a/eidos/eidos_script.cpp +++ b/eidos/eidos_script.cpp @@ -2406,7 +2406,7 @@ EidosASTNode *EidosScript::Parse_DefaultValue(void) if (numeric_value->Type() == EidosValueType::kValueFloat) { double float_value = numeric_value->FloatAtIndex_NOCAST(0, current_token_); - negated_value = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(-float_value)); + negated_value = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(-float_value)); } else if (numeric_value->Type() == EidosValueType::kValueInt) { diff --git a/eidos/eidos_symbol_table.cpp b/eidos/eidos_symbol_table.cpp index da779f63b..e43570973 100644 --- a/eidos/eidos_symbol_table.cpp +++ b/eidos/eidos_symbol_table.cpp @@ -153,10 +153,10 @@ EidosSymbolTable::EidosSymbolTable(EidosSymbolTableType p_table_type, EidosSymbo trueConstant = new EidosSymbolTableEntry(gEidosID_T, gStaticEidosValue_LogicalT); falseConstant = new EidosSymbolTableEntry(gEidosID_F, gStaticEidosValue_LogicalF); nullConstant = new EidosSymbolTableEntry(gEidosID_NULL, gStaticEidosValueNULL); - piConstant = new EidosSymbolTableEntry(gEidosID_PI, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_PI))); - eConstant = new EidosSymbolTableEntry(gEidosID_E, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(M_E))); - infConstant = new EidosSymbolTableEntry(gEidosID_INF, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::infinity()))); - nanConstant = new EidosSymbolTableEntry(gEidosID_NAN, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(std::numeric_limits::quiet_NaN()))); + piConstant = new EidosSymbolTableEntry(gEidosID_PI, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(M_PI))); + eConstant = new EidosSymbolTableEntry(gEidosID_E, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(M_E))); + infConstant = new EidosSymbolTableEntry(gEidosID_INF, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(std::numeric_limits::infinity()))); + nanConstant = new EidosSymbolTableEntry(gEidosID_NAN, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(std::numeric_limits::quiet_NaN()))); // ensure that the constant_ flag is set on all of these values, to prevent modification in all code paths piConstant->second->MarkAsConstant(); diff --git a/eidos/eidos_test.cpp b/eidos/eidos_test.cpp index 534e49b17..9aec38eee 100644 --- a/eidos/eidos_test.cpp +++ b/eidos/eidos_test.cpp @@ -181,12 +181,12 @@ void EidosAssertScriptSuccess_IV(const std::string &p_script_string, std::initia void EidosAssertScriptSuccess_F(const std::string &p_script_string, double p_float) { - EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(p_float))); + EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(p_float))); } void EidosAssertScriptSuccess_FV(const std::string &p_script_string, std::initializer_list p_float_vec) { - EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(p_float_vec))); + EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(p_float_vec))); } void EidosAssertScriptSuccess_S(const std::string &p_script_string, const char *p_string) diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index bf8d04d54..f3a7ce7d8 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1725,7 +1725,7 @@ void EidosValue_Int_singleton::PushValueFromIndexOfEidosValue(int p_idx, const E #pragma unused(p_idx, p_source_script_value) WILL_MODIFY(this); - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Int_singleton is not modifiable." << EidosTerminate(p_blame_token); } void EidosValue_Int_singleton::Sort(bool p_ascending) @@ -1733,7 +1733,7 @@ void EidosValue_Int_singleton::Sort(bool p_ascending) #pragma unused(p_ascending) WILL_MODIFY(this); - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::Sort): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::Sort): (internal error) EidosValue_Int_singleton is not modifiable." << EidosTerminate(nullptr); } @@ -1744,6 +1744,33 @@ void EidosValue_Int_singleton::Sort(bool p_ascending) #pragma mark EidosValue_Float #pragma mark - +EidosValue_Float::EidosValue_Float(const std::vector &p_doublevec) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) +{ + size_t count = p_doublevec.size(); + const double *values = p_doublevec.data(); + + resize_no_initialize(count); + + for (size_t index = 0; index < count; ++index) + set_float_no_check(values[index], index); +} + +EidosValue_Float::EidosValue_Float(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) +{ + reserve(p_init_list.size()); + + for (auto init_item : p_init_list) + push_float_no_check(init_item); +} + +EidosValue_Float::EidosValue_Float(const double *p_values, size_t p_count) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) +{ + resize_no_initialize(p_count); + + for (size_t index = 0; index < p_count; ++index) + set_float_no_check(p_values[index], index); +} + const std::string &EidosValue_Float::ElementType(void) const { return gEidosStr_float; @@ -1751,7 +1778,7 @@ const std::string &EidosValue_Float::ElementType(void) const EidosValue_SP EidosValue_Float::NewMatchingType(void) const { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); } void EidosValue_Float::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const @@ -1770,130 +1797,108 @@ nlohmann::json EidosValue_Float::JSONRepresentation(void) const return json_object; } - -// EidosValue_Float_vector -#pragma mark EidosValue_Float_vector - -EidosValue_Float_vector::EidosValue_Float_vector(const std::vector &p_doublevec) : EidosValue_Float(false) -{ - size_t count = p_doublevec.size(); - const double *values = p_doublevec.data(); - - resize_no_initialize(count); - - for (size_t index = 0; index < count; ++index) - set_float_no_check(values[index], index); -} - -EidosValue_Float_vector::EidosValue_Float_vector(std::initializer_list p_init_list) : EidosValue_Float(false) -{ - reserve(p_init_list.size()); - - for (auto init_item : p_init_list) - push_float_no_check(init_item); -} - -EidosValue_Float_vector::EidosValue_Float_vector(const double *p_values, size_t p_count) : EidosValue_Float(false) -{ - resize_no_initialize(p_count); - - for (size_t index = 0; index < p_count; ++index) - set_float_no_check(p_values[index], index); -} - -double EidosValue_Float_vector::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::FloatAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -double EidosValue_Float_vector::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { // casts integer to float, otherwise does not cast; considered _NOCAST if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -eidos_logical_t EidosValue_Float_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_Float::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; if (std::isnan(value)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::LogicalAtIndex_CAST): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::LogicalAtIndex_CAST): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); return (value == 0 ? false : true); } -std::string EidosValue_Float_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_Float::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosStringForFloat(values_[p_idx]); } -int64_t EidosValue_Float_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Float::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); double value = values_[p_idx]; if (std::isnan(value)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::IntAtIndex_CAST): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); if (std::isinf(value)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::IntAtIndex_CAST): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... if ((value < (double)INT64_MIN) || (value >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::IntAtIndex_CAST): float value " << value << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::IntAtIndex_CAST): float value " << value << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); return static_cast(value); } -double EidosValue_Float_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Float::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -EidosValue_SP EidosValue_Float_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const +EidosValue_SP EidosValue_Float::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(values_[p_idx])); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(values_[p_idx])); } -EidosValue_SP EidosValue_Float_vector::CopyValues(void) const +EidosValue_SP EidosValue_Float::CopyValues(void) const { // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(values_, count_))->CopyDimensionsFromValue(this)); + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float(values_, count_))->CopyDimensionsFromValue(this)); } -void EidosValue_Float_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) +EidosValue_SP EidosValue_Float::VectorBasedCopy(void) const +{ + // same as CopyValues() now; slated for removal + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float(values_, count_))->CopyDimensionsFromValue(this)); +} + +void EidosValue_Float::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); if (p_source_script_value.Type() == EidosValueType::kValueFloat) push_float(p_source_script_value.FloatAtIndex_NOCAST(p_idx, p_blame_token)); else - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Float::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } -void EidosValue_Float_vector::Sort(bool p_ascending) +void EidosValue_Float::Sort(bool p_ascending) { WILL_MODIFY(this); + if (count_ < 2) + return; + // Unfortunately a custom comparator is needed to make the sort order with NANs match that of R if (p_ascending) Eidos_ParallelSort_Comparator(values_, count_, [](const double& a, const double& b) { return std::isnan(b) || (a < b); }); @@ -1901,15 +1906,30 @@ void EidosValue_Float_vector::Sort(bool p_ascending) Eidos_ParallelSort_Comparator(values_, count_, [](const double& a, const double& b) { return std::isnan(b) || (a > b); }); } -EidosValue_Float_vector *EidosValue_Float_vector::reserve(size_t p_reserved_size) +EidosValue_Float *EidosValue_Float::reserve(size_t p_reserved_size) { WILL_MODIFY(this); if (p_reserved_size > capacity_) { - values_ = (double *)realloc(values_, p_reserved_size * sizeof(double)); - if (!values_) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_vector::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + // this is a reservation for an explicit size, so we give that size exactly, to avoid wasting space + + if (values_ == &singleton_value_) + { + values_ = (double *)malloc(p_reserved_size * sizeof(double)); + + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Float::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + + values_[0] = singleton_value_; + } + else + { + values_ = (double *)realloc(values_, p_reserved_size * sizeof(double)); + + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Float::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + } capacity_ = p_reserved_size; } @@ -1917,27 +1937,7 @@ EidosValue_Float_vector *EidosValue_Float_vector::reserve(size_t p_reserved_size return this; } -EidosValue_Float_vector *EidosValue_Float_vector::resize_no_initialize(size_t p_new_size) -{ - WILL_MODIFY(this); - - reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees - count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size - - return this; -} - -void EidosValue_Float_vector::expand(void) -{ - WILL_MODIFY(this); - - if (capacity_ == 0) - reserve(16); // if no reserve() call was made, start out with a bit of room - else - reserve(capacity_ << 1); -} - -void EidosValue_Float_vector::erase_index(size_t p_index) +void EidosValue_Float::erase_index(size_t p_index) { WILL_MODIFY(this); @@ -1960,114 +1960,6 @@ void EidosValue_Float_vector::erase_index(size_t p_index) } - -// EidosValue_Float_singleton -#pragma mark EidosValue_Float_singleton - -double EidosValue_Float_singleton::FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -double EidosValue_Float_singleton::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - // casts integer to float, otherwise does not cast; considered _NOCAST - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -eidos_logical_t EidosValue_Float_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - if (std::isnan(value_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::LogicalAtIndex_CAST): NAN cannot be converted to logical type." << EidosTerminate(p_blame_token); - - return (value_ == 0 ? false : true); -} - -std::string EidosValue_Float_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosStringForFloat(value_); -} - -int64_t EidosValue_Float_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - if (std::isnan(value_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): NAN cannot be converted to integer type." << EidosTerminate(p_blame_token); - if (std::isinf(value_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): INF cannot be converted to integer type." << EidosTerminate(p_blame_token); - - // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... - if ((value_ < (double)INT64_MIN) || (value_ >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::IntAtIndex_CAST): float value " << value_ << " is too large to be converted to integer type." << EidosTerminate(p_blame_token); - - return static_cast(value_); -} - -double EidosValue_Float_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -EidosValue_SP EidosValue_Float_singleton::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(value_)); -} - -EidosValue_SP EidosValue_Float_singleton::CopyValues(void) const -{ - // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(value_))->CopyDimensionsFromValue(this)); -} - -EidosValue_SP EidosValue_Float_singleton::VectorBasedCopy(void) const -{ - // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added - // note that constness, invisibility, etc. do not get copied - EidosValue_Float_vector_SP new_vec = EidosValue_Float_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector()); - - new_vec->push_float(value_); - new_vec->CopyDimensionsFromValue(this); - - return new_vec; -} - -void EidosValue_Float_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_source_script_value) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - -void EidosValue_Float_singleton::Sort(bool p_ascending) -{ -#pragma unused(p_ascending) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_Float_singleton::Sort): (internal error) EidosValue_Float_singleton is not modifiable." << EidosTerminate(nullptr); -} - - // // EidosValue_Object // @@ -2888,7 +2780,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ } else if (sig_mask == kEidosValueMaskFloat) { - EidosValue_Float_vector *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(); + EidosValue_Float *float_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Float(); if (return_is_singleton) { diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index f2f3e0bd6..f54d35398 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -832,9 +832,7 @@ class EidosValue_Int_singleton final : public EidosValue_Int // ********************************************************************************************************* // -// EidosValue_Float represents floating-point (C++ double) values in Eidos. The subclass -// EidosValue_Float_vector is the standard instance class, used to hold vectors of floats. -// EidosValue_Float_singleton is used for speed, to represent single values. +// EidosValue_Float represents floating-point (C++ double) values in Eidos. // class EidosValue_Float : public EidosValue @@ -843,54 +841,33 @@ class EidosValue_Float : public EidosValue typedef EidosValue super; protected: - explicit inline EidosValue_Float(bool p_singleton) : EidosValue(EidosValueType::kValueFloat, p_singleton) {} - - virtual int Count_Virtual(void) const override = 0; - -public: - EidosValue_Float(const EidosValue_Float &p_original) = delete; // no copy-construct - EidosValue_Float(void) = delete; // no default constructor - EidosValue_Float& operator=(const EidosValue_Float&) = delete; // no copying - inline virtual ~EidosValue_Float(void) override { } - - virtual const std::string &ElementType(void) const override; - virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; - virtual nlohmann::json JSONRepresentation(void) const override; - - virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - - virtual EidosValue_SP CopyValues(void) const override = 0; - virtual EidosValue_SP NewMatchingType(void) const override; - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override = 0; - virtual void Sort(bool p_ascending) override = 0; -}; - -class EidosValue_Float_vector final : public EidosValue_Float -{ -private: - typedef EidosValue_Float super; - -protected: - double *values_ = nullptr; - size_t count_ = 0, capacity_ = 0; + // singleton/vector design: values_ will either point to singleton_value_, or to a malloced buffer; it will never be nullptr + // in the case of a zero-length vector, note that values_ will point to singleton_value_ with count_ == 0 but capacity_ == 1 + double singleton_value_; + double *values_; + size_t count_, capacity_; virtual int Count_Virtual(void) const override { return (int)count_; } public: - EidosValue_Float_vector(const EidosValue_Float_vector &p_original) = delete; // no copy-construct - EidosValue_Float_vector& operator=(const EidosValue_Float_vector&) = delete; // no copying + EidosValue_Float(const EidosValue_Float &p_original) = delete; // no copy-construct + EidosValue_Float& operator=(const EidosValue_Float&) = delete; // no copying - inline EidosValue_Float_vector(void) : EidosValue_Float(false) { } - explicit EidosValue_Float_vector(const std::vector &p_doublevec); - //explicit EidosValue_Float_vector(double p_float1); // disabled to encourage use of EidosValue_Float_singleton for this case - explicit EidosValue_Float_vector(std::initializer_list p_init_list); - explicit EidosValue_Float_vector(const double *p_values, size_t p_count); - inline virtual ~EidosValue_Float_vector(void) override { free(values_); } + explicit inline EidosValue_Float(void) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) { } + explicit inline EidosValue_Float(double p_float1) : EidosValue(EidosValueType::kValueFloat, false), singleton_value_(p_float1), values_(&singleton_value_), count_(1), capacity_(1) { } + explicit EidosValue_Float(const std::vector &p_doublevec); + explicit EidosValue_Float(std::initializer_list p_init_list); + explicit EidosValue_Float(const double *p_values, size_t p_count); + inline virtual ~EidosValue_Float(void) override { if (values_ != &singleton_value_) free(values_); } virtual const double *FloatData(void) const override { return values_; } virtual double *FloatData_Mutable(void) override { WILL_MODIFY(this); return values_; } + virtual const std::string &ElementType(void) const override; + virtual EidosValue_SP NewMatchingType(void) const override; + virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; + virtual nlohmann::json JSONRepresentation(void) const override; + virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast @@ -900,16 +877,36 @@ class EidosValue_Float_vector final : public EidosValue_Float virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; + virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; + + // vector lookalike methods for speed; not virtual, only for clients with an EidosValue_Float* + EidosValue_Float *reserve(size_t p_reserved_size); // as in std::vector + void erase_index(size_t p_index); // a weak substitute for erase() - // vector lookalike methods; not virtual, only for clients with a EidosValue_Int_vector* - EidosValue_Float_vector *reserve(size_t p_reserved_size); // as in std::vector - EidosValue_Float_vector *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! - void expand(void); // expand to fit (at least) one new value - void erase_index(size_t p_index); // a weak substitute for erase() + inline void expand(void) + { + // expand to fit (at least) one new value + WILL_MODIFY(this); + + if (capacity_ <= 8) + reserve(16); + else + reserve(capacity_ << 1); + } + + inline EidosValue_Float *resize_no_initialize(size_t p_new_size) + { + // resizes but does not zero-initialize, unlike std::vector! + WILL_MODIFY(this); + + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees + count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size + + return this; + } inline __attribute__((always_inline)) double *data(void) { WILL_MODIFY(this); return values_; } inline __attribute__((always_inline)) const double *data(void) const { return values_; } @@ -937,45 +934,6 @@ class EidosValue_Float_vector final : public EidosValue_Float } }; -class EidosValue_Float_singleton final : public EidosValue_Float -{ -private: - typedef EidosValue_Float super; - -protected: - double value_; - - virtual int Count_Virtual(void) const override { return 1; } - -public: - EidosValue_Float_singleton(const EidosValue_Float_singleton &p_original) = delete; // no copy-construct - EidosValue_Float_singleton& operator=(const EidosValue_Float_singleton&) = delete; // no copying - EidosValue_Float_singleton(void) = delete; - explicit inline EidosValue_Float_singleton(double p_float1) : EidosValue_Float(true), value_(p_float1) { } - inline virtual ~EidosValue_Float_singleton(void) override { } - - virtual const double *FloatData(void) const override { return &value_; } - virtual double *FloatData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; used only in Evaluate_Assign() - inline __attribute__((always_inline)) void SetValue(double p_float) { WILL_MODIFY(this); value_ = p_float; } // very dangerous; used only in Evaluate_For() - - virtual double FloatAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast - - virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; - - virtual EidosValue_SP VectorBasedCopy(void) const override; - - // prohibited actions because there is no backing vector - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; - virtual void Sort(bool p_ascending) override; -}; - #pragma mark - #pragma mark EidosValue_Object From 3c2b97823216903922719bd6ccde31ed3b95abb4 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 11:50:30 -0500 Subject: [PATCH 13/18] abolish the singleton/vector distinction for EidosValue_Int --- SLiMgui/slim_gui.mm | 2 +- core/chromosome.cpp | 28 +-- core/community_eidos.cpp | 6 +- core/genome.cpp | 16 +- core/genomic_element.cpp | 12 +- core/genomic_element_type.cpp | 8 +- core/individual.cpp | 30 +-- core/interaction_type.cpp | 22 +- core/log_file.cpp | 14 +- core/mutation.cpp | 22 +- core/mutation_type.cpp | 10 +- core/population.cpp | 10 +- core/slim_eidos_block.cpp | 10 +- core/slim_functions.cpp | 14 +- core/slim_globals.cpp | 6 +- core/spatial_map.cpp | 8 +- core/species_eidos.cpp | 14 +- core/subpopulation.cpp | 24 +-- core/substitution.cpp | 26 +-- eidos/eidos_class_DataFrame.cpp | 8 +- eidos/eidos_class_Dictionary.cpp | 10 +- eidos/eidos_class_Image.cpp | 10 +- eidos/eidos_class_Object.cpp | 2 +- eidos/eidos_class_TestElement.cpp | 8 +- eidos/eidos_functions.cpp | 14 +- eidos/eidos_functions_distributions.cpp | 38 ++-- eidos/eidos_functions_math.cpp | 66 +++--- eidos/eidos_functions_matrices.cpp | 22 +- eidos/eidos_functions_other.cpp | 256 +++++++++++------------ eidos/eidos_functions_stats.cpp | 14 +- eidos/eidos_functions_strings.cpp | 12 +- eidos/eidos_functions_values.cpp | 70 +++---- eidos/eidos_globals.cpp | 14 +- eidos/eidos_globals.h | 4 - eidos/eidos_interpreter.cpp | 80 ++++---- eidos/eidos_script.cpp | 2 +- eidos/eidos_test.cpp | 4 +- eidos/eidos_test_functions_other.cpp | 6 +- eidos/eidos_value.cpp | 262 ++++++++---------------- eidos/eidos_value.h | 134 +++++------- 40 files changed, 586 insertions(+), 732 deletions(-) diff --git a/SLiMgui/slim_gui.mm b/SLiMgui/slim_gui.mm index 475fda626..10bbb2bae 100644 --- a/SLiMgui/slim_gui.mm +++ b/SLiMgui/slim_gui.mm @@ -69,7 +69,7 @@ // constants case gID_pid: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(getpid())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(getpid())); } // variables diff --git a/core/chromosome.cpp b/core/chromosome.cpp index daa470df2..539f8cd2a 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -867,7 +867,7 @@ Mutation *Chromosome::ApplyMutationCallbacks(Mutation *p_mut, Genome *p_genome, // The callback is active and matches the mutation type id of the mutation, so we need to execute it // This code is similar to Population::ExecuteScript, but we set up an additional symbol table, and we use the return value EidosValue_Object_singleton local_mut(p_mut, gSLiM_Mutation_Class); - EidosValue_Int_singleton local_originalNuc(p_original_nucleotide); + EidosValue_Int local_originalNuc(p_original_nucleotide); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table { @@ -1580,7 +1580,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) case gID_lastPosition: { if (!cached_value_lastpos_) - cached_value_lastpos_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(last_position_)); + cached_value_lastpos_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(last_position_)); return cached_value_lastpos_; } @@ -1590,7 +1590,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotEndPositions is only defined in nucleotide-based models." << EidosTerminate(); if (!single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotEndPositions is not defined since sex-specific hotspot maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(hotspot_end_positions_H_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(hotspot_end_positions_H_)); } case gID_hotspotEndPositionsM: { @@ -1598,7 +1598,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotEndPositionsM is only defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotEndPositionsM is not defined since sex-specific hotspot maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(hotspot_end_positions_M_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(hotspot_end_positions_M_)); } case gID_hotspotEndPositionsF: { @@ -1606,7 +1606,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotEndPositionsF is only defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotEndPositionsF is not defined since sex-specific hotspot maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(hotspot_end_positions_F_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(hotspot_end_positions_F_)); } case gID_hotspotMultipliers: @@ -1640,7 +1640,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationEndPositions is not defined in nucleotide-based models." << EidosTerminate(); if (!single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationEndPositions is not defined since sex-specific mutation rate maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(mutation_end_positions_H_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_end_positions_H_)); } case gID_mutationEndPositionsM: { @@ -1648,7 +1648,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationEndPositionsM is not defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationEndPositionsM is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(mutation_end_positions_M_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_end_positions_M_)); } case gID_mutationEndPositionsF: { @@ -1656,7 +1656,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationEndPositionsF is not defined in nucleotide-based models." << EidosTerminate(); if (single_mutation_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationEndPositionsF is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(mutation_end_positions_F_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_end_positions_F_)); } case gID_mutationRates: @@ -1732,19 +1732,19 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) { if (!single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationEndPositions is not defined since sex-specific recombination rate maps have been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(recombination_end_positions_H_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(recombination_end_positions_H_)); } case gID_recombinationEndPositionsM: { if (single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationEndPositionsM is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(recombination_end_positions_M_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(recombination_end_positions_M_)); } case gID_recombinationEndPositionsF: { if (single_recombination_map_) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationEndPositionsF is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(recombination_end_positions_F_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(recombination_end_positions_F_)); } case gID_recombinationRates: @@ -1807,7 +1807,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property tag accessed on chromosome before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -2002,7 +2002,7 @@ EidosValue_SP Chromosome::ExecuteMethod_drawBreakpoints(EidosGlobalStringID p_me if (all_breakpoints.size() == 0) return gStaticEidosValue_Integer_ZeroVec; else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(all_breakpoints)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(all_breakpoints)); } // ********************* (integer$)setAncestralNucleotides(is sequence) @@ -2136,7 +2136,7 @@ EidosValue_SP Chromosome::ExecuteMethod_setAncestralNucleotides(EidosGlobalStrin // debugging //std::cout << "ancestral sequence set: " << *ancestral_seq_buffer_ << std::endl; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(ancestral_seq_buffer_->size())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(ancestral_seq_buffer_->size())); } // ********************* – (void)setGeneConversion(numeric$ nonCrossoverFraction, numeric$ meanLength, numeric$ simpleConversionFraction, [numeric$ bias = 0]) diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index fcbe7a8c9..b447d6311 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -420,7 +420,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) if (cached_value_tick_ && (cached_value_tick_->IntData()[0] != tick_)) cached_value_tick_.reset(); if (!cached_value_tick_) - cached_value_tick_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tick_)); + cached_value_tick_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tick_)); return cached_value_tick_; } case gID_cycleStage: @@ -436,10 +436,10 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Community::GetProperty): property tag accessed on simulation object before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } case gID_verbosity: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(SLiM_verbosity_level)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(SLiM_verbosity_level)); // all others, including gID_none default: diff --git a/core/genome.cpp b/core/genome.cpp index a310a56e6..184369c7e 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -418,7 +418,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) if (!individual_->subpopulation_->species_.PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Genome::GetProperty): property genomePedigreeID is not available because pedigree recording has not been enabled." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(genome_id_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(genome_id_)); } case gID_genomeType: { @@ -468,7 +468,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Genome::GetProperty): property tag accessed on genome before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -479,7 +479,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) EidosValue *Genome::GetProperty_Accelerated_genomePedigreeID(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); size_t value_index = 0; // check that pedigrees are enabled, once @@ -520,7 +520,7 @@ EidosValue *Genome::GetProperty_Accelerated_isNullGenome(EidosObject **p_values, EidosValue *Genome::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -817,7 +817,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_countOfMutationsOfType(EidosObje // Count the number of mutations of the given type const int32_t mutrun_count = ((Genome *)(p_elements[0]))->mutrun_count_; Mutation *mut_block_ptr = gSLiM_Mutation_Block; - EidosValue_Int_vector *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_elements_size); + EidosValue_Int *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_elements_size); bool saw_error = false; EIDOS_THREAD_COUNT(gEidos_OMP_threads_G_COUNT_OF_MUTS_OF_TYPE); @@ -970,7 +970,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, // patch the sequence with nucleotide mutations // no singleton case; we force a vector return from NucleotidesAsCodonVector() for simplicity - int64_t *int_vec = ((EidosValue_Int_vector *)(codon_value.get()))->data(); + int64_t *int_vec = ((EidosValue_Int *)(codon_value.get()))->data(); GenomeWalker walker(this); walker.MoveToPosition(start); @@ -1119,7 +1119,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, else { // vector case: replace the appropriate element in integer_value - int64_t *int_vec = ((EidosValue_Int_vector *)(integer_value.get()))->data(); + int64_t *int_vec = ((EidosValue_Int *)(integer_value.get()))->data(); GenomeWalker walker(this); walker.MoveToPosition(start); @@ -1226,7 +1226,7 @@ EidosValue_SP Genome::ExecuteMethod_positionsOfMutationsOfType(EidosGlobalString MutationType *mutation_type_ptr = SLiM_ExtractMutationTypeFromEidosValue_io(mutType_value, 0, &species.community_, &species, "positionsOfMutationsOfType()"); // SPECIES CONSISTENCY CHECK // Return the positions of mutations of the given type - EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); Mutation *mut_block_ptr = gSLiM_Mutation_Block; for (int run_index = 0; run_index < mutrun_count_; ++run_index) diff --git a/core/genomic_element.cpp b/core/genomic_element.cpp index 9312d1a16..1f71055fd 100644 --- a/core/genomic_element.cpp +++ b/core/genomic_element.cpp @@ -80,9 +80,9 @@ EidosValue_SP GenomicElement::GetProperty(EidosGlobalStringID p_property_id) case gID_genomicElementType: // ACCELERATED return genomic_element_type_ptr_->SymbolTableEntry().second; case gID_startPosition: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(start_position_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(start_position_)); case gID_endPosition: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(end_position_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(end_position_)); // variables case gID_tag: // ACCELERATED @@ -92,7 +92,7 @@ EidosValue_SP GenomicElement::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (GenomicElement::GetProperty): property tag accessed on genomic element before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -103,7 +103,7 @@ EidosValue_SP GenomicElement::GetProperty(EidosGlobalStringID p_property_id) EidosValue *GenomicElement::GetProperty_Accelerated_startPosition(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -117,7 +117,7 @@ EidosValue *GenomicElement::GetProperty_Accelerated_startPosition(EidosObject ** EidosValue *GenomicElement::GetProperty_Accelerated_endPosition(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -131,7 +131,7 @@ EidosValue *GenomicElement::GetProperty_Accelerated_endPosition(EidosObject **p_ EidosValue *GenomicElement::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index 88726292b..5c3d0d6a1 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -254,7 +254,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) case gID_id: // ACCELERATED { if (!cached_value_getype_id_) - cached_value_getype_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(genomic_element_type_id_)); + cached_value_getype_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(genomic_element_type_id_)); return cached_value_getype_id_; } case gID_mutationTypes: @@ -292,7 +292,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (GenomicElementType::GetProperty): property tag accessed on genomic element type before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -303,7 +303,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) EidosValue *GenomicElementType::GetProperty_Accelerated_id(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -317,7 +317,7 @@ EidosValue *GenomicElementType::GetProperty_Accelerated_id(EidosObject **p_value EidosValue *GenomicElementType::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/individual.cpp b/core/individual.cpp index 2738de857..d0223c673 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -344,7 +344,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) } case gID_index: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(index_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(index_)); } case gID_genomes: { @@ -421,7 +421,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (age_ == -1) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property age is not available in WF models." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(age_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(age_)); } case gID_meanParentAge: { @@ -435,14 +435,14 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (!subpopulation_->species_.PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property pedigreeID is not available because pedigree recording has not been enabled." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(pedigree_id_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(pedigree_id_)); } case gID_pedigreeParentIDs: { if (!subpopulation_->species_.PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property pedigreeParentIDs is not available because pedigree recording has not been enabled." << EidosTerminate(); - EidosValue_Int_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(2); + EidosValue_Int *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(2); vec->set_int_no_check(pedigree_p1_, 0); vec->set_int_no_check(pedigree_p2_, 1); @@ -454,7 +454,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (!subpopulation_->species_.PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property pedigreeGrandparentIDs is not available because pedigree recording has not been enabled." << EidosTerminate(); - EidosValue_Int_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(4); + EidosValue_Int *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(4); vec->set_int_no_check(pedigree_g1_, 0); vec->set_int_no_check(pedigree_g2_, 1); @@ -468,7 +468,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (!subpopulation_->species_.PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property reproductiveOutput is not available because pedigree recording has not been enabled." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(reproductive_output_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(reproductive_output_)); } case gID_spatialPosition: // ACCELERATED { @@ -631,7 +631,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property tag accessed on individual before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } case gID_tagF: // ACCELERATED { @@ -720,7 +720,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) EidosValue *Individual::GetProperty_Accelerated_index(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -734,7 +734,7 @@ EidosValue *Individual::GetProperty_Accelerated_index(EidosObject **p_values, si EidosValue *Individual::GetProperty_Accelerated_pedigreeID(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); size_t value_index = 0; // check that pedigrees are enabled, once @@ -761,7 +761,7 @@ EidosValue *Individual::GetProperty_Accelerated_pedigreeID(EidosObject **p_value EidosValue *Individual::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -782,7 +782,7 @@ EidosValue *Individual::GetProperty_Accelerated_age(EidosObject **p_values, size if ((p_values_size > 0) && (((Individual *)(p_values[0]))->subpopulation_->community_.ModelType() == SLiMModelType::kModelTypeWF)) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property age is not available in WF models." << EidosTerminate(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -799,7 +799,7 @@ EidosValue *Individual::GetProperty_Accelerated_reproductiveOutput(EidosObject * if ((p_values_size > 0) && !((Individual *)(p_values[0]))->subpopulation_->species_.PedigreesEnabledByUser()) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property reproductiveOutput is not available because pedigree recording has not been enabled." << EidosTerminate(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1705,7 +1705,7 @@ EidosValue_SP Individual::ExecuteMethod_Accelerated_countOfMutationsOfType(Eidos // Count the number of mutations of the given type Mutation *mut_block_ptr = gSLiM_Mutation_Block; - EidosValue_Int_vector *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_elements_size); + EidosValue_Int *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_elements_size); EIDOS_THREAD_COUNT(gEidos_OMP_threads_I_COUNT_OF_MUTS_OF_TYPE); #pragma omp parallel for schedule(dynamic, 1) default(none) shared(p_elements_size) firstprivate(p_elements, mut_block_ptr, mutation_type_ptr, integer_result) if(p_elements_size >= EIDOS_OMPMIN_I_COUNT_OF_MUTS_OF_TYPE) num_threads(thread_count) @@ -1848,11 +1848,11 @@ EidosValue_SP Individual::ExecuteMethod_sharedParentCount(EidosGlobalStringID p_ else shared_count = (ind == this) ? 2.0 : 0.0; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(shared_count)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(shared_count)); } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(individuals_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(individuals_count); if (pedigree_tracking_enabled) { diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 660248454..87b023e2e 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -3462,7 +3462,7 @@ EidosValue_SP InteractionType::GetProperty(EidosGlobalStringID p_property_id) case gID_id: // ACCELERATED { if (!cached_value_inttype_id_) - cached_value_inttype_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(interaction_type_id_)); + cached_value_inttype_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(interaction_type_id_)); return cached_value_inttype_id_; } case gID_reciprocal: @@ -3504,7 +3504,7 @@ EidosValue_SP InteractionType::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (InteractionType::GetProperty): property tag accessed on interaction type before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -3515,7 +3515,7 @@ EidosValue_SP InteractionType::GetProperty(EidosGlobalStringID p_property_id) EidosValue *InteractionType::GetProperty_Accelerated_id(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -3529,7 +3529,7 @@ EidosValue *InteractionType::GetProperty_Accelerated_id(EidosObject **p_values, EidosValue *InteractionType::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -4655,7 +4655,7 @@ EidosValue_SP InteractionType::ExecuteMethod_interactingNeighborCount(EidosGloba } else { - EidosValue_Int_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(receivers_count); + EidosValue_Int *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(receivers_count); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) result_vec->set_int_no_check(0, receiver_index); @@ -4692,11 +4692,11 @@ EidosValue_SP InteractionType::ExecuteMethod_interactingNeighborCount(EidosGloba default: neighborCount = 0; break; // unsupported value } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(neighborCount)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(neighborCount)); } else { - EidosValue_Int_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(receivers_count); + EidosValue_Int *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(receivers_count); bool saw_error_1 = false, saw_error_2 = false, saw_error_3 = false; EIDOS_THREAD_COUNT(gEidos_OMP_threads_INTNEIGHCOUNT); @@ -5562,7 +5562,7 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCount(EidosGlobalStringID p } else { - EidosValue_Int_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(receivers_count); + EidosValue_Int *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(receivers_count); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) result_vec->set_int_no_check(0, receiver_index); @@ -5595,11 +5595,11 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCount(EidosGlobalStringID p default: neighborCount = 0; break; // unsupported value } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(neighborCount)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(neighborCount)); } else { - EidosValue_Int_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(receivers_count); + EidosValue_Int *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(receivers_count); bool saw_error_1 = false, saw_error_2 = false; EIDOS_THREAD_COUNT(gEidos_OMP_threads_NEIGHCOUNT); @@ -5691,7 +5691,7 @@ EidosValue_SP InteractionType::ExecuteMethod_neighborCountOfPoint(EidosGlobalStr default: EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_neighborCountOfPoint): (internal error) unsupported spatiality" << EidosTerminate(); } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(neighborCount)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(neighborCount)); } // ********************* - (void)setConstraints(string$ who, [Ns$ sex = NULL], [Ni$ tag = NULL], [Ni$ minAge = NULL], [Ni$ maxAge = NULL], [Nl$ migrant = NULL], diff --git a/core/log_file.cpp b/core/log_file.cpp index 9d3dd09d9..ae5eecb1c 100644 --- a/core/log_file.cpp +++ b/core/log_file.cpp @@ -130,7 +130,7 @@ EidosValue_SP LogFile::_GeneratedValue_Cycle(const LogFileGeneratorInfo &p_gener Species *species = all_species[p_generator_info.objectid_]; slim_tick_t cycle = species->Cycle(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(cycle)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(cycle)); } EidosValue_SP LogFile::_GeneratedValue_CycleStage(const LogFileGeneratorInfo &p_generator_info) @@ -181,7 +181,7 @@ EidosValue_SP LogFile::_GeneratedValue_PopulationSize(const LogFileGeneratorInfo for (auto &subpop_iter : species->population_.subpops_) total_individuals += (subpop_iter.second)->CurrentSubpopSize(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(total_individuals)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(total_individuals)); } EidosValue_SP LogFile::_GeneratedValue_SubpopulationSexRatio(const LogFileGeneratorInfo &p_generator_info) @@ -209,7 +209,7 @@ EidosValue_SP LogFile::_GeneratedValue_SubpopulationSize(const LogFileGeneratorI if (subpop) { slim_popsize_t subpop_size = subpop->CurrentSubpopSize(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(subpop_size)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(subpop_size)); } else { @@ -223,7 +223,7 @@ EidosValue_SP LogFile::_GeneratedValue_Tick(const LogFileGeneratorInfo &p_genera #pragma unused(p_generator_info) slim_tick_t tick = community_.Tick(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tick)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tick)); } EidosValue_SP LogFile::_GeneratedValue_CustomScript(const LogFileGeneratorInfo &p_generator_info) @@ -564,11 +564,11 @@ EidosValue_SP LogFile::GetProperty(EidosGlobalStringID p_property_id) case gEidosID_filePath: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(user_file_path_)); case gID_logInterval: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(log_interval_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(log_interval_)); // variables case gID_precision: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(float_precision_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(float_precision_)); case gID_tag: { slim_usertag_t tag_value = tag_value_; @@ -576,7 +576,7 @@ EidosValue_SP LogFile::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (LogFile::GetProperty): property tag accessed on simulation object before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none diff --git a/core/mutation.cpp b/core/mutation.cpp index c54937800..0a8572366 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -369,7 +369,7 @@ EidosValue_SP Mutation::GetProperty(EidosGlobalStringID p_property_id) { // constants case gID_id: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(mutation_id_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_id_)); case gID_isFixed: // ACCELERATED return (((state_ == MutationState::kFixedAndSubstituted) || (state_ == MutationState::kRemovedWithSubstitution)) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gID_isSegregating: // ACCELERATED @@ -377,9 +377,9 @@ EidosValue_SP Mutation::GetProperty(EidosGlobalStringID p_property_id) case gID_mutationType: // ACCELERATED return mutation_type_ptr_->SymbolTableEntry().second; case gID_originTick: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(origin_tick_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(origin_tick_)); case gID_position: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(position_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(position_)); case gID_selectionCoeff: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selection_coeff_)); @@ -415,7 +415,7 @@ EidosValue_SP Mutation::GetProperty(EidosGlobalStringID p_property_id) } } case gID_subpopID: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(subpop_index_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(subpop_index_)); case gID_tag: // ACCELERATED { slim_usertag_t tag_value = tag_value_; @@ -423,7 +423,7 @@ EidosValue_SP Mutation::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Mutation::GetProperty): property tag accessed on mutation before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -434,7 +434,7 @@ EidosValue_SP Mutation::GetProperty(EidosGlobalStringID p_property_id) EidosValue *Mutation::GetProperty_Accelerated_id(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -501,7 +501,7 @@ EidosValue *Mutation::GetProperty_Accelerated_nucleotide(EidosObject **p_values, EidosValue *Mutation::GetProperty_Accelerated_nucleotideValue(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -519,7 +519,7 @@ EidosValue *Mutation::GetProperty_Accelerated_nucleotideValue(EidosObject **p_va EidosValue *Mutation::GetProperty_Accelerated_originTick(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -533,7 +533,7 @@ EidosValue *Mutation::GetProperty_Accelerated_originTick(EidosObject **p_values, EidosValue *Mutation::GetProperty_Accelerated_position(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -547,7 +547,7 @@ EidosValue *Mutation::GetProperty_Accelerated_position(EidosObject **p_values, s EidosValue *Mutation::GetProperty_Accelerated_subpopID(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -561,7 +561,7 @@ EidosValue *Mutation::GetProperty_Accelerated_subpopID(EidosObject **p_values, s EidosValue *Mutation::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index 58a19b09e..df2cf8064 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -421,7 +421,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) case gID_id: // ACCELERATED { if (!cached_value_muttype_id_) - cached_value_muttype_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(mutation_type_id_)); + cached_value_muttype_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_type_id_)); return cached_value_muttype_id_; } case gID_distributionType: @@ -484,7 +484,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) case gID_haploidDominanceCoeff: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(haploid_dominance_coeff_)); case gID_mutationStackGroup: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(stack_group_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(stack_group_)); case gID_nucleotideBased: return (nucleotide_based_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gID_mutationStackPolicy: @@ -520,7 +520,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (MutationType::GetProperty): property tag accessed on mutation type before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -531,7 +531,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) EidosValue *MutationType::GetProperty_Accelerated_id(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -545,7 +545,7 @@ EidosValue *MutationType::GetProperty_Accelerated_id(EidosObject **p_values, siz EidosValue *MutationType::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/population.cpp b/core/population.cpp index 4e10a260d..640cff04a 100644 --- a/core/population.cpp +++ b/core/population.cpp @@ -2454,7 +2454,7 @@ bool Population::ApplyRecombinationCallbacks(slim_popsize_t p_parent_index, Geno if (recombination_callback->contains_breakpoints_) { if (!local_crossovers_ptr) - local_crossovers_ptr = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(p_crossovers)); + local_crossovers_ptr = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(p_crossovers)); client_symbols.SetValueForSymbolNoCopy(gID_breakpoints, local_crossovers_ptr); } @@ -6906,11 +6906,11 @@ EidosValue_SP Population::Eidos_CountsForTalliedMutations(EidosValue *mutations_ else if (mut_state == MutationState::kLostAndRemoved) count = 0; else count = total_genome_count; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(count)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(count)); } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(mutations_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(mutations_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < mutations_count; ++value_index) @@ -6935,7 +6935,7 @@ EidosValue_SP Population::Eidos_CountsForTalliedMutations(EidosValue *mutations_ const MutationIndex *registry = MutationRegistry(®istry_size); Mutation *mutation_block_ptr = gSLiM_Mutation_Block; - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(registry_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(registry_size); result_SP = EidosValue_SP(int_result); for (int registry_index = 0; registry_index < registry_size; registry_index++) @@ -6956,7 +6956,7 @@ EidosValue_SP Population::Eidos_CountsForTalliedMutations(EidosValue *mutations_ int registry_size; const MutationIndex *registry = MutationRegistry(®istry_size); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(registry_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(registry_size); result_SP = EidosValue_SP(int_result); for (int registry_index = 0; registry_index < registry_size; registry_index++) diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 6f84be522..39a0c675e 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -1452,13 +1452,13 @@ EidosValue_SP SLiMEidosBlock::GetProperty(EidosGlobalStringID p_property_id) case gID_id: { if (!cached_value_block_id_) - cached_value_block_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(block_id_)); + cached_value_block_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(block_id_)); return cached_value_block_id_; } case gEidosID_start: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(start_tick_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(start_tick_)); case gEidosID_end: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(end_tick_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(end_tick_)); case gEidosID_type: { switch (type_) @@ -1502,7 +1502,7 @@ EidosValue_SP SLiMEidosBlock::GetProperty(EidosGlobalStringID p_property_id) // variables case gID_active: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(block_active_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(block_active_)); case gID_tag: { slim_usertag_t tag_value = tag_value_; @@ -1510,7 +1510,7 @@ EidosValue_SP SLiMEidosBlock::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (SLiMEidosBlock::GetProperty): property tag accessed on script block before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index ee993fe1d..4317c500b 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -599,7 +599,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_Int_singleton(codon2aa_int[codon])); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(codon2aa_int[codon])); } else { @@ -614,7 +614,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(codons_length); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(codons_length); for (int value_index = 0; value_index < codons_length; ++value_index) { @@ -734,7 +734,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)length_3); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)length_3); for (int64_t value_index = 0; value_index < length_3; ++value_index) { @@ -764,7 +764,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotidesToCodons(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)length_3); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)length_3); if (sequence_type == EidosValueType::kValueString) { @@ -1015,7 +1015,7 @@ EidosValue_SP SLiM_ExecuteFunction_nucleotideCounts(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(4); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(4); int_result->set_int_no_check(total_ACGT[0], 0); int_result->set_int_no_check(total_ACGT[1], 1); @@ -1147,7 +1147,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)length); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)length); for (int value_index = 0; value_index < length; ++value_index) { @@ -1245,7 +1245,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)length); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)length); for (int codon_index = 0; codon_index < codons_length; ++codon_index) { diff --git a/core/slim_globals.cpp b/core/slim_globals.cpp index 70327ed08..7f35ec853 100644 --- a/core/slim_globals.cpp +++ b/core/slim_globals.cpp @@ -852,7 +852,7 @@ EidosValue_SP NucleotideArray::NucleotidesAsIntegerVector(int64_t start, int64_t else { // return a vector of integers, 3 0 3 0 - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)length); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)length); for (int value_index = 0; value_index < length; ++value_index) int_result->set_int_no_check(NucleotideAtIndex(start + value_index), value_index); @@ -874,7 +874,7 @@ EidosValue_SP NucleotideArray::NucleotidesAsCodonVector(int64_t start, int64_t e int nuc3 = NucleotideAtIndex(start + 2); int codon = nuc1 * 16 + nuc2 * 4 + nuc3; // 0..63 - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(codon)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(codon)); } else { @@ -884,7 +884,7 @@ EidosValue_SP NucleotideArray::NucleotidesAsCodonVector(int64_t start, int64_t e if (length % 3 != 0) EIDOS_TERMINATION << "ERROR (NucleotideArray::NucleotidesAsCodonVector): to obtain codons, the requested sequence length must be a multiple of 3." << EidosTerminate(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)length_3); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)length_3); for (int64_t value_index = 0; value_index < length_3; ++value_index) { diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index 916299b51..e7e71b2ad 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -1072,9 +1072,9 @@ EidosValue_SP SpatialMap::GetProperty(EidosGlobalStringID p_property_id) { switch (spatiality_) { - case 1: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{grid_size_[0]}); - case 2: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{grid_size_[0], grid_size_[1]}); - case 3: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{grid_size_[0], grid_size_[1], grid_size_[2]}); + case 1: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{grid_size_[0]}); + case 2: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{grid_size_[0], grid_size_[1]}); + case 3: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{grid_size_[0], grid_size_[1], grid_size_[2]}); default: return gStaticEidosValueNULL; // never hit; here to make the compiler happy } } @@ -1109,7 +1109,7 @@ EidosValue_SP SpatialMap::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (SpatialMap::GetProperty): property tag accessed on spatial map before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index 4789996eb..24799b9f6 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -185,7 +185,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeAncestralNucleotides(con num_ancseq_declarations_++; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(chromosome_->ancestral_seq_buffer_->size())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(chromosome_->ancestral_seq_buffer_->size())); } // ********************* (object)initializeGenomicElement(io genomicElementType, integer start, integer end) @@ -1503,7 +1503,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_id: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(species_id_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(species_id_)); } case gID_periodicity: { @@ -1625,7 +1625,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) if (cached_value_cycle_ && (cached_value_cycle_->IntData()[0] != cycle_)) cached_value_cycle_.reset(); if (!cached_value_cycle_) - cached_value_cycle_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(cycle_)); + cached_value_cycle_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(cycle_)); return cached_value_cycle_; } case gID_tag: @@ -1635,7 +1635,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Species::GetProperty): property tag accessed on simulation object before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -2336,7 +2336,7 @@ EidosValue_SP Species::ExecuteMethod_countOfMutationsOfType(EidosGlobalStringID MutationRun &muttype_registry = mutation_type_ptr->muttype_registry_; int mutation_count = muttype_registry.size(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(mutation_count)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_count)); } else #endif @@ -2350,7 +2350,7 @@ EidosValue_SP Species::ExecuteMethod_countOfMutationsOfType(EidosGlobalStringID if ((mut_block_ptr + registry[registry_index])->mutation_type_ptr_ == mutation_type_ptr) ++match_count; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(match_count)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(match_count)); } } @@ -2740,7 +2740,7 @@ EidosValue_SP Species::ExecuteMethod_readFromPopulationFile(EidosGlobalStringID slim_tick_t file_tick = InitializePopulationFromFile(file_path, &p_interpreter, subpopRemap); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(file_tick)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(file_tick)); } // ********************* – (void)recalculateFitness([Ni$ tick = NULL]) diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 111010a04..13bcf5e1b 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -3882,11 +3882,11 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) case gID_id: // ACCELERATED { if (!cached_value_subpop_id_) - cached_value_subpop_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(subpopulation_id_)); + cached_value_subpop_id_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(subpopulation_id_)); return cached_value_subpop_id_; } case gID_firstMaleIndex: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(CurrentFirstMaleIndex())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(CurrentFirstMaleIndex())); case gID_genomes: { if (child_generation_valid_) @@ -4021,7 +4021,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (model_type_ == SLiMModelType::kModelTypeNonWF) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): property immigrantSubpopIDs is not available in nonWF models." << EidosTerminate(); - EidosValue_Int_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto migrant_pair : migrant_fractions_) @@ -4051,7 +4051,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) std::vector &lifetime_rep_F = lifetime_reproductive_output_F_; int lifetime_rep_count_M = (int)lifetime_rep_M.size(); int lifetime_rep_count_F = (int)lifetime_rep_F.size(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(lifetime_rep_count_M + lifetime_rep_count_F); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(lifetime_rep_count_M + lifetime_rep_count_F); for (int value_index = 0; value_index < lifetime_rep_count_M; ++value_index) int_result->set_int_no_check(lifetime_rep_M[value_index], value_index); @@ -4069,7 +4069,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) std::vector &lifetime_rep = lifetime_reproductive_output_MH_; int lifetime_rep_count = (int)lifetime_rep.size(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(lifetime_rep_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(lifetime_rep_count); for (int value_index = 0; value_index < lifetime_rep_count; ++value_index) int_result->set_int_no_check(lifetime_rep[value_index], value_index); @@ -4085,7 +4085,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) std::vector &lifetime_rep = lifetime_reproductive_output_F_; int lifetime_rep_count = (int)lifetime_rep.size(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(lifetime_rep_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(lifetime_rep_count); for (int value_index = 0; value_index < lifetime_rep_count; ++value_index) int_result->set_int_no_check(lifetime_rep[value_index], value_index); @@ -4151,7 +4151,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(&species_, gSLiM_Species_Class)); } case gID_individualCount: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(CurrentSubpopSize())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(CurrentSubpopSize())); // variables case gID_tag: // ACCELERATED @@ -4161,7 +4161,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): property tag accessed on subpopulation before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } case gID_fitnessScaling: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(subpop_fitness_scaling_)); @@ -4174,7 +4174,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) EidosValue *Subpopulation::GetProperty_Accelerated_id(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -4188,7 +4188,7 @@ EidosValue *Subpopulation::GetProperty_Accelerated_id(EidosObject **p_values, si EidosValue *Subpopulation::GetProperty_Accelerated_firstMaleIndex(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -4202,7 +4202,7 @@ EidosValue *Subpopulation::GetProperty_Accelerated_firstMaleIndex(EidosObject ** EidosValue *Subpopulation::GetProperty_Accelerated_individualCount(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -4216,7 +4216,7 @@ EidosValue *Subpopulation::GetProperty_Accelerated_individualCount(EidosObject * EidosValue *Subpopulation::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/substitution.cpp b/core/substitution.cpp index e4557cf8a..2cc0b5e2d 100644 --- a/core/substitution.cpp +++ b/core/substitution.cpp @@ -82,17 +82,17 @@ EidosValue_SP Substitution::GetProperty(EidosGlobalStringID p_property_id) { // constants case gID_id: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(mutation_id_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(mutation_id_)); case gID_mutationType: // ACCELERATED return mutation_type_ptr_->SymbolTableEntry().second; case gID_position: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(position_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(position_)); case gID_selectionCoeff: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selection_coeff_)); case gID_originTick: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(origin_tick_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(origin_tick_)); case gID_fixationTick: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(fixation_tick_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(fixation_tick_)); // variables case gID_nucleotide: // ACCELERATED @@ -126,7 +126,7 @@ EidosValue_SP Substitution::GetProperty(EidosGlobalStringID p_property_id) } } case gID_subpopID: // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(subpop_index_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(subpop_index_)); case gID_tag: // ACCELERATED { slim_usertag_t tag_value = tag_value_; @@ -134,7 +134,7 @@ EidosValue_SP Substitution::GetProperty(EidosGlobalStringID p_property_id) if (tag_value == SLIM_TAG_UNSET_VALUE) EIDOS_TERMINATION << "ERROR (Substitution::GetProperty): property tag accessed on substitution before being set." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(tag_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(tag_value)); } // all others, including gID_none @@ -145,7 +145,7 @@ EidosValue_SP Substitution::GetProperty(EidosGlobalStringID p_property_id) EidosValue *Substitution::GetProperty_Accelerated_id(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -184,7 +184,7 @@ EidosValue *Substitution::GetProperty_Accelerated_nucleotide(EidosObject **p_val EidosValue *Substitution::GetProperty_Accelerated_nucleotideValue(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -202,7 +202,7 @@ EidosValue *Substitution::GetProperty_Accelerated_nucleotideValue(EidosObject ** EidosValue *Substitution::GetProperty_Accelerated_originTick(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -216,7 +216,7 @@ EidosValue *Substitution::GetProperty_Accelerated_originTick(EidosObject **p_val EidosValue *Substitution::GetProperty_Accelerated_fixationTick(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -230,7 +230,7 @@ EidosValue *Substitution::GetProperty_Accelerated_fixationTick(EidosObject **p_v EidosValue *Substitution::GetProperty_Accelerated_position(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -244,7 +244,7 @@ EidosValue *Substitution::GetProperty_Accelerated_position(EidosObject **p_value EidosValue *Substitution::GetProperty_Accelerated_subpopID(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -258,7 +258,7 @@ EidosValue *Substitution::GetProperty_Accelerated_subpopID(EidosObject **p_value EidosValue *Substitution::GetProperty_Accelerated_tag(EidosObject **p_values, size_t p_values_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_values_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/eidos/eidos_class_DataFrame.cpp b/eidos/eidos_class_DataFrame.cpp index 84ce3f66a..3d88ff382 100644 --- a/eidos/eidos_class_DataFrame.cpp +++ b/eidos/eidos_class_DataFrame.cpp @@ -414,11 +414,11 @@ EidosValue_SP EidosDataFrame::GetProperty(EidosGlobalStringID p_property_id) case gEidosID_colNames: return AllKeys(); case gEidosID_dim: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{RowCount(), ColumnCount()}); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{RowCount(), ColumnCount()}); case gEidosID_ncol: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(ColumnCount())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(ColumnCount())); case gEidosID_nrow: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(RowCount())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(RowCount())); // all others, including gID_none default: @@ -1171,7 +1171,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(nrows); + EidosValue_Int *integer_column = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(nrows); column_values = EidosValue_SP(integer_column); for (int row_index = 0; row_index < nrows; ++row_index) diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index 234da8bfb..87aef1218 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -271,7 +271,7 @@ std::string EidosDictionaryUnretained::Serialization_SLiM(void) const // We want to output our keys in the same order as allKeys, so we just use AllKeys() EidosValue_SP all_keys = AllKeys(); - EidosValue_Int_vector *integer_vec = dynamic_cast(all_keys.get()); + EidosValue_Int *integer_vec = dynamic_cast(all_keys.get()); if (!integer_vec) EIDOS_TERMINATION << "ERROR (EidosDictionaryUnretained::Serialization_SLiM): (internal error) allKeys did not return an integer vector." << EidosTerminate(nullptr); @@ -620,7 +620,7 @@ EidosValue_SP EidosDictionaryUnretained::AllKeys(void) const if (key_count == 0) return gStaticEidosValue_Integer_ZeroVec; - EidosValue_Int_vector *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve(key_count); + EidosValue_Int *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(key_count); for (int64_t key : keys) integer_result->push_int_no_check(key); @@ -878,7 +878,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) else if (value.is_number_integer() || value.is_number_unsigned()) { int64_t int_value = value; - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int_value)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int_value)); } else if (value.is_number_float()) { @@ -927,7 +927,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) // ok, all elements are of a single type, so let's create a vector of that type from the values in the array if (array_type == nlohmann::json::value_t::number_integer) { - EidosValue_Int_vector *int_value = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(array_count); + EidosValue_Int *int_value = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(array_count); for (size_t element_index = 0; element_index < array_count; ++element_index) { @@ -1149,7 +1149,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_compactIndices(EidosGloba EidosDictionaryState_IntegerKeys *state_ptr = (EidosDictionaryState_IntegerKeys *)state_ptr_; EidosDictionaryHashTable_IntegerKeys &symbols = state_ptr->dictionary_symbols_; size_t key_count = symbols.size(); - EidosValue_Int_vector *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve(key_count); + EidosValue_Int *integer_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(key_count); std::vector compacted_values; if (preserveOrder) diff --git a/eidos/eidos_class_Image.cpp b/eidos/eidos_class_Image.cpp index 9b07151d3..de6b5b9c0 100644 --- a/eidos/eidos_class_Image.cpp +++ b/eidos/eidos_class_Image.cpp @@ -130,7 +130,7 @@ EidosValue_SP EidosImage::ValueForIntegerChannel(EidosValue_SP &p_channel_cache, return p_channel_cache; int64_t pixel_stride = 0, pixel_suboffset = 0; - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(height_ * width_); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(height_ * width_); p_channel_cache = EidosValue_SP(int_result); GetChannelMetrics(p_channel, pixel_stride, pixel_suboffset); @@ -182,11 +182,11 @@ EidosValue_SP EidosImage::GetProperty(EidosGlobalStringID p_property_id) { // constants case gEidosID_width: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(width_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(width_)); case gEidosID_height: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(height_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(height_)); case gEidosID_bitsPerChannel: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(8)); // only 8 is supported for now, but this is for future expansion + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(8)); // only 8 is supported for now, but this is for future expansion case gEidosID_isGrayscale: return (is_grayscale_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gEidosID_integerR: @@ -297,7 +297,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorData(); - EidosValue_Int_vector *int_values = (EidosValue_Int_vector *)p_arguments[0].get(); + EidosValue_Int *int_values = (EidosValue_Int *)p_arguments[0].get(); const int64_t *int_data = int_values->data(); // translate the data from by-column to by-row, to match the in-memory format of images diff --git a/eidos/eidos_class_Object.cpp b/eidos/eidos_class_Object.cpp index 022802bff..d491dadf5 100644 --- a/eidos/eidos_class_Object.cpp +++ b/eidos/eidos_class_Object.cpp @@ -681,7 +681,7 @@ EidosValue_SP EidosClass::ExecuteMethod_size_length(EidosGlobalStringID p_method { #pragma unused (p_method_id, p_target, p_arguments, p_interpreter) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(p_target->Count())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(p_target->Count())); } diff --git a/eidos/eidos_class_TestElement.cpp b/eidos/eidos_class_TestElement.cpp index e98512f08..ce304172b 100644 --- a/eidos/eidos_class_TestElement.cpp +++ b/eidos/eidos_class_TestElement.cpp @@ -63,7 +63,7 @@ void EidosTestElement::Print(std::ostream &p_ostream) const EidosValue_SP EidosTestElement::GetProperty(EidosGlobalStringID p_property_id) { if (p_property_id == gEidosID__yolk) // ACCELERATED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(yolk_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(yolk_)); else if (p_property_id == gEidosID__increment) { EidosTestElement *inc_element = new EidosTestElement(yolk_ + 1); @@ -80,7 +80,7 @@ EidosValue_SP EidosTestElement::GetProperty(EidosGlobalStringID p_property_id) EidosValue *EidosTestElement::GetProperty_Accelerated__yolk(EidosObject **p_elements, size_t p_elements_size) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_elements_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_elements_size); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) { @@ -137,7 +137,7 @@ EidosValue_SP EidosTestElement::ExecuteInstanceMethod(EidosGlobalStringID p_meth EidosValue_SP EidosTestElement::ExecuteMethod_Accelerated_cubicYolk(EidosObject **p_elements, size_t p_elements_size, EidosGlobalStringID p_method_id, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { #pragma unused (p_method_id, p_arguments, p_interpreter) - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(p_elements_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(p_elements_size); for (size_t element_index = 0; element_index < p_elements_size; ++element_index) { @@ -282,7 +282,7 @@ void EidosTestElementNRR::Print(std::ostream &p_ostream) const EidosValue_SP EidosTestElementNRR::GetProperty(EidosGlobalStringID p_property_id) { if (p_property_id == gEidosID__yolk) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(yolk_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(yolk_)); // all others, including gID_none else diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index c1d50b8a9..5d9c81421 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -613,8 +613,8 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (highest_type == EidosValueType::kValueInt) { - EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(reserve_size); - EidosValue_Int_vector_SP result_SP = EidosValue_Int_vector_SP(result); + EidosValue_Int *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(reserve_size); + EidosValue_Int_SP result_SP = EidosValue_Int_SP(result); int result_set_index = 0; for (int arg_index = 0; arg_index < argument_count; ++arg_index) @@ -845,7 +845,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API const int64_t *int_data = x_value->IntData(); - EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); result_SP = EidosValue_SP(int_result); if (p_preserve_order) @@ -1079,8 +1079,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueInt) { const int64_t *first_child_data = p_original_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) if (logical_index_data[value_idx]) @@ -1175,8 +1175,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa { // result type is integer; optimize for that const int64_t *first_child_data = p_original_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->reserve(indices_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_distributions.cpp b/eidos/eidos_functions_distributions.cpp index 6ef2f821e..56404bb52 100644 --- a/eidos/eidos_functions_distributions.cpp +++ b/eidos/eidos_functions_distributions.cpp @@ -81,7 +81,7 @@ EidosValue_SP Eidos_ExecuteFunction_findInterval(const std::vectorAllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); if (vec_type == EidosValueType::kValueInt) { @@ -841,18 +841,18 @@ EidosValue_SP Eidos_ExecuteFunction_rbinom(const std::vector &p_a { Eidos_RNG_State *rng_state = EIDOS_STATE_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton((int64_t)Eidos_RandomBool(rng_state))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int((int64_t)Eidos_RandomBool(rng_state))); } else { gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gsl_ran_binomial(rng, probability0, size0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gsl_ran_binomial(rng, probability0, size0))); } } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(int_result); if ((probability0 == 0.5) && (size0 == 1)) @@ -883,7 +883,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbinom(const std::vector &p_a } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(int_result); bool saw_error1 = false, saw_error2 = false; @@ -1027,18 +1027,18 @@ EidosValue_SP Eidos_ExecuteFunction_rdunif(const std::vector &p_a { Eidos_RNG_State *rng_state = EIDOS_STATE_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(Eidos_RandomBool(rng_state) + min_value0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(Eidos_RandomBool(rng_state) + min_value0)); } else { Eidos_MT_State *mt = EIDOS_MT_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(Eidos_rng_uniform_int_MT64(mt, count0) + min_value0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(Eidos_rng_uniform_int_MT64(mt, count0) + min_value0)); } } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(int_result); if (count0 == 2) @@ -1069,7 +1069,7 @@ EidosValue_SP Eidos_ExecuteFunction_rdunif(const std::vector &p_a } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(int_result); bool saw_error = false; @@ -1458,13 +1458,13 @@ EidosValue_SP Eidos_ExecuteFunction_rgeom(const std::vector &p_ar if (num_draws == 1) { if (p0 == 1.0) // special-case p==1.0 - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(0)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gsl_ran_geometric(rng, p0) - 1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gsl_ran_geometric(rng, p0) - 1)); } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(int_result); if (p0 == 1.0) // special-case p==1.0 @@ -1477,7 +1477,7 @@ EidosValue_SP Eidos_ExecuteFunction_rgeom(const std::vector &p_ar } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(int_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1708,11 +1708,11 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ if (num_draws == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gsl_ran_negative_binomial(rng, probability0, size0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gsl_ran_negative_binomial(rng, probability0, size0))); } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(int_result); for (int64_t draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1721,7 +1721,7 @@ EidosValue_SP Eidos_ExecuteFunction_rnbinom(const std::vector &p_ } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(int_result); for (int draw_index = 0; draw_index < num_draws; ++draw_index) @@ -1873,11 +1873,11 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar { gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gsl_ran_poisson(rng, lambda0))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gsl_ran_poisson(rng, lambda0))); } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(num_draws); result_SP = EidosValue_SP(int_result); EIDOS_THREAD_COUNT(gEidos_OMP_threads_RPOIS_1); @@ -1893,7 +1893,7 @@ EidosValue_SP Eidos_ExecuteFunction_rpois(const std::vector &p_ar } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize((int)num_draws); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize((int)num_draws); result_SP = EidosValue_SP(int_result); bool saw_error = false; diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 17fe479f9..568ddbd1b 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -63,7 +63,7 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu if (x_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(llabs(x_value->IntAtIndex_NOCAST(0, nullptr))); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(llabs(x_value->IntAtIndex_NOCAST(0, nullptr))); int64_t operand = x_value->IntAtIndex_NOCAST(0, nullptr); @@ -73,13 +73,13 @@ EidosValue_SP Eidos_ExecuteFunction_abs(const std::vector &p_argu int64_t abs_result = llabs(operand); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(abs_result)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(abs_result)); } else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API const int64_t *int_data = x_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -313,14 +313,14 @@ EidosValue_SP Eidos_ExecuteFunction_cumProduct(const std::vector { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->IntAtIndex_NOCAST(0, nullptr))); } else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API const int64_t *int_data = x_value->IntData(); int64_t product = 1; - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -376,14 +376,14 @@ EidosValue_SP Eidos_ExecuteFunction_cumSum(const std::vector &p_a { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->IntAtIndex_NOCAST(0, nullptr))); } else { // We have x_count != 1, so the type of x_value must be EidosValue_Int_vector; we can use the fast API const int64_t *int_data = x_value->IntData(); int64_t sum = 0; - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -522,7 +522,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector if (int2 == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_integerDiv): function integerDiv() cannot perform division by 0." << EidosTerminate(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int1 / int2)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int1 / int2)); } else { @@ -530,7 +530,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector { const int64_t *int1_data = x_value->IntData(); const int64_t *int2_data = y_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -548,7 +548,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector { int64_t int1 = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int2_data = y_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < y_count; ++value_index) @@ -565,7 +565,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerDiv(const std::vector { const int64_t *int1_data = x_value->IntData(); int64_t int2 = y_value->IntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); if (int2 == 0) @@ -623,7 +623,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector if (int2 == 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_integerMod): function integerMod() cannot perform modulo by 0." << EidosTerminate(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int1 % int2)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int1 % int2)); } else { @@ -631,7 +631,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector { const int64_t *int1_data = x_value->IntData(); const int64_t *int2_data = y_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -649,7 +649,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector { int64_t int1 = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *int2_data = y_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(y_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(y_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < y_count; ++value_index) @@ -666,7 +666,7 @@ EidosValue_SP Eidos_ExecuteFunction_integerMod(const std::vector { const int64_t *int1_data = x_value->IntData(); int64_t int2 = y_value->IntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); if (int2 == 0) @@ -924,7 +924,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->IntAtIndex_NOCAST(0, nullptr))); } else { @@ -957,7 +957,7 @@ EidosValue_SP Eidos_ExecuteFunction_product(const std::vector &p_ product_d *= product; // multiply in whatever integer accumulation has not overflowed if (fits_in_integer) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(product)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(product)); else result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(product_d)); } @@ -1142,7 +1142,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorAllocateChunk()) EidosValue_Int_singleton(int0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int0)); } else if (arg_type == EidosValueType::kValueFloat) { @@ -1185,7 +1185,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorAllocateChunk()) EidosValue_Int_singleton(int0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int0)); } else if (arg_type == EidosValueType::kValueFloat) { @@ -1235,7 +1235,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); + EidosValue_Int *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1296,7 +1296,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorIntData(); const int64_t *int_data1 = y_value->IntData(); - EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); result_SP = EidosValue_SP(int_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1544,7 +1544,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorIntAtIndex_NOCAST(0, nullptr), int1 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int0 == int1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int0)); else result_SP = gStaticEidosValue_Integer_ZeroVec; } @@ -1654,7 +1654,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorIntData(); const int64_t *int_data1 = y_value->IntData(); - EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); result_SP = EidosValue_SP(int_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1913,7 +1913,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorAllocateChunk()) EidosValue_Int_vector{int0, int1}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{int0, int1}); } else if (arg_type == EidosValueType::kValueFloat) { @@ -1964,7 +1964,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); + EidosValue_Int *int_vec = dynamic_cast(result_SP.get()); const int64_t *int_data = int_vec->data(); int value_index; @@ -2040,7 +2040,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorIntData(); const int64_t *int_data1 = y_value->IntData(); - EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); result_SP = EidosValue_SP(int_result); for (value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -2380,9 +2380,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p int64_t int0 = x_value->IntAtIndex_NOCAST(0, nullptr), int1 = y_value->IntAtIndex_NOCAST(0, nullptr); if (int0 == int1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(int0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(int0)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{int0, int1}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{int0, int1}); } else if (arg_type == EidosValueType::kValueFloat) { @@ -2443,7 +2443,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (scan_index == result_count) { - EidosValue_Int_vector *int_vec = dynamic_cast(result_SP.get()); + EidosValue_Int *int_vec = dynamic_cast(result_SP.get()); int_vec->push_int(value); } @@ -2601,7 +2601,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu { if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->IntAtIndex_NOCAST(0, nullptr))); } else #ifndef _OPENMP @@ -2635,7 +2635,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu sum_d += sum; // add in whatever integer accumulation has not overflowed if (fits_in_integer) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(sum)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(sum)); else result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum_d)); } @@ -2656,7 +2656,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu bool fits_in_integer = (((double)sum == sum_d) && (sum < 9007199254740992L) && (sum > -9007199254740992L)); if (fits_in_integer) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(sum)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(sum)); else result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(sum_d)); } @@ -2693,7 +2693,7 @@ EidosValue_SP Eidos_ExecuteFunction_sum(const std::vector &p_argu for (int value_index = 0; value_index < x_count; ++value_index) sum += logical_data[value_index]; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(sum)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(sum)); } return result_SP; diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index 33b8d293f..e49f0869d 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -394,7 +394,7 @@ EidosValue_SP Eidos_ExecuteFunction_cbind(const std::vector &p_ar case EidosValueType::kValueVOID: break; // never hit // NOLINT(*-branch-clone) : intentional consecutive branches case EidosValueType::kValueNULL: break; // never hit case EidosValueType::kValueLogical: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->reserve(result_length)); break; - case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve(result_length)); break; + case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; @@ -435,7 +435,7 @@ EidosValue_SP Eidos_ExecuteFunction_dim(const std::vector &p_argu const int64_t *dim_values = data_value->Dimensions(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(dim_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(dim_count); result_SP = EidosValue_SP(int_result); for (int dim_index = 0; dim_index < dim_count; ++dim_index) @@ -643,7 +643,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector if (overflow) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_matrixMult): integer multiplication overflow in function matrixMult(); you may wish to cast the matrices to float with asFloat() before multiplying." << EidosTerminate(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(multiply_result)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(multiply_result)); } else // (x_type == EidosValueType::kValueFloat) { @@ -660,7 +660,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector { int64_t x_singleton = x_value->IntAtIndex_NOCAST(0, nullptr); const int64_t *y_data = y_value->IntData(); - EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); + EidosValue_Int *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); for (int64_t y_index = 0; y_index < y_length; ++y_index) @@ -693,7 +693,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector { const int64_t *x_data = x_value->IntData(); int64_t y_singleton = y_value->IntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); + EidosValue_Int *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); for (int64_t x_index = 0; x_index < x_length; ++x_index) @@ -726,7 +726,7 @@ EidosValue_SP Eidos_ExecuteFunction_matrixMult(const std::vector { const int64_t *x_data = x_value->IntData(); const int64_t *y_data = y_value->IntData(); - EidosValue_Int_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(result_length); + EidosValue_Int *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(result_length); result_SP = EidosValue_SP(result); for (int64_t result_col_index = 0; result_col_index < result_cols; ++result_col_index) @@ -817,7 +817,7 @@ EidosValue_SP Eidos_ExecuteFunction_ncol(const std::vector &p_arg const int64_t *dim_values = data_value->Dimensions(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(dim_values[1])); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(dim_values[1])); } // (integer$)nrow(* x) @@ -831,7 +831,7 @@ EidosValue_SP Eidos_ExecuteFunction_nrow(const std::vector &p_arg const int64_t *dim_values = data_value->Dimensions(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(dim_values[0])); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(dim_values[0])); } // (*)rbind(...) @@ -912,7 +912,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbind(const std::vector &p_ar case EidosValueType::kValueVOID: break; // never hit // NOLINT(*-branch-clone) : intentional consecutive branches case EidosValueType::kValueNULL: break; // never hit case EidosValueType::kValueLogical: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->reserve(result_length)); break; - case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve(result_length)); break; + case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; @@ -1149,7 +1149,7 @@ EidosValue_SP Eidos_ExecuteFunction_diag(const std::vector &p_arg if ((nrow < 1) || (ncol < 1)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_diag): in function diag() when an identity matrix is being generated, both dimensions of that matrix must be >= 1." << EidosTerminate(nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(nrow * ncol); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(nrow * ncol); EidosValue_SP result_SP(int_result); for (int64_t col_index = 0; col_index < ncol; ++col_index) @@ -1170,7 +1170,7 @@ EidosValue_SP Eidos_ExecuteFunction_diag(const std::vector &p_arg if (size < 1) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_diag): in function diag() when x specificies an identity matrix size, that size must be >= 1." << EidosTerminate(nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(size * size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(size * size); EidosValue_SP result_SP(int_result); for (int64_t col_index = 0; col_index < size; ++col_index) diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 4ff98cdd6..784bd7a2b 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -632,7 +632,7 @@ EidosValue_SP Eidos_ExecuteFunction_getSeed(__attribute__((unused)) const std::v // Note that this function ignores matrix/array attributes, and always returns a vector, by design EidosValue_SP result_SP(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(last_seed)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(last_seed)); return result_SP; } @@ -706,7 +706,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelGetNumThreads(__attribute__((unused) { EidosValue_SP result_SP(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidosNumThreads)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidosNumThreads)); return result_SP; } @@ -716,7 +716,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelGetMaxThreads(__attribute__((unused) { EidosValue_SP result_SP(nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidosMaxThreads)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidosMaxThreads)); return result_SP; } @@ -728,131 +728,131 @@ EidosValue_SP Eidos_ExecuteFunction_parallelGetTaskThreadCounts(__attribute__((u EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); #ifdef _OPENMP - objectElement->SetKeyValue_StringKeys("ABS_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_ABS_FLOAT))); - objectElement->SetKeyValue_StringKeys("CEIL", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_CEIL))); - objectElement->SetKeyValue_StringKeys("EXP_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_EXP_FLOAT))); - objectElement->SetKeyValue_StringKeys("FLOOR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FLOOR))); - objectElement->SetKeyValue_StringKeys("LOG_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_LOG_FLOAT))); - objectElement->SetKeyValue_StringKeys("LOG10_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_LOG10_FLOAT))); - objectElement->SetKeyValue_StringKeys("LOG2_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_LOG2_FLOAT))); - objectElement->SetKeyValue_StringKeys("ROUND", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_ROUND))); - objectElement->SetKeyValue_StringKeys("SQRT_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SQRT_FLOAT))); - objectElement->SetKeyValue_StringKeys("SUM_INTEGER", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SUM_INTEGER))); - objectElement->SetKeyValue_StringKeys("SUM_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SUM_FLOAT))); - objectElement->SetKeyValue_StringKeys("SUM_LOGICAL", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SUM_LOGICAL))); - objectElement->SetKeyValue_StringKeys("TRUNC", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_TRUNC))); - - objectElement->SetKeyValue_StringKeys("MAX_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MAX_INT))); - objectElement->SetKeyValue_StringKeys("MAX_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MAX_FLOAT))); - objectElement->SetKeyValue_StringKeys("MIN_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MIN_INT))); - objectElement->SetKeyValue_StringKeys("MIN_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MIN_FLOAT))); - objectElement->SetKeyValue_StringKeys("PMAX_INT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMAX_INT_1))); - objectElement->SetKeyValue_StringKeys("PMAX_INT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMAX_INT_2))); - objectElement->SetKeyValue_StringKeys("PMAX_FLOAT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMAX_FLOAT_1))); - objectElement->SetKeyValue_StringKeys("PMAX_FLOAT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMAX_FLOAT_2))); - objectElement->SetKeyValue_StringKeys("PMIN_INT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMIN_INT_1))); - objectElement->SetKeyValue_StringKeys("PMIN_INT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMIN_INT_2))); - objectElement->SetKeyValue_StringKeys("PMIN_FLOAT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMIN_FLOAT_1))); - objectElement->SetKeyValue_StringKeys("PMIN_FLOAT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PMIN_FLOAT_2))); - - objectElement->SetKeyValue_StringKeys("MATCH_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MATCH_INT))); - objectElement->SetKeyValue_StringKeys("MATCH_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MATCH_FLOAT))); - objectElement->SetKeyValue_StringKeys("MATCH_STRING", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MATCH_STRING))); - objectElement->SetKeyValue_StringKeys("MATCH_OBJECT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MATCH_OBJECT))); - objectElement->SetKeyValue_StringKeys("SAMPLE_INDEX", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_INDEX))); - objectElement->SetKeyValue_StringKeys("SAMPLE_R_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_R_INT))); - objectElement->SetKeyValue_StringKeys("SAMPLE_R_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_R_FLOAT))); - objectElement->SetKeyValue_StringKeys("SAMPLE_R_OBJECT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_R_OBJECT))); - objectElement->SetKeyValue_StringKeys("SAMPLE_WR_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_WR_INT))); - objectElement->SetKeyValue_StringKeys("SAMPLE_WR_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_WR_FLOAT))); - objectElement->SetKeyValue_StringKeys("SAMPLE_WR_OBJECT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_WR_OBJECT))); - objectElement->SetKeyValue_StringKeys("TABULATE_MAXBIN", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_TABULATE_MAXBIN))); - objectElement->SetKeyValue_StringKeys("TABULATE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_TABULATE))); - - objectElement->SetKeyValue_StringKeys("CONTAINS_MARKER_MUT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_CONTAINS_MARKER_MUT))); - objectElement->SetKeyValue_StringKeys("I_COUNT_OF_MUTS_OF_TYPE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_I_COUNT_OF_MUTS_OF_TYPE))); - objectElement->SetKeyValue_StringKeys("G_COUNT_OF_MUTS_OF_TYPE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_G_COUNT_OF_MUTS_OF_TYPE))); - objectElement->SetKeyValue_StringKeys("INDS_W_PEDIGREE_IDS", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_INDS_W_PEDIGREE_IDS))); - objectElement->SetKeyValue_StringKeys("RELATEDNESS", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RELATEDNESS))); - objectElement->SetKeyValue_StringKeys("SAMPLE_INDIVIDUALS_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_INDIVIDUALS_1))); - objectElement->SetKeyValue_StringKeys("SAMPLE_INDIVIDUALS_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SAMPLE_INDIVIDUALS_2))); - objectElement->SetKeyValue_StringKeys("SET_FITNESS_SCALE_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_FITNESS_SCALE_1))); - objectElement->SetKeyValue_StringKeys("SET_FITNESS_SCALE_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_FITNESS_SCALE_2))); - objectElement->SetKeyValue_StringKeys("SUM_OF_MUTS_OF_TYPE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SUM_OF_MUTS_OF_TYPE))); - - objectElement->SetKeyValue_StringKeys("DNORM_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_DNORM_1))); - objectElement->SetKeyValue_StringKeys("DNORM_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_DNORM_2))); - objectElement->SetKeyValue_StringKeys("RBINOM_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RBINOM_1))); - objectElement->SetKeyValue_StringKeys("RBINOM_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RBINOM_2))); - objectElement->SetKeyValue_StringKeys("RBINOM_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RBINOM_3))); - objectElement->SetKeyValue_StringKeys("RDUNIF_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RDUNIF_1))); - objectElement->SetKeyValue_StringKeys("RDUNIF_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RDUNIF_2))); - objectElement->SetKeyValue_StringKeys("RDUNIF_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RDUNIF_3))); - objectElement->SetKeyValue_StringKeys("REXP_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_REXP_1))); - objectElement->SetKeyValue_StringKeys("REXP_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_REXP_2))); - objectElement->SetKeyValue_StringKeys("RNORM_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RNORM_1))); - objectElement->SetKeyValue_StringKeys("RNORM_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RNORM_2))); - objectElement->SetKeyValue_StringKeys("RNORM_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RNORM_3))); - objectElement->SetKeyValue_StringKeys("RPOIS_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RPOIS_1))); - objectElement->SetKeyValue_StringKeys("RPOIS_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RPOIS_2))); - objectElement->SetKeyValue_StringKeys("RUNIF_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RUNIF_1))); - objectElement->SetKeyValue_StringKeys("RUNIF_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RUNIF_2))); - objectElement->SetKeyValue_StringKeys("RUNIF_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RUNIF_3))); - - objectElement->SetKeyValue_StringKeys("SORT_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SORT_INT))); - objectElement->SetKeyValue_StringKeys("SORT_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SORT_FLOAT))); - objectElement->SetKeyValue_StringKeys("SORT_STRING", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SORT_STRING))); - - objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_IN_BOUNDS_1D))); - objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_IN_BOUNDS_2D))); - objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_IN_BOUNDS_3D))); - objectElement->SetKeyValue_StringKeys("POINT_PERIODIC_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_PERIODIC_1D))); - objectElement->SetKeyValue_StringKeys("POINT_PERIODIC_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_PERIODIC_2D))); - objectElement->SetKeyValue_StringKeys("POINT_PERIODIC_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_PERIODIC_3D))); - objectElement->SetKeyValue_StringKeys("POINT_REFLECTED_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_REFLECTED_1D))); - objectElement->SetKeyValue_StringKeys("POINT_REFLECTED_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_REFLECTED_2D))); - objectElement->SetKeyValue_StringKeys("POINT_REFLECTED_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_REFLECTED_3D))); - objectElement->SetKeyValue_StringKeys("POINT_STOPPED_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_STOPPED_1D))); - objectElement->SetKeyValue_StringKeys("POINT_STOPPED_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_STOPPED_2D))); - objectElement->SetKeyValue_StringKeys("POINT_STOPPED_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_STOPPED_3D))); - objectElement->SetKeyValue_StringKeys("POINT_UNIFORM_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_UNIFORM_1D))); - objectElement->SetKeyValue_StringKeys("POINT_UNIFORM_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_UNIFORM_2D))); - objectElement->SetKeyValue_StringKeys("POINT_UNIFORM_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_UNIFORM_3D))); - objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_1_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_SPATIAL_POS_1_1D))); - objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_1_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_SPATIAL_POS_1_2D))); - objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_1_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_SPATIAL_POS_1_3D))); - objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_2_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_SPATIAL_POS_2_1D))); - objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_2_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_SPATIAL_POS_2_2D))); - objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_2_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SET_SPATIAL_POS_2_3D))); - objectElement->SetKeyValue_StringKeys("SPATIAL_MAP_VALUE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SPATIAL_MAP_VALUE))); - - objectElement->SetKeyValue_StringKeys("CLIPPEDINTEGRAL_1S", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_CLIPPEDINTEGRAL_1S))); - objectElement->SetKeyValue_StringKeys("CLIPPEDINTEGRAL_2S", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_CLIPPEDINTEGRAL_2S))); - //objectElement->SetKeyValue_StringKeys("CLIPPEDINTEGRAL_3S", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_CLIPPEDINTEGRAL_3S))); - objectElement->SetKeyValue_StringKeys("DRAWBYSTRENGTH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_DRAWBYSTRENGTH))); - objectElement->SetKeyValue_StringKeys("INTNEIGHCOUNT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_INTNEIGHCOUNT))); - objectElement->SetKeyValue_StringKeys("LOCALPOPDENSITY", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_LOCALPOPDENSITY))); - objectElement->SetKeyValue_StringKeys("NEARESTINTNEIGH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_NEARESTINTNEIGH))); - objectElement->SetKeyValue_StringKeys("NEARESTNEIGH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_NEARESTNEIGH))); - objectElement->SetKeyValue_StringKeys("NEIGHCOUNT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_NEIGHCOUNT))); - objectElement->SetKeyValue_StringKeys("TOTNEIGHSTRENGTH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_TOTNEIGHSTRENGTH))); - - objectElement->SetKeyValue_StringKeys("AGE_INCR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_AGE_INCR))); - objectElement->SetKeyValue_StringKeys("DEFERRED_REPRO", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_DEFERRED_REPRO))); - objectElement->SetKeyValue_StringKeys("WF_REPRO", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_WF_REPRO))); - objectElement->SetKeyValue_StringKeys("FITNESS_ASEX_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FITNESS_ASEX_1))); - objectElement->SetKeyValue_StringKeys("FITNESS_ASEX_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FITNESS_ASEX_2))); - objectElement->SetKeyValue_StringKeys("FITNESS_ASEX_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FITNESS_ASEX_3))); - objectElement->SetKeyValue_StringKeys("FITNESS_SEX_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FITNESS_SEX_1))); - objectElement->SetKeyValue_StringKeys("FITNESS_SEX_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FITNESS_SEX_2))); - objectElement->SetKeyValue_StringKeys("FITNESS_SEX_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_FITNESS_SEX_3))); - objectElement->SetKeyValue_StringKeys("MIGRANT_CLEAR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_MIGRANT_CLEAR))); - objectElement->SetKeyValue_StringKeys("SIMPLIFY_SORT_PRE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SIMPLIFY_SORT_PRE))); - objectElement->SetKeyValue_StringKeys("SIMPLIFY_SORT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SIMPLIFY_SORT))); - objectElement->SetKeyValue_StringKeys("SIMPLIFY_SORT_POST", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SIMPLIFY_SORT_POST))); - objectElement->SetKeyValue_StringKeys("PARENTS_CLEAR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_PARENTS_CLEAR))); - objectElement->SetKeyValue_StringKeys("UNIQUE_MUTRUNS", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_UNIQUE_MUTRUNS))); - objectElement->SetKeyValue_StringKeys("SURVIVAL", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SURVIVAL))); + objectElement->SetKeyValue_StringKeys("ABS_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_ABS_FLOAT))); + objectElement->SetKeyValue_StringKeys("CEIL", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_CEIL))); + objectElement->SetKeyValue_StringKeys("EXP_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_EXP_FLOAT))); + objectElement->SetKeyValue_StringKeys("FLOOR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FLOOR))); + objectElement->SetKeyValue_StringKeys("LOG_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_LOG_FLOAT))); + objectElement->SetKeyValue_StringKeys("LOG10_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_LOG10_FLOAT))); + objectElement->SetKeyValue_StringKeys("LOG2_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_LOG2_FLOAT))); + objectElement->SetKeyValue_StringKeys("ROUND", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_ROUND))); + objectElement->SetKeyValue_StringKeys("SQRT_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SQRT_FLOAT))); + objectElement->SetKeyValue_StringKeys("SUM_INTEGER", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SUM_INTEGER))); + objectElement->SetKeyValue_StringKeys("SUM_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SUM_FLOAT))); + objectElement->SetKeyValue_StringKeys("SUM_LOGICAL", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SUM_LOGICAL))); + objectElement->SetKeyValue_StringKeys("TRUNC", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_TRUNC))); + + objectElement->SetKeyValue_StringKeys("MAX_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MAX_INT))); + objectElement->SetKeyValue_StringKeys("MAX_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MAX_FLOAT))); + objectElement->SetKeyValue_StringKeys("MIN_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MIN_INT))); + objectElement->SetKeyValue_StringKeys("MIN_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MIN_FLOAT))); + objectElement->SetKeyValue_StringKeys("PMAX_INT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMAX_INT_1))); + objectElement->SetKeyValue_StringKeys("PMAX_INT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMAX_INT_2))); + objectElement->SetKeyValue_StringKeys("PMAX_FLOAT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMAX_FLOAT_1))); + objectElement->SetKeyValue_StringKeys("PMAX_FLOAT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMAX_FLOAT_2))); + objectElement->SetKeyValue_StringKeys("PMIN_INT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMIN_INT_1))); + objectElement->SetKeyValue_StringKeys("PMIN_INT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMIN_INT_2))); + objectElement->SetKeyValue_StringKeys("PMIN_FLOAT_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMIN_FLOAT_1))); + objectElement->SetKeyValue_StringKeys("PMIN_FLOAT_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PMIN_FLOAT_2))); + + objectElement->SetKeyValue_StringKeys("MATCH_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MATCH_INT))); + objectElement->SetKeyValue_StringKeys("MATCH_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MATCH_FLOAT))); + objectElement->SetKeyValue_StringKeys("MATCH_STRING", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MATCH_STRING))); + objectElement->SetKeyValue_StringKeys("MATCH_OBJECT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MATCH_OBJECT))); + objectElement->SetKeyValue_StringKeys("SAMPLE_INDEX", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_INDEX))); + objectElement->SetKeyValue_StringKeys("SAMPLE_R_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_R_INT))); + objectElement->SetKeyValue_StringKeys("SAMPLE_R_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_R_FLOAT))); + objectElement->SetKeyValue_StringKeys("SAMPLE_R_OBJECT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_R_OBJECT))); + objectElement->SetKeyValue_StringKeys("SAMPLE_WR_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_WR_INT))); + objectElement->SetKeyValue_StringKeys("SAMPLE_WR_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_WR_FLOAT))); + objectElement->SetKeyValue_StringKeys("SAMPLE_WR_OBJECT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_WR_OBJECT))); + objectElement->SetKeyValue_StringKeys("TABULATE_MAXBIN", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_TABULATE_MAXBIN))); + objectElement->SetKeyValue_StringKeys("TABULATE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_TABULATE))); + + objectElement->SetKeyValue_StringKeys("CONTAINS_MARKER_MUT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_CONTAINS_MARKER_MUT))); + objectElement->SetKeyValue_StringKeys("I_COUNT_OF_MUTS_OF_TYPE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_I_COUNT_OF_MUTS_OF_TYPE))); + objectElement->SetKeyValue_StringKeys("G_COUNT_OF_MUTS_OF_TYPE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_G_COUNT_OF_MUTS_OF_TYPE))); + objectElement->SetKeyValue_StringKeys("INDS_W_PEDIGREE_IDS", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_INDS_W_PEDIGREE_IDS))); + objectElement->SetKeyValue_StringKeys("RELATEDNESS", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RELATEDNESS))); + objectElement->SetKeyValue_StringKeys("SAMPLE_INDIVIDUALS_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_INDIVIDUALS_1))); + objectElement->SetKeyValue_StringKeys("SAMPLE_INDIVIDUALS_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SAMPLE_INDIVIDUALS_2))); + objectElement->SetKeyValue_StringKeys("SET_FITNESS_SCALE_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_FITNESS_SCALE_1))); + objectElement->SetKeyValue_StringKeys("SET_FITNESS_SCALE_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_FITNESS_SCALE_2))); + objectElement->SetKeyValue_StringKeys("SUM_OF_MUTS_OF_TYPE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SUM_OF_MUTS_OF_TYPE))); + + objectElement->SetKeyValue_StringKeys("DNORM_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_DNORM_1))); + objectElement->SetKeyValue_StringKeys("DNORM_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_DNORM_2))); + objectElement->SetKeyValue_StringKeys("RBINOM_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RBINOM_1))); + objectElement->SetKeyValue_StringKeys("RBINOM_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RBINOM_2))); + objectElement->SetKeyValue_StringKeys("RBINOM_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RBINOM_3))); + objectElement->SetKeyValue_StringKeys("RDUNIF_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RDUNIF_1))); + objectElement->SetKeyValue_StringKeys("RDUNIF_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RDUNIF_2))); + objectElement->SetKeyValue_StringKeys("RDUNIF_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RDUNIF_3))); + objectElement->SetKeyValue_StringKeys("REXP_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_REXP_1))); + objectElement->SetKeyValue_StringKeys("REXP_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_REXP_2))); + objectElement->SetKeyValue_StringKeys("RNORM_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RNORM_1))); + objectElement->SetKeyValue_StringKeys("RNORM_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RNORM_2))); + objectElement->SetKeyValue_StringKeys("RNORM_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RNORM_3))); + objectElement->SetKeyValue_StringKeys("RPOIS_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RPOIS_1))); + objectElement->SetKeyValue_StringKeys("RPOIS_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RPOIS_2))); + objectElement->SetKeyValue_StringKeys("RUNIF_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RUNIF_1))); + objectElement->SetKeyValue_StringKeys("RUNIF_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RUNIF_2))); + objectElement->SetKeyValue_StringKeys("RUNIF_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_RUNIF_3))); + + objectElement->SetKeyValue_StringKeys("SORT_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SORT_INT))); + objectElement->SetKeyValue_StringKeys("SORT_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SORT_FLOAT))); + objectElement->SetKeyValue_StringKeys("SORT_STRING", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SORT_STRING))); + + objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_IN_BOUNDS_1D))); + objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_IN_BOUNDS_2D))); + objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_IN_BOUNDS_3D))); + objectElement->SetKeyValue_StringKeys("POINT_PERIODIC_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_PERIODIC_1D))); + objectElement->SetKeyValue_StringKeys("POINT_PERIODIC_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_PERIODIC_2D))); + objectElement->SetKeyValue_StringKeys("POINT_PERIODIC_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_PERIODIC_3D))); + objectElement->SetKeyValue_StringKeys("POINT_REFLECTED_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_REFLECTED_1D))); + objectElement->SetKeyValue_StringKeys("POINT_REFLECTED_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_REFLECTED_2D))); + objectElement->SetKeyValue_StringKeys("POINT_REFLECTED_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_REFLECTED_3D))); + objectElement->SetKeyValue_StringKeys("POINT_STOPPED_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_STOPPED_1D))); + objectElement->SetKeyValue_StringKeys("POINT_STOPPED_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_STOPPED_2D))); + objectElement->SetKeyValue_StringKeys("POINT_STOPPED_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_STOPPED_3D))); + objectElement->SetKeyValue_StringKeys("POINT_UNIFORM_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_UNIFORM_1D))); + objectElement->SetKeyValue_StringKeys("POINT_UNIFORM_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_UNIFORM_2D))); + objectElement->SetKeyValue_StringKeys("POINT_UNIFORM_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_POINT_UNIFORM_3D))); + objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_1_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_SPATIAL_POS_1_1D))); + objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_1_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_SPATIAL_POS_1_2D))); + objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_1_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_SPATIAL_POS_1_3D))); + objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_2_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_SPATIAL_POS_2_1D))); + objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_2_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_SPATIAL_POS_2_2D))); + objectElement->SetKeyValue_StringKeys("SET_SPATIAL_POS_2_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SET_SPATIAL_POS_2_3D))); + objectElement->SetKeyValue_StringKeys("SPATIAL_MAP_VALUE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SPATIAL_MAP_VALUE))); + + objectElement->SetKeyValue_StringKeys("CLIPPEDINTEGRAL_1S", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_CLIPPEDINTEGRAL_1S))); + objectElement->SetKeyValue_StringKeys("CLIPPEDINTEGRAL_2S", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_CLIPPEDINTEGRAL_2S))); + //objectElement->SetKeyValue_StringKeys("CLIPPEDINTEGRAL_3S", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_CLIPPEDINTEGRAL_3S))); + objectElement->SetKeyValue_StringKeys("DRAWBYSTRENGTH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_DRAWBYSTRENGTH))); + objectElement->SetKeyValue_StringKeys("INTNEIGHCOUNT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_INTNEIGHCOUNT))); + objectElement->SetKeyValue_StringKeys("LOCALPOPDENSITY", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_LOCALPOPDENSITY))); + objectElement->SetKeyValue_StringKeys("NEARESTINTNEIGH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_NEARESTINTNEIGH))); + objectElement->SetKeyValue_StringKeys("NEARESTNEIGH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_NEARESTNEIGH))); + objectElement->SetKeyValue_StringKeys("NEIGHCOUNT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_NEIGHCOUNT))); + objectElement->SetKeyValue_StringKeys("TOTNEIGHSTRENGTH", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_TOTNEIGHSTRENGTH))); + + objectElement->SetKeyValue_StringKeys("AGE_INCR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_AGE_INCR))); + objectElement->SetKeyValue_StringKeys("DEFERRED_REPRO", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_DEFERRED_REPRO))); + objectElement->SetKeyValue_StringKeys("WF_REPRO", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_WF_REPRO))); + objectElement->SetKeyValue_StringKeys("FITNESS_ASEX_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FITNESS_ASEX_1))); + objectElement->SetKeyValue_StringKeys("FITNESS_ASEX_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FITNESS_ASEX_2))); + objectElement->SetKeyValue_StringKeys("FITNESS_ASEX_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FITNESS_ASEX_3))); + objectElement->SetKeyValue_StringKeys("FITNESS_SEX_1", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FITNESS_SEX_1))); + objectElement->SetKeyValue_StringKeys("FITNESS_SEX_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FITNESS_SEX_2))); + objectElement->SetKeyValue_StringKeys("FITNESS_SEX_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_FITNESS_SEX_3))); + objectElement->SetKeyValue_StringKeys("MIGRANT_CLEAR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_MIGRANT_CLEAR))); + objectElement->SetKeyValue_StringKeys("SIMPLIFY_SORT_PRE", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SIMPLIFY_SORT_PRE))); + objectElement->SetKeyValue_StringKeys("SIMPLIFY_SORT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SIMPLIFY_SORT))); + objectElement->SetKeyValue_StringKeys("SIMPLIFY_SORT_POST", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SIMPLIFY_SORT_POST))); + objectElement->SetKeyValue_StringKeys("PARENTS_CLEAR", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_PARENTS_CLEAR))); + objectElement->SetKeyValue_StringKeys("UNIQUE_MUTRUNS", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_UNIQUE_MUTRUNS))); + objectElement->SetKeyValue_StringKeys("SURVIVAL", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_SURVIVAL))); #endif objectElement->ContentsChanged("parallelGetTaskThreadCounts()"); diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index 8f3a41130..bad4d985a 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -229,7 +229,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(max)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(max)); } else if (x_type == EidosValueType::kValueFloat) { @@ -435,7 +435,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(min)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(min)); } else if (x_type == EidosValueType::kValueFloat) { @@ -596,7 +596,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg { const int64_t * __restrict__ int0_data = x_value->IntData(); int64_t y_singleton_value = y_value->IntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -666,7 +666,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg { const int64_t * __restrict__ int0_data = x_value->IntData(); const int64_t * __restrict__ int1_data = y_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -794,7 +794,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg { const int64_t * __restrict__ int0_data = x_value->IntData(); int64_t y_singleton_value = y_value->IntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -854,7 +854,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg { const int64_t * __restrict__ int0_data = x_value->IntData(); const int64_t * __restrict__ int1_data = y_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); int64_t * __restrict__ int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -1048,7 +1048,7 @@ EidosValue_SP Eidos_ExecuteFunction_range(const std::vector &p_ar } else if (x_type == EidosValueType::kValueInt) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(2); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(2); result_SP = EidosValue_SP(int_result); int64_t max = p_arguments[first_nonempty_argument]->IntAtIndex_NOCAST(0, nullptr); diff --git a/eidos/eidos_functions_strings.cpp b/eidos/eidos_functions_strings.cpp index e689e187a..7d2be7892 100644 --- a/eidos/eidos_functions_strings.cpp +++ b/eidos/eidos_functions_strings.cpp @@ -92,12 +92,12 @@ EidosValue_SP Eidos_ExecuteFunction_grep(const std::vector &p_arg // Make our return value EidosValue_SP result_SP(nullptr); EidosValue_Logical *result_logical = nullptr; - EidosValue_Int_vector *result_int = nullptr; + EidosValue_Int *result_int = nullptr; EidosValue_String_vector *result_string = nullptr; if (value_enum == kIndices) { - result_int = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); + result_int = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); result_SP = EidosValue_SP(result_int); } else if ((value_enum == kElements) || (value_enum == kMatches)) @@ -230,13 +230,13 @@ EidosValue_SP Eidos_ExecuteFunction_nchar(const std::vector &p_ar if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->StringRefAtIndex_NOCAST(0, nullptr).size())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->StringRefAtIndex_NOCAST(0, nullptr).size())); } else { const std::string *string_vec = x_value->StringData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -317,13 +317,13 @@ EidosValue_SP Eidos_ExecuteFunction_strfind(const std::vector &p_ { const std::string &x = x_value->StringRefAtIndex_NOCAST(0, nullptr); size_t index = x.find(s, pos); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(index == std::string::npos ? -1 : (int64_t)index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(index == std::string::npos ? -1 : (int64_t)index)); } else { const std::string *string_vec = x_value->StringData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 145f00d93..758c73b9e 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -121,7 +121,7 @@ EidosValue_SP Eidos_ExecuteFunction_integer(const std::vector &p_ if (element_count == 0) return gStaticEidosValue_Integer_ZeroVec; - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(element_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(element_count); result_SP = EidosValue_SP(int_result); for (int64_t value_index = 0; value_index < element_count; ++value_index) @@ -462,7 +462,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a if (x_type == EidosValueType::kValueInt) { const int64_t *int_data = x_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(sample_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(sample_size); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -779,7 +779,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a else if (x_type == EidosValueType::kValueInt) { const int64_t *int_data = x_value->IntData(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(sample_size); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(sample_size); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -949,13 +949,13 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if (length == 1) { // If a sequence of length 1 is requested, generate a single integer at the start - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_value)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(first_value)); } else if ((second_value - first_value) % (length - 1) == 0) { // length divides evenly, so generate an integer sequence int64_t by = (second_value - first_value) / (length - 1); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(length); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(length); result_SP = EidosValue_SP(int_result); for (int64_t seq_index = 0; seq_index < length; ++seq_index) @@ -1021,7 +1021,7 @@ EidosValue_SP Eidos_ExecuteFunction_seq(const std::vector &p_argu if (((first_value < second_value) && (by < 0)) || ((first_value > second_value) && (by > 0))) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seq): function seq() by has incorrect sign." << EidosTerminate(nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->reserve((int)(1 + (second_value - first_value) / by)); // take a stab at a reserve size; might not be quite right, but no harm + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve((int)(1 + (second_value - first_value) / by)); // take a stab at a reserve size; might not be quite right, but no harm result_SP = EidosValue_SP(int_result); if (by > 0) @@ -1048,7 +1048,7 @@ EidosValue_SP Eidos_ExecuteFunction_seqAlong(const std::vector &p EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -1068,7 +1068,7 @@ EidosValue_SP Eidos_ExecuteFunction_seqLen(const std::vector &p_a if (length < 0) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_seqLen): function seqLen() requires length to be greater than or equal to 0 (" << length << " supplied)." << EidosTerminate(nullptr); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(length); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(length); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < length; ++value_index) @@ -1516,8 +1516,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a { const int64_t *true_data = trueValues_value->IntData(); const int64_t *false_data = falseValues_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(test_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(test_count); for (int value_index = 0; value_index < test_count; ++value_index) int_result->set_int_no_check(logical_vec[value_index] ? true_data[value_index] : false_data[value_index], value_index); @@ -1613,8 +1613,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a { int64_t true_value = trueValues_value->IntAtIndex_NOCAST(0, nullptr); int64_t false_value = falseValues_value->IntAtIndex_NOCAST(0, nullptr); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(test_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(test_count); for (int value_index = 0; value_index < test_count; ++value_index) int_result->set_int_no_check(logical_vec[value_index] ? true_value : false_value, value_index); @@ -1756,22 +1756,22 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar { // Handle singleton matching separately, to allow the use of the fast vector API below if (x_type == EidosValueType::kValueLogical) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->LogicalAtIndex_NOCAST(0, nullptr) == table_value->LogicalAtIndex_NOCAST(0, nullptr) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->LogicalAtIndex_NOCAST(0, nullptr) == table_value->LogicalAtIndex_NOCAST(0, nullptr) ? 0 : -1)); else if (x_type == EidosValueType::kValueInt) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_NOCAST(0, nullptr) == table_value->IntAtIndex_NOCAST(0, nullptr) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->IntAtIndex_NOCAST(0, nullptr) == table_value->IntAtIndex_NOCAST(0, nullptr) ? 0 : -1)); else if (x_type == EidosValueType::kValueFloat) { double f0 = x_value->FloatAtIndex_NOCAST(0, nullptr), f1 = table_value->FloatAtIndex_NOCAST(0, nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(((std::isnan(f0) && std::isnan(f1)) || (f0 == f1)) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(((std::isnan(f0) && std::isnan(f1)) || (f0 == f1)) ? 0 : -1)); } else if (x_type == EidosValueType::kValueString) { const std::string &s0 = ((EidosValue_String *)x_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string &s1 = ((EidosValue_String *)table_value)->StringRefAtIndex_NOCAST(0, nullptr); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(s0 == s1 ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(s0 == s1 ? 0 : -1)); } else if (x_type == EidosValueType::kValueObject) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->ObjectElementAtIndex_NOCAST(0, nullptr) == table_value->ObjectElementAtIndex_NOCAST(0, nullptr) ? 0 : -1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->ObjectElementAtIndex_NOCAST(0, nullptr) == table_value->ObjectElementAtIndex_NOCAST(0, nullptr) ? 0 : -1)); } else if (x_count == 1) // && (table_count != 1) { @@ -1785,7 +1785,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar for (table_index = 0; table_index < table_count; ++table_index) if (value0 == logical_data1[table_index]) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(table_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(table_index)); break; } } @@ -1797,7 +1797,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar for (table_index = 0; table_index < table_count; ++table_index) if (value0 == int_data1[table_index]) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(table_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(table_index)); break; } } @@ -1812,7 +1812,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar if ((std::isnan(value0) && std::isnan(f1)) || (value0 == f1)) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(table_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(table_index)); break; } } @@ -1825,7 +1825,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar for (table_index = 0; table_index < table_count; ++table_index) if (value0 == string_vec1[table_index]) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(table_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(table_index)); break; } } @@ -1837,17 +1837,17 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar for (table_index = 0; table_index < table_count; ++table_index) if (value0 == objelement_vec1[table_index]) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(table_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(table_index)); break; } } if (table_index == table_count) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-1)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(-1)); } else if (table_count == 1) // && (x_count != 1) { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); if (x_type == EidosValueType::kValueLogical) @@ -1898,7 +1898,7 @@ EidosValue_SP Eidos_ExecuteFunction_match(const std::vector &p_ar else // ((x_count != 1) && (table_count != 1)) { // We can use the fast vector API; we want match() to be very fast since it is a common bottleneck - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); int64_t *int_result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -2150,7 +2150,7 @@ EidosValue_SP Eidos_ExecuteFunction_order(const std::vector &p_ar else if (x_type == EidosValueType::kValueString) order = EidosSortIndexes(x_value->StringData(), x_count, ascending); - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(order)); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int(order)); result_SP = EidosValue_SP(int_result); } @@ -2316,7 +2316,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg { // Here we handle the vector cases, which can be done with direct access EidosValue_Float *float_result = nullptr; - EidosValue_Int_vector *int_result = nullptr; + EidosValue_Int *int_result = nullptr; EidosValueType x_type = x_value->Type(); if (tiesMethod == TiesMethod::kTiesAverage) @@ -2326,7 +2326,7 @@ EidosValue_SP Eidos_ExecuteFunction_rank(const std::vector &p_arg } else { - int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); } @@ -2525,7 +2525,7 @@ EidosValue_SP Eidos_ExecuteFunction_size_length(const std::vector EidosValue *x_value = p_arguments[0].get(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->Count())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->Count())); return result_SP; } @@ -2634,7 +2634,7 @@ EidosValue_SP Eidos_ExecuteFunction_tabulate(const std::vector &p // set up the result vector and zero it out int64_t num_bins = maxbin + 1; - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(num_bins); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(num_bins); int64_t *result_data = int_result->data(); result_SP = EidosValue_SP(int_result); @@ -2708,7 +2708,7 @@ EidosValue_SP Eidos_ExecuteFunction_which(const std::vector &p_ar EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); const eidos_logical_t *logical_data = x_value->LogicalData(); - EidosValue_Int_vector *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *int_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -2802,7 +2802,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMax(const std::vector &p } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(first_index)); } return result_SP; @@ -2892,7 +2892,7 @@ EidosValue_SP Eidos_ExecuteFunction_whichMin(const std::vector &p } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_index)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(first_index)); } return result_SP; @@ -2944,11 +2944,11 @@ EidosValue_SP Eidos_ExecuteFunction_asInteger(const std::vector & if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(x_value->IntAtIndex_CAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(x_value->IntAtIndex_CAST(0, nullptr))); } else { - EidosValue_Int_vector *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector())->resize_no_initialize(x_count); + EidosValue_Int *int_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->resize_no_initialize(x_count); result_SP = EidosValue_SP(int_result); for (int value_index = 0; value_index < x_count; ++value_index) diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index 6252bd67f..f39bcf6d7 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1084,8 +1084,6 @@ void Eidos_WarmUp(void) maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String_vector)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String_singleton)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int_vector)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int_singleton)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_vector)); @@ -1098,8 +1096,6 @@ void Eidos_WarmUp(void) // std::cout << "sizeof(EidosValue_String_vector) == " << sizeof(EidosValue_String_vector) << std::endl; // std::cout << "sizeof(EidosValue_String_singleton) == " << sizeof(EidosValue_String_singleton) << std::endl; // std::cout << "sizeof(EidosValue_Int) == " << sizeof(EidosValue_Int) << std::endl; -// std::cout << "sizeof(EidosValue_Int_vector) == " << sizeof(EidosValue_Int_vector) << std::endl; -// std::cout << "sizeof(EidosValue_Int_singleton) == " << sizeof(EidosValue_Int_singleton) << std::endl; // std::cout << "sizeof(EidosValue_Float) == " << sizeof(EidosValue_Float) << std::endl; // std::cout << "sizeof(EidosValue_Object) == " << sizeof(EidosValue_Object) << std::endl; // std::cout << "sizeof(EidosValue_Object_vector) == " << sizeof(EidosValue_Object_vector) << std::endl; @@ -1132,7 +1128,7 @@ void Eidos_WarmUp(void) gStaticEidosValue_Logical_ZeroVec = EidosValue_Logical_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Logical()); gStaticEidosValue_Logical_ZeroVec->MarkAsConstant(); - gStaticEidosValue_Integer_ZeroVec = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); + gStaticEidosValue_Integer_ZeroVec = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); gStaticEidosValue_Integer_ZeroVec->MarkAsConstant(); gStaticEidosValue_Float_ZeroVec = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); @@ -1141,16 +1137,16 @@ void Eidos_WarmUp(void) gStaticEidosValue_String_ZeroVec = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); gStaticEidosValue_String_ZeroVec->MarkAsConstant(); - gStaticEidosValue_Integer0 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); + gStaticEidosValue_Integer0 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(0)); gStaticEidosValue_Integer0->MarkAsConstant(); - gStaticEidosValue_Integer1 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(1)); + gStaticEidosValue_Integer1 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(1)); gStaticEidosValue_Integer1->MarkAsConstant(); - gStaticEidosValue_Integer2 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(2)); + gStaticEidosValue_Integer2 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(2)); gStaticEidosValue_Integer2->MarkAsConstant(); - gStaticEidosValue_Integer3 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(3)); + gStaticEidosValue_Integer3 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(3)); gStaticEidosValue_Integer3->MarkAsConstant(); gStaticEidosValue_Float0 = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(0.0)); diff --git a/eidos/eidos_globals.h b/eidos/eidos_globals.h index 24dd3aa4e..2e1b47511 100644 --- a/eidos/eidos_globals.h +++ b/eidos/eidos_globals.h @@ -1187,8 +1187,6 @@ class EidosValue_VOID; class EidosValue_NULL; class EidosValue_Logical; class EidosValue_Int; -class EidosValue_Int_singleton; -class EidosValue_Int_vector; class EidosValue_Float; class EidosValue_String; class EidosValue_String_singleton; @@ -1226,8 +1224,6 @@ typedef Eidos_intrusive_ptr EidosValue_VOID_SP; typedef Eidos_intrusive_ptr EidosValue_NULL_SP; typedef Eidos_intrusive_ptr EidosValue_Logical_SP; typedef Eidos_intrusive_ptr EidosValue_Int_SP; -typedef Eidos_intrusive_ptr EidosValue_Int_singleton_SP; -typedef Eidos_intrusive_ptr EidosValue_Int_vector_SP; typedef Eidos_intrusive_ptr EidosValue_Float_SP; typedef Eidos_intrusive_ptr EidosValue_String_SP; typedef Eidos_intrusive_ptr EidosValue_String_singleton_SP; diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index f75d5f28f..8f0a1b619 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -957,8 +957,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode if (second_int - first_int + 1 > 100000000) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_Evaluate_RangeExpr_Internal): a range with more than 100000000 entries cannot be constructed." << EidosTerminate(operator_token); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_int - first_int + 1); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(second_int - first_int + 1); for (int64_t range_index = 0; range_index <= second_int - first_int; ++range_index) int_result->set_int_no_check(range_index + first_int, range_index); @@ -970,8 +970,8 @@ EidosValue_SP EidosInterpreter::_Evaluate_RangeExpr_Internal(const EidosASTNode if (first_int - second_int + 1 > 100000000) EIDOS_TERMINATION << "ERROR (EidosInterpreter::_Evaluate_RangeExpr_Internal): a range with more than 100000000 entries cannot be constructed." << EidosTerminate(operator_token); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_int - second_int + 1); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_int - second_int + 1); for (int64_t range_index = 0; range_index <= first_int - second_int; ++range_index) int_result->set_int_no_check(first_int - range_index, range_index); @@ -2047,7 +2047,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex_NOCAST(0, operator_token) + second_child_value->IntAtIndex_NOCAST(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(first_child_value->IntAtIndex_NOCAST(0, operator_token) + second_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); @@ -2057,14 +2057,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Plus): integer addition overflow with the binary '+' operator." << EidosTerminate(operator_token); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(add_result)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(add_result)); } else { const int64_t *first_child_data = first_child_value->IntData(); const int64_t *second_child_data = second_child_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) { @@ -2089,8 +2089,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) { int64_t singleton_int = first_child_value->IntAtIndex_NOCAST(0, operator_token); const int64_t *second_child_data = second_child_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(second_child_count); for (int value_index = 0; value_index < second_child_count; ++value_index) { @@ -2113,8 +2113,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) { const int64_t *first_child_data = first_child_value->IntData(); int64_t singleton_int = second_child_value->IntAtIndex_NOCAST(0, operator_token); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) { @@ -2267,7 +2267,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-first_child_value->IntAtIndex_NOCAST(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(-first_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t subtract_result; @@ -2276,13 +2276,13 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Minus): integer negation overflow with the unary '-' operator." << EidosTerminate(operator_token); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(subtract_result)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(subtract_result)); } else { const int64_t *first_child_data = first_child_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) { @@ -2350,7 +2350,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex_NOCAST(0, operator_token) - second_child_value->IntAtIndex_NOCAST(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(first_child_value->IntAtIndex_NOCAST(0, operator_token) - second_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); @@ -2360,14 +2360,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Minus): integer subtraction overflow with the binary '-' operator." << EidosTerminate(operator_token); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(subtract_result)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(subtract_result)); } else { const int64_t *first_child_data = first_child_value->IntData(); const int64_t *second_child_data = second_child_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) { @@ -2392,8 +2392,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { int64_t singleton_int = first_child_value->IntAtIndex_NOCAST(0, operator_token); const int64_t *second_child_data = second_child_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(second_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(second_child_count); for (int value_index = 0; value_index < second_child_count; ++value_index) { @@ -2416,8 +2416,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Minus(const EidosASTNode *p_node) { const int64_t *first_child_data = first_child_value->IntData(); int64_t singleton_int = second_child_value->IntAtIndex_NOCAST(0, operator_token); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) { @@ -2722,7 +2722,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) if (first_child_count == 1) { // This is an overflow-safe version of: - //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(first_child_value->IntAtIndex_NOCAST(0, operator_token) * second_child_value->IntAtIndex_NOCAST(0, operator_token)); + //result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(first_child_value->IntAtIndex_NOCAST(0, operator_token) * second_child_value->IntAtIndex_NOCAST(0, operator_token)); int64_t first_operand = first_child_value->IntAtIndex_NOCAST(0, operator_token); int64_t second_operand = second_child_value->IntAtIndex_NOCAST(0, operator_token); @@ -2732,14 +2732,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Mult): integer multiplication overflow with the '*' operator." << EidosTerminate(operator_token); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(multiply_result)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(multiply_result)); } else { const int64_t *first_child_data = first_child_value->IntData(); const int64_t *second_child_data = second_child_value->IntData(); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(first_child_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) { @@ -2827,8 +2827,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Mult(const EidosASTNode *p_node) { const int64_t *any_count_data = any_count_child->IntData(); int64_t singleton_int = one_count_child->IntAtIndex_NOCAST(0, operator_token); - EidosValue_Int_vector_SP int_result_SP = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - EidosValue_Int_vector *int_result = int_result_SP->resize_no_initialize(any_count); + EidosValue_Int_SP int_result_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); + EidosValue_Int *int_result = int_result_SP->resize_no_initialize(any_count); for (int value_index = 0; value_index < any_count; ++value_index) { @@ -3774,7 +3774,7 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) if ((lvalue_count == 1) && lvalue->IsSingleton()) { - EidosValue_Int_singleton *int_singleton = static_cast(lvalue); + EidosValue_Int *int_singleton = static_cast(lvalue); switch (compound_operator) { @@ -5192,7 +5192,7 @@ EidosValue_SP EidosInterpreter::NumericValueForString(const std::string &p_numbe if ((converted_value < (double)INT64_MIN) || (converted_value >= (double)INT64_MAX)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::NumericValueForString): '" << p_number_string << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(static_cast(converted_value))); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(static_cast(converted_value))); } else // plain integer { @@ -5201,7 +5201,7 @@ EidosValue_SP EidosInterpreter::NumericValueForString(const std::string &p_numbe if (errno || (last_used_char == c_str)) EIDOS_TERMINATION << "ERROR (EidosInterpreter::NumericValueForString): '" << p_number_string << "' could not be represented as an integer (strtoll conversion error)." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(converted_value)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(converted_value)); } } @@ -5762,20 +5762,20 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) if (range_index == range_count) range_index--; - global_symbols_->SetValueForSymbolNoCopy(identifier_name, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(counting_up ? start_int + range_index : start_int - range_index))); + global_symbols_->SetValueForSymbolNoCopy(identifier_name, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(counting_up ? start_int + range_index : start_int - range_index))); } else // !assigns_index, guaranteed above { // the loop index variable is referenced in the loop body but is not assigned to, so we can use a single // EidosValue that we stick new values into – much, much faster. - EidosValue_Int_singleton_SP index_value_SP = EidosValue_Int_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); - EidosValue_Int_singleton *index_value = index_value_SP.get(); + EidosValue_Int_SP index_value_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(0)); + EidosValue_Int *index_value = index_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(identifier_name, index_value_SP); for (int range_index = 0; range_index < range_count; ++range_index) { - index_value->SetValue(counting_up ? start_int + range_index : start_int - range_index); + index_value->data()[0] = (counting_up ? start_int + range_index : start_int - range_index); EidosASTNode *statement_node = p_node->children_[2]; @@ -5855,14 +5855,14 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) if (range_type == EidosValueType::kValueInt) { const int64_t *range_data = range_value->IntData(); - EidosValue_Int_singleton_SP index_value_SP = EidosValue_Int_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(0)); - EidosValue_Int_singleton *index_value = index_value_SP.get(); + EidosValue_Int_SP index_value_SP = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(0)); + EidosValue_Int *index_value = index_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(identifier_name, index_value_SP); for (int range_index = 0; range_index < range_count; ++range_index) { - index_value->SetValue(range_data[range_index]); + index_value->data()[0] = range_data[range_index]; EidosASTNode *statement_node = p_node->children_[2]; diff --git a/eidos/eidos_script.cpp b/eidos/eidos_script.cpp index cc78b4b48..6ae07d461 100644 --- a/eidos/eidos_script.cpp +++ b/eidos/eidos_script.cpp @@ -2411,7 +2411,7 @@ EidosASTNode *EidosScript::Parse_DefaultValue(void) else if (numeric_value->Type() == EidosValueType::kValueInt) { int64_t int_value = numeric_value->IntAtIndex_NOCAST(0, current_token_); - negated_value = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(-int_value)); // note that overflow is not possible + negated_value = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(-int_value)); // note that overflow is not possible } else { diff --git a/eidos/eidos_test.cpp b/eidos/eidos_test.cpp index 9aec38eee..21888a9fa 100644 --- a/eidos/eidos_test.cpp +++ b/eidos/eidos_test.cpp @@ -171,12 +171,12 @@ void EidosAssertScriptSuccess_LV(const std::string &p_script_string, std::initia void EidosAssertScriptSuccess_I(const std::string &p_script_string, int64_t p_integer) { - EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(p_integer))); + EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(p_integer))); } void EidosAssertScriptSuccess_IV(const std::string &p_script_string, std::initializer_list p_integer_vec) { - EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(p_integer_vec))); + EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(p_integer_vec))); } void EidosAssertScriptSuccess_F(const std::string &p_script_string, double p_float) diff --git a/eidos/eidos_test_functions_other.cpp b/eidos/eidos_test_functions_other.cpp index 5821485b0..f1b322f70 100644 --- a/eidos/eidos_test_functions_other.cpp +++ b/eidos/eidos_test_functions_other.cpp @@ -1602,7 +1602,7 @@ void _RunCodeExampleTests(void) fib = c(fib, next_fib); \ } \ fib;", - EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765})); + EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765})); EidosAssertScriptSuccess( "counter = 12; \ factorial = 1; \ @@ -1613,7 +1613,7 @@ void _RunCodeExampleTests(void) } \ while (counter > 0); \ factorial;", - EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(479001600))); + EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(479001600))); EidosAssertScriptSuccess( "last = 200; \ p = integer(0); \ @@ -1627,7 +1627,7 @@ void _RunCodeExampleTests(void) x = x[x % v != 0]; \ } while (T); \ c(p, x);", - EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199})); + EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199})); } #pragma mark user-defined functions diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index f3a7ce7d8..5ee1203ee 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1420,39 +1420,7 @@ void EidosValue_String_singleton::Sort(bool p_ascending) #pragma mark EidosValue_Int #pragma mark - -const std::string &EidosValue_Int::ElementType(void) const -{ - return gEidosStr_integer; -} - -EidosValue_SP EidosValue_Int::NewMatchingType(void) const -{ - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); -} - -void EidosValue_Int::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const -{ - int64_t value = IntAtIndex_NOCAST(p_idx, nullptr); - - p_ostream << value; -} - -nlohmann::json EidosValue_Int::JSONRepresentation(void) const -{ - nlohmann::json json_object = nlohmann::json::array(); // always write as an array, for consistency; makes automated parsing easier - int count = Count(); - - for (int i = 0; i < count; ++i) - json_object.emplace_back(IntAtIndex_NOCAST(i, nullptr)); - - return json_object; -} - - -// EidosValue_Int_vector -#pragma mark EidosValue_Int_vector - -EidosValue_Int_vector::EidosValue_Int_vector(const std::vector &p_intvec) : EidosValue_Int(false) +EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_intvec.size(); const int16_t *values = p_intvec.data(); @@ -1463,7 +1431,7 @@ EidosValue_Int_vector::EidosValue_Int_vector(const std::vector &p_intve set_int_no_check(values[index], index); } -EidosValue_Int_vector::EidosValue_Int_vector(const std::vector &p_intvec) : EidosValue_Int(false) +EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_intvec.size(); const int32_t *values = p_intvec.data(); @@ -1474,7 +1442,7 @@ EidosValue_Int_vector::EidosValue_Int_vector(const std::vector &p_intve set_int_no_check(values[index], index); } -EidosValue_Int_vector::EidosValue_Int_vector(const std::vector &p_intvec) : EidosValue_Int(false) +EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_intvec.size(); const int64_t *values = p_intvec.data(); @@ -1485,7 +1453,7 @@ EidosValue_Int_vector::EidosValue_Int_vector(const std::vector &p_intve set_int_no_check(values[index], index); } -EidosValue_Int_vector::EidosValue_Int_vector(std::initializer_list p_init_list) : EidosValue_Int(false) +EidosValue_Int::EidosValue_Int(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { reserve(p_init_list.size()); @@ -1493,7 +1461,7 @@ EidosValue_Int_vector::EidosValue_Int_vector(std::initializer_list p_in push_int_no_check(init_item); } -EidosValue_Int_vector::EidosValue_Int_vector(const int64_t *p_values, size_t p_count) : EidosValue_Int(false) +EidosValue_Int::EidosValue_Int(const int64_t *p_values, size_t p_count) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { resize_no_initialize(p_count); @@ -1501,96 +1469,148 @@ EidosValue_Int_vector::EidosValue_Int_vector(const int64_t *p_values, size_t p_c set_int_no_check(p_values[index], index); } -int64_t EidosValue_Int_vector::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +const std::string &EidosValue_Int::ElementType(void) const +{ + return gEidosStr_integer; +} + +EidosValue_SP EidosValue_Int::NewMatchingType(void) const +{ + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int()); +} + +void EidosValue_Int::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const +{ + int64_t value = IntAtIndex_NOCAST(p_idx, nullptr); + + p_ostream << value; +} + +nlohmann::json EidosValue_Int::JSONRepresentation(void) const +{ + nlohmann::json json_object = nlohmann::json::array(); // always write as an array, for consistency; makes automated parsing easier + int count = Count(); + + for (int i = 0; i < count; ++i) + json_object.emplace_back(IntAtIndex_NOCAST(i, nullptr)); + + return json_object; +} + +int64_t EidosValue_Int::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::IntAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -double EidosValue_Int_vector::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Int::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { // casts integer to float, otherwise does not cast; considered _NOCAST if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -eidos_logical_t EidosValue_Int_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_Int::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx] == 0 ? false : true); } -std::string EidosValue_Int_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_Int::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return std::to_string(values_[p_idx]); // way faster than std::ostringstream } -int64_t EidosValue_Int_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_Int::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -double EidosValue_Int_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_Int::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -EidosValue_SP EidosValue_Int_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const +EidosValue_SP EidosValue_Int::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(values_[p_idx])); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(values_[p_idx])); } -EidosValue_SP EidosValue_Int_vector::CopyValues(void) const +EidosValue_SP EidosValue_Int::CopyValues(void) const { // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(values_, count_))->CopyDimensionsFromValue(this)); + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int(values_, count_))->CopyDimensionsFromValue(this)); +} + +EidosValue_SP EidosValue_Int::VectorBasedCopy(void) const +{ + // same as CopyValues() now; slated for removal + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int(values_, count_))->CopyDimensionsFromValue(this)); } -void EidosValue_Int_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) +void EidosValue_Int::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); if (p_source_script_value.Type() == EidosValueType::kValueInt) push_int(p_source_script_value.IntAtIndex_NOCAST(p_idx, p_blame_token)); else - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Int::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } -void EidosValue_Int_vector::Sort(bool p_ascending) +void EidosValue_Int::Sort(bool p_ascending) { WILL_MODIFY(this); + if (count_ < 2) + return; + // This will sort in parallel if the task is large enough (and we're running parallel) Eidos_ParallelSort(values_, count_, p_ascending); } -EidosValue_Int_vector *EidosValue_Int_vector::reserve(size_t p_reserved_size) +EidosValue_Int *EidosValue_Int::reserve(size_t p_reserved_size) { WILL_MODIFY(this); if (p_reserved_size > capacity_) { - values_ = (int64_t *)realloc(values_, p_reserved_size * sizeof(int64_t)); - if (!values_) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_vector::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + // this is a reservation for an explicit size, so we give that size exactly, to avoid wasting space + + if (values_ == &singleton_value_) + { + values_ = (int64_t *)malloc(p_reserved_size * sizeof(int64_t)); + + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Int::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + + values_[0] = singleton_value_; + } + else + { + values_ = (int64_t *)realloc(values_, p_reserved_size * sizeof(int64_t)); + + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Int::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + } capacity_ = p_reserved_size; } @@ -1598,27 +1618,7 @@ EidosValue_Int_vector *EidosValue_Int_vector::reserve(size_t p_reserved_size) return this; } -EidosValue_Int_vector *EidosValue_Int_vector::resize_no_initialize(size_t p_new_size) -{ - WILL_MODIFY(this); - - reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees - count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size - - return this; -} - -void EidosValue_Int_vector::expand(void) -{ - WILL_MODIFY(this); - - if (capacity_ == 0) - reserve(16); // if no reserve() call was made, start out with a bit of room - else - reserve(capacity_ << 1); -} - -void EidosValue_Int_vector::erase_index(size_t p_index) +void EidosValue_Int::erase_index(size_t p_index) { WILL_MODIFY(this); @@ -1641,102 +1641,6 @@ void EidosValue_Int_vector::erase_index(size_t p_index) } - -// EidosValue_Int_singleton -#pragma mark EidosValue_Int_singleton - -int64_t EidosValue_Int_singleton::IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -double EidosValue_Int_singleton::NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - // casts integer to float, otherwise does not cast; considered _NOCAST - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::NumericAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -eidos_logical_t EidosValue_Int_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return (value_ == 0 ? false : true); -} - -std::string EidosValue_Int_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return std::to_string(value_); // way faster than std::ostringstream -} - -int64_t EidosValue_Int_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -double EidosValue_Int_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -EidosValue_SP EidosValue_Int_singleton::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(value_)); -} - -EidosValue_SP EidosValue_Int_singleton::CopyValues(void) const -{ - // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(value_))->CopyDimensionsFromValue(this)); -} - -EidosValue_SP EidosValue_Int_singleton::VectorBasedCopy(void) const -{ - // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added - // note that constness, invisibility, etc. do not get copied - EidosValue_Int_vector_SP new_vec = EidosValue_Int_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector()); - - new_vec->push_int(value_); - new_vec->CopyDimensionsFromValue(this); - - return new_vec; -} - -void EidosValue_Int_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_source_script_value) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Int_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - -void EidosValue_Int_singleton::Sort(bool p_ascending) -{ -#pragma unused(p_ascending) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_Int_singleton::Sort): (internal error) EidosValue_Int_singleton is not modifiable." << EidosTerminate(nullptr); -} - - // // EidosValue_Float // @@ -2739,7 +2643,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ } else if (sig_mask == kEidosValueMaskInt) { - EidosValue_Int_vector *integer_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int_vector(); + EidosValue_Int *integer_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Int(); if (return_is_singleton) { diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index f54d35398..faa6772ea 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -679,9 +679,7 @@ class EidosValue_String_singleton final : public EidosValue_String // ********************************************************************************************************* // -// EidosValue_Int represents integer (C++ int64_t) values in Eidos. The subclass -// EidosValue_Int_vector is the standard instance class, used to hold vectors of floats. -// EidosValue_Int_singleton is used for speed, to represent single values. +// EidosValue_Int represents integer (C++ int64_t) values in Eidos. // class EidosValue_Int : public EidosValue @@ -690,56 +688,35 @@ class EidosValue_Int : public EidosValue typedef EidosValue super; protected: - explicit inline EidosValue_Int(bool p_singleton) : EidosValue(EidosValueType::kValueInt, p_singleton) {} + // singleton/vector design: values_ will either point to singleton_value_, or to a malloced buffer; it will never be nullptr + // in the case of a zero-length vector, note that values_ will point to singleton_value_ with count_ == 0 but capacity_ == 1 + int64_t singleton_value_; + int64_t *values_ = nullptr; + size_t count_, capacity_; - virtual int Count_Virtual(void) const override = 0; + virtual int Count_Virtual(void) const override { return (int)count_; } public: EidosValue_Int(const EidosValue_Int &p_original) = delete; // no copy-construct - EidosValue_Int(void) = delete; // no default constructor EidosValue_Int& operator=(const EidosValue_Int&) = delete; // no copying - inline virtual ~EidosValue_Int(void) override { } - virtual const std::string &ElementType(void) const override; - virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; - virtual nlohmann::json JSONRepresentation(void) const override; - - virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - - virtual EidosValue_SP CopyValues(void) const override = 0; - virtual EidosValue_SP NewMatchingType(void) const override; - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override = 0; - virtual void Sort(bool p_ascending) override = 0; -}; - -class EidosValue_Int_vector final : public EidosValue_Int -{ -private: - typedef EidosValue_Int super; - -protected: - int64_t *values_ = nullptr; - size_t count_ = 0, capacity_ = 0; - - virtual int Count_Virtual(void) const override { return (int)count_; } - -public: - EidosValue_Int_vector(const EidosValue_Int_vector &p_original) = delete; // no copy-construct - EidosValue_Int_vector& operator=(const EidosValue_Int_vector&) = delete; // no copying - - inline EidosValue_Int_vector(void) : EidosValue_Int(false) { } - explicit EidosValue_Int_vector(const std::vector &p_intvec); - explicit EidosValue_Int_vector(const std::vector &p_intvec); - explicit EidosValue_Int_vector(const std::vector &p_intvec); - //explicit EidosValue_Int_vector(int64_t p_int1); // disabled to encourage use of EidosValue_Int_singleton for this case - explicit EidosValue_Int_vector(std::initializer_list p_init_list); - explicit EidosValue_Int_vector(const int64_t *p_values, size_t p_count); - inline virtual ~EidosValue_Int_vector(void) override { free(values_); } + explicit inline EidosValue_Int(void) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { } + explicit inline EidosValue_Int(int64_t p_int1) : EidosValue(EidosValueType::kValueInt, false), singleton_value_(p_int1), values_(&singleton_value_), count_(1), capacity_(1) { } + explicit EidosValue_Int(const std::vector &p_intvec); + explicit EidosValue_Int(const std::vector &p_intvec); + explicit EidosValue_Int(const std::vector &p_intvec); + explicit EidosValue_Int(std::initializer_list p_init_list); + explicit EidosValue_Int(const int64_t *p_values, size_t p_count); + inline virtual ~EidosValue_Int(void) override { if (values_ != &singleton_value_) free(values_); } virtual const int64_t *IntData(void) const override { return values_; } virtual int64_t *IntData_Mutable(void) override { WILL_MODIFY(this); return values_; } + virtual const std::string &ElementType(void) const override; + virtual EidosValue_SP NewMatchingType(void) const override; + virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; + virtual nlohmann::json JSONRepresentation(void) const override; + virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast @@ -749,17 +726,37 @@ class EidosValue_Int_vector final : public EidosValue_Int virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; + virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; - // vector lookalike methods; not virtual, only for clients with a EidosValue_Int_vector* - EidosValue_Int_vector *reserve(size_t p_reserved_size); // as in std::vector - EidosValue_Int_vector *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! - void expand(void); // expand to fit (at least) one new value + // vector lookalike methods for speed; not virtual, only for clients with an EidosValue_Int* + EidosValue_Int *reserve(size_t p_reserved_size); // as in std::vector void erase_index(size_t p_index); // a weak substitute for erase() + inline void expand(void) + { + // expand to fit (at least) one new value + WILL_MODIFY(this); + + if (capacity_ <= 8) + reserve(16); + else + reserve(capacity_ << 1); + } + + inline EidosValue_Int *resize_no_initialize(size_t p_new_size) + { + // resizes but does not zero-initialize, unlike std::vector! + WILL_MODIFY(this); + + reserve(p_new_size); // might set a capacity greater than p_new_size; no guarantees + count_ = p_new_size; // regardless of the capacity set, set the size to exactly p_new_size + + return this; + } + inline __attribute__((always_inline)) int64_t *data(void) { WILL_MODIFY(this); return values_; } inline __attribute__((always_inline)) const int64_t *data(void) const { return values_; } inline __attribute__((always_inline)) void push_int(int64_t p_int) @@ -786,45 +783,6 @@ class EidosValue_Int_vector final : public EidosValue_Int } }; -class EidosValue_Int_singleton final : public EidosValue_Int -{ -private: - typedef EidosValue_Int super; - -protected: - int64_t value_; - - virtual int Count_Virtual(void) const override { return 1; } - -public: - EidosValue_Int_singleton(const EidosValue_Int_singleton &p_original) = delete; // no copy-construct - EidosValue_Int_singleton& operator=(const EidosValue_Int_singleton&) = delete; // no copying - EidosValue_Int_singleton(void) = delete; - explicit inline EidosValue_Int_singleton(int64_t p_int1) : EidosValue_Int(true), value_(p_int1) { } - inline virtual ~EidosValue_Int_singleton(void) override { } - - virtual const int64_t *IntData(void) const override { return &value_; } - virtual int64_t *IntData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; used only in Evaluate_Assign() - inline __attribute__((always_inline)) void SetValue(int64_t p_int) { WILL_MODIFY(this); value_ = p_int; } // very dangerous; used only in Evaluate_For() - - virtual int64_t IntAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual double NumericAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; // casts integer to float, otherwise does not cast - - virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; - - virtual EidosValue_SP VectorBasedCopy(void) const override; - - // prohibited actions because there is no backing vector - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; - virtual void Sort(bool p_ascending) override; -}; - #pragma mark - #pragma mark EidosValue_Float @@ -1068,7 +1026,7 @@ class EidosValue_Object_vector final : public EidosValue_Object virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) override; virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) override; - // vector lookalike methods; not virtual, only for clients with a EidosValue_Int_vector* + // vector lookalike methods; not virtual, only for clients with a EidosValue_Object_vector* void clear(void); // as in std::vector EidosValue_Object_vector *reserve(size_t p_reserved_size); // as in std::vector EidosValue_Object_vector *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! From ca2b33392c14e1bfdc4c7d3fadb3ee5401dd349a Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 14:23:03 -0500 Subject: [PATCH 14/18] abolish the singleton/vector distinction for EidosValue_Object --- SLiMgui/slim_gui.mm | 2 +- core/chromosome.cpp | 6 +- core/community.cpp | 8 +- core/community_eidos.cpp | 44 +-- core/genome.cpp | 28 +- core/genomic_element.cpp | 4 +- core/genomic_element_type.cpp | 6 +- core/individual.cpp | 28 +- core/interaction_type.cpp | 66 ++-- core/interaction_type.h | 8 +- core/mutation.cpp | 2 +- core/mutation_type.cpp | 4 +- core/slim_eidos_block.cpp | 16 +- core/slim_functions.cpp | 8 +- core/spatial_map.cpp | 26 +- core/species.cpp | 2 +- core/species_eidos.cpp | 44 +-- core/subpopulation.cpp | 66 ++-- core/subpopulation.h | 2 +- core/substitution.cpp | 2 +- eidos/eidos_class_DataFrame.cpp | 10 +- eidos/eidos_class_Dictionary.cpp | 10 +- eidos/eidos_class_Image.cpp | 2 +- eidos/eidos_class_TestElement.cpp | 8 +- eidos/eidos_functions.cpp | 14 +- eidos/eidos_functions_math.cpp | 24 +- eidos/eidos_functions_matrices.cpp | 4 +- eidos/eidos_functions_other.cpp | 2 +- eidos/eidos_functions_values.cpp | 14 +- eidos/eidos_globals.cpp | 6 +- eidos/eidos_globals.h | 4 - eidos/eidos_interpreter.cpp | 10 +- eidos/eidos_test_functions_vector.cpp | 10 +- eidos/eidos_value.cpp | 468 +++++++++----------------- eidos/eidos_value.h | 213 ++++-------- 35 files changed, 467 insertions(+), 704 deletions(-) diff --git a/SLiMgui/slim_gui.mm b/SLiMgui/slim_gui.mm index 10bbb2bae..4e457a8ec 100644 --- a/SLiMgui/slim_gui.mm +++ b/SLiMgui/slim_gui.mm @@ -35,7 +35,7 @@ SLiMgui::SLiMgui(Community &p_community, SLiMWindowController *p_controller) : community_(p_community), controller_(p_controller), - self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMgui_Class))) + self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMgui_Class))) { } diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 539f8cd2a..35e99db01 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -866,7 +866,7 @@ Mutation *Chromosome::ApplyMutationCallbacks(Mutation *p_mut, Genome *p_genome, // The callback is active and matches the mutation type id of the mutation, so we need to execute it // This code is similar to Population::ExecuteScript, but we set up an additional symbol table, and we use the return value - EidosValue_Object_singleton local_mut(p_mut, gSLiM_Mutation_Class); + EidosValue_Object local_mut(p_mut, gSLiM_Mutation_Class); EidosValue_Int local_originalNuc(p_original_nucleotide); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table @@ -1569,7 +1569,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) // constants case gID_genomicElements: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElement_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElement_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (GenomicElement *genomic_element : genomic_elements_) @@ -1768,7 +1768,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) case gID_species: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(&species_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(&species_, gSLiM_Species_Class)); } // variables diff --git a/core/community.cpp b/core/community.cpp index c920c14b1..1de86f4e6 100644 --- a/core/community.cpp +++ b/core/community.cpp @@ -81,7 +81,7 @@ extern "C" { #pragma mark Community #pragma mark - -Community::Community(void) : self_symbol_(gID_community, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Community_Class))) +Community::Community(void) : self_symbol_(gID_community, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Community_Class))) { // self_symbol_ is always a constant, but can't be marked as such on construction self_symbol_.second->MarkAsConstant(); @@ -1329,7 +1329,7 @@ Species *Community::SpeciesForIndividuals(EidosValue *value) if (value_count == 1) return &((Individual *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_->species_; - EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value; + EidosValue_Object *object_vector_value = (EidosValue_Object *)object_value; Individual **individuals = (Individual **)object_vector_value->data(); return Community::SpeciesForIndividualsVector(individuals, value_count); @@ -1374,7 +1374,7 @@ Species *Community::SpeciesForGenomes(EidosValue *value) if (value_count == 1) return &((Genome *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->OwningIndividual()->subpopulation_->species_; - EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value; + EidosValue_Object *object_vector_value = (EidosValue_Object *)object_value; Genome **genomes = (Genome **)object_vector_value->data(); return Community::SpeciesForGenomesVector(genomes, value_count); @@ -1419,7 +1419,7 @@ Species *Community::SpeciesForMutations(EidosValue *value) if (value_count == 1) return &((Mutation *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->mutation_type_ptr_->species_; - EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value; + EidosValue_Object *object_vector_value = (EidosValue_Object *)object_value; Mutation **mutations = (Mutation **)object_vector_value->data(); return Community::SpeciesForMutationsVector(mutations, value_count); diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index b447d6311..4ec76856c 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -321,7 +321,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) // constants case gID_allGenomicElementTypes: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto getype : all_genomic_element_types_) @@ -331,7 +331,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) } case gID_allInteractionTypes: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_InteractionType_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_InteractionType_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto inttype : interaction_types_) @@ -341,7 +341,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) } case gID_allMutationTypes: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto muttype : all_mutation_types_) @@ -351,7 +351,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) } case gID_allScriptBlocks: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class); EidosValue_SP result_SP = EidosValue_SP(vec); std::vector &script_blocks = AllScriptBlocks(); @@ -363,7 +363,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) } case gID_allSpecies: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto species : all_species_) @@ -373,7 +373,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) } case gID_allSubpopulations: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto species : all_species_) @@ -384,7 +384,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) } case gID_logFiles: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_LogFile_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_LogFile_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (LogFile *logfile : log_file_registry_) @@ -624,7 +624,7 @@ EidosValue_SP Community::ExecuteMethod_createLogFile(EidosGlobalStringID p_metho // Create the LogFile object LogFile *logfile = new LogFile(*this); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(logfile, gSLiM_LogFile_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(logfile, gSLiM_LogFile_Class)); // Add it to our registry; it has a retain count from new that we will take over at this point log_file_registry_.emplace_back(logfile); @@ -730,12 +730,12 @@ EidosValue_SP Community::ExecuteMethod_genomicElementTypesWithIDs(EidosGlobalStr if (!object) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_genomicElementTypesWithIDs): genomicElementTypesWithIDs() did not find a genomic element type with id " << id << "." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_GenomicElementType_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_GenomicElementType_Class)); } else { // Vector case - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class))->resize_no_initialize_RR(ids_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class))->resize_no_initialize_RR(ids_count); for (int id_index = 0; id_index < ids_count; id_index++) { @@ -769,12 +769,12 @@ EidosValue_SP Community::ExecuteMethod_interactionTypesWithIDs(EidosGlobalString if (!object) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_interactionTypesWithIDs): interactionTypesWithIDs() did not find an interaction type with id " << id << "." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_InteractionType_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_InteractionType_Class)); } else { // Vector case - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_InteractionType_Class))->resize_no_initialize_RR(ids_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_InteractionType_Class))->resize_no_initialize_RR(ids_count); for (int id_index = 0; id_index < ids_count; id_index++) { @@ -808,12 +808,12 @@ EidosValue_SP Community::ExecuteMethod_mutationTypesWithIDs(EidosGlobalStringID if (!object) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_mutationTypesWithIDs): mutationTypesWithIDs() did not find a genomic element type with id " << id << "." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_MutationType_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_MutationType_Class)); } else { // Vector case - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class))->resize_no_initialize_RR(ids_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class))->resize_no_initialize_RR(ids_count); for (int id_index = 0; id_index < ids_count; id_index++) { @@ -847,12 +847,12 @@ EidosValue_SP Community::ExecuteMethod_scriptBlocksWithIDs(EidosGlobalStringID p if (!object) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_scriptBlocksWithIDs): scriptBlocksWithIDs() did not find a script block with id " << id << "." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_SLiMEidosBlock_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_SLiMEidosBlock_Class)); } else { // Vector case - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class))->resize_no_initialize_RR(ids_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class))->resize_no_initialize_RR(ids_count); for (int id_index = 0; id_index < ids_count; id_index++) { @@ -886,12 +886,12 @@ EidosValue_SP Community::ExecuteMethod_speciesWithIDs(EidosGlobalStringID p_meth if (!object) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_speciesWithIDs): speciesWithIDs() did not find a species with id " << id << "." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_Species_Class)); } else { // Vector case - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class))->resize_no_initialize_RR(ids_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class))->resize_no_initialize_RR(ids_count); for (int id_index = 0; id_index < ids_count; id_index++) { @@ -925,12 +925,12 @@ EidosValue_SP Community::ExecuteMethod_subpopulationsWithIDs(EidosGlobalStringID if (!object) EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_subpopulationsWithIDs): subpopulationsWithIDs() did not find a subpopulation with id " << id << "." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_Subpopulation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_Subpopulation_Class)); } else { // Vector case - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class))->resize_no_initialize_RR(ids_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class))->resize_no_initialize_RR(ids_count); for (int id_index = 0; id_index < ids_count; id_index++) { @@ -1265,7 +1265,7 @@ EidosValue_SP Community::ExecuteMethod_rescheduleScriptBlock(EidosGlobalStringID gSLiMScheduling << std::endl; #endif - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(block, gSLiM_SLiMEidosBlock_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(block, gSLiM_SLiMEidosBlock_Class)); } else if (!ticks_null && (start_null && end_null)) { @@ -1289,7 +1289,7 @@ EidosValue_SP Community::ExecuteMethod_rescheduleScriptBlock(EidosGlobalStringID CheckScheduling(ticks.front(), stage); // finally, go through the tick vector and schedule blocks for sequential runs - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class)); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class)); EidosValue_SP result_SP = EidosValue_SP(vec); bool first_block = true; diff --git a/core/genome.cpp b/core/genome.cpp index 184369c7e..56c067a66 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -382,7 +382,7 @@ void Genome::record_derived_states(Species *p_species) const void Genome::GenerateCachedEidosValue(void) { // Note that this cache cannot be invalidated as long as a symbol table might exist that this value has been placed into - self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Genome_Class)); + self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Genome_Class)); } const EidosClass *Genome::Class(void) const @@ -432,7 +432,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) } case gID_individual: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(individual_, gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(individual_, gSLiM_Individual_Class)); } case gID_isNullGenome: // ACCELERATED return ((mutrun_count_ == 0) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); @@ -443,7 +443,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) Mutation *mut_block_ptr = gSLiM_Mutation_Block; int mut_count = mutation_count(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mut_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mut_count); EidosValue_SP result_SP = EidosValue_SP(vec); int set_index = 0; @@ -632,7 +632,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMarkerMutation(EidosObje if (returnMutation == false) return (mut ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); else - return (mut ? EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(mut, gSLiM_Mutation_Class)) : (EidosValue_SP)gStaticEidosValueNULL); + return (mut ? EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(mut, gSLiM_Mutation_Class)) : (EidosValue_SP)gStaticEidosValueNULL); } } else if (returnMutation == false) @@ -664,7 +664,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMarkerMutation(EidosObje else // (returnMutation == true) { // We will return an object vector, one Mutation (or NULL) for each target genome; not parallelized, for now - EidosValue_Object_vector *result_obj_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->reserve(p_elements_size); + EidosValue_Object *result_obj_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->reserve(p_elements_size); bool null_genome_seen = false; for (size_t element_index = 0; element_index < p_elements_size; ++element_index) @@ -873,7 +873,7 @@ EidosValue_SP Genome::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_method // We do this by not creating a vector until we see the second match; with one match, we make a singleton. Mutation *mut_block_ptr = gSLiM_Mutation_Block; Mutation *first_match = nullptr; - EidosValue_Object_vector *vec = nullptr; + EidosValue_Object *vec = nullptr; EidosValue_SP result_SP; int run_index; @@ -895,7 +895,7 @@ EidosValue_SP Genome::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_method first_match = mut; else { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); result_SP = EidosValue_SP(vec); vec->push_object_element_RR(first_match); @@ -914,13 +914,13 @@ EidosValue_SP Genome::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_method // Now return the appropriate return value if (first_match) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(first_match, gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(first_match, gSLiM_Mutation_Class)); } else { if (!vec) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); result_SP = EidosValue_SP(vec); } @@ -2491,7 +2491,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m ((nucleotide_count != 1) && (nucleotide_count != count_to_add))) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " requires that mutationType, " << ((p_method_id == gID_addNewMutation) ? "selectionCoeff, " : "") << "position, originSubpop, and nucleotide be either (1) singleton, or (2) equal in length to the other non-singleton argument(s), or (3) NULL, for originSubpop and nucleotide." << EidosTerminate(); - EidosValue_Object_vector_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + EidosValue_Object_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); if (count_to_add == 0) return retval; @@ -3225,12 +3225,12 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromMS(EidosGlobalStringID p_metho // Return the instantiated mutations int mutation_count = (int)mutation_indices.size(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); for (int mut_index = 0; mut_index < mutation_count; ++mut_index) vec->set_object_element_no_check_no_previous_RR(mut_block_ptr + mutation_indices[mut_index], mut_index); - return EidosValue_Object_vector_SP(vec); + return EidosValue_Object_SP(vec); } // ********************* + (o)readFromVCF(s$ filePath = NULL, [Nio mutationType = NULL]) @@ -3809,12 +3809,12 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromVCF(EidosGlobalStringID p_meth // Return the instantiated mutations Mutation *mut_block_ptr = gSLiM_Mutation_Block; int mutation_count = (int)mutation_indices.size(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); for (int mut_index = 0; mut_index < mutation_count; ++mut_index) vec->set_object_element_no_check_no_previous_RR(mut_block_ptr + mutation_indices[mut_index], mut_index); - return EidosValue_Object_vector_SP(vec); + return EidosValue_Object_SP(vec); } // ********************* + (void)removeMutations([No mutations = NULL], [logical$ substitute = F]) diff --git a/core/genomic_element.cpp b/core/genomic_element.cpp index 1f71055fd..17a84b8f6 100644 --- a/core/genomic_element.cpp +++ b/core/genomic_element.cpp @@ -58,7 +58,7 @@ std::ostream &operator<<(std::ostream &p_outstream, const GenomicElement &p_geno void GenomicElement::GenerateCachedEidosValue(void) { // Note that this cache cannot be invalidated as long as a symbol table might exist that this value has been placed into - self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_GenomicElement_Class)); + self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_GenomicElement_Class)); } const EidosClass *GenomicElement::Class(void) const @@ -149,7 +149,7 @@ EidosValue *GenomicElement::GetProperty_Accelerated_tag(EidosObject **p_values, EidosValue *GenomicElement::GetProperty_Accelerated_genomicElementType(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index 5c3d0d6a1..70857adae 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -36,7 +36,7 @@ #pragma mark - GenomicElementType::GenomicElementType(Species &p_species, slim_objectid_t p_genomic_element_type_id, std::vector p_mutation_type_ptrs, std::vector p_mutation_fractions) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('g', p_genomic_element_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_GenomicElementType_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('g', p_genomic_element_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_GenomicElementType_Class))), species_(p_species), genomic_element_type_id_(p_genomic_element_type_id), mutation_type_ptrs_(std::move(p_mutation_type_ptrs)), mutation_fractions_(std::move(p_mutation_fractions)), mutation_matrix_(nullptr) { // self_symbol_ is always a constant, but can't be marked as such on construction @@ -259,7 +259,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) } case gID_mutationTypes: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto mut_type : mutation_type_ptrs_) @@ -279,7 +279,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) } case gID_species: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(&species_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(&species_, gSLiM_Species_Class)); } // variables diff --git a/core/individual.cpp b/core/individual.cpp index d0223c673..544cd387b 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -313,7 +313,7 @@ int Individual::SharedParentCountWithIndividual(Individual &p_ind) void Individual::GenerateCachedEidosValue(void) { // Note that this cache cannot be invalidated as long as a symbol table might exist that this value has been placed into - self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Individual_Class)); + self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Individual_Class)); } const EidosClass *Individual::Class(void) const @@ -340,7 +340,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (killed_) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property subpopulation is not available for individuals that have been killed; they have no subpopulation." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(subpopulation_, gSLiM_Subpopulation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(subpopulation_, gSLiM_Subpopulation_Class)); } case gID_index: // ACCELERATED { @@ -348,7 +348,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) } case gID_genomes: { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(2); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(2); vec->set_object_element_no_check_NORR(genome1_, 0); vec->set_object_element_no_check_NORR(genome2_, 1); @@ -363,17 +363,17 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (genome1null) { if (genome2null) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome2_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome2_, gSLiM_Genome_Class)); } else { if (genome2null) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome1_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome1_, gSLiM_Genome_Class)); else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(2); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(2); vec->set_object_element_no_check_NORR(genome1_, 0); vec->set_object_element_no_check_NORR(genome2_, 1); @@ -384,11 +384,11 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) } case gID_genome1: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome1_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome1_, gSLiM_Genome_Class)); } case gID_genome2: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome2_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome2_, gSLiM_Genome_Class)); } case gID_sex: { @@ -496,7 +496,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) // We reserve a vector large enough to hold all the mutations from both genomes; probably usually overkill, but it does little harm int genome1_size = (genome1_->IsNull() ? 0 : genome1_->mutation_count()); int genome2_size = (genome2_->IsNull() ? 0 : genome2_->mutation_count()); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); EidosValue_SP result_SP = EidosValue_SP(vec); if ((genome1_size == 0) && (genome2_size == 0)) @@ -1069,7 +1069,7 @@ EidosValue *Individual::GetProperty_Accelerated_spatialPosition(EidosObject **p_ EidosValue *Individual::GetProperty_Accelerated_subpopulation(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1086,7 +1086,7 @@ EidosValue *Individual::GetProperty_Accelerated_subpopulation(EidosObject **p_va EidosValue *Individual::GetProperty_Accelerated_genome1(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1100,7 +1100,7 @@ EidosValue *Individual::GetProperty_Accelerated_genome1(EidosObject **p_values, EidosValue *Individual::GetProperty_Accelerated_genome2(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1977,7 +1977,7 @@ EidosValue_SP Individual::ExecuteMethod_uniqueMutationsOfType(EidosGlobalStringI // We try to reserve a vector large enough to hold all the mutations; probably usually overkill, but it does little harm int genome1_size = (genome1_->IsNull() ? 0 : genome1_->mutation_count()); int genome2_size = (genome2_->IsNull() ? 0 : genome2_->mutation_count()); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); EidosValue_SP result_SP = EidosValue_SP(vec); if ((genome1_size == 0) && (genome2_size == 0)) diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 87b023e2e..c0e026585 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -76,7 +76,7 @@ void InteractionType::_WarmUp(void) InteractionType::InteractionType(Community &p_community, slim_objectid_t p_interaction_type_id, std::string p_spatiality_string, bool p_reciprocal, double p_max_distance, IndividualSex p_receiver_sex, IndividualSex p_exerter_sex) : self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('i', p_interaction_type_id)), - EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_InteractionType_Class))), + EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_InteractionType_Class))), spatiality_string_(std::move(p_spatiality_string)), reciprocal_(p_reciprocal), max_distance_(p_max_distance), max_distance_sq_(p_max_distance * p_max_distance), if_type_(SpatialKernelType::kFixed), if_param1_(1.0), if_param2_(0.0), community_(p_community), interaction_type_id_(p_interaction_type_id) { @@ -3219,7 +3219,7 @@ void InteractionType::FindNeighbors1_3(SLiM_kdNode *root, double *nd, slim_popsi } // find all neighbors in 1D -void InteractionType::FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals) +void InteractionType::FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals) { double d = dist_sq1(root, nd); #ifndef __clang_analyzer__ @@ -3255,7 +3255,7 @@ void InteractionType::FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsi } // find all neighbors in 2D -void InteractionType::FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase) +void InteractionType::FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase) { double d = dist_sq2(root, nd); #ifndef __clang_analyzer__ @@ -3293,7 +3293,7 @@ void InteractionType::FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsi } // find all neighbors in 3D -void InteractionType::FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase) +void InteractionType::FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase) { double d = dist_sq3(root, nd); #ifndef __clang_analyzer__ @@ -3335,7 +3335,7 @@ void InteractionType::FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsi // They were not thread-safe, and were replaced by FillSparseVectorForReceiverDistances_ALL_NEIGHBORS(); // now (11/2/2023) that has turned into FillSparseVectorForReceiverDistances() using kd_root_ALL_, below. -void InteractionType::FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object_vector &p_result_vec, Individual *p_excluded_individual, bool constraints_active) +void InteractionType::FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object &p_result_vec, Individual *p_excluded_individual, bool constraints_active) { // If this method is passed kd_root_ALL_, from EnsureKDTreePresent_ALL(), it finds all neighbors, regardless // of exerter constraints. If it is passed kd_root_EXERTERS_, from EnsureKDTreePresent_EXERTERS(), it finds @@ -4218,7 +4218,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID { // With no receivers, return an empty Dictionary EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->ContentsChanged("InteractionType::ExecuteMethod_drawByStrength()"); @@ -4258,7 +4258,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID { // This is the single-threaded, single-receiver case; it returns a vector of Individual objects if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); @@ -4269,7 +4269,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID // Check constraints for the receiver; if the individual is disqualified, no draws can occur and the return is empty if (!CheckIndividualConstraints(receiver, receiver_constraints_)) // potentially raises - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (spatiality_ == 0) { @@ -4279,7 +4279,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID slim_popsize_t receiver_index = ((exerter_subpop == receiver->subpopulation_) && (receiver->index_ >= 0) ? receiver->index_ : -1); std::vector &callbacks = exerter_subpop_data.evaluation_interaction_callbacks_; - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); double total_interaction_strength = 0.0; std::vector cached_strength; std::vector &exerters = exerter_subpop->parent_individuals_; @@ -4320,7 +4320,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receiver_subpop); double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; SLiM_kdNode *kd_root_EXERTERS = EnsureKDTreePresent_EXERTERS(exerter_subpop, exerter_subpop_data); - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); SparseVector *sv = nullptr; // If there are no exerters satisfying constraints, short-circuit @@ -4422,13 +4422,13 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_drawByStrength): drawByStrength() supports returning a Dictionary of results, with returnDict=T, only in the spatial case." << EidosTerminate(); EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); int receivers_count = receiver_value->Count(); - EidosValue_Object_vector **result_vectors = (EidosValue_Object_vector **)malloc(receivers_count * sizeof(EidosValue_Object_vector *)); + EidosValue_Object **result_vectors = (EidosValue_Object **)malloc(receivers_count * sizeof(EidosValue_Object *)); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - EidosValue_Object_vector *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class); + EidosValue_Object *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class); dictionary->SetKeyValue_IntegerKeys(receiver_index, EidosValue_SP(empty_individuals_vec)); result_vectors[receiver_index] = empty_individuals_vec; @@ -4484,7 +4484,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; - EidosValue_Object_vector *result_vec = result_vectors[receiver_index]; + EidosValue_Object *result_vec = result_vectors[receiver_index]; SparseVector *sv = nullptr; if (optimize_fixed_interaction_strengths) @@ -5144,7 +5144,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl { // With no receivers, return an empty Dictionary EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->ContentsChanged("InteractionType::ExecuteMethod_nearestInteractingNeighbors()"); @@ -5184,7 +5184,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl { // This is the single-threaded, single-receiver case; it returns a vector of Individual objects if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); @@ -5195,14 +5195,14 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl // Check constraints for the receiver; if the individual is disqualified, there are no interacting neighbors if (!CheckIndividualConstraints(receiver, receiver_constraints_)) // potentially raises - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // Find the neighbors double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; InteractionsData &exerter_subpop_data = InteractionsDataForSubpop(data_, exerter_subpop); SLiM_kdNode *kd_root_EXERTERS = EnsureKDTreePresent_EXERTERS(exerter_subpop, exerter_subpop_data); - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5216,13 +5216,13 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl // This is the multi-threaded, multi-receiver case; it returns a Dictionary object vectors of Individual objects // We start by making a Dictionary with an empty Individual vector for each receiver EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); int receivers_count = receiver_value->Count(); - EidosValue_Object_vector **result_vectors = (EidosValue_Object_vector **)malloc(receivers_count * sizeof(EidosValue_Object_vector *)); + EidosValue_Object **result_vectors = (EidosValue_Object **)malloc(receivers_count * sizeof(EidosValue_Object *)); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - EidosValue_Object_vector *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class); + EidosValue_Object *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class); dictionary->SetKeyValue_IntegerKeys(receiver_index, EidosValue_SP(empty_individuals_vec)); result_vectors[receiver_index] = empty_individuals_vec; @@ -5272,7 +5272,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; - EidosValue_Object_vector *result_vec = result_vectors[receiver_index]; + EidosValue_Object *result_vec = result_vectors[receiver_index]; if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5337,7 +5337,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI { // With no receivers, return an empty Dictionary EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->ContentsChanged("InteractionType::ExecuteMethod_nearestNeighbors()"); @@ -5377,7 +5377,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI { // This is the single-threaded, single-receiver case; it returns a vector of Individual objects if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); @@ -5391,7 +5391,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI InteractionsData &exerter_subpop_data = InteractionsDataForSubpop(data_, exerter_subpop); SLiM_kdNode *kd_root_ALL = EnsureKDTreePresent_ALL(exerter_subpop, exerter_subpop_data); - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5405,13 +5405,13 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI // This is the multi-threaded, multi-receiver case; it returns a Dictionary object vectors of Individual objects // We start by making a Dictionary with an empty Individual vector for each receiver EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); int receivers_count = receiver_value->Count(); - EidosValue_Object_vector **result_vectors = (EidosValue_Object_vector **)malloc(receivers_count * sizeof(EidosValue_Object_vector *)); + EidosValue_Object **result_vectors = (EidosValue_Object **)malloc(receivers_count * sizeof(EidosValue_Object *)); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - EidosValue_Object_vector *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class); + EidosValue_Object *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class); dictionary->SetKeyValue_IntegerKeys(receiver_index, EidosValue_SP(empty_individuals_vec)); result_vectors[receiver_index] = empty_individuals_vec; @@ -5451,7 +5451,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; - EidosValue_Object_vector *result_vec = result_vectors[receiver_index]; + EidosValue_Object *result_vec = result_vectors[receiver_index]; if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5512,10 +5512,10 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighborsOfPoint(EidosGlobal count = exerter_subpop_data.kd_node_count_ALL_; if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // Find the neighbors - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -6142,7 +6142,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID else { if (returnIndividuals) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); else return gStaticEidosValue_LogicalF; } @@ -6154,7 +6154,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID if (returnIndividuals) { - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); for (int index = 0; index < individuals_count; ++index) { diff --git a/core/interaction_type.h b/core/interaction_type.h index 9050ab31c..1c5f51af0 100644 --- a/core/interaction_type.h +++ b/core/interaction_type.h @@ -280,13 +280,13 @@ class InteractionType : public EidosDictionaryUnretained void FindNeighbors1_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, SLiM_kdNode **best, double *best_dist); void FindNeighbors1_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, SLiM_kdNode **best, double *best_dist, int p_phase); void FindNeighbors1_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, SLiM_kdNode **best, double *best_dist, int p_phase); - void FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals); - void FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase); - void FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase); + void FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals); + void FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase); + void FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase); void FindNeighborsN_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, int p_count, SLiM_kdNode **best, double *best_dist); void FindNeighborsN_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, int p_count, SLiM_kdNode **best, double *best_dist, int p_phase); void FindNeighborsN_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, int p_count, SLiM_kdNode **best, double *best_dist, int p_phase); - void FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object_vector &p_result_vec, Individual *p_excluded_individual, bool constraints_active); + void FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object &p_result_vec, Individual *p_excluded_individual, bool constraints_active); // this is a malloced 1D/2D/3D buffer, depending on our spatiality, that contains clipped integral values // for distances, for a focal individual, from 0 to max_distance_ to the nearest edge in each dimension diff --git a/core/mutation.cpp b/core/mutation.cpp index 0a8572366..f7dbd90d6 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -593,7 +593,7 @@ EidosValue *Mutation::GetProperty_Accelerated_selectionCoeff(EidosObject **p_val EidosValue *Mutation::GetProperty_Accelerated_mutationType(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index df2cf8064..20d46caed 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -60,7 +60,7 @@ MutationType::MutationType(Species &p_species, slim_objectid_t p_mutation_type_i #else MutationType::MutationType(Species &p_species, slim_objectid_t p_mutation_type_id, double p_dominance_coeff, bool p_nuc_based, DFEType p_dfe_type, std::vector p_dfe_parameters, std::vector p_dfe_strings) : #endif -self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('m', p_mutation_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_MutationType_Class))), +self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('m', p_mutation_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_MutationType_Class))), species_(p_species), mutation_type_id_(p_mutation_type_id), dominance_coeff_(static_cast(p_dominance_coeff)), haploid_dominance_coeff_(1.0), dfe_type_(p_dfe_type), dfe_parameters_(std::move(p_dfe_parameters)), dfe_strings_(std::move(p_dfe_strings)), nucleotide_based_(p_nuc_based), convert_to_substitution_(false), stack_policy_(MutationStackPolicy::kStack), stack_group_(p_mutation_type_id), cached_dfe_script_(nullptr) #ifdef SLIM_KEEP_MUTTYPE_REGISTRIES , muttype_registry_call_count_(0), keeping_muttype_registry_(false) @@ -469,7 +469,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) } case gID_species: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(&species_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(&species_, gSLiM_Species_Class)); } // variables diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 39a0c675e..789cd82cb 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -784,8 +784,8 @@ SLiMEidosBlockType SLiMEidosBlock::BlockTypeForRootNode(EidosASTNode *p_root_nod } SLiMEidosBlock::SLiMEidosBlock(EidosASTNode *p_root_node) : - self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), - script_block_symbol_(gEidosID_none, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), + self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), + script_block_symbol_(gEidosID_none, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), root_node_(p_root_node), user_script_line_offset_(p_root_node->token_->token_line_) { // self_symbol_ is always a constant, but can't be marked as such on construction @@ -1118,8 +1118,8 @@ SLiMEidosBlock::SLiMEidosBlock(EidosASTNode *p_root_node) : } SLiMEidosBlock::SLiMEidosBlock(slim_objectid_t p_id, const std::string &p_script_string, int32_t p_user_script_line_offset, SLiMEidosBlockType p_type, slim_tick_t p_start, slim_tick_t p_end, Species *p_species_spec, Species *p_ticks_spec) : - self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), - script_block_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('s', p_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), + self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), + script_block_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('s', p_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), type_(p_type), block_id_(p_id), start_tick_(p_start), end_tick_(p_end), species_spec_(p_species_spec), ticks_spec_(p_ticks_spec), user_script_line_offset_(p_user_script_line_offset) { // self_symbol_ is always a constant, but can't be marked as such on construction @@ -1487,17 +1487,17 @@ EidosValue_SP SLiMEidosBlock::GetProperty(EidosGlobalStringID p_property_id) { // With no species spec, we return an empty object vector of class Species; this is allowed since this is a read-only property if (species_spec_) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(species_spec_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(species_spec_, gSLiM_Species_Class)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class)); } case gID_ticksSpec: { // With no ticks spec, we return an empty object vector of class Species; this is allowed since this is a read-only property if (ticks_spec_) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(ticks_spec_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(ticks_spec_, gSLiM_Species_Class)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class)); } // variables diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index 4317c500b..5f73f629b 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -1415,7 +1415,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectordata(); + individuals_buffer = (Individual **)((EidosValue_Object *)individuals_value)->data(); } // This very weird code tests that the layout of ivars inside Individual is what we expect it to be below @@ -1663,7 +1663,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorAllocateChunk()) EidosValue_Object_vector(gEidosDictionaryRetained_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosDictionaryRetained_Class)); } std::string metadata_schema_string(temp_tables.metadata_schema, temp_tables.metadata_schema_length); @@ -1894,7 +1894,7 @@ EidosValue_SP SLiM_ExecuteFunction_treeSeqMetadata(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); objectElement->AddJSONFrom(metadata); objectElement->ContentsChanged("treeSeqMetadata()"); diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index e7e71b2ad..07f11cd02 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -1224,7 +1224,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_add(EidosGlobalStringID p_method_id, con _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)blend(ifo x, float$ xFraction) @@ -1275,7 +1275,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_blend(EidosGlobalStringID p_method_id, c _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)multiply(ifo x) @@ -1319,7 +1319,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_multiply(EidosGlobalStringID p_method_id _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)subtract(ifo x) @@ -1363,7 +1363,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_subtract(EidosGlobalStringID p_method_id _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)divide(ifo x) @@ -1407,7 +1407,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_divide(EidosGlobalStringID p_method_id, _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)power(ifo x) @@ -1451,7 +1451,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_power(EidosGlobalStringID p_method_id, c _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)exp(void) @@ -1465,7 +1465,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_exp(EidosGlobalStringID p_method_id, con _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (void)changeColors([Nif valueRange = NULL], [Ns color = NULL]) @@ -1842,7 +1842,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_interpolate(EidosGlobalStringID p_method } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (string)mapColor(numeric value) @@ -1977,7 +1977,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapImage(EidosGlobalStringID p_method_id } } - EidosValue_SP result_SP(EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(image, gEidosImage_Class))); + EidosValue_SP result_SP(EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(image, gEidosImage_Class))); // image is now retained by result_SP, so we can release it image->Release(); @@ -2111,7 +2111,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_rescale(EidosGlobalStringID p_method_id, _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (float)sampleImprovedNearbyPoint(float point, float$ maxDistance, string$ functionType, ...) @@ -2595,7 +2595,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_smooth(EidosGlobalStringID p_method_id, _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } @@ -2616,7 +2616,7 @@ EidosValue_SP SpatialMap::_DeriveTemporarySpatialMapWithEidosValue(EidosValue *p // make a duplicate of this SpatialMap SpatialMap *objectElement = new SpatialMap("__tempmap__INTERNAL__", *this); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gSLiM_SpatialMap_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gSLiM_SpatialMap_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -2639,7 +2639,7 @@ static EidosValue_SP SLiM_Instantiate_SpatialMap(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr); SpatialMap *objectElement = new SpatialMap(name, *map); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gSLiM_SpatialMap_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gSLiM_SpatialMap_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); diff --git a/core/species.cpp b/core/species.cpp index 810729dbd..b94f77224 100644 --- a/core/species.cpp +++ b/core/species.cpp @@ -100,7 +100,7 @@ static const char *SLIM_TREES_FILE_VERSION = "0.8"; // SLiM 4.0.x onward, wit #pragma mark - Species::Species(Community &p_community, slim_objectid_t p_species_id, const std::string &p_name) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(p_name), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Species_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(p_name), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Species_Class))), x_experiments_enabled_(false), model_type_(p_community.model_type_), community_(p_community), population_(*this), name_(p_name), species_id_(p_species_id) { // self_symbol_ is always a constant, but can't be marked as such on construction diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index 24799b9f6..a753c2f90 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -212,7 +212,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGenomicElement(const std GenomicElementType *genomic_element_type_ptr_0 = ((type_count == 1) ? SLiM_ExtractGenomicElementTypeFromEidosValue_io(genomicElementType_value, 0, &community_, this, "initializeGenomicElement()") : nullptr); // SPECIES CONSISTENCY CHECK GenomicElementType *genomic_element_type_ptr = nullptr; slim_position_t start_position = 0, end_position = 0; - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElement_Class))->resize_no_initialize(element_count); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElement_Class))->resize_no_initialize(element_count); for (int element_index = 0; element_index < element_count; ++element_index) { @@ -1461,7 +1461,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(avatar_)); } case gID_chromosome: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(chromosome_, gSLiM_Chromosome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(chromosome_, gSLiM_Chromosome_Class)); case gID_chromosomeType: { switch (modeled_chromosome_type_) @@ -1540,7 +1540,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_genomicElementTypes: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto ge_type : genomic_element_types_) @@ -1553,7 +1553,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) Mutation *mut_block_ptr = gSLiM_Mutation_Block; int registry_size; const MutationIndex *registry = population_.MutationRegistry(®istry_size); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(registry_size); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(registry_size); EidosValue_SP result_SP = EidosValue_SP(vec); for (int registry_index = 0; registry_index < registry_size; ++registry_index) @@ -1563,7 +1563,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_mutationTypes: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto mutation_type : mutation_types_) @@ -1581,7 +1581,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_scriptBlocks: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class); EidosValue_SP result_SP = EidosValue_SP(vec); const std::vector &script_blocks = community_.AllScriptBlocksForSpecies(this); // this will only be species-specific callbacks @@ -1594,7 +1594,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) return (sex_enabled_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gID_subpopulations: { - EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class); + EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class); EidosValue_SP result_SP = EidosValue_SP(vec); for (auto pop : population_.subpops_) @@ -1606,7 +1606,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) { std::vector &substitutions = population_.substitutions_; int substitution_count = (int)substitutions.size(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Substitution_Class))->resize_no_initialize_RR(substitution_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Substitution_Class))->resize_no_initialize_RR(substitution_count); EidosValue_SP result_SP = EidosValue_SP(vec); for (int sub_index = 0; sub_index < substitution_count; ++sub_index) @@ -1853,7 +1853,7 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin int pedigreeIDs_count = pedigreeIDs_value->Count(); if (pedigreeIDs_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // Assemble the result if (pedigreeIDs_count == 1) @@ -1868,18 +1868,18 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin for (Individual *ind : inds) { if (ind->PedigreeID() == pedigree_id) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(ind, gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(ind, gSLiM_Individual_Class)); } } // Didn't find a match, so return an empty result - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); } else { // Non-singleton case: vectorized access to the pedigree IDs const int64_t *pedigree_id_data = pedigreeIDs_value->IntData(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(pedigreeIDs_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(pedigreeIDs_count); // reserve enough space for all results if (pedigreeIDs_count < 30) // crossover point determined by timing tests on macOS with various subpop sizes; 30 seems good, although it will vary across paltforms etc. { @@ -2234,11 +2234,11 @@ EidosValue_SP Species::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_metho if (mutation_count == 1) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(mut_block_ptr + mutation_registry[0], gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(mut_block_ptr + mutation_registry[0], gSLiM_Mutation_Class)); } else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); EidosValue_SP result_SP = EidosValue_SP(vec); for (int mut_index = 0; mut_index < mutation_count; ++mut_index) @@ -2271,11 +2271,11 @@ EidosValue_SP Species::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_metho // Now allocate the result vector and assemble it if (match_count == 1) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(mut_block_ptr + first_match, gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(mut_block_ptr + first_match, gSLiM_Mutation_Class)); } else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(match_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(match_count); EidosValue_SP result_SP = EidosValue_SP(vec); if (match_count != 0) @@ -3116,7 +3116,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho const MutationIndex *registry = population_.MutationRegistry(®istry_size); int match_count = 0, registry_index; Mutation *first_match = nullptr; - EidosValue_Object_vector *vec = nullptr; + EidosValue_Object *vec = nullptr; if (has_id && !exclude && !mutation_type_ptr && (position == -1) && (nucleotide == -1) && !has_tag) { @@ -3136,7 +3136,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (match_count == 2) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); vec->push_object_element_RR(first_match); vec->push_object_element_RR(mut); } @@ -3165,7 +3165,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (match_count == 2) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); vec->push_object_element_RR(first_match); vec->push_object_element_RR(mut); } @@ -3197,7 +3197,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (match_count == 2) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); vec->push_object_element_RR(first_match); vec->push_object_element_RR(mut); } @@ -3209,9 +3209,9 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } if (match_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); else if (match_count == 1) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(first_match, gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(first_match, gSLiM_Mutation_Class)); else return EidosValue_SP(vec); } diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 13bcf5e1b..338a1960f 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -834,7 +834,7 @@ void Subpopulation::CheckIndividualIntegrity(void) } Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopulation_id, slim_popsize_t p_subpop_size, bool p_record_in_treeseq, bool p_haploid) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Subpopulation_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Subpopulation_Class))), community_(p_population.species_.community_), species_(p_population.species_), population_(p_population), model_type_(p_population.model_type_), subpopulation_id_(p_subpopulation_id), name_(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), genome_pool_(p_population.species_genome_pool_), individual_pool_(p_population.species_individual_pool_), genome_junkyard_nonnull(p_population.species_genome_junkyard_nonnull), genome_junkyard_null(p_population.species_genome_junkyard_null), parent_subpop_size_(p_subpop_size), child_subpop_size_(p_subpop_size) #if defined(SLIMGUI) @@ -876,7 +876,7 @@ Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopu // SEX ONLY Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopulation_id, slim_popsize_t p_subpop_size, bool p_record_in_treeseq, double p_sex_ratio, GenomeType p_modeled_chromosome_type, bool p_haploid) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Subpopulation_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Subpopulation_Class))), community_(p_population.species_.community_), species_(p_population.species_), population_(p_population), model_type_(p_population.model_type_), subpopulation_id_(p_subpopulation_id), name_(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), genome_pool_(p_population.species_genome_pool_), individual_pool_(p_population.species_individual_pool_), genome_junkyard_nonnull(p_population.species_genome_junkyard_nonnull), genome_junkyard_null(p_population.species_genome_junkyard_null), parent_subpop_size_(p_subpop_size), parent_sex_ratio_(p_sex_ratio), child_subpop_size_(p_subpop_size), child_sex_ratio_(p_sex_ratio), sex_enabled_(true), modeled_chromosome_type_(p_modeled_chromosome_type) @@ -2200,7 +2200,7 @@ double Subpopulation::ApplyMutationEffectCallbacks(MutationIndex p_mutation, int else { // local variables for the callback parameters that we might need to allocate here, and thus need to free below - EidosValue_Object_singleton local_mut(gSLiM_Mutation_Block + p_mutation, gSLiM_Mutation_Class); + EidosValue_Object local_mut(gSLiM_Mutation_Block + p_mutation, gSLiM_Mutation_Class); EidosValue_Float local_effect(p_computed_fitness); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table @@ -3893,7 +3893,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) { if (!cached_child_genomes_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(child_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(child_genomes_.size()); cached_child_genomes_value_ = EidosValue_SP(vec); for (auto genome_iter : child_genomes_) @@ -3923,7 +3923,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) { if (!cached_parent_genomes_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); cached_parent_genomes_value_ = EidosValue_SP(vec); for (auto genome_iter : parent_genomes_) @@ -3954,7 +3954,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) { if (child_generation_valid_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(child_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(child_genomes_.size()); for (auto genome_iter : child_genomes_) if (!genome_iter->IsNull()) @@ -3964,7 +3964,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) } else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); for (auto genome_iter : parent_genomes_) if (!genome_iter->IsNull()) @@ -3983,10 +3983,10 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (cached_child_individuals_value_ && (cached_child_individuals_value_->Count() != subpop_size)) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): (internal error) cached_child_individuals_value_ out of date." << EidosTerminate(); - // Build and return an EidosValue_Object_vector with the current set of individuals in it + // Build and return an EidosValue_Object with the current set of individuals in it if (!cached_child_individuals_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(subpop_size); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(subpop_size); cached_child_individuals_value_ = EidosValue_SP(vec); for (slim_popsize_t individual_index = 0; individual_index < subpop_size; individual_index++) @@ -4003,10 +4003,10 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (cached_parent_individuals_value_ && (cached_parent_individuals_value_->Count() != subpop_size)) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): (internal error) cached_parent_individuals_value_ out of date." << EidosTerminate(); - // Build and return an EidosValue_Object_vector with the current set of individuals in it + // Build and return an EidosValue_Object with the current set of individuals in it if (!cached_parent_individuals_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(subpop_size); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(subpop_size); cached_parent_individuals_value_ = EidosValue_SP(vec); for (slim_popsize_t individual_index = 0; individual_index < subpop_size; individual_index++) @@ -4139,7 +4139,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) } case gID_spatialMaps: { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SpatialMap_Class))->reserve(spatial_maps_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SpatialMap_Class))->reserve(spatial_maps_.size()); for (const auto &spatialMapIter : spatial_maps_) vec->push_object_element_no_check_RR(spatialMapIter.second); @@ -4148,7 +4148,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) } case gID_species: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(&species_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(&species_, gSLiM_Species_Class)); } case gID_individualCount: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(CurrentSubpopSize())); @@ -4493,7 +4493,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCloned(EidosGlobalStringID p_metho if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCloned): addCloned() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -4643,7 +4643,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCrossed(EidosGlobalStringID p_meth if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCrossed): addCrossed() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -4776,7 +4776,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addEmpty(EidosGlobalStringID p_method if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addEmpty): addEmpty() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -4932,7 +4932,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addRecombinant): addRecombinant() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -5519,7 +5519,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addSelfed(EidosGlobalStringID p_metho if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addSelfed): addSelfed() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -7076,7 +7076,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID if (sample_size < 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_sampleIndividuals): sampleIndividuals() requires a sample size >= 0 (" << sample_size << " supplied)." << EidosTerminate(nullptr); if ((sample_size == 0) || (x_count == 0)) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // a specific individual may be excluded EidosValue *exclude_value = p_arguments[2].get(); @@ -7185,7 +7185,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID { // we're in the simple case of no specifed tag/ageMin/ageMax/migrant/tagL, so maybe we can handle it quickly if (candidate_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); else if (!replace && (candidate_count < sample_size)) sample_size = candidate_count; @@ -7198,13 +7198,13 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID if ((excluded_index != -1) && (sample_index >= excluded_index)) sample_index++; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(parent_individuals_[sample_index], gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(parent_individuals_[sample_index], gSLiM_Individual_Class)); } else if (replace) { // with replacement, we can just do a series of independent draws - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get())->resize_no_initialize(sample_size); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get())->resize_no_initialize(sample_size); EidosObject **object_result_data = result->data(); EIDOS_THREAD_COUNT(gEidos_OMP_threads_SAMPLE_INDIVIDUALS_1); @@ -7241,8 +7241,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID { // a sample size of two without replacement is expected to be common (interacting pairs) so optimize for it // note that the code above guarantees that here there are at least two candidates to draw - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get())->resize_no_initialize(sample_size); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get())->resize_no_initialize(sample_size); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); int sample_index1 = (int)Eidos_rng_uniform_int(rng, candidate_count) + first_candidate_index; @@ -7346,7 +7346,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(parent_individuals_[sample_index], gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(parent_individuals_[sample_index], gSLiM_Individual_Class)); } } @@ -7455,13 +7455,13 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID } if (candidate_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); else if (!replace && (candidate_count < sample_size)) sample_size = candidate_count; // do the sampling - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get())->resize_no_initialize(sample_size); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get())->resize_no_initialize(sample_size); EidosObject **object_result_data = result->data(); if (replace) @@ -7528,7 +7528,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID int x_count = parent_subpop_size_; if (x_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // a specific individual may be excluded EidosValue *exclude_value = p_arguments[0].get(); @@ -7633,8 +7633,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID else excluded_index = -1; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get()); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get()); if (!tag_specified && !ageMin_specified && !ageMax_specified && !migrant_specified && !any_tagL_specified) { @@ -7771,7 +7771,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_defineSpatialMap(EidosGlobalStringID spatial_maps_.emplace(map_name, spatial_map); // already retained by new SpatialMap(); that is the retain for spatial_maps_ - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(spatial_map, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(spatial_map, gSLiM_SpatialMap_Class)); } // ********************* – (void)addSpatialMap(object$ map) diff --git a/core/subpopulation.h b/core/subpopulation.h index 14ac27559..0d3f2c784 100644 --- a/core/subpopulation.h +++ b/core/subpopulation.h @@ -377,7 +377,7 @@ class Subpopulation : public EidosDictionaryUnretained void ViabilitySurvival(std::vector &p_survival_callbacks); void IncrementIndividualAges(void); IndividualSex _GenomeConfigurationForSex(EidosValue *p_sex_value, GenomeType &p_genome1_type, GenomeType &p_genome2_type, bool &p_genome1_null, bool &p_genome2_null); - inline __attribute__((always_inline)) void _ProcessNewOffspring(bool p_proposed_child_accepted, Individual *p_individual, Genome *p_genome1, Genome *p_genome2, EidosValue_Object_vector *p_result) + inline __attribute__((always_inline)) void _ProcessNewOffspring(bool p_proposed_child_accepted, Individual *p_individual, Genome *p_genome1, Genome *p_genome2, EidosValue_Object *p_result) { if (p_proposed_child_accepted) { diff --git a/core/substitution.cpp b/core/substitution.cpp index 2cc0b5e2d..1dbfe9cbe 100644 --- a/core/substitution.cpp +++ b/core/substitution.cpp @@ -290,7 +290,7 @@ EidosValue *Substitution::GetProperty_Accelerated_selectionCoeff(EidosObject **p EidosValue *Substitution::GetProperty_Accelerated_mutationType(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/eidos/eidos_class_DataFrame.cpp b/eidos/eidos_class_DataFrame.cpp index 3d88ff382..2dafc6a82 100644 --- a/eidos/eidos_class_DataFrame.cpp +++ b/eidos/eidos_class_DataFrame.cpp @@ -634,7 +634,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subset(EidosGlobalStringID p_method_ else { // Note that this retains cols_subset, before the call to Release below - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(cols_subset, gEidosDataFrame_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(cols_subset, gEidosDataFrame_Class)); } rows_subset->Release(); @@ -658,7 +658,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subsetColumns(EidosGlobalStringID p_ EidosDataFrame *objectElement = SubsetColumns(index_value); objectElement->ContentsChanged("subsetColumns()"); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -678,7 +678,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subsetRows(EidosGlobalStringID p_met EidosDataFrame *objectElement = SubsetRows(index_value, drop_value->LogicalAtIndex_NOCAST(0, nullptr)); objectElement->ContentsChanged("subsetRows()"); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -700,7 +700,7 @@ static EidosValue_SP Eidos_Instantiate_EidosDataFrame(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -1132,7 +1132,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); objectElement->Release(); // objectElement is now retained by result_SP, so we can release it diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index 87aef1218..b1079a3b9 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -862,7 +862,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) if (value.is_null()) { EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->Release(); // now retained by state_ptr->dictionary_symbols_ } else if (value.is_boolean()) @@ -889,7 +889,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) { EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); dictionary->AddJSONFrom(value); - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->Release(); // now retained by state_ptr->dictionary_symbols_ } else if (value.is_array()) @@ -975,7 +975,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) } else if (array_type == nlohmann::json::value_t::object) { - EidosValue_Object_vector *object_value = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosDictionaryRetained_Class); + EidosValue_Object *object_value = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosDictionaryRetained_Class); for (size_t element_index = 0; element_index < array_count; ++element_index) { @@ -1218,7 +1218,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_getRowValues(EidosGlobalS EidosValue_SP result_SP(nullptr); EidosDictionaryRetained *objectElement = new EidosDictionaryRetained(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); // With no columns, the indices don't matter, and the result is a new empty dictionary if (KeyCount() == 0) @@ -1648,7 +1648,7 @@ static EidosValue_SP Eidos_Instantiate_EidosDictionaryRetained(const std::vector EidosValue_SP result_SP(nullptr); EidosDictionaryRetained *objectElement = new EidosDictionaryRetained(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); diff --git a/eidos/eidos_class_Image.cpp b/eidos/eidos_class_Image.cpp index de6b5b9c0..b0dae9e11 100644 --- a/eidos/eidos_class_Image.cpp +++ b/eidos/eidos_class_Image.cpp @@ -366,7 +366,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosImage_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosImage_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); diff --git a/eidos/eidos_class_TestElement.cpp b/eidos/eidos_class_TestElement.cpp index ce304172b..f2758a6dd 100644 --- a/eidos/eidos_class_TestElement.cpp +++ b/eidos/eidos_class_TestElement.cpp @@ -67,7 +67,7 @@ EidosValue_SP EidosTestElement::GetProperty(EidosGlobalStringID p_property_id) else if (p_property_id == gEidosID__increment) { EidosTestElement *inc_element = new EidosTestElement(yolk_ + 1); - EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(inc_element, gEidosTestElement_Class)); + EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(inc_element, gEidosTestElement_Class)); inc_element->Release(); // retval now owns it; release the retain from new return retval; @@ -153,7 +153,7 @@ EidosValue_SP EidosTestElement::ExecuteMethod_squareTest(EidosGlobalStringID p_m { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosTestElement *sq_element = new EidosTestElement(yolk_ * yolk_); - EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(sq_element, gEidosTestElement_Class)); + EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(sq_element, gEidosTestElement_Class)); sq_element->Release(); // retval now owns it; release the retain from new return retval; @@ -176,7 +176,7 @@ static EidosValue_SP Eidos_Instantiate_EidosTestElement(const std::vectorIntAtIndex_NOCAST(0, nullptr)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosTestElement_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosTestElement_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -319,7 +319,7 @@ static EidosValue_SP Eidos_Instantiate_EidosTestElementNRR(const std::vectorIntAtIndex_NOCAST(0, nullptr)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosTestElementNRR_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosTestElementNRR_Class)); // Note that since these are not under retain/release, and Eidos has no logic to keep track of them and release them, they just leak // This is probably what EidosTestElement::FreeThunks() used to do before EidosTestElement was put under retain/release, so that diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 5d9c81421..4b33f1ac0 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -729,8 +729,8 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (has_object_type) { - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(element_class))->resize_no_initialize_RR(reserve_size); - EidosValue_Object_vector_SP result_SP = EidosValue_Object_vector_SP(result); + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(element_class))->resize_no_initialize_RR(reserve_size); + EidosValue_Object_SP result_SP = EidosValue_Object_SP(result); int result_set_index = 0; for (int arg_index = 0; arg_index < argument_count; ++arg_index) @@ -971,7 +971,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { // We have x_count != 1, so the type of x_value must be EidosValue_Object_vector; we can use the fast API EidosObject * const *object_data = x_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); if (p_preserve_order) @@ -1115,8 +1115,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueObject) { EidosObject * const *first_child_vec = p_original_value->ObjectData(); - EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); - EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); + EidosValue_Object_SP obj_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)p_original_value)->Class())); + EidosValue_Object *obj_result = obj_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) if (logical_index_data[value_idx]) @@ -1197,8 +1197,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa { // result type is object; optimize for that EidosObject * const *first_child_vec = p_original_value->ObjectData(); - EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); - EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); + EidosValue_Object_SP obj_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)p_original_value)->Class())); + EidosValue_Object *obj_result = obj_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 568ddbd1b..283cece34 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -1170,7 +1170,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorNewMatchingType(); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); } } else if (x_count == 1) @@ -1222,7 +1222,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorNewMatchingType(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); } } else if (y_count == 1) @@ -1278,7 +1278,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr); - EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + EidosValue_Object *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1397,7 +1397,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectData(); EidosObject * const *object_vec1 = y_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1572,7 +1572,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); else result_SP = x_value->NewMatchingType(); } @@ -1750,7 +1750,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectData(); EidosObject * const *object_vec1 = y_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1941,7 +1941,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorNewMatchingType(); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); } } else if ((x_count == 1) || (y_count == 1)) @@ -2016,7 +2016,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr); - EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + EidosValue_Object *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); int value_index; @@ -2203,7 +2203,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectData(); EidosObject * const *object_vec1 = y_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); for (value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -2408,9 +2408,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); } } else if ((x_count == 1) || (y_count == 1)) @@ -2503,7 +2503,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (scan_index == result_count) { - EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + EidosValue_Object *object_element_vec = dynamic_cast(result_SP.get()); object_element_vec->push_object_element_CRR(value); } diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index e49f0869d..e8a3a8b28 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -397,7 +397,7 @@ EidosValue_SP Eidos_ExecuteFunction_cbind(const std::vector &p_ar case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; - case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; + case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(result_class))->reserve(result_length)); break; } EidosValue *result = result_SP.get(); @@ -915,7 +915,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbind(const std::vector &p_ar case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; - case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; + case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(result_class))->reserve(result_length)); break; } EidosValue *result = result_SP.get(); diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 784bd7a2b..0b8475ca5 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -725,7 +725,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelGetMaxThreads(__attribute__((unused) EidosValue_SP Eidos_ExecuteFunction_parallelGetTaskThreadCounts(__attribute__((unused)) const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosDictionaryRetained *objectElement = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); #ifdef _OPENMP objectElement->SetKeyValue_StringKeys("ABS_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_ABS_FLOAT))); diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 758c73b9e..b21c11313 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -505,7 +505,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a { EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); result_SP = EidosValue_SP(object_result); @@ -820,7 +820,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a { EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); result_SP = EidosValue_SP(object_result); @@ -1558,8 +1558,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a EidosObject * const *true_vec = trueValues_value->ObjectData(); EidosObject * const *false_vec = falseValues_value->ObjectData(); - EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); - EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); + EidosValue_Object_SP object_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(trueValues_class)); + EidosValue_Object *object_result = object_result_SP->resize_no_initialize_RR(test_count); if (object_result->UsesRetainRelease()) { @@ -1655,8 +1655,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a EidosObject *true_value = trueValues_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject *false_value = falseValues_value->ObjectElementAtIndex_NOCAST(0, nullptr); - EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); - EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); + EidosValue_Object_SP object_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(trueValues_class)); + EidosValue_Object *object_result = object_result_SP->resize_no_initialize_RR(test_count); if (object_result->UsesRetainRelease()) { @@ -2560,7 +2560,7 @@ EidosValue_SP Eidos_ExecuteFunction_sortBy(const std::vector &p_a EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()))->resize_no_initialize_RR(x_count); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()))->resize_no_initialize_RR(x_count); result_SP = EidosValue_SP(object_result); if (object_result->UsesRetainRelease()) diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index f39bcf6d7..049d09fbf 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1086,8 +1086,6 @@ void Eidos_WarmUp(void) maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_vector)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_singleton)); // std::cout << "sizeof(EidosValue) == " << sizeof(EidosValue) << std::endl; // std::cout << "sizeof(EidosValue_NULL) == " << sizeof(EidosValue_NULL) << std::endl; @@ -1098,8 +1096,6 @@ void Eidos_WarmUp(void) // std::cout << "sizeof(EidosValue_Int) == " << sizeof(EidosValue_Int) << std::endl; // std::cout << "sizeof(EidosValue_Float) == " << sizeof(EidosValue_Float) << std::endl; // std::cout << "sizeof(EidosValue_Object) == " << sizeof(EidosValue_Object) << std::endl; -// std::cout << "sizeof(EidosValue_Object_vector) == " << sizeof(EidosValue_Object_vector) << std::endl; -// std::cout << "sizeof(EidosValue_Object_singleton) == " << sizeof(EidosValue_Object_singleton) << std::endl; // std::cout << "maxEidosValueSize == " << maxEidosValueSize << std::endl; gEidosValuePool = new EidosObjectPool("EidosObjectPool(EidosValue)", maxEidosValueSize); @@ -1216,7 +1212,7 @@ void Eidos_WarmUp(void) // This has to be allocated after gEidosObject_Class has been initialized above; the other global permanents must be initialized // before that point, however, since properties and method signatures may use some of those global permanent values - gStaticEidosValue_Object_ZeroVec = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosObject_Class)); + gStaticEidosValue_Object_ZeroVec = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosObject_Class)); gStaticEidosValue_Object_ZeroVec->MarkAsConstant(); // Set up the built-in function map, which is immutable diff --git a/eidos/eidos_globals.h b/eidos/eidos_globals.h index 2e1b47511..f2a3b0939 100644 --- a/eidos/eidos_globals.h +++ b/eidos/eidos_globals.h @@ -1192,8 +1192,6 @@ class EidosValue_String; class EidosValue_String_singleton; class EidosValue_String_vector; class EidosValue_Object; -class EidosValue_Object_singleton; -class EidosValue_Object_vector; class EidosObjectPool; class EidosPropertySignature; @@ -1229,8 +1227,6 @@ typedef Eidos_intrusive_ptr EidosValue_String_SP; typedef Eidos_intrusive_ptr EidosValue_String_singleton_SP; typedef Eidos_intrusive_ptr EidosValue_String_vector_SP; typedef Eidos_intrusive_ptr EidosValue_Object_SP; -typedef Eidos_intrusive_ptr EidosValue_Object_singleton_SP; -typedef Eidos_intrusive_ptr EidosValue_Object_vector_SP; // EidosValueType is an enum of the possible types for EidosValue objects. Note that all of these types are vectors of the stated diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 8f0a1b619..04eb0375e 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -752,7 +752,7 @@ void EidosInterpreter::_AssignRValueToLValue(EidosValue_SP p_rvalue, const Eidos } case EidosValueType::kValueObject: { - EidosValue_Object_vector *base_object_vector = dynamic_cast(base_value.get()); + EidosValue_Object *base_object_vector = dynamic_cast(base_value.get()); if (base_object_vector) { @@ -773,7 +773,7 @@ void EidosInterpreter::_AssignRValueToLValue(EidosValue_SP p_rvalue, const Eidos { // true singleton case; we can't use set_object_element_no_check_CRR() to set the element // note (rvalue_count == 1) must be true here, so there is only one case to handle - EidosValue_Object_singleton *base_object_singleton = dynamic_cast(base_value.get()); + EidosValue_Object *base_object_singleton = dynamic_cast(base_value.get()); EidosObject *rvalue = p_rvalue->ObjectElementAtIndex_CAST(0, nullptr); base_object_singleton->set_object_element_no_check_CRR(rvalue, 0); @@ -5954,14 +5954,14 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) else if (range_type == EidosValueType::kValueObject) { EidosObject * const *range_vec = range_value->ObjectData(); - EidosValue_Object_singleton_SP index_value_SP = EidosValue_Object_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(nullptr, ((EidosValue_Object *)range_value.get())->Class())); - EidosValue_Object_singleton *index_value = index_value_SP.get(); + EidosValue_Object_SP index_value_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(nullptr, ((EidosValue_Object *)range_value.get())->Class())); + EidosValue_Object *index_value = index_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(identifier_name, index_value_SP); for (int range_index = 0; range_index < range_count; ++range_index) { - index_value->SetValue(range_vec[range_index]); + index_value->set_object_element_no_check_CRR(range_vec[range_index], 0); EidosASTNode *statement_node = p_node->children_[2]; diff --git a/eidos/eidos_test_functions_vector.cpp b/eidos/eidos_test_functions_vector.cpp index 1e7bac1c0..8f0434a30 100644 --- a/eidos/eidos_test_functions_vector.cpp +++ b/eidos/eidos_test_functions_vector.cpp @@ -67,9 +67,9 @@ void _RunFunctionVectorConstructionTests_a_through_r(void) EidosAssertScriptSuccess_I("c(object(), _Test(7))._yolk;", 7); EidosAssertScriptSuccess_I("c(_Test(7), object())._yolk;", 7); EidosAssertScriptSuccess("c(object(), object());", gStaticEidosValue_Object_ZeroVec); - //EidosAssertScriptSuccess("c(object(), object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); // should fail - EidosAssertScriptSuccess("c(object(), _Test(7)[F]);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); - EidosAssertScriptSuccess("c(_Test(7)[F], object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); + //EidosAssertScriptSuccess("c(object(), object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); // should fail + EidosAssertScriptSuccess("c(object(), _Test(7)[F]);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); + EidosAssertScriptSuccess("c(_Test(7)[F], object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); // float() EidosAssertScriptSuccess("float(0);", gStaticEidosValue_Float_ZeroVec); @@ -129,7 +129,7 @@ void _RunFunctionVectorConstructionTests_a_through_r(void) EidosAssertScriptSuccess("rep(3, 0);", gStaticEidosValue_Integer_ZeroVec); EidosAssertScriptSuccess("rep(3.5, 0);", gStaticEidosValue_Float_ZeroVec); EidosAssertScriptSuccess("rep('foo', 0);", gStaticEidosValue_String_ZeroVec); - EidosAssertScriptSuccess("rep(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); + EidosAssertScriptSuccess("rep(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); EidosAssertScriptSuccess_NULL("rep(NULL, 2);"); EidosAssertScriptSuccess_LV("rep(T, 2);", {true, true}); EidosAssertScriptSuccess_IV("rep(3, 2);", {3, 3}); @@ -161,7 +161,7 @@ void _RunFunctionVectorConstructionTests_a_through_r(void) EidosAssertScriptSuccess("repEach(3, 0);", gStaticEidosValue_Integer_ZeroVec); EidosAssertScriptSuccess("repEach(3.5, 0);", gStaticEidosValue_Float_ZeroVec); EidosAssertScriptSuccess("repEach('foo', 0);", gStaticEidosValue_String_ZeroVec); - EidosAssertScriptSuccess("repEach(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); + EidosAssertScriptSuccess("repEach(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); EidosAssertScriptSuccess_NULL("repEach(NULL, 2);"); EidosAssertScriptSuccess_LV("repEach(T, 2);", {true, true}); EidosAssertScriptSuccess_IV("repEach(3, 2);", {3, 3}); diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 5ee1203ee..cce2547f5 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1874,9 +1874,11 @@ void EidosValue_Float::erase_index(size_t p_index) // See comments on EidosValue_Object::EidosValue_Object() below. Note this is shared by all species. std::vector gEidosValue_Object_Mutation_Registry; -EidosValue_Object::EidosValue_Object(bool p_singleton, const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject, p_singleton), class_(p_class), - class_uses_retain_release_(p_class == gEidosObject_Class ? true : p_class->UsesRetainRelease()) +EidosValue_Object::EidosValue_Object(const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject, false), + class_(p_class), values_(&singleton_value_), count_(0), capacity_(1) { + class_uses_retain_release_ = (class_ == gEidosObject_Class ? true : class_->UsesRetainRelease()); + // BCH 7 May 2017: OK, so, this is a hack of breathtaking disgustingness. Here is the problem. In SLiM we // need to reallocate the block in which all Mutation objects live, which invalidates all their pointers. // SLiM can mostly handle that for itself, but there is a big problem when it comes to EidosValue_Object @@ -1904,110 +1906,24 @@ EidosValue_Object::EidosValue_Object(bool p_singleton, const EidosClass *p_class } } -EidosValue_Object::~EidosValue_Object(void) +EidosValue_Object::EidosValue_Object(EidosObject *p_element1, const EidosClass *p_class) : EidosValue_Object(p_class) { - // See comment on EidosValue_Object::EidosValue_Object() above - if (registered_for_patching_) - { - THREAD_SAFETY_IN_ACTIVE_PARALLEL("EidosValue_Object::~EidosValue_Object(): gEidosValue_Object_Mutation_Registry change"); - - auto erase_iter = std::find(gEidosValue_Object_Mutation_Registry.begin(), gEidosValue_Object_Mutation_Registry.end(), this); - - if (erase_iter != gEidosValue_Object_Mutation_Registry.end()) - gEidosValue_Object_Mutation_Registry.erase(erase_iter); - else - EIDOS_TERMINATION << "ERROR (EidosValue_Object::~EidosValue_Object): (internal error) unregistered EidosValue_Object of class Mutation." << EidosTerminate(nullptr); - - //std::cout << "popped Mutation EidosValue_Object, count == " << gEidosValue_Object_Mutation_Registry.size() << std::endl; - } -} - -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_vector::PatchPointersByAdding(std::uintptr_t p_pointer_difference) -{ - for (size_t i = 0; i < count_; ++i) - { - std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); - std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; - - values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) - } -} - -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_vector::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) -{ - for (size_t i = 0; i < count_; ++i) + // we want to allow nullptr as a momentary placeholder, although in general a value should exist + // this is a bit gross; I think it is only in EidosInterpreter::Evaluate_For(), which wants to + // set up the loop index variable and *then* put the first value into it; could probably be cleaned up. + if (p_element1) + push_object_element_CRR(p_element1); + else { - std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); - std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; + // this puts nullptr into singleton_value_, but does it following the standard procedure + if (count_ == capacity_) + expand(); - values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) + values_[count_++] = nullptr; } } -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_singleton::PatchPointersByAdding(std::uintptr_t p_pointer_difference) -{ - std::uintptr_t old_element_ptr = reinterpret_cast(value_); - std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; - - value_ = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) -} - -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_singleton::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) -{ - std::uintptr_t old_element_ptr = reinterpret_cast(value_); - std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; - - value_ = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) -} - -void EidosValue_Object::RaiseForClassMismatch(void) const -{ - EIDOS_TERMINATION << "ERROR (EidosValue_Object::RaiseForClassMismatch): the type of an object cannot be changed." << EidosTerminate(nullptr); -} - -const std::string &EidosValue_Object::ElementType(void) const -{ - return Class()->ClassName(); -} - -EidosValue_SP EidosValue_Object::NewMatchingType(void) const -{ - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(Class())); -} - -void EidosValue_Object::Sort(bool p_ascending) -{ -#pragma unused(p_ascending) - EIDOS_TERMINATION << "ERROR (EidosValue_Object::Sort): Sort() is not defined for type object." << EidosTerminate(nullptr); -} - -void EidosValue_Object::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const -{ - EidosObject *value = ObjectElementAtIndex_NOCAST(p_idx, nullptr); - - p_ostream << *value; -} - -nlohmann::json EidosValue_Object::JSONRepresentation(void) const -{ - nlohmann::json json_object = nlohmann::json::array(); // always write as an array, for consistency; makes automated parsing easier - int count = Count(); - - for (int i = 0; i < count; ++i) - json_object.emplace_back(ObjectElementAtIndex_NOCAST(i, nullptr)->JSONRepresentation()); - - return json_object; -} - - -// EidosValue_Object_vector -#pragma mark EidosValue_Object_vector - -EidosValue_Object_vector::EidosValue_Object_vector(const EidosValue_Object_vector &p_original) : EidosValue_Object(false, p_original.Class()) +EidosValue_Object::EidosValue_Object(const EidosValue_Object &p_original) : EidosValue_Object(p_original.Class()) { size_t count = p_original.Count(); EidosObject * const *values = p_original.data(); @@ -2026,7 +1942,7 @@ EidosValue_Object_vector::EidosValue_Object_vector(const EidosValue_Object_vecto } } -EidosValue_Object_vector::EidosValue_Object_vector(const std::vector &p_elementvec, const EidosClass *p_class) : EidosValue_Object(false, p_class) +EidosValue_Object::EidosValue_Object(const std::vector &p_elementvec, const EidosClass *p_class) : EidosValue_Object(p_class) { size_t count = p_elementvec.size(); EidosObject * const *values = p_elementvec.data(); @@ -2045,7 +1961,7 @@ EidosValue_Object_vector::EidosValue_Object_vector(const std::vector p_init_list, const EidosClass *p_class) : EidosValue_Object(false, p_class) +EidosValue_Object::EidosValue_Object(std::initializer_list p_init_list, const EidosClass *p_class) : EidosValue_Object(p_class) { reserve(p_init_list.size()); @@ -2061,7 +1977,7 @@ EidosValue_Object_vector::EidosValue_Object_vector(std::initializer_list(values_[i]); + std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; + + values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) + } +} + +// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments +void EidosValue_Object::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) +{ + for (size_t i = 0; i < count_; ++i) + { + std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); + std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; + + values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) + } +} + +void EidosValue_Object::RaiseForClassMismatch(void) const +{ + EIDOS_TERMINATION << "ERROR (EidosValue_Object::RaiseForClassMismatch): the type of an object cannot be changed." << EidosTerminate(nullptr); +} + +const std::string &EidosValue_Object::ElementType(void) const +{ + return Class()->ClassName(); +} + +EidosValue_SP EidosValue_Object::NewMatchingType(void) const +{ + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(Class())); +} + +void EidosValue_Object::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const +{ + EidosObject *value = ObjectElementAtIndex_NOCAST(p_idx, nullptr); + + p_ostream << *value; +} + +nlohmann::json EidosValue_Object::JSONRepresentation(void) const +{ + nlohmann::json json_object = nlohmann::json::array(); // always write as an array, for consistency; makes automated parsing easier + int count = Count(); + + for (int i = 0; i < count; ++i) + json_object.emplace_back(ObjectElementAtIndex_NOCAST(i, nullptr)->JSONRepresentation()); + + return json_object; } -EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue_Object::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue_Object::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const +EidosValue_SP EidosValue_Object::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(values_[p_idx], Class())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(values_[p_idx], Class())); } -EidosValue_SP EidosValue_Object_vector::CopyValues(void) const +EidosValue_SP EidosValue_Object::CopyValues(void) const { // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(*this))->CopyDimensionsFromValue(this)); + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(*this))->CopyDimensionsFromValue(this)); } -void EidosValue_Object_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) +EidosValue_SP EidosValue_Object::VectorBasedCopy(void) const +{ + // same as CopyValues() now; slated for removal + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(*this))->CopyDimensionsFromValue(this)); +} + +void EidosValue_Object::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); if (p_source_script_value.Type() == EidosValueType::kValueObject) push_object_element_CRR(p_source_script_value.ObjectElementAtIndex_NOCAST(p_idx, p_blame_token)); else - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); +} + +void EidosValue_Object::Sort(bool p_ascending) +{ +#pragma unused(p_ascending) + EIDOS_TERMINATION << "ERROR (EidosValue_Object::Sort): Sort() is not defined for type object." << EidosTerminate(nullptr); } static bool CompareLogicalObjectSortPairsAscending(std::pair i, std::pair j) { return (i.first < j.first); } @@ -2145,15 +2146,15 @@ static bool CompareFloatObjectSortPairsDescending(std::pair &i, const std::pair &j) { return (i.first < j.first); } static bool CompareStringObjectSortPairsDescending(const std::pair &i, const std::pair &j) { return (i.first > j.first); } -void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_ascending) +void EidosValue_Object::SortBy(const std::string &p_property, bool p_ascending) { WILL_MODIFY(this); // At present this is called only by the sortBy() Eidos function, so we do not need a // blame token; all errors will be attributed to that function automatically. - // length 0 is already sorted - if (count_ == 0) + // length 0 or 1 is already sorted + if (count_ <= 1) return; // figure out what type the property returns @@ -2167,7 +2168,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce case EidosValueType::kValueVOID: case EidosValueType::kValueNULL: case EidosValueType::kValueObject: - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " returned " << property_type << "; a property that evaluates to logical, int, float, or string is required." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " returned " << property_type << "; a property that evaluates to logical, int, float, or string is required." << EidosTerminate(nullptr); break; case EidosValueType::kValueLogical: @@ -2181,9 +2182,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->LogicalAtIndex_NOCAST(0, nullptr), value); } @@ -2214,9 +2215,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->IntAtIndex_NOCAST(0, nullptr), value); } @@ -2247,9 +2248,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->FloatAtIndex_NOCAST(0, nullptr), value); } @@ -2280,9 +2281,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->StringAtIndex_NOCAST(0, nullptr), value); } @@ -2304,13 +2305,13 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce } } -EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringID p_property_id) const +EidosValue_SP EidosValue_Object::GetPropertyOfElements(EidosGlobalStringID p_property_id) const { size_t values_size = count_; const EidosPropertySignature *signature = class_->SignatureForProperty(p_property_id); if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(nullptr); if (values_size == 0) { @@ -2333,18 +2334,16 @@ EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringI const EidosClass *value_class = signature->value_class_; if (value_class) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(value_class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(value_class)); else return gStaticEidosValue_Object_ZeroVec; } - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " does not specify an unambiguous value type, and thus cannot be accessed on a zero-length vector." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " does not specify an unambiguous value type, and thus cannot be accessed on a zero-length vector." << EidosTerminate(nullptr); } else if (values_size == 1) { - // the singleton case is very common, so it should be special-cased for speed - // accelerated property is not used for singletons because we want to generate a singleton-class result - // of course the accelerated getters could be smart enough to do that, but that makes them more complex; not a clear win + // The singleton case is very common, so it should be special-cased for speed EidosObject *value = values_[0]; EidosValue_SP result = value->GetProperty(p_property_id); @@ -2361,6 +2360,7 @@ EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringI else if (signature->accelerated_get_) { // Accelerated property access is enabled for this property, so the class will do all the work for us + // We put this case below the (values_size == 1) case so the accelerated getter can focus on the vectorized case EidosValue_SP result = EidosValue_SP(signature->accelerated_getter(values_, values_size)); // Access of singleton properties retains the matrix/array structure of the target @@ -2428,14 +2428,14 @@ EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringI } } -void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) +void EidosValue_Object::SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) { const EidosPropertySignature *signature = Class()->SignatureForProperty(p_property_id); // BCH 9 Sept. 2022: if the property does not exist, raise an error on the token for the property name. // Note that other errors stemming from this call will refer to whatever the current error range is. if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); signature->CheckAssignedValue(p_value); // will raise if the type being assigned in is not an exact match @@ -2446,6 +2446,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope if (p_value_count == 1) { // we have a multiplex assignment of one value to (maybe) more than one element: x.foo = 10 + // Here (unlike the accelerated getter), the accelerated version is probably a win so we always use it if (signature->accelerated_set_) { // Accelerated property writing is enabled for this property, so we call the setter directly @@ -2479,10 +2480,10 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope } } else - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetPropertyOfElements): assignment to a property requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SetPropertyOfElements): assignment to a property requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); } -EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) +EidosValue_SP EidosValue_Object::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { // This is an instance method, so it gets dispatched to all of our elements auto values_size = count_; @@ -2508,12 +2509,12 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ const EidosClass *return_class = p_method_signature->return_class_; if (return_class) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(return_class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(return_class)); else return gStaticEidosValue_Object_ZeroVec; } - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ExecuteMethodCall): method " << EidosStringRegistry::StringForGlobalStringID(p_method_id) << " does not specify an unambiguous return type, and thus cannot be called on a zero-length vector." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::ExecuteMethodCall): method " << EidosStringRegistry::StringForGlobalStringID(p_method_id) << " does not specify an unambiguous return type, and thus cannot be called on a zero-length vector." << EidosTerminate(nullptr); } else if (p_method_signature->accelerated_imp_) { @@ -2729,7 +2730,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ else if (sig_mask == kEidosValueMaskObject && p_method_signature->return_class_) { const EidosClass *return_class = p_method_signature->return_class_; - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(return_class); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(return_class); if (return_is_singleton) { @@ -2810,7 +2811,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ } } -void EidosValue_Object_vector::clear(void) +void EidosValue_Object::clear(void) { WILL_MODIFY(this); @@ -2828,15 +2829,29 @@ void EidosValue_Object_vector::clear(void) count_ = 0; } -EidosValue_Object_vector *EidosValue_Object_vector::reserve(size_t p_reserved_size) +EidosValue_Object *EidosValue_Object::reserve(size_t p_reserved_size) { WILL_MODIFY(this); if (p_reserved_size > capacity_) { - values_ = (EidosObject **)realloc(values_, p_reserved_size * sizeof(EidosObject *)); - if (!values_) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + // this is a reservation for an explicit size, so we give that size exactly, to avoid wasting space + + if (values_ == &singleton_value_) + { + values_ = (EidosObject **)malloc(p_reserved_size * sizeof(EidosObject *)); + + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Object::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + + values_[0] = singleton_value_; + } + else + { + values_ = (EidosObject **)realloc(values_, p_reserved_size * sizeof(EidosObject *)); + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Object::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + } capacity_ = p_reserved_size; } @@ -2844,7 +2859,7 @@ EidosValue_Object_vector *EidosValue_Object_vector::reserve(size_t p_reserved_si return this; } -EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize(size_t p_new_size) +EidosValue_Object *EidosValue_Object::resize_no_initialize(size_t p_new_size) { WILL_MODIFY(this); @@ -2877,7 +2892,7 @@ EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize(size_t return this; } -EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize_RR(size_t p_new_size) +EidosValue_Object *EidosValue_Object::resize_no_initialize_RR(size_t p_new_size) { WILL_MODIFY(this); @@ -2888,7 +2903,7 @@ EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize_RR(size return this; } -void EidosValue_Object_vector::expand(void) +void EidosValue_Object::expand(void) { WILL_MODIFY(this); @@ -2898,7 +2913,7 @@ void EidosValue_Object_vector::expand(void) reserve(capacity_ << 1); } -void EidosValue_Object_vector::erase_index(size_t p_index) +void EidosValue_Object::erase_index(size_t p_index) { WILL_MODIFY(this); @@ -2925,157 +2940,6 @@ void EidosValue_Object_vector::erase_index(size_t p_index) } -// EidosValue_Object_singleton -#pragma mark EidosValue_Object_singleton - -EidosValue_Object_singleton::EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class) : EidosValue_Object(true, p_class), value_(p_element1) -{ - // we want to allow nullptr as a momentary placeholder, although in general a value should exist - if (p_element1) - { - DeclareClassFromElement(p_element1); - - if (class_uses_retain_release_) - static_cast(p_element1)->Retain(); // unsafe cast to avoid virtual function overhead - } -} - -EidosValue_Object_singleton::~EidosValue_Object_singleton(void) -{ - if (class_uses_retain_release_) - if (value_) - static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead -} - -EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -EidosValue_SP EidosValue_Object_singleton::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(value_, Class())); -} - -void EidosValue_Object_singleton::SetValue(EidosObject *p_element) -{ - WILL_MODIFY(this); - - DeclareClassFromElement(p_element); - - if (class_uses_retain_release_) - { - static_cast(p_element)->Retain(); // unsafe cast to avoid virtual function overhead - - // we might have been initialized with nullptr with the aim of setting a value here - if (value_) - static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead - } - - value_ = p_element; -} - -EidosValue_SP EidosValue_Object_singleton::CopyValues(void) const -{ - // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(value_, Class()))->CopyDimensionsFromValue(this)); -} - -EidosValue_SP EidosValue_Object_singleton::VectorBasedCopy(void) const -{ - // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added - // note that constness, invisibility, etc. do not get copied - EidosValue_Object_vector_SP new_vec = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(Class())); - - new_vec->push_object_element_CRR(value_); - new_vec->CopyDimensionsFromValue(this); - - return new_vec; -} - -void EidosValue_Object_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_source_script_value) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Object_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - -EidosValue_SP EidosValue_Object_singleton::GetPropertyOfElements(EidosGlobalStringID p_property_id) const -{ - const EidosPropertySignature *signature = value_->Class()->SignatureForProperty(p_property_id); - - if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(nullptr); - - EidosValue_SP result = value_->GetProperty(p_property_id); - - // Access of singleton properties retains the matrix/array structure of the target - if (signature->value_mask_ & kEidosValueMaskSingleton) - result->CopyDimensionsFromValue(this); - -#if DEBUG - // This is time-consuming, and will fail only due to internal bugs, so we should do it only in DEBUG - signature->CheckResultValue(*result); -#endif - - return result; -} - -void EidosValue_Object_singleton::SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) -{ - const EidosPropertySignature *signature = value_->Class()->SignatureForProperty(p_property_id); - - // BCH 9 Sept. 2022: if the property does not exist, raise an error on the token for the property name. - // Note that other errors stemming from this call will refer to whatever the current error range is. - if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); - - signature->CheckAssignedValue(p_value); // will raise if the type being assigned in is not an exact match - - // We have to check the count ourselves; the signature does not do that for us - if (p_value.Count() == 1) - { - value_->SetProperty(p_property_id, p_value); - } - else - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::SetPropertyOfElements): assignment to a property requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); -} - -EidosValue_SP EidosValue_Object_singleton::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) -{ - // This is an instance method, so it gets dispatched to our element - if (p_method_signature->accelerated_imp_) - { - // the method is accelerated, so call through its accelerated imp - EidosValue_SP result = p_method_signature->accelerated_imper_(&value_, 1, p_method_id, p_arguments, p_interpreter); - - p_method_signature->CheckReturn(*result); - return result; - } - else - { - // not accelerated, so ExecuteInstanceMethod() handles it - EidosValue_SP result = value_->ExecuteInstanceMethod(p_method_id, p_arguments, p_interpreter); - - p_method_signature->CheckReturn(*result); - return result; - } -} diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index faa6772ea..4ddd36382 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -184,6 +184,7 @@ class EidosValue unsigned int invisible_ : 1; // as in R; if true, the value will not normally be printed to the console unsigned int is_singleton_ : 1; // allows Count() and IsSingleton() to be inline; cached at construction unsigned int registered_for_patching_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; declared here for reasons of memory packing + unsigned int class_uses_retain_release_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; cached from UsesRetainRelease() of class_; true until class_ is set int64_t *dim_; // nullptr for vectors; points to a malloced, OWNED array of dimensions for matrices and arrays // when allocated, the first value in the buffer is a count of the dimensions that follow @@ -460,7 +461,7 @@ class EidosValue_NULL final : public EidosValue // those should be used for singleton values when possible. // -class EidosValue_Logical : public EidosValue +class EidosValue_Logical final : public EidosValue { private: typedef EidosValue super; @@ -682,7 +683,7 @@ class EidosValue_String_singleton final : public EidosValue_String // EidosValue_Int represents integer (C++ int64_t) values in Eidos. // -class EidosValue_Int : public EidosValue +class EidosValue_Int final : public EidosValue { private: typedef EidosValue super; @@ -793,7 +794,7 @@ class EidosValue_Int : public EidosValue // EidosValue_Float represents floating-point (C++ double) values in Eidos. // -class EidosValue_Float : public EidosValue +class EidosValue_Float final : public EidosValue { private: typedef EidosValue super; @@ -900,8 +901,7 @@ class EidosValue_Float : public EidosValue // ********************************************************************************************************* // // EidosValue_Object represents objects in Eidos: entities that have properties and can respond to -// methods. The subclass EidosValue_Object_vector is the standard instance class, used to hold vectors -// of objects. EidosValue_Object_singleton is used for speed, to represent single values. +// methods. The value type for it is EidosObject (or a subclass thereof). // // EidosObject supports a retain/release mechanism that disposes of objects when no longer @@ -912,24 +912,25 @@ class EidosValue_Float : public EidosValue // script. Note that if you inherit from EidosDictionaryRetained you *must* subclass from // EidosDictionaryRetained_Class, and vice versa; each is considered a guarantee of the other. -class EidosValue_Object : public EidosValue +class EidosValue_Object final : public EidosValue { private: typedef EidosValue super; protected: - const EidosClass *class_; // can be gEidosObject_Class if the vector is empty - bool class_uses_retain_release_; // cached from UsesRetainRelease() of class_; true until class_ is set, to catch errors + // singleton/vector design: values_ will either point to singleton_value_, or to a malloced buffer; it will never be nullptr + // in the case of a zero-length vector, note that values_ will point to singleton_value_ with count_ == 0 but capacity_ == 1 + EidosObject *singleton_value_; + EidosObject **values_; // these may use a retain/release system of ownership; see below + size_t count_, capacity_; - EidosValue_Object(bool p_singleton, const EidosClass *p_class); + const EidosClass *class_; // can be gEidosObject_Class if the vector is empty - virtual int Count_Virtual(void) const override = 0; + // declared by EidosValue for our benefit, to pack bytes + //unsigned int registered_for_patching_ : 1; // for mutation pointer patching; see EidosValue_Object::EidosValue_Object() + //unsigned int class_uses_retain_release_ : 1; // cached from UsesRetainRelease() of class_; true until class_ is set -public: - EidosValue_Object(const EidosValue_Object &p_original) = delete; // no copy-construct - EidosValue_Object(void) = delete; // no default constructor - EidosValue_Object& operator=(const EidosValue_Object&) = delete; // no copying - virtual ~EidosValue_Object(void) override; + virtual int Count_Virtual(void) const override { return (int)count_; } // check the type of a new element being added to an EidosValue_Object, and update class_uses_retain_release_ inline __attribute__((always_inline)) void DeclareClassFromElement(const EidosObject *p_element, bool p_undeclared_is_error = false) @@ -952,85 +953,57 @@ class EidosValue_Object : public EidosValue } } void RaiseForClassMismatch(void) const; - - virtual const std::string &ElementType(void) const override; - inline __attribute__((always_inline)) const EidosClass *Class(void) const { return class_; } - inline __attribute__((always_inline)) bool UsesRetainRelease(void) const { return class_uses_retain_release_; } - virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; - virtual nlohmann::json JSONRepresentation(void) const override; - - virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosValue_SP CopyValues(void) const override = 0; - virtual EidosValue_SP NewMatchingType(void) const override; - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override = 0; - virtual void Sort(bool p_ascending) override; - - // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a - // EidosValue_Object instance defines depend upon the type of the EidosObject objects it contains. - virtual EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const = 0; - virtual void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) = 0; + // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments + void PatchPointersByAdding(std::uintptr_t p_pointer_difference); + void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference); - virtual EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) = 0; +public: + EidosValue_Object(void) = delete; // no default constructor + EidosValue_Object& operator=(const EidosValue_Object&) = delete; // no copying + explicit EidosValue_Object(const EidosClass *p_class); // funnel initializer; allows gEidosObject_Class - // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments - virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) = 0; - virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) = 0; -}; - -class EidosValue_Object_vector final : public EidosValue_Object -{ -private: - typedef EidosValue_Object super; - -protected: - EidosObject **values_ = nullptr; // these may use a retain/release system of ownership; see below - size_t count_ = 0, capacity_ = 0; + explicit EidosValue_Object(EidosObject *p_element1, const EidosClass *p_class); + explicit EidosValue_Object(const EidosValue_Object &p_original); + explicit EidosValue_Object(const std::vector &p_elementvec, const EidosClass *p_class); + explicit EidosValue_Object(std::initializer_list p_init_list, const EidosClass *p_class); + explicit EidosValue_Object(EidosObject **p_values, size_t p_count, const EidosClass *p_class); + virtual ~EidosValue_Object(void) override; - virtual int Count_Virtual(void) const override { return (int)count_; } + virtual EidosObject * const *ObjectData(void) const override { return values_; } + virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return values_; } -public: - EidosValue_Object_vector(const EidosValue_Object_vector &p_original); // can copy-construct - EidosValue_Object_vector& operator=(const EidosValue_Object_vector&) = delete; // no copying + inline __attribute__((always_inline)) const EidosClass *Class(void) const { return class_; } + inline __attribute__((always_inline)) bool UsesRetainRelease(void) const { return class_uses_retain_release_; } - explicit inline EidosValue_Object_vector(const EidosClass *p_class) : EidosValue_Object(false, p_class) { } // can be gEidosObject_Class - explicit EidosValue_Object_vector(const std::vector &p_elementvec, const EidosClass *p_class); - //explicit EidosValue_Object_vector(EidosObject *p_element1); // disabled to encourage use of EidosValue_Object_singleton for this case - explicit EidosValue_Object_vector(std::initializer_list p_init_list, const EidosClass *p_class); - explicit EidosValue_Object_vector(EidosObject **p_values, size_t p_count, const EidosClass *p_class); - virtual ~EidosValue_Object_vector(void) override; + virtual const std::string &ElementType(void) const override; + virtual EidosValue_SP NewMatchingType(void) const override; + virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; + virtual nlohmann::json JSONRepresentation(void) const override; virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject * const *ObjectData(void) const override { return values_; } - virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return values_; } - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; + virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; + virtual void Sort(bool p_ascending) override; void SortBy(const std::string &p_property, bool p_ascending); // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a // EidosValue_Object instance defines depend upon the type of the EidosObject objects it contains. - virtual EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const override; - virtual void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) override; + EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const; + void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token); - virtual EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) override; - - // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments - virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) override; - virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) override; + EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter); - // vector lookalike methods; not virtual, only for clients with a EidosValue_Object_vector* + // vector lookalike methods for speed; not virtual, only for clients with a EidosValue_Object* void clear(void); // as in std::vector - EidosValue_Object_vector *reserve(size_t p_reserved_size); // as in std::vector - EidosValue_Object_vector *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! - EidosValue_Object_vector *resize_no_initialize_RR(size_t p_new_size); // doesn't zero-initialize even for the RR case (set_object_element_no_check_RR may not be used, use set_object_element_no_check_no_previous_RR) + EidosValue_Object *reserve(size_t p_reserved_size); // as in std::vector + EidosValue_Object *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! + EidosValue_Object *resize_no_initialize_RR(size_t p_new_size); // doesn't zero-initialize even for the RR case (set_object_element_no_check_RR may not be used, use set_object_element_no_check_no_previous_RR) void expand(void); // expand to fit (at least) one new value void erase_index(size_t p_index); // a weak substitute for erase() @@ -1055,9 +1028,11 @@ class EidosValue_Object_vector final : public EidosValue_Object void set_object_element_no_check_RR(EidosObject *p_object, size_t p_index); // specifies retain/release void set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index); // specifies retain/release, previous value assumed invalid from resize_no_initialize_RR void set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index); // specifies no retain/release + + friend void SLiM_IncreaseMutationBlockCapacity(void); // for PatchPointersByAdding() / PatchPointersBySubtracting() }; -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_CRR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_CRR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1072,7 +1047,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_RR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_RR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1091,7 +1066,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_NORR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_NORR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1108,7 +1083,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_capcheck_NORR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_capcheck_NORR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1124,7 +1099,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_CRR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_CRR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1140,7 +1115,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_RR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_RR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1156,7 +1131,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_NORR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_NORR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1170,7 +1145,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_already_retained(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_already_retained(EidosObject *p_object) { WILL_MODIFY(this); @@ -1184,7 +1159,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1205,7 +1180,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_RR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_RR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1224,7 +1199,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1241,7 +1216,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1256,74 +1231,6 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -class EidosValue_Object_singleton final : public EidosValue_Object -{ -private: - typedef EidosValue_Object super; - -protected: - EidosObject *value_; // these may use a retain/release system of ownership; see below - - virtual int Count_Virtual(void) const override { return 1; } - -public: - EidosValue_Object_singleton(const EidosValue_Object_singleton &p_original) = delete; // no copy-construct - EidosValue_Object_singleton& operator=(const EidosValue_Object_singleton&) = delete; // no copying - EidosValue_Object_singleton(void) = delete; - explicit EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class); - explicit EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class, bool p_register_for_patching); // a variant for self-pointer EidosValues; not for general use - virtual ~EidosValue_Object_singleton(void) override; - - virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosObject * const *ObjectData(void) const override { return &value_; } - virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; do not use - void SetValue(EidosObject *p_element); // very dangerous; used only in Evaluate_For() - - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; - - virtual EidosValue_SP VectorBasedCopy(void) const override; - - // prohibited actions because there is no backing vector - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; - - // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a - // EidosValue_Object instance defines depend upon the type of the EidosObject objects it contains. - virtual EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const override; - virtual void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) override; - - virtual EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) override; - - // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments - virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) override; - virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) override; - - // We support just this method, from EidosValue_Object_vector's suite of setters, for now - void set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index); // checks for retain/release -}; - -inline __attribute__((always_inline)) void EidosValue_Object_singleton::set_object_element_no_check_CRR(EidosObject *p_object, __attribute__((unused)) size_t p_index) -{ - WILL_MODIFY(this); - -#if DEBUG - // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors - if (p_index >= 1) RaiseForRangeViolation(); - DeclareClassFromElement(p_object, true); // require a prior matching declaration -#endif - if (class_uses_retain_release_) - { - static_cast(p_object)->Retain(); // unsafe cast to avoid virtual function overhead - if (value_) - static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead - } - - value_ = p_object; -} - #endif /* defined(__Eidos__eidos_value__) */ From 364f65498c3e4a14dfb446f6a01411ea1dce4c6b Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 15:22:03 -0500 Subject: [PATCH 15/18] abolish the singleton/vector distinction for EidosValue_String --- core/chromosome.cpp | 4 +- core/community_eidos.cpp | 6 +- core/genome.cpp | 10 +- core/genomic_element_type.cpp | 2 +- core/individual.cpp | 10 +- core/interaction_type.cpp | 4 +- core/log_file.cpp | 4 +- core/mutation.cpp | 2 +- core/mutation_type.cpp | 26 ++-- core/slim_eidos_block.cpp | 30 ++--- core/slim_functions.cpp | 22 ++-- core/slim_globals.cpp | 14 +-- core/spatial_map.cpp | 8 +- core/species_eidos.cpp | 36 +++--- core/subpopulation.cpp | 8 +- core/substitution.cpp | 2 +- eidos/eidos_ast_node.cpp | 2 +- eidos/eidos_class_DataFrame.cpp | 2 +- eidos/eidos_class_Dictionary.cpp | 14 +-- eidos/eidos_class_Object.cpp | 2 +- eidos/eidos_functions.cpp | 20 +-- eidos/eidos_functions_colors.cpp | 16 +-- eidos/eidos_functions_files.cpp | 14 +-- eidos/eidos_functions_math.cpp | 24 ++-- eidos/eidos_functions_matrices.cpp | 6 +- eidos/eidos_functions_other.cpp | 38 +++--- eidos/eidos_functions_stats.cpp | 12 +- eidos/eidos_functions_strings.cpp | 16 +-- eidos/eidos_functions_values.cpp | 28 ++--- eidos/eidos_globals.cpp | 26 ++-- eidos/eidos_globals.h | 4 - eidos/eidos_interpreter.cpp | 22 ++-- eidos/eidos_test.cpp | 4 +- eidos/eidos_value.cpp | 192 ++++++++--------------------- eidos/eidos_value.h | 112 ++++------------- 35 files changed, 288 insertions(+), 454 deletions(-) diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 35e99db01..a317a28c2 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -1773,7 +1773,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id) // variables case gID_colorSubstitution: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(color_sub_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(color_sub_)); case gID_geneConversionEnabled: return using_DSB_model_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF; case gID_geneConversionGCBias: @@ -2575,7 +2575,7 @@ const std::vector *Chromosome_Class::Methods(void) con methods = new std::vector(*super::Methods()); - methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_ancestralNucleotides, kEidosValueMaskInt | kEidosValueMaskString))->AddInt_OSN(gEidosStr_start, gStaticEidosValueNULL)->AddInt_OSN(gEidosStr_end, gStaticEidosValueNULL)->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("string")))); + methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_ancestralNucleotides, kEidosValueMaskInt | kEidosValueMaskString))->AddInt_OSN(gEidosStr_start, gStaticEidosValueNULL)->AddInt_OSN(gEidosStr_end, gStaticEidosValueNULL)->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("string")))); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_drawBreakpoints, kEidosValueMaskInt))->AddObject_OSN("parent", gSLiM_Individual_Class, gStaticEidosValueNULL)->AddInt_OSN("n", gStaticEidosValueNULL)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_setAncestralNucleotides, kEidosValueMaskInt | kEidosValueMaskSingleton))->AddIntString("sequence")); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_setGeneConversion, kEidosValueMaskVOID))->AddNumeric_S("nonCrossoverFraction")->AddNumeric_S("meanLength")->AddNumeric_S("simpleConversionFraction")->AddNumeric_OS("bias", gStaticEidosValue_Integer0)); diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index 4ec76856c..fb5b279e6 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -401,8 +401,8 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) { if (!static_model_type_string_WF) { - static_model_type_string_WF = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("WF")); - static_model_type_string_nonWF = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("nonWF")); + static_model_type_string_WF = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("WF")); + static_model_type_string_nonWF = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("nonWF")); } } @@ -427,7 +427,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id) { SLiMCycleStage cycle_stage = CycleStage(); std::string cycle_stage_str = StringForSLiMCycleStage(cycle_stage); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(cycle_stage_str)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(cycle_stage_str)); } case gID_tag: { diff --git a/core/genome.cpp b/core/genome.cpp index 56c067a66..7e7afdb8a 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -424,9 +424,9 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) { switch (genome_type_) { - case GenomeType::kAutosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_A)); - case GenomeType::kXChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_X)); - case GenomeType::kYChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_Y)); + case GenomeType::kAutosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_A)); + case GenomeType::kXChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_X)); + case GenomeType::kYChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_Y)); } EIDOS_TERMINATION << "ERROR (Genome::GetProperty): (internal error) unknown value for genome_type_." << EidosTerminate(); } @@ -1056,7 +1056,7 @@ EidosValue_SP Genome::ExecuteMethod_nucleotides(EidosGlobalStringID p_method_id, else { // vector case: replace the appropriate character in string_value - std::string &string_string = ((EidosValue_String_singleton *)(string_value.get()))->StringValue_Mutable(); + std::string &string_string = ((EidosValue_String *)(string_value.get()))->StringData_Mutable()[0]; char *string_ptr = &string_string[0]; // data() returns a const pointer, but this is safe in C++11 and later GenomeWalker walker(this); @@ -2051,7 +2051,7 @@ const std::vector *Genome_Class::Methods(void) const methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_mutationCountsInGenomes, kEidosValueMaskInt))->AddObject_ON("mutations", gSLiM_Mutation_Class, gStaticEidosValueNULL)); methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_mutationFrequenciesInGenomes, kEidosValueMaskFloat))->AddObject_ON("mutations", gSLiM_Mutation_Class, gStaticEidosValueNULL)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_mutationsOfType, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddIntObject_S("mutType", gSLiM_MutationType_Class)); - methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_nucleotides, kEidosValueMaskInt | kEidosValueMaskString))->AddInt_OSN(gEidosStr_start, gStaticEidosValueNULL)->AddInt_OSN(gEidosStr_end, gStaticEidosValueNULL)->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("string")))); + methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_nucleotides, kEidosValueMaskInt | kEidosValueMaskString))->AddInt_OSN(gEidosStr_start, gStaticEidosValueNULL)->AddInt_OSN(gEidosStr_end, gStaticEidosValueNULL)->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("string")))); methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_readFromMS, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddString_S(gEidosStr_filePath)->AddIntObject_S("mutationType", gSLiM_MutationType_Class)); methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_readFromVCF, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddString_S(gEidosStr_filePath)->AddIntObject_OSN("mutationType", gSLiM_MutationType_Class, gStaticEidosValueNULL)); methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_removeMutations, kEidosValueMaskVOID))->AddObject_ON("mutations", gSLiM_Mutation_Class, gStaticEidosValueNULL)->AddLogical_OS("substitute", gStaticEidosValue_LogicalF)); diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index 70857adae..d9e844fa7 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -284,7 +284,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) // variables case gEidosID_color: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(color_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(color_)); case gID_tag: // ACCELERATED { slim_usertag_t tag_value = tag_value_; diff --git a/core/individual.cpp b/core/individual.cpp index 544cd387b..800017a18 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -401,10 +401,10 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) { if (!static_sex_string_H) { - static_sex_string_H = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("H")); - static_sex_string_F = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("F")); - static_sex_string_M = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("M")); - static_sex_string_O = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("?")); + static_sex_string_H = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("H")); + static_sex_string_F = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("F")); + static_sex_string_M = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("M")); + static_sex_string_O = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("?")); } } @@ -622,7 +622,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) Eidos_GetColorString(colorR_, colorG_, colorB_, hex_chars); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(std::string(hex_chars))); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(std::string(hex_chars))); } case gID_tag: // ACCELERATED { diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index c0e026585..0c504e296 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -3487,11 +3487,11 @@ EidosValue_SP InteractionType::GetProperty(EidosGlobalStringID p_property_id) default: sex_segregation_string += "*"; break; } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(sex_segregation_string)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(sex_segregation_string)); } case gID_spatiality: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(spatiality_string_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(spatiality_string_)); } // variables diff --git a/core/log_file.cpp b/core/log_file.cpp index ae5eecb1c..fb0ffbd79 100644 --- a/core/log_file.cpp +++ b/core/log_file.cpp @@ -139,7 +139,7 @@ EidosValue_SP LogFile::_GeneratedValue_CycleStage(const LogFileGeneratorInfo &p_ SLiMCycleStage cycle_stage = community_.CycleStage(); std::string stage_string = StringForSLiMCycleStage(cycle_stage); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(stage_string)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(stage_string)); } EidosValue_SP LogFile::_GeneratedValue_PopulationSexRatio(const LogFileGeneratorInfo &p_generator_info) @@ -562,7 +562,7 @@ EidosValue_SP LogFile::GetProperty(EidosGlobalStringID p_property_id) // constants //case gEidosID_allKeys: // not technically overridden here, but we override AllKeys() to provide new behavior case gEidosID_filePath: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(user_file_path_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(user_file_path_)); case gID_logInterval: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(log_interval_)); diff --git a/core/mutation.cpp b/core/mutation.cpp index f7dbd90d6..510ab1c74 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -476,7 +476,7 @@ EidosValue *Mutation::GetProperty_Accelerated_isSegregating(EidosObject **p_valu EidosValue *Mutation::GetProperty_Accelerated_nucleotide(EidosObject **p_values, size_t p_values_size) { - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve((int)p_values_size); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index 20d46caed..442f24d71 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -438,13 +438,13 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) { if (!static_dfe_string_f) { - static_dfe_string_f = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_f)); - static_dfe_string_g = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_g)); - static_dfe_string_e = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_e)); - static_dfe_string_n = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_n)); - static_dfe_string_w = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_w)); - static_dfe_string_p = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_p)); - static_dfe_string_s = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_s)); + static_dfe_string_f = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_f)); + static_dfe_string_g = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_g)); + static_dfe_string_e = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_e)); + static_dfe_string_n = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_n)); + static_dfe_string_w = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_w)); + static_dfe_string_p = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_p)); + static_dfe_string_s = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_s)); } } @@ -465,7 +465,7 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) if (dfe_parameters_.size() > 0) return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(dfe_parameters_)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(dfe_strings_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(dfe_strings_)); } case gID_species: { @@ -474,9 +474,9 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) // variables case gEidosID_color: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(color_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(color_)); case gID_colorSubstitution: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(color_sub_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(color_sub_)); case gID_convertToSubstitution: return (convert_to_substitution_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gID_dominanceCoeff: // ACCELERATED @@ -499,9 +499,9 @@ EidosValue_SP MutationType::GetProperty(EidosGlobalStringID p_property_id) { THREAD_SAFETY_IN_ACTIVE_PARALLEL("MutationType::GetProperty(): usage of statics"); - static_policy_string_s = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_s)); - static_policy_string_f = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_f)); - static_policy_string_l = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_l)); + static_policy_string_s = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_s)); + static_policy_string_f = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_f)); + static_policy_string_l = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_l)); } } diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 789cd82cb..b4adbdd03 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -1463,26 +1463,26 @@ EidosValue_SP SLiMEidosBlock::GetProperty(EidosGlobalStringID p_property_id) { switch (type_) { - case SLiMEidosBlockType::SLiMEidosEventFirst: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_first)); - case SLiMEidosBlockType::SLiMEidosEventEarly: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_early)); - case SLiMEidosBlockType::SLiMEidosEventLate: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_late)); - case SLiMEidosBlockType::SLiMEidosInitializeCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_initialize)); - case SLiMEidosBlockType::SLiMEidosMutationEffectCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_mutationEffect)); - case SLiMEidosBlockType::SLiMEidosFitnessEffectCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_fitnessEffect)); - case SLiMEidosBlockType::SLiMEidosInteractionCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_interaction)); - case SLiMEidosBlockType::SLiMEidosMateChoiceCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_mateChoice)); - case SLiMEidosBlockType::SLiMEidosModifyChildCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_modifyChild)); - case SLiMEidosBlockType::SLiMEidosRecombinationCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_recombination)); - case SLiMEidosBlockType::SLiMEidosMutationCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_mutation)); - case SLiMEidosBlockType::SLiMEidosSurvivalCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_survival)); - case SLiMEidosBlockType::SLiMEidosReproductionCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_reproduction)); - case SLiMEidosBlockType::SLiMEidosUserDefinedFunction: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_function)); + case SLiMEidosBlockType::SLiMEidosEventFirst: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_first)); + case SLiMEidosBlockType::SLiMEidosEventEarly: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_early)); + case SLiMEidosBlockType::SLiMEidosEventLate: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_late)); + case SLiMEidosBlockType::SLiMEidosInitializeCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_initialize)); + case SLiMEidosBlockType::SLiMEidosMutationEffectCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_mutationEffect)); + case SLiMEidosBlockType::SLiMEidosFitnessEffectCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_fitnessEffect)); + case SLiMEidosBlockType::SLiMEidosInteractionCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_interaction)); + case SLiMEidosBlockType::SLiMEidosMateChoiceCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_mateChoice)); + case SLiMEidosBlockType::SLiMEidosModifyChildCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_modifyChild)); + case SLiMEidosBlockType::SLiMEidosRecombinationCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_recombination)); + case SLiMEidosBlockType::SLiMEidosMutationCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_mutation)); + case SLiMEidosBlockType::SLiMEidosSurvivalCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_survival)); + case SLiMEidosBlockType::SLiMEidosReproductionCallback: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_reproduction)); + case SLiMEidosBlockType::SLiMEidosUserDefinedFunction: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_function)); case SLiMEidosBlockType::SLiMEidosNoBlockType: return gStaticEidosValue_StringAsterisk; // never hit } EIDOS_TERMINATION << "ERROR (SLiMEidosBlock::GetProperty): (internal error) unrecognized value for type_." << EidosTerminate(); } case gEidosID_source: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(compound_statement_node_->token_->token_string_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(compound_statement_node_->token_->token_string_)); case gID_speciesSpec: { // With no species spec, we return an empty object vector of class Species; this is allowed since this is a read-only property diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index 5f73f629b..362950c80 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -55,14 +55,14 @@ const std::vector *Community::SLiMFunctionSignatures // Nucleotide utilities sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("codonsToAminoAcids", SLiM_ExecuteFunction_codonsToAminoAcids, kEidosValueMaskString | kEidosValueMaskInt, "SLiM"))->AddInt("codons")->AddArgWithDefault(kEidosValueMaskLogical | kEidosValueMaskInt | kEidosValueMaskOptional | kEidosValueMaskSingleton, "long", nullptr, gStaticEidosValue_LogicalF)->AddLogical_OS("paste", gStaticEidosValue_LogicalT)); - sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("codonsToNucleotides", SLiM_ExecuteFunction_codonsToNucleotides, kEidosValueMaskInt | kEidosValueMaskString, "SLiM"))->AddInt("codons")->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("string")))); + sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("codonsToNucleotides", SLiM_ExecuteFunction_codonsToNucleotides, kEidosValueMaskInt | kEidosValueMaskString, "SLiM"))->AddInt("codons")->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("string")))); sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("mm16To256", SLiM_ExecuteFunction_mm16To256, kEidosValueMaskFloat, "SLiM"))->AddFloat("mutationMatrix16")); sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("mmJukesCantor", SLiM_ExecuteFunction_mmJukesCantor, kEidosValueMaskFloat, "SLiM"))->AddFloat_S("alpha")); sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("mmKimura", SLiM_ExecuteFunction_mmKimura, kEidosValueMaskFloat, "SLiM"))->AddFloat_S("alpha")->AddFloat_S("beta")); sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("nucleotideCounts", SLiM_ExecuteFunction_nucleotideCounts, kEidosValueMaskInt, "SLiM"))->AddIntString("sequence")); sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("nucleotideFrequencies", SLiM_ExecuteFunction_nucleotideFrequencies, kEidosValueMaskFloat, "SLiM"))->AddIntString("sequence")); sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("nucleotidesToCodons", SLiM_ExecuteFunction_nucleotidesToCodons, kEidosValueMaskInt, "SLiM"))->AddIntString("sequence")); - sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("randomNucleotides", SLiM_ExecuteFunction_randomNucleotides, kEidosValueMaskInt | kEidosValueMaskString, "SLiM"))->AddInt_S("length")->AddNumeric_ON("basis", gStaticEidosValueNULL)->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("string")))); + sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("randomNucleotides", SLiM_ExecuteFunction_randomNucleotides, kEidosValueMaskInt | kEidosValueMaskString, "SLiM"))->AddInt_S("length")->AddNumeric_ON("basis", gStaticEidosValueNULL)->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("string")))); // Population genetics utilities (implemented with Eidos code) sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("calcFST", gSLiMSourceCode_calcFST, kEidosValueMaskFloat | kEidosValueMaskSingleton, "SLiM"))->AddObject("genomes1", gSLiM_Genome_Class)->AddObject("genomes2", gSLiM_Genome_Class)->AddObject_ON("muts", gSLiM_Mutation_Class, gStaticEidosValueNULL)->AddInt_OSN("start", gStaticEidosValueNULL)->AddInt_OSN("end", gStaticEidosValueNULL)); @@ -605,7 +605,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_singleton(aa)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(aa)); } } else @@ -638,7 +638,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vector 0)) { // pasting: "Aaa-Bbb-Ccc" - EidosValue_String_singleton *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("")); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String("")); std::string &aa_string = string_result->StringData_Mutable()[0]; aa_string.resize(codons_length * 4 - 1); // create space for all the amino acids we will generate, including hyphens @@ -668,7 +668,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String("")); std::string &aa_string = string_result->StringData_Mutable()[0]; aa_string.resize(codons_length); // create space for all the amino acids we will generate @@ -693,7 +693,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToAminoAcids(const std::vectorAllocateChunk()) EidosValue_String_vector())->Reserve(codons_length); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(codons_length); for (int value_index = 0; value_index < codons_length; ++value_index) { @@ -1130,7 +1130,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorAllocateChunk()) EidosValue_String_vector())->Reserve((int)length); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)length); for (int value_index = 0; value_index < length; ++value_index) { @@ -1164,7 +1164,7 @@ EidosValue_SP SLiM_ExecuteFunction_randomNucleotides(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String("")); std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate @@ -1201,7 +1201,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorAllocateChunk()) EidosValue_String_vector())->Reserve((int)length); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)length); for (int codon_index = 0; codon_index < codons_length; ++codon_index) { @@ -1268,7 +1268,7 @@ EidosValue_SP SLiM_ExecuteFunction_codonsToNucleotides(const std::vectorAllocateChunk()) EidosValue_String_singleton("")); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String("")); std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate @@ -1624,7 +1624,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vector(operation_value); + EidosValue_String *lambda_value_singleton = dynamic_cast(operation_value); EidosScript *script = (lambda_value_singleton ? lambda_value_singleton->CachedScript() : nullptr); // Errors in lambdas should be reported for the lambda script, not for the calling script, diff --git a/core/slim_globals.cpp b/core/slim_globals.cpp index 7f35ec853..333b280b1 100644 --- a/core/slim_globals.cpp +++ b/core/slim_globals.cpp @@ -98,10 +98,10 @@ void SLiM_WarmUp(void) SLiM_ConfigureContext(); // Allocate global permanents - gStaticEidosValue_StringA = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_A)); - gStaticEidosValue_StringC = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_C)); - gStaticEidosValue_StringG = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_G)); - gStaticEidosValue_StringT = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_T)); + gStaticEidosValue_StringA = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_A)); + gStaticEidosValue_StringC = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_C)); + gStaticEidosValue_StringG = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_G)); + gStaticEidosValue_StringT = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_T)); #if DO_MEMORY_CHECKS // Check for a memory limit and prepare for memory-limit testing @@ -921,7 +921,7 @@ EidosValue_SP NucleotideArray::NucleotidesAsStringVector(int64_t start, int64_t else { // return a vector of one-character strings, "T" "A" "T" "A" - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve((int)length); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)length); for (int value_index = 0; value_index < length; ++value_index) { @@ -961,8 +961,8 @@ EidosValue_SP NucleotideArray::NucleotidesAsStringSingleton(int64_t start, int64 else { // return a singleton string for the whole sequence, "TATA"; we munge the std::string inside the EidosValue to avoid memory copying, very naughty - EidosValue_String_singleton *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("")); - std::string &nuc_string = string_result->StringValue_Mutable(); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String("")); + std::string &nuc_string = string_result->StringData_Mutable()[0]; nuc_string.resize(length); // create space for all the nucleotides we will generate diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index 07f11cd02..056b3fc5f 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -1080,7 +1080,7 @@ EidosValue_SP SpatialMap::GetProperty(EidosGlobalStringID p_property_id) } case gID_name: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name_)); } case gID_spatialBounds: { @@ -1094,7 +1094,7 @@ EidosValue_SP SpatialMap::GetProperty(EidosGlobalStringID p_property_id) } case gID_spatiality: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(spatiality_string_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(spatiality_string_)); } // variables @@ -1857,7 +1857,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapColor(EidosGlobalStringID p_method_id EIDOS_TERMINATION << "ERROR (SpatialMap::ExecuteMethod_mapColor): mapColor() no color map defined for spatial map." << EidosTerminate(); int value_count = values->Count(); - EidosValue_String_vector *string_return = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(value_count); + EidosValue_String *string_return = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(value_count); EidosValue_SP result_SP = EidosValue_SP(string_return); for (slim_popsize_t value_index = 0; value_index < value_count; value_index++) @@ -2701,7 +2701,7 @@ const std::vector *SpatialMap_Class::Methods(void) con methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_changeColors, kEidosValueMaskVOID))->AddNumeric_ON("valueRange", gStaticEidosValueNULL)->AddString_ON("colors", gStaticEidosValueNULL)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_changeValues, kEidosValueMaskVOID))->AddArg(kEidosValueMaskNumeric | kEidosValueMaskObject, "x", gSLiM_SpatialMap_Class)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_gridValues, kEidosValueMaskFloat))); - methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_interpolate, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_SpatialMap_Class))->AddInt_S("factor")->AddString_OS("method", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("linear")))); + methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_interpolate, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_SpatialMap_Class))->AddInt_S("factor")->AddString_OS("method", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("linear")))); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_mapColor, kEidosValueMaskString))->AddNumeric("value")); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_mapImage, kEidosValueMaskObject | kEidosValueMaskSingleton, gEidosImage_Class))->AddInt_OSN(gEidosStr_width, gStaticEidosValueNULL)->AddInt_OSN(gEidosStr_height, gStaticEidosValueNULL)->AddLogical_OS("centers", gStaticEidosValue_LogicalF)->AddLogical_OS(gEidosStr_color, gStaticEidosValue_LogicalT)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_mapValue, kEidosValueMaskFloat))->AddFloat("point")); diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index a753c2f90..acd5cb1a4 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -1458,7 +1458,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) // constants case gID_avatar: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(avatar_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(avatar_)); } case gID_chromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(chromosome_, gSLiM_Chromosome_Class)); @@ -1466,15 +1466,15 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) { switch (modeled_chromosome_type_) { - case GenomeType::kAutosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_A)); - case GenomeType::kXChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_X)); - case GenomeType::kYChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gStr_Y)); + case GenomeType::kAutosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_A)); + case GenomeType::kXChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_X)); + case GenomeType::kYChromosome: return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gStr_Y)); } EIDOS_TERMINATION << "ERROR (Species::GetProperty): (internal error) unrecognized value for modeled_chromosome_type_." << EidosTerminate(); } case gEidosID_color: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(color_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(color_)); } case gID_dimensionality: { @@ -1486,9 +1486,9 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) { if (!static_dimensionality_string_x) { - static_dimensionality_string_x = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_x)); - static_dimensionality_string_xy = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("xy")); - static_dimensionality_string_xyz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("xyz")); + static_dimensionality_string_x = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_x)); + static_dimensionality_string_xy = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("xy")); + static_dimensionality_string_xyz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("xyz")); } } @@ -1519,13 +1519,13 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) { if (!static_periodicity_string_x) { - static_periodicity_string_x = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_x)); - static_periodicity_string_y = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_y)); - static_periodicity_string_z = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_z)); - static_periodicity_string_xy = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("xy")); - static_periodicity_string_xz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("xz")); - static_periodicity_string_yz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("yz")); - static_periodicity_string_xyz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("xyz")); + static_periodicity_string_x = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_x)); + static_periodicity_string_y = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_y)); + static_periodicity_string_z = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_z)); + static_periodicity_string_xy = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("xy")); + static_periodicity_string_xz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("xz")); + static_periodicity_string_yz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("yz")); + static_periodicity_string_xyz = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("xyz")); } } @@ -1573,7 +1573,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_name: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name_)); } case gID_nucleotideBased: { @@ -1618,7 +1618,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) // variables case gID_description: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(description_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(description_)); } case gID_cycle: { @@ -3260,7 +3260,7 @@ EidosValue_SP Species::ExecuteMethod_treeSeqRememberIndividuals(EidosGlobalStrin { #pragma unused (p_method_id, p_interpreter) EidosValue_Object *individuals_value = (EidosValue_Object *)p_arguments[0].get(); - EidosValue_Object *permanent_value = (EidosValue_Object *)p_arguments[1].get(); + EidosValue *permanent_value = p_arguments[1].get(); int ind_count = individuals_value->Count(); if (!recording_tree_) diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 338a1960f..91fad5b58 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -4094,11 +4094,11 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) } case gID_name: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name_)); } case gID_description: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(description_)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(description_)); } case gID_selfingRate: { @@ -5009,8 +5009,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ static EidosValue_SP static_sex_string_F; static EidosValue_SP static_sex_string_M; - if (!static_sex_string_F) static_sex_string_F = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("F")); - if (!static_sex_string_M) static_sex_string_M = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("M")); + if (!static_sex_string_F) static_sex_string_F = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("F")); + if (!static_sex_string_M) static_sex_string_M = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("M")); if (strand3->Type() == GenomeType::kXChromosome) sex_value = static_sex_string_F.get(); diff --git a/core/substitution.cpp b/core/substitution.cpp index 1dbfe9cbe..85f6d3cfb 100644 --- a/core/substitution.cpp +++ b/core/substitution.cpp @@ -159,7 +159,7 @@ EidosValue *Substitution::GetProperty_Accelerated_id(EidosObject **p_values, siz EidosValue *Substitution::GetProperty_Accelerated_nucleotide(EidosObject **p_values, size_t p_values_size) { - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve((int)p_values_size); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/eidos/eidos_ast_node.cpp b/eidos/eidos_ast_node.cpp index 2909179e8..6c293c820 100644 --- a/eidos/eidos_ast_node.cpp +++ b/eidos/eidos_ast_node.cpp @@ -102,7 +102,7 @@ void EidosASTNode::_OptimizeConstants(void) const else if (token_type == EidosTokenType::kTokenString) { // This is taken from EidosInterpreter::Evaluate_String and needs to match exactly! - cached_literal_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(token_->token_string_)); + cached_literal_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(token_->token_string_)); cached_literal_value_->MarkAsConstant(); } else if (token_type == EidosTokenType::kTokenIdentifier) diff --git a/eidos/eidos_class_DataFrame.cpp b/eidos/eidos_class_DataFrame.cpp index 2dafc6a82..7c988622c 100644 --- a/eidos/eidos_class_DataFrame.cpp +++ b/eidos/eidos_class_DataFrame.cpp @@ -1235,7 +1235,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorAllocateChunk()) EidosValue_String_vector())->Reserve(nrows); + EidosValue_String *string_column = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(nrows); column_values = EidosValue_SP(string_column); for (int row_index = 0; row_index < nrows; ++row_index) diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index b1079a3b9..638c2b93f 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -340,7 +340,7 @@ EidosValue_SP EidosDictionaryUnretained::Serialization_CSV(const std::string &p_ // Make a string vector big enough for everything int result_count = longest_col + 1; // room for the header - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(result_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(result_count); EidosValue_SP result_SP(string_result); // Generate the header @@ -605,7 +605,7 @@ EidosValue_SP EidosDictionaryUnretained::AllKeys(void) const if (key_count == 0) return gStaticEidosValue_String_ZeroVec; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(key_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(key_count); for (const std::string &key : keys) string_result->PushString(key); @@ -873,7 +873,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) else if (value.is_string()) { const std::string &string_value = value; - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string_value)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string_value)); } else if (value.is_number_integer() || value.is_number_unsigned()) { @@ -963,7 +963,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) } else if (array_type == nlohmann::json::value_t::string) { - EidosValue_String_vector *string_value = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve((int)array_count); + EidosValue_String *string_value = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)array_count); for (size_t element_index = 0; element_index < array_count; ++element_index) { @@ -1456,14 +1456,14 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_serialize(EidosGlobalStri if (format_name == "slim") { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(Serialization_SLiM())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(Serialization_SLiM())); } else if (format_name == "json") { nlohmann::json json_rep = JSONRepresentation(); std::string json_string = json_rep.dump(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(json_string)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(json_string)); } else if (format_name == "csv") { @@ -1525,7 +1525,7 @@ const std::vector *EidosDictionaryUnretained_Class::Me methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gEidosStr_getRowValues, kEidosValueMaskObject | kEidosValueMaskSingleton, gEidosDictionaryRetained_Class))->AddArg(kEidosValueMaskLogical | kEidosValueMaskInt, "index", nullptr)->AddLogical_OS("drop", gStaticEidosValue_LogicalF)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gEidosStr_getValue, kEidosValueMaskAny))->AddArg(kEidosValueMaskInt | kEidosValueMaskString | kEidosValueMaskSingleton, "key", nullptr)); methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gEidosStr_identicalContents, kEidosValueMaskLogical | kEidosValueMaskSingleton))->AddObject_S("x", nullptr)); - methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gEidosStr_serialize, kEidosValueMaskString))->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("slim")))); + methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gEidosStr_serialize, kEidosValueMaskString))->AddString_OS("format", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("slim")))); methods->emplace_back(((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gEidosStr_setValue, kEidosValueMaskVOID))->AddArg(kEidosValueMaskInt | kEidosValueMaskString | kEidosValueMaskSingleton, "key", nullptr)->AddAny("value"))->DeclareAcceleratedImp(EidosDictionaryUnretained::ExecuteMethod_Accelerated_setValue)); std::sort(methods->begin(), methods->end(), CompareEidosCallSignatures); diff --git a/eidos/eidos_class_Object.cpp b/eidos/eidos_class_Object.cpp index d491dadf5..2b00963a5 100644 --- a/eidos/eidos_class_Object.cpp +++ b/eidos/eidos_class_Object.cpp @@ -245,7 +245,7 @@ EidosValue_SP EidosObject::ExecuteMethod_stringRepresentation(EidosGlobalStringI Print(oss); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(oss.str())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(oss.str())); } EidosValue_SP EidosObject::ContextDefinedFunctionDispatch(const std::string &p_function_name, const std::vector &p_arguments, EidosInterpreter &p_interpreter) diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 4b33f1ac0..739ce7707 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -284,10 +284,10 @@ const std::vector &EidosInterpreter::BuiltInFunction signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("assert", Eidos_ExecuteFunction_assert, kEidosValueMaskVOID))->AddLogical("assertions")->AddString_OSN("message", gStaticEidosValueNULL)); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gEidosStr_apply, Eidos_ExecuteFunction_apply, kEidosValueMaskAny))->AddAny("x")->AddInt("margin")->AddString_S("lambdaSource")); - signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gEidosStr_sapply, Eidos_ExecuteFunction_sapply, kEidosValueMaskAny))->AddAny("x")->AddString_S("lambdaSource")->AddString_OS("simplify", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("vector")))); + signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gEidosStr_sapply, Eidos_ExecuteFunction_sapply, kEidosValueMaskAny))->AddAny("x")->AddString_S("lambdaSource")->AddString_OS("simplify", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("vector")))); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("beep", Eidos_ExecuteFunction_beep, kEidosValueMaskVOID))->AddString_OSN("soundName", gStaticEidosValueNULL)); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("citation", Eidos_ExecuteFunction_citation, kEidosValueMaskVOID))); - signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("clock", Eidos_ExecuteFunction_clock, kEidosValueMaskFloat | kEidosValueMaskSingleton))->AddString_OS("type", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("cpu")))); + signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("clock", Eidos_ExecuteFunction_clock, kEidosValueMaskFloat | kEidosValueMaskSingleton))->AddString_OS("type", EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("cpu")))); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("date", Eidos_ExecuteFunction_date, kEidosValueMaskString | kEidosValueMaskSingleton))); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("debugIndent", Eidos_ExecuteFunction_debugIndent, kEidosValueMaskString | kEidosValueMaskSingleton))); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("defineConstant", Eidos_ExecuteFunction_defineConstant, kEidosValueMaskVOID))->AddString_S("symbol")->AddAny("value")); @@ -313,7 +313,7 @@ const std::vector &EidosInterpreter::BuiltInFunction signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("sysinfo", Eidos_ExecuteFunction_sysinfo, kEidosValueMaskAny))->AddString_S("key")); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("system", Eidos_ExecuteFunction_system, kEidosValueMaskString))->AddString_S("command")->AddString_O("args", gStaticEidosValue_StringEmpty)->AddString_O("input", gStaticEidosValue_StringEmpty)->AddLogical_OS("stderr", gStaticEidosValue_LogicalF)->AddLogical_OS("wait", gStaticEidosValue_LogicalT)); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("time", Eidos_ExecuteFunction_time, kEidosValueMaskString | kEidosValueMaskSingleton))); - signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gEidosStr_usage, Eidos_ExecuteFunction_usage, kEidosValueMaskFloat | kEidosValueMaskSingleton))->AddArgWithDefault(kEidosValueMaskLogical | kEidosValueMaskString | kEidosValueMaskOptional | kEidosValueMaskSingleton, "type", nullptr, EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("rss")))); + signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gEidosStr_usage, Eidos_ExecuteFunction_usage, kEidosValueMaskFloat | kEidosValueMaskSingleton))->AddArgWithDefault(kEidosValueMaskLogical | kEidosValueMaskString | kEidosValueMaskOptional | kEidosValueMaskSingleton, "type", nullptr, EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("rss")))); signatures->emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("version", Eidos_ExecuteFunction_version, kEidosValueMaskFloat))->AddLogical_OS("print", gStaticEidosValue_LogicalT)); @@ -695,8 +695,8 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (highest_type == EidosValueType::kValueString) { - EidosValue_String_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(reserve_size); - EidosValue_String_vector_SP result_SP = EidosValue_String_vector_SP(result); + EidosValue_String *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(reserve_size); + EidosValue_String_SP result_SP = EidosValue_String_SP(result); for (int arg_index = 0; arg_index < argument_count; ++arg_index) { @@ -930,7 +930,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { // We have x_count != 1, so the type of x_value must be EidosValue_String_vector; we can use the fast API const std::string *string_vec = x_value->StringData(); - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); if (p_preserve_order) @@ -1103,8 +1103,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueString) { const std::string *first_child_vec = p_original_value->StringData(); - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) if (logical_index_data[value_idx]) @@ -1241,8 +1241,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa { // result type is string; optimize for that const std::string *first_child_vec = p_original_value->StringData(); - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(indices_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_colors.cpp b/eidos/eidos_functions_colors.cpp index 8d657ff35..d2566b8ad 100644 --- a/eidos/eidos_functions_colors.cpp +++ b/eidos/eidos_functions_colors.cpp @@ -47,7 +47,7 @@ EidosValue_SP Eidos_ExecuteFunction_cmColors(const std::vector &p EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_cmColors): cmColors() requires 0 <= n <= 100000." << EidosTerminate(nullptr); int color_count = (int)n; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -100,7 +100,7 @@ EidosValue_SP Eidos_ExecuteFunction_colors(const std::vector &p_a EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_colors): colors() requires 0 <= x <= 100000." << EidosTerminate(nullptr); int color_count = (int)x; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -117,7 +117,7 @@ EidosValue_SP Eidos_ExecuteFunction_colors(const std::vector &p_a else if (x_value->Type() == EidosValueType::kValueFloat) { int color_count = x_value->Count(); - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -185,7 +185,7 @@ EidosValue_SP Eidos_ExecuteFunction_heatColors(const std::vector EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_heatColors): heatColors() requires 0 <= n <= 100000." << EidosTerminate(nullptr); int color_count = (int)n; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -285,7 +285,7 @@ EidosValue_SP Eidos_ExecuteFunction_rainbow(const std::vector &p_ char hex_chars[8]; int color_count = (int)n; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); double r, g, b; @@ -329,12 +329,12 @@ EidosValue_SP Eidos_ExecuteFunction_rgb2color(const std::vector & Eidos_GetColorString(r, g, b, hex_chars); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(std::string(hex_chars))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(std::string(hex_chars))); } else { int color_count = rgb_count / 3; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < color_count; ++value_index) @@ -404,7 +404,7 @@ EidosValue_SP Eidos_ExecuteFunction_terrainColors(const std::vectorAllocateChunk()) EidosValue_String_vector())->Reserve(color_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(color_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < color_count; ++value_index) diff --git a/eidos/eidos_functions_files.cpp b/eidos/eidos_functions_files.cpp index 07fb74e80..a433c1987 100644 --- a/eidos/eidos_functions_files.cpp +++ b/eidos/eidos_functions_files.cpp @@ -116,7 +116,7 @@ EidosValue_SP Eidos_ExecuteFunction_filesAtPath(const std::vector if (dp != NULL) { - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); while (true) @@ -166,7 +166,7 @@ EidosValue_SP Eidos_ExecuteFunction_getwd(__attribute__((unused)) const std::vec EidosValue_SP result_SP(nullptr); std::string cwd = Eidos_CurrentDirectory(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(cwd)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(cwd)); return result_SP; } @@ -193,7 +193,7 @@ EidosValue_SP Eidos_ExecuteFunction_readFile(const std::vector &p } else { - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); std::string line; @@ -220,7 +220,7 @@ EidosValue_SP Eidos_ExecuteFunction_setwd(const std::vector &p_ar // Get the path; this code is identical to getwd() above, except it makes the value invisible std::string cwd = Eidos_CurrentDirectory(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(cwd)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(cwd)); result_SP->SetInvisible(true); // Now set the path @@ -240,7 +240,7 @@ EidosValue_SP Eidos_ExecuteFunction_setwd(const std::vector &p_ar // (string$)tempdir(void) EidosValue_SP Eidos_ExecuteFunction_tempdir(__attribute__((unused)) const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(Eidos_TemporaryDirectory())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(Eidos_TemporaryDirectory())); } // (logical$)flushFile(string$ filePath) @@ -433,7 +433,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vectorAllocateChunk()) EidosValue_String_singleton(file_path)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(file_path)); } } } @@ -479,7 +479,7 @@ EidosValue_SP Eidos_ExecuteFunction_writeTempFile(const std::vectorAllocateChunk()) EidosValue_String_singleton(file_path)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(file_path)); } } } diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 283cece34..a409ffff6 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -1161,7 +1161,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorAllocateChunk()) EidosValue_String_singleton(string0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string0)); } else if (arg_type == EidosValueType::kValueObject) { @@ -1211,7 +1211,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorAllocateChunk()) EidosValue_String_singleton(string0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string0)); } else if (arg_type == EidosValueType::kValueObject) { @@ -1265,7 +1265,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringRefAtIndex_NOCAST(0, nullptr); - EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + EidosValue_String *string_vector_obj = dynamic_cast(result_SP.get()); std::vector &string_vec = string_vector_obj->StringVectorData(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1366,7 +1366,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorStringData(); const std::string *string_vec1 = y_value->StringData(); - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1563,7 +1563,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorStringRefAtIndex_NOCAST(0, nullptr); if (string0 == string1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string0)); else result_SP = gStaticEidosValue_String_ZeroVec; } @@ -1720,7 +1720,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorStringData(); const std::string *string_vec1 = y_value->StringData(); - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1932,7 +1932,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorAllocateChunk()) EidosValue_String_vector{string0, string1}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String{string0, string1}); } else if (arg_type == EidosValueType::kValueObject) { @@ -2000,7 +2000,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorStringRefAtIndex_NOCAST(0, nullptr); - EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + EidosValue_String *string_vector_obj = dynamic_cast(result_SP.get()); std::vector &string_vec = string_vector_obj->StringVectorData(); int value_index; @@ -2154,7 +2154,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorStringData(); const std::string *string_vec1 = y_value->StringData(); - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); for (value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -2399,9 +2399,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p const std::string &string1 = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); if (string0 == string1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string0)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string0)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector{string0, string1}); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String{string0, string1}); } else if (arg_type == EidosValueType::kValueObject) { @@ -2483,7 +2483,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (scan_index == result_count) { - EidosValue_String_vector *string_vector_obj = dynamic_cast(result_SP.get()); + EidosValue_String *string_vector_obj = dynamic_cast(result_SP.get()); std::vector &string_vec = string_vector_obj->StringVectorData(); string_vec.emplace_back(value); diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index e8a3a8b28..2bcaad765 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -78,7 +78,7 @@ EidosValue_SP Eidos_ExecuteFunction_apply(const std::vector &p_ar // Get the lambda string and cache its script EidosValue *lambda_value = p_arguments[2].get(); - EidosValue_String_singleton *lambda_value_singleton = dynamic_cast(p_arguments[2].get()); + EidosValue_String *lambda_value_singleton = dynamic_cast(p_arguments[2].get()); EidosScript *script = (lambda_value_singleton ? lambda_value_singleton->CachedScript() : nullptr); // Errors in lambdas should be reported for the lambda script, not for the calling script, @@ -396,7 +396,7 @@ EidosValue_SP Eidos_ExecuteFunction_cbind(const std::vector &p_ar case EidosValueType::kValueLogical: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->reserve(result_length)); break; case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; - case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; + case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); break; case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(result_class))->reserve(result_length)); break; } @@ -914,7 +914,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbind(const std::vector &p_ar case EidosValueType::kValueLogical: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Logical())->reserve(result_length)); break; case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; - case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; + case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); break; case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(result_class))->reserve(result_length)); break; } diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 0b8475ca5..9d3c2e0ca 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -184,7 +184,7 @@ EidosValue_SP Eidos_ExecuteFunction_date(__attribute__((unused)) const std::vect localtime_r(&rawtime, &timeinfo); strftime(buffer, 25, "%d-%m-%Y", &timeinfo); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(std::string(buffer))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(std::string(buffer))); return result_SP; } @@ -193,7 +193,7 @@ EidosValue_SP Eidos_ExecuteFunction_date(__attribute__((unused)) const std::vect EidosValue_SP Eidos_ExecuteFunction_debugIndent(__attribute__((unused)) const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { #if DEBUG_POINTS_ENABLED - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(EidosDebugPointIndent::Indent())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(EidosDebugPointIndent::Indent())); #else return gStaticEidosValue_StringEmpty; #endif @@ -328,7 +328,7 @@ EidosValue_SP Eidos_ExecuteLambdaInternal(const std::vector &p_ar EidosValue_SP result_SP(nullptr); EidosValue *lambdaSource_value = p_arguments[0].get(); - EidosValue_String_singleton *lambdaSource_value_singleton = dynamic_cast(p_arguments[0].get()); + EidosValue_String *lambdaSource_value_singleton = dynamic_cast(p_arguments[0].get()); EidosScript *script = (lambdaSource_value_singleton ? lambdaSource_value_singleton->CachedScript() : nullptr); // Errors in lambdas should be reported for the lambda script, not for the calling script, @@ -375,7 +375,7 @@ EidosValue_SP Eidos_ExecuteLambdaInternal(const std::vector &p_ar } // Execute inside try/catch so we can handle errors well - EidosValue_String *timed_value = (EidosValue_String *)p_arguments[1].get(); + EidosValue *timed_value = p_arguments[1].get(); EidosValueType timed_value_type = timed_value->Type(); bool timed = false; int timer_type = 0; // cpu by default, for legacy reasons @@ -387,7 +387,7 @@ EidosValue_SP Eidos_ExecuteLambdaInternal(const std::vector &p_ar } else if (timed_value_type == EidosValueType::kValueString) { - const std::string &timed_string = timed_value->StringRefAtIndex_NOCAST(0, nullptr); + const std::string &timed_string = ((EidosValue_String *)timed_value)->StringRefAtIndex_NOCAST(0, nullptr); if (timed_string == "cpu") { @@ -1138,7 +1138,7 @@ EidosValue_SP Eidos_ExecuteFunction_sapply(const std::vector &p_a // Get the lambda string and cache its script EidosValue *lambda_value = p_arguments[1].get(); - EidosValue_String_singleton *lambda_value_singleton = dynamic_cast(p_arguments[1].get()); + EidosValue_String *lambda_value_singleton = dynamic_cast(p_arguments[1].get()); EidosScript *script = (lambda_value_singleton ? lambda_value_singleton->CachedScript() : nullptr); // Errors in lambdas should be reported for the lambda script, not for the calling script, @@ -1339,11 +1339,11 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ if (key == "os") { #if defined(__APPLE__) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("macOS")); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("macOS")); #elif defined(_WIN32) || (_WIN64) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("Windows")); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("Windows")); #else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("Unix")); // assumed if we are not macOS or Windows + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("Unix")); // assumed if we are not macOS or Windows #endif } else if (key == "sysname") @@ -1352,7 +1352,7 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ int ret = uname(&name); if (ret == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name.sysname)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name.sysname)); } else if (key == "release") { @@ -1360,7 +1360,7 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ int ret = uname(&name); if (ret == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name.release)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name.release)); } else if (key == "version") { @@ -1368,7 +1368,7 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ int ret = uname(&name); if (ret == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name.version)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name.version)); } else if (key == "nodename") { @@ -1376,7 +1376,7 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ int ret = uname(&name); if (ret == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name.nodename)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name.nodename)); } else if (key == "machine") { @@ -1384,7 +1384,7 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ int ret = uname(&name); if (ret == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name.machine)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name.machine)); } #if 0 // "login" doesn't work on Windows, and "user" doesn't work on both Windows and Ubuntu 18.04; disabling both for now, nobody has asked for them anyway @@ -1393,7 +1393,7 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ char *name = getlogin(); if (name) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(name)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(name)); } else if (key == "user") { @@ -1401,12 +1401,12 @@ EidosValue_SP Eidos_ExecuteFunction_sysinfo(const std::vector &p_ struct passwd *pwd = getpwuid(uid); if (pwd && pwd->pw_name) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(pwd->pw_name)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(pwd->pw_name)); } #endif // if we fall through the here, the value is unknown - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("unknown")); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("unknown")); } // (string)system(string$ command, [string args = ""], [string input = ""], [logical$ stderr = F], [logical$ wait = T]) @@ -1524,7 +1524,7 @@ EidosValue_SP Eidos_ExecuteFunction_system(const std::vector &p_a // Parse the result into lines and make a result vector std::istringstream result_stream(result); - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); std::string line; @@ -1561,7 +1561,7 @@ EidosValue_SP Eidos_ExecuteFunction_time(__attribute__((unused)) const std::vect localtime_r(&rawtime, &timeinfo); strftime(buffer, 20, "%H:%M:%S", &timeinfo); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(std::string(buffer))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(std::string(buffer))); return result_SP; } diff --git a/eidos/eidos_functions_stats.cpp b/eidos/eidos_functions_stats.cpp index bad4d985a..521698ff1 100644 --- a/eidos/eidos_functions_stats.cpp +++ b/eidos/eidos_functions_stats.cpp @@ -309,7 +309,7 @@ EidosValue_SP Eidos_ExecuteFunction_max(const std::vector &p_argu } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(*max)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(*max)); } return result_SP; @@ -515,7 +515,7 @@ EidosValue_SP Eidos_ExecuteFunction_min(const std::vector &p_argu } } - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(*min)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(*min)); } return result_SP; @@ -642,7 +642,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg { const std::string *string0_vec = x_value->StringData(); const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -704,7 +704,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmax(const std::vector &p_arg { const std::string *string0_vec = x_value->StringData(); const std::string *string1_vec = y_value->StringData(); - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -830,7 +830,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg { const std::string *string0_vec = x_value->StringData(); const std::string &y_singleton_value = ((EidosValue_String *)y_value)->StringRefAtIndex_NOCAST(0, nullptr); - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -892,7 +892,7 @@ EidosValue_SP Eidos_ExecuteFunction_pmin(const std::vector &p_arg { const std::string *string0_vec = x_value->StringData(); const std::string *string1_vec = y_value->StringData(); - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < x_count; ++value_index) diff --git a/eidos/eidos_functions_strings.cpp b/eidos/eidos_functions_strings.cpp index 7d2be7892..ff42cda62 100644 --- a/eidos/eidos_functions_strings.cpp +++ b/eidos/eidos_functions_strings.cpp @@ -93,7 +93,7 @@ EidosValue_SP Eidos_ExecuteFunction_grep(const std::vector &p_arg EidosValue_SP result_SP(nullptr); EidosValue_Logical *result_logical = nullptr; EidosValue_Int *result_int = nullptr; - EidosValue_String_vector *result_string = nullptr; + EidosValue_String *result_string = nullptr; if (value_enum == kIndices) { @@ -102,7 +102,7 @@ EidosValue_SP Eidos_ExecuteFunction_grep(const std::vector &p_arg } else if ((value_enum == kElements) || (value_enum == kMatches)) { - result_string = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); + result_string = (new (gEidosValuePool->AllocateChunk()) EidosValue_String()); result_SP = EidosValue_SP(result_string); } else if (value_enum == kLogical) @@ -390,7 +390,7 @@ EidosValue_SP Eidos_ExecuteFunction_strsplit(const std::vector &p EidosValue_String *x_value = (EidosValue_String *)p_arguments[0].get(); EidosValue_String *sep_value = (EidosValue_String *)p_arguments[1].get(); - EidosValue_String_vector *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(); + EidosValue_String *string_result = new (gEidosValuePool->AllocateChunk()) EidosValue_String(); result_SP = EidosValue_SP(string_result); const std::string &joined_string = x_value->StringRefAtIndex_NOCAST(0, nullptr); @@ -510,9 +510,9 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (clamped_last >= len) clamped_last = (int)len - 1; if ((clamped_first >= len) || (clamped_last < 0) || (clamped_first > clamped_last)) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_empty_string)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_empty_string)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string_value.substr(clamped_first, clamped_last - clamped_first + 1))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string_value.substr(clamped_first, clamped_last - clamped_first + 1))); } else { @@ -522,9 +522,9 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (clamped_first < 0) clamped_first = 0; if (clamped_first >= len) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_empty_string)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_empty_string)); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(string_value.substr(clamped_first, len))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(string_value.substr(clamped_first, len))); } } else @@ -537,7 +537,7 @@ EidosValue_SP Eidos_ExecuteFunction_substr(const std::vector &p_a if (!first_singleton && (arg_first_count != x_count)) EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_substr): function substr() requires the size of first to be 1, or equal to the size of x." << EidosTerminate(nullptr); - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); int64_t first0 = arg_first->IntAtIndex_NOCAST(0, nullptr); diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index b21c11313..4d1a18fad 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -1093,7 +1093,7 @@ EidosValue_SP Eidos_ExecuteFunction_string(const std::vector &p_a if (element_count == 0) return gStaticEidosValue_String_ZeroVec; - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve((int)element_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve((int)element_count); result_SP = EidosValue_SP(string_result); for (int64_t value_index = element_count; value_index > 0; --value_index) @@ -1442,12 +1442,12 @@ EidosValue_SP Eidos_ExecuteFunction_format(const std::vector &p_a else if (x_type == EidosValueType::kValueFloat) result_string = EidosStringFormat(format, x_value->FloatAtIndex_NOCAST(0, nullptr)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(result_string)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(result_string)); } else { // non-singleton x vector, with a singleton format vector - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); if (x_type == EidosValueType::kValueInt) @@ -1540,8 +1540,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a { const std::string *true_vec = trueValues_value->StringData(); const std::string *false_vec = falseValues_value->StringData(); - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(test_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(test_count); for (int value_index = 0; value_index < test_count; ++value_index) string_result->PushString(logical_vec[value_index] ? true_vec[value_index] : false_vec[value_index]); @@ -1637,8 +1637,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a { const std::string &true_value = ((EidosValue_String *)trueValues_value)->StringRefAtIndex_NOCAST(0, nullptr); const std::string &false_value = ((EidosValue_String *)falseValues_value)->StringRefAtIndex_NOCAST(0, nullptr); - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(test_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(test_count); for (int value_index = 0; value_index < test_count; ++value_index) string_result->PushString(logical_vec[value_index] ? true_value : false_value); @@ -2206,7 +2206,7 @@ EidosValue_SP Eidos_ExecuteFunction_paste(const std::vector &p_ar } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(result_string)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(result_string)); } // (string$)paste0(...) @@ -2239,7 +2239,7 @@ EidosValue_SP Eidos_ExecuteFunction_paste0(const std::vector &p_a } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(result_string)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(result_string)); } // (void)print(* x, [logical$ error = F]) @@ -2997,15 +2997,15 @@ EidosValue_SP Eidos_ExecuteFunction_asString(const std::vector &p if ((x_count == 0) && (x_value->Type() == EidosValueType::kValueNULL)) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_NULL)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_NULL)); } else if (x_count == 1) { - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(x_value->StringAtIndex_CAST(0, nullptr))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(x_value->StringAtIndex_CAST(0, nullptr))); } else { - EidosValue_String_vector *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector())->Reserve(x_count); + EidosValue_String *string_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_String())->Reserve(x_count); result_SP = EidosValue_SP(string_result); for (int value_index = 0; value_index < x_count; ++value_index) @@ -3026,7 +3026,7 @@ EidosValue_SP Eidos_ExecuteFunction_elementType(const std::vector EidosValue *x_value = p_arguments[0].get(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(x_value->ElementType())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(x_value->ElementType())); return result_SP; } @@ -3130,7 +3130,7 @@ EidosValue_SP Eidos_ExecuteFunction_type(const std::vector &p_arg EidosValue *x_value = p_arguments[0].get(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(StringForEidosValueType(x_value->Type()))); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(StringForEidosValueType(x_value->Type()))); return result_SP; } diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index 049d09fbf..071e852c0 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1081,8 +1081,6 @@ void Eidos_WarmUp(void) size_t maxEidosValueSize = sizeof(EidosValue_NULL); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Logical)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String_vector)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_String_singleton)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object)); @@ -1091,8 +1089,6 @@ void Eidos_WarmUp(void) // std::cout << "sizeof(EidosValue_NULL) == " << sizeof(EidosValue_NULL) << std::endl; // std::cout << "sizeof(EidosValue_Logical) == " << sizeof(EidosValue_Logical) << std::endl; // std::cout << "sizeof(EidosValue_String) == " << sizeof(EidosValue_String) << std::endl; -// std::cout << "sizeof(EidosValue_String_vector) == " << sizeof(EidosValue_String_vector) << std::endl; -// std::cout << "sizeof(EidosValue_String_singleton) == " << sizeof(EidosValue_String_singleton) << std::endl; // std::cout << "sizeof(EidosValue_Int) == " << sizeof(EidosValue_Int) << std::endl; // std::cout << "sizeof(EidosValue_Float) == " << sizeof(EidosValue_Float) << std::endl; // std::cout << "sizeof(EidosValue_Object) == " << sizeof(EidosValue_Object) << std::endl; @@ -1130,7 +1126,7 @@ void Eidos_WarmUp(void) gStaticEidosValue_Float_ZeroVec = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float()); gStaticEidosValue_Float_ZeroVec->MarkAsConstant(); - gStaticEidosValue_String_ZeroVec = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); + gStaticEidosValue_String_ZeroVec = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); gStaticEidosValue_String_ZeroVec->MarkAsConstant(); gStaticEidosValue_Integer0 = EidosValue_Int_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(0)); @@ -1169,34 +1165,34 @@ void Eidos_WarmUp(void) gStaticEidosValue_FloatPI = EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(M_PI)); gStaticEidosValue_FloatPI->MarkAsConstant(); - gStaticEidosValue_StringEmpty = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("")); + gStaticEidosValue_StringEmpty = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("")); gStaticEidosValue_StringEmpty->MarkAsConstant(); - gStaticEidosValue_StringSpace = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(" ")); + gStaticEidosValue_StringSpace = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(" ")); gStaticEidosValue_StringSpace->MarkAsConstant(); - gStaticEidosValue_StringAsterisk = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("*")); + gStaticEidosValue_StringAsterisk = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("*")); gStaticEidosValue_StringAsterisk->MarkAsConstant(); - gStaticEidosValue_StringDoubleAsterisk = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("**")); + gStaticEidosValue_StringDoubleAsterisk = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("**")); gStaticEidosValue_StringDoubleAsterisk->MarkAsConstant(); - gStaticEidosValue_StringComma = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(",")); + gStaticEidosValue_StringComma = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(",")); gStaticEidosValue_StringComma->MarkAsConstant(); - gStaticEidosValue_StringPeriod = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(".")); + gStaticEidosValue_StringPeriod = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(".")); gStaticEidosValue_StringPeriod->MarkAsConstant(); - gStaticEidosValue_StringDoubleQuote = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("\"")); + gStaticEidosValue_StringDoubleQuote = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("\"")); gStaticEidosValue_StringDoubleQuote->MarkAsConstant(); - gStaticEidosValue_String_ECMAScript = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("ECMAScript")); + gStaticEidosValue_String_ECMAScript = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("ECMAScript")); gStaticEidosValue_String_ECMAScript->MarkAsConstant(); - gStaticEidosValue_String_indices = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("indices")); + gStaticEidosValue_String_indices = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("indices")); gStaticEidosValue_String_indices->MarkAsConstant(); - gStaticEidosValue_String_average = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton("average")); + gStaticEidosValue_String_average = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String("average")); gStaticEidosValue_String_average->MarkAsConstant(); // Create the global class objects for all Eidos classes, from superclass to subclass diff --git a/eidos/eidos_globals.h b/eidos/eidos_globals.h index f2a3b0939..de6c851c5 100644 --- a/eidos/eidos_globals.h +++ b/eidos/eidos_globals.h @@ -1189,8 +1189,6 @@ class EidosValue_Logical; class EidosValue_Int; class EidosValue_Float; class EidosValue_String; -class EidosValue_String_singleton; -class EidosValue_String_vector; class EidosValue_Object; class EidosObjectPool; @@ -1224,8 +1222,6 @@ typedef Eidos_intrusive_ptr EidosValue_Logical_SP; typedef Eidos_intrusive_ptr EidosValue_Int_SP; typedef Eidos_intrusive_ptr EidosValue_Float_SP; typedef Eidos_intrusive_ptr EidosValue_String_SP; -typedef Eidos_intrusive_ptr EidosValue_String_singleton_SP; -typedef Eidos_intrusive_ptr EidosValue_String_vector_SP; typedef Eidos_intrusive_ptr EidosValue_Object_SP; diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 04eb0375e..db79226f8 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -1997,14 +1997,14 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) const std::string &&first_string = (first_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : first_child_value->StringAtIndex_CAST(0, operator_token); const std::string &&second_string = (second_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : second_child_value->StringAtIndex_CAST(0, operator_token); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(first_string + second_string)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(first_string + second_string)); } else { if (first_child_count == second_child_count) { - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(first_child_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) string_result->PushString(first_child_value->StringAtIndex_CAST(value_index, operator_token) + second_child_value->StringAtIndex_CAST(value_index, operator_token)); @@ -2014,8 +2014,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (first_child_count == 1) { std::string singleton_string = (first_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : first_child_value->StringAtIndex_CAST(0, operator_token); - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(second_child_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(second_child_count); for (int value_index = 0; value_index < second_child_count; ++value_index) string_result->PushString(singleton_string + second_child_value->StringAtIndex_CAST(value_index, operator_token)); @@ -2025,8 +2025,8 @@ EidosValue_SP EidosInterpreter::Evaluate_Plus(const EidosASTNode *p_node) else if (second_child_count == 1) { std::string singleton_string = (second_child_type == EidosValueType::kValueNULL) ? gEidosStr_NULL : second_child_value->StringAtIndex_CAST(0, operator_token); - EidosValue_String_vector_SP string_result_SP = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - EidosValue_String_vector *string_result = string_result_SP->Reserve(first_child_count); + EidosValue_String_SP string_result_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); + EidosValue_String *string_result = string_result_SP->Reserve(first_child_count); for (int value_index = 0; value_index < first_child_count; ++value_index) string_result->PushString(first_child_value->StringAtIndex_CAST(value_index, operator_token) + singleton_string); @@ -5236,7 +5236,7 @@ EidosValue_SP EidosInterpreter::Evaluate_String(const EidosASTNode *p_node) if (!result_SP) { // CODE COVERAGE: This is dead code - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(p_node->token_->token_string_)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(p_node->token_->token_string_)); } EIDOS_EXIT_EXECUTION_LOG("Evaluate_String()"); @@ -5921,14 +5921,14 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) else if (range_type == EidosValueType::kValueString) { const std::string *range_vec = range_value->StringData(); - EidosValue_String_singleton_SP index_value_SP = EidosValue_String_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(gEidosStr_empty_string)); - EidosValue_String_singleton *index_value = index_value_SP.get(); + EidosValue_String_SP index_value_SP = EidosValue_String_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(gEidosStr_empty_string)); + EidosValue_String *index_value = index_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(identifier_name, index_value_SP); for (int range_index = 0; range_index < range_count; ++range_index) { - index_value->SetValue(range_vec[range_index]); + index_value->StringVectorData()[0] = range_vec[range_index]; EidosASTNode *statement_node = p_node->children_[2]; diff --git a/eidos/eidos_test.cpp b/eidos/eidos_test.cpp index 21888a9fa..5f0af2bf4 100644 --- a/eidos/eidos_test.cpp +++ b/eidos/eidos_test.cpp @@ -191,12 +191,12 @@ void EidosAssertScriptSuccess_FV(const std::string &p_script_string, std::initia void EidosAssertScriptSuccess_S(const std::string &p_script_string, const char *p_string) { - EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(p_string))); + EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(p_string))); } void EidosAssertScriptSuccess_SV(const std::string &p_script_string, std::initializer_list p_string_vec) { - EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(p_string_vec))); + EidosAssertScriptSuccess(p_script_string, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(p_string_vec))); } // Instantiates and runs the script, and prints an error if the script does not cause an exception to be raised diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index cce2547f5..92cdf285c 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1174,6 +1174,22 @@ void EidosValue_Logical::erase_index(size_t p_index) #pragma mark EidosValue_String #pragma mark - +EidosValue_String::EidosValue_String(const std::vector &p_stringvec) : EidosValue(EidosValueType::kValueString, false), values_(p_stringvec) +{ +} + +EidosValue_String::EidosValue_String(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueString, false) +{ + for (const auto &init_item : p_init_list) + values_.emplace_back(init_item); +} + +EidosValue_String::EidosValue_String(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueString, false) +{ + for (const auto &init_item : p_init_list) + values_.emplace_back(init_item); +} + const std::string &EidosValue_String::ElementType(void) const { return gEidosStr_string; @@ -1181,7 +1197,7 @@ const std::string &EidosValue_String::ElementType(void) const EidosValue_SP EidosValue_String::NewMatchingType(void) const { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String()); } void EidosValue_String::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const @@ -1203,62 +1219,42 @@ nlohmann::json EidosValue_String::JSONRepresentation(void) const return json_object; } - -// EidosValue_String_vector -#pragma mark EidosValue_String_vector - -EidosValue_String_vector::EidosValue_String_vector(const std::vector &p_stringvec) : EidosValue_String(false), values_(p_stringvec) -{ -} - -EidosValue_String_vector::EidosValue_String_vector(std::initializer_list p_init_list) : EidosValue_String(false) -{ - for (const auto &init_item : p_init_list) - values_.emplace_back(init_item); -} - -EidosValue_String_vector::EidosValue_String_vector(std::initializer_list p_init_list) : EidosValue_String(false) -{ - for (const auto &init_item : p_init_list) - values_.emplace_back(init_item); -} - -std::string EidosValue_String_vector::StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_String::StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::StringAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -const std::string &EidosValue_String_vector::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +const std::string &EidosValue_String::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringRefAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::StringRefAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -eidos_logical_t EidosValue_String_vector::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +eidos_logical_t EidosValue_String::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return (values_[p_idx].length() > 0); } -std::string EidosValue_String_vector::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +std::string EidosValue_String::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -int64_t EidosValue_String_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +int64_t EidosValue_String::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); // We don't use IntForString because an integer has been specifically requested, so even if the string appears to contain a // float value we want to force it into being an int; the way to do that is to use FloatForString and then convert to int64_t @@ -1266,153 +1262,63 @@ int64_t EidosValue_String_vector::IntAtIndex_CAST(int p_idx, const EidosToken *p // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... if ((converted_value < (double)INT64_MIN) || (converted_value >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::IntAtIndex_CAST): '" << values_[p_idx] << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::IntAtIndex_CAST): '" << values_[p_idx] << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); return static_cast(converted_value); } -double EidosValue_String_vector::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +double EidosValue_String::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return EidosInterpreter::FloatForString(values_[p_idx], p_blame_token); } -EidosValue_SP EidosValue_String_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const +EidosValue_SP EidosValue_String::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)values_.size())) - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(values_[p_idx])); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String(values_[p_idx])); } -EidosValue_SP EidosValue_String_vector::CopyValues(void) const +EidosValue_SP EidosValue_String::CopyValues(void) const { // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector(values_))->CopyDimensionsFromValue(this)); + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String(values_))->CopyDimensionsFromValue(this)); +} + +EidosValue_SP EidosValue_String::VectorBasedCopy(void) const +{ + // same as CopyValues() now; slated for removal + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String(values_))->CopyDimensionsFromValue(this)); } -void EidosValue_String_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) +void EidosValue_String::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); + UncacheScript(); if (p_source_script_value.Type() == EidosValueType::kValueString) values_.emplace_back(p_source_script_value.StringAtIndex_NOCAST(p_idx, p_blame_token)); else - EIDOS_TERMINATION << "ERROR (EidosValue_String_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_String::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); } -void EidosValue_String_vector::Sort(bool p_ascending) +void EidosValue_String::Sort(bool p_ascending) { WILL_MODIFY(this); + UncacheScript(); + + if (values_.size() < 2) + return; // This will sort in parallel if the task is large enough (and we're running parallel) Eidos_ParallelSort(values_.data(), values_.size(), p_ascending); } -// EidosValue_String_singleton -#pragma mark EidosValue_String_singleton - -std::string EidosValue_String_singleton::StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -const std::string &EidosValue_String_singleton::StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringRefAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -eidos_logical_t EidosValue_String_singleton::LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::LogicalAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return (value_.length() > 0); -} - -std::string EidosValue_String_singleton::StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::StringAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -int64_t EidosValue_String_singleton::IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - // We don't use IntForString because an integer has been specifically requested, so even if the string appears to contain a - // float value we want to force it into being an int; the way to do that is to use FloatForString and then convert to int64_t - double converted_value = EidosInterpreter::FloatForString(value_, p_blame_token); - - // nwellnhof on stackoverflow points out that the >= here is correct even though it looks wrong, because reasons... - if ((converted_value < (double)INT64_MIN) || (converted_value >= (double)INT64_MAX)) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::IntAtIndex_CAST): '" << value_ << "' could not be represented as an integer (out of range)." << EidosTerminate(p_blame_token); - - return static_cast(converted_value); -} - -double EidosValue_String_singleton::FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::FloatAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosInterpreter::FloatForString(value_, p_blame_token); -} - -EidosValue_SP EidosValue_String_singleton::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(value_)); -} - -EidosValue_SP EidosValue_String_singleton::CopyValues(void) const -{ - // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(value_))->CopyDimensionsFromValue(this)); -} - -EidosValue_SP EidosValue_String_singleton::VectorBasedCopy(void) const -{ - // note that constness, invisibility, etc. do not get copied - EidosValue_String_vector_SP new_vec = EidosValue_String_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); - - new_vec->PushString(value_); - new_vec->CopyDimensionsFromValue(this); - - return new_vec; -} - -void EidosValue_String_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_source_script_value) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_String_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - -void EidosValue_String_singleton::Sort(bool p_ascending) -{ -#pragma unused(p_ascending) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_String_singleton::Sort): (internal error) EidosValue_String_singleton is not modifiable." << EidosTerminate(nullptr); -} - - // // EidosValue_Int // diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 4ddd36382..39c2335f2 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -551,108 +551,47 @@ class EidosValue_Logical final : public EidosValue // EidosValue_String_singleton is used for speed, to represent single values. // -class EidosValue_String : public EidosValue +class EidosValue_String final : public EidosValue { private: typedef EidosValue super; -protected: - explicit inline EidosValue_String(bool p_singleton) : EidosValue(EidosValueType::kValueString, p_singleton) {} - - virtual int Count_Virtual(void) const override = 0; - -public: - EidosValue_String(const EidosValue_String &p_original) = delete; // no copy-construct - EidosValue_String(void) = delete; // no default constructor - EidosValue_String& operator=(const EidosValue_String&) = delete; // no copying - inline virtual ~EidosValue_String(void) override { } - - virtual const std::string &ElementType(void) const override; - virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; - virtual nlohmann::json JSONRepresentation(void) const override; - - virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const = 0; // const reference for speed - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - - virtual EidosValue_SP CopyValues(void) const override = 0; - virtual EidosValue_SP NewMatchingType(void) const override; - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override = 0; - virtual void Sort(bool p_ascending) override = 0; -}; - -class EidosValue_String_vector final : public EidosValue_String -{ -private: - typedef EidosValue_String super; - protected: // this is not converted to a malloced buffer because unlike the other types, we can't get away with // not initializing the memory belonging to a std::string, so the malloc strategy doesn't work + // for the same reason, we do not use the singleton/vector design here; string is not a bottleneck anyway std::vector values_; + EidosScript *cached_script_ = nullptr; // cached by executeLambda(), apply(), and sapply() to avoid multiple tokenize/parse overhead + + inline void UncacheScript(void) { if (cached_script_) { delete cached_script_; cached_script_ = nullptr; } } + virtual int Count_Virtual(void) const override { return (int)values_.size(); } public: - EidosValue_String_vector(const EidosValue_String_vector &p_original) = delete; // no copy-construct - EidosValue_String_vector& operator=(const EidosValue_String_vector&) = delete; // no copying - - inline EidosValue_String_vector(void) : EidosValue_String(false) { } - explicit EidosValue_String_vector(const std::vector &p_stringvec); - EidosValue_String_vector(double *p_doublebuf, int p_buffer_length); - //explicit EidosValue_String_vector(const std::string &p_string1); // disabled to encourage use of EidosValue_String_singleton for this case - explicit EidosValue_String_vector(std::initializer_list p_init_list); - explicit EidosValue_String_vector(std::initializer_list p_init_list); - inline virtual ~EidosValue_String_vector(void) override { } + EidosValue_String(const EidosValue_String &p_original) = delete; // no copy-construct + EidosValue_String& operator=(const EidosValue_String&) = delete; // no copying + inline EidosValue_String(void) : EidosValue(EidosValueType::kValueString, false) { } + explicit EidosValue_String(const std::string &p_string1) : EidosValue(EidosValueType::kValueString, false), values_({p_string1}) { } + explicit EidosValue_String(const std::vector &p_stringvec); + explicit EidosValue_String(std::initializer_list p_init_list); + explicit EidosValue_String(std::initializer_list p_init_list); + inline virtual ~EidosValue_String(void) override { delete cached_script_; } virtual const std::string *StringData(void) const override { return values_.data(); } - virtual std::string *StringData_Mutable(void) override { WILL_MODIFY(this); return values_.data(); } - std::vector &StringVectorData(void) { WILL_MODIFY(this); return values_; } // to get the std::vector for direct modification - - inline __attribute__((always_inline)) void PushString(const std::string &p_string) { WILL_MODIFY(this); values_.emplace_back(p_string); } - inline __attribute__((always_inline)) EidosValue_String_vector *Reserve(int p_reserved_size) { WILL_MODIFY(this); values_.reserve(p_reserved_size); return this; } - - virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual int64_t IntAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual double FloatAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual std::string *StringData_Mutable(void) override { WILL_MODIFY(this); UncacheScript(); return values_.data(); } + std::vector &StringVectorData(void) { WILL_MODIFY(this); UncacheScript(); return values_; } // to get the std::vector for direct modification - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosValue_SP CopyValues(void) const override; - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; - virtual void Sort(bool p_ascending) override; -}; - -class EidosValue_String_singleton final : public EidosValue_String -{ -private: - typedef EidosValue_String super; - -protected: - std::string value_; - EidosScript *cached_script_ = nullptr; // cached by executeLambda(), apply(), and sapply() to avoid multiple tokenize/parse overhead - - virtual int Count_Virtual(void) const override { return 1; } - -public: - EidosValue_String_singleton(const EidosValue_String_singleton &p_original) = delete; // no copy-construct - EidosValue_String_singleton& operator=(const EidosValue_String_singleton&) = delete; // no copying - EidosValue_String_singleton(void) = delete; - explicit inline EidosValue_String_singleton(const std::string &p_string1) : EidosValue_String(true), value_(p_string1) { } - inline virtual ~EidosValue_String_singleton(void) override { delete cached_script_; } - - inline __attribute__((always_inline)) std::string &StringValue_Mutable(void) { WILL_MODIFY(this); delete cached_script_; cached_script_ = nullptr; return value_; } // very dangerous; do not use + virtual const std::string &ElementType(void) const override; + virtual EidosValue_SP NewMatchingType(void) const override; + virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; + virtual nlohmann::json JSONRepresentation(void) const override; - virtual const std::string *StringData(void) const override { return &value_; } - virtual std::string *StringData_Mutable(void) override { WILL_MODIFY(this); delete cached_script_; cached_script_ = nullptr; return &value_; } // very dangerous; do not use - inline __attribute__((always_inline)) void SetValue(const std::string &p_string) { WILL_MODIFY(this); delete cached_script_; cached_script_ = nullptr; value_ = p_string; } // very dangerous; used only in Evaluate_For() + inline __attribute__((always_inline)) void PushString(const std::string &p_string) { WILL_MODIFY(this); UncacheScript(); values_.emplace_back(p_string); } + inline __attribute__((always_inline)) EidosValue_String *Reserve(int p_reserved_size) { WILL_MODIFY(this); values_.reserve(p_reserved_size); return this; } virtual std::string StringAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; + virtual const std::string &StringRefAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const; virtual eidos_logical_t LogicalAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; virtual std::string StringAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; @@ -661,14 +600,11 @@ class EidosValue_String_singleton final : public EidosValue_String virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; - virtual EidosValue_SP VectorBasedCopy(void) const override; - - // prohibited actions because there is no backing vector virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; - // script caching; this is something that only EidosValue_String_singleton does! + // script caching; this is used only for singleton strings that are used as lambdas inline __attribute__((always_inline)) EidosScript *CachedScript(void) { return cached_script_; } inline __attribute__((always_inline)) void SetCachedScript(EidosScript *p_script) { cached_script_ = p_script; } }; From 07ec4e0ab0587931a0bca9a6ae5920df78110b99 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 15:31:37 -0500 Subject: [PATCH 16/18] remove VectorBasedCopy(), no longer needed --- eidos/eidos_functions.cpp | 13 +++++-------- eidos/eidos_functions.h | 2 +- eidos/eidos_functions_math.cpp | 18 +++++++++--------- eidos/eidos_functions_values.cpp | 2 +- eidos/eidos_value.cpp | 30 ------------------------------ eidos/eidos_value.h | 5 ----- 6 files changed, 16 insertions(+), 54 deletions(-) diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 739ce7707..505b4d830 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -776,7 +776,7 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen return EidosValue_SP(nullptr); } -EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vector, bool p_preserve_order) +EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_preserve_order) { EidosValue_SP result_SP(nullptr); @@ -790,10 +790,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec } else if (x_count == 1) { - if (p_force_new_vector) - result_SP = x_value->VectorBasedCopy(); - else - result_SP = x_value->CopyValues(); + result_SP = x_value->CopyValues(); } else if (x_type == EidosValueType::kValueLogical) { @@ -826,11 +823,11 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec } if (containsF && !containsT) - result_SP = (p_force_new_vector ? EidosValue_SP(gStaticEidosValue_LogicalF->VectorBasedCopy()) : (EidosValue_SP)gStaticEidosValue_LogicalF); + result_SP = (EidosValue_SP)gStaticEidosValue_LogicalF; else if (containsT && !containsF) - result_SP = (p_force_new_vector ? EidosValue_SP(gStaticEidosValue_LogicalT->VectorBasedCopy()) : (EidosValue_SP)gStaticEidosValue_LogicalT); + result_SP = (EidosValue_SP)gStaticEidosValue_LogicalT; else if (!containsT && !containsF) - result_SP = (p_force_new_vector ? EidosValue_SP(gStaticEidosValue_Logical_ZeroVec->VectorBasedCopy()) : (EidosValue_SP)gStaticEidosValue_Logical_ZeroVec); + result_SP = (EidosValue_SP)gStaticEidosValue_Logical_ZeroVec; else // containsT && containsF { // In this case, we need to be careful to preserve the order of occurrence diff --git a/eidos/eidos_functions.h b/eidos/eidos_functions.h index 7265bc433..34aa06ac1 100644 --- a/eidos/eidos_functions.h +++ b/eidos/eidos_functions.h @@ -32,7 +32,7 @@ // Utility functions usable by everybody bool IdenticalEidosValues(EidosValue *x_value, EidosValue *y_value, bool p_compare_dimensions = true); EidosValue_SP ConcatenateEidosValues(const std::vector &p_arguments, bool p_allow_null, bool p_allow_void); -EidosValue_SP UniqueEidosValue(const EidosValue *p_value, bool p_force_new_vector, bool p_preserve_order); +EidosValue_SP UniqueEidosValue(const EidosValue *p_value, bool p_preserve_order); EidosValue_SP Eidos_ExecuteLambdaInternal(const std::vector &p_arguments, EidosInterpreter &p_interpreter, bool p_execute_in_outer_scope); EidosValue_SP SubsetEidosValue(const EidosValue *p_value, const EidosValue *p_indices, EidosToken *p_error_token, bool p_raise_range_errors); diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index a409ffff6..d9bb9eee6 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -1056,7 +1056,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorCount(); @@ -1828,11 +1828,11 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vector 1, y_count == 1 - result_SP = UniqueEidosValue(x_value, true, true); + result_SP = UniqueEidosValue(x_value, true); int result_count = result_SP->Count(); @@ -2365,12 +2365,12 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p else if (x_count == 0) { // x is zero-length, y is >1, so we just need to unique y - result_SP = UniqueEidosValue(y_value, false, true); + result_SP = UniqueEidosValue(y_value, true); } else if (y_count == 0) { // y is zero-length, x is >1, so we just need to unique x - result_SP = UniqueEidosValue(x_value, false, true); + result_SP = UniqueEidosValue(x_value, true); } else if ((x_count == 1) && (y_count == 1)) { @@ -2424,7 +2424,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p } // now x_count > 1, y_count == 1 - result_SP = UniqueEidosValue(x_value, true, true); + result_SP = UniqueEidosValue(x_value, true); int result_count = result_SP->Count(); @@ -2516,7 +2516,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p // This code might look slow, but really the uniquing is O(N^2) and everything else is O(N), so since // we are in the vector/vector case here, it really isn't worth worrying about optimizing the O(N) part. result_SP = ConcatenateEidosValues(p_arguments, false, false); // no NULL, no VOID - result_SP = UniqueEidosValue(result_SP.get(), false, true); + result_SP = UniqueEidosValue(result_SP.get(), true); } return result_SP; diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 4d1a18fad..b7ffec6d8 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -2695,7 +2695,7 @@ EidosValue_SP Eidos_ExecuteFunction_unique(const std::vector &p_a { // Note that this function ignores matrix/array attributes, and always returns a vector, by design - return UniqueEidosValue(p_arguments[0].get(), false, p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr)); + return UniqueEidosValue(p_arguments[0].get(), p_arguments[1]->LogicalAtIndex_NOCAST(0, nullptr)); } // (integer)which(logical x) diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 92cdf285c..d2021808f 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -394,12 +394,6 @@ void EidosValue::RaiseForRetainReleaseViolation(void) const EIDOS_TERMINATION << "ERROR (EidosValue::RaiseForRetainReleaseViolation): (internal error) access violated the retain/release policy of an EidosValue." << EidosTerminate(nullptr); } -EidosValue_SP EidosValue::VectorBasedCopy(void) const -{ - // note that constness, invisibility, etc. do not get copied - return CopyValues(); -} - bool EidosValue::MatchingDimensions(const EidosValue *p_value1, const EidosValue *p_value2) { int x_dimcount = p_value1->DimensionCount(); @@ -1289,12 +1283,6 @@ EidosValue_SP EidosValue_String::CopyValues(void) const return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String(values_))->CopyDimensionsFromValue(this)); } -EidosValue_SP EidosValue_String::VectorBasedCopy(void) const -{ - // same as CopyValues() now; slated for removal - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_String(values_))->CopyDimensionsFromValue(this)); -} - void EidosValue_String::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); @@ -1466,12 +1454,6 @@ EidosValue_SP EidosValue_Int::CopyValues(void) const return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int(values_, count_))->CopyDimensionsFromValue(this)); } -EidosValue_SP EidosValue_Int::VectorBasedCopy(void) const -{ - // same as CopyValues() now; slated for removal - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int(values_, count_))->CopyDimensionsFromValue(this)); -} - void EidosValue_Int::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); @@ -1686,12 +1668,6 @@ EidosValue_SP EidosValue_Float::CopyValues(void) const return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float(values_, count_))->CopyDimensionsFromValue(this)); } -EidosValue_SP EidosValue_Float::VectorBasedCopy(void) const -{ - // same as CopyValues() now; slated for removal - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float(values_, count_))->CopyDimensionsFromValue(this)); -} - void EidosValue_Float::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); @@ -2018,12 +1994,6 @@ EidosValue_SP EidosValue_Object::CopyValues(void) const return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(*this))->CopyDimensionsFromValue(this)); } -EidosValue_SP EidosValue_Object::VectorBasedCopy(void) const -{ - // same as CopyValues() now; slated for removal - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(*this))->CopyDimensionsFromValue(this)); -} - void EidosValue_Object::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index 39c2335f2..a8d5594fb 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -261,7 +261,6 @@ class EidosValue virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const; // methods to allow type-agnostic manipulation of EidosValues - virtual EidosValue_SP VectorBasedCopy(void) const; // just calls CopyValues() by default, but guarantees a mutable copy virtual EidosValue_SP CopyValues(void) const = 0; // a deep copy of the receiver with invisible_ == false virtual EidosValue_SP NewMatchingType(void) const = 0; // a new EidosValue instance of the same type as the receiver virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) = 0; // copy a value @@ -600,7 +599,6 @@ class EidosValue_String final : public EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; - virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -664,7 +662,6 @@ class EidosValue_Int final : public EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; - virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -773,7 +770,6 @@ class EidosValue_Float final : public EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; - virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; @@ -923,7 +919,6 @@ class EidosValue_Object final : public EidosValue virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; virtual EidosValue_SP CopyValues(void) const override; - virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; virtual void Sort(bool p_ascending) override; void SortBy(const std::string &p_property, bool p_ascending); From 202ae02cd2d1d6994a598f8623bdef7e8705c2bb Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 15:47:45 -0500 Subject: [PATCH 17/18] remove IsSingleton(), no longer needed --- eidos/eidos_interpreter.cpp | 209 +++++++++++------------------------- eidos/eidos_value.cpp | 34 +++--- eidos/eidos_value.h | 51 ++++----- 3 files changed, 96 insertions(+), 198 deletions(-) diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index db79226f8..c6aeb1c3a 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -3771,89 +3771,48 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) { EidosTokenType compound_operator = rvalue_node->token_->token_type_; int64_t operand2_value = cached_operand2->IntAtIndex_NOCAST(0, nullptr); + int64_t *int_data = lvalue->IntData_Mutable(); - if ((lvalue_count == 1) && lvalue->IsSingleton()) + switch (compound_operator) { - EidosValue_Int *int_singleton = static_cast(lvalue); - - switch (compound_operator) + case EidosTokenType::kTokenPlus: { - case EidosTokenType::kTokenPlus: + for (int value_index = 0; value_index < lvalue_count; ++value_index) { - int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; - bool overflow = Eidos_add_overflow(operand1_value, operand2_value, &operand1_value); + int64_t &int_vec_value = int_data[value_index]; + bool overflow = Eidos_add_overflow(int_vec_value, operand2_value, &int_vec_value); if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): integer addition overflow with the binary '+' operator." << EidosTerminate(rvalue_node->token_); - goto compoundAssignmentSuccess; } - case EidosTokenType::kTokenMinus: + goto compoundAssignmentSuccess; + } + case EidosTokenType::kTokenMinus: + { + for (int value_index = 0; value_index < lvalue_count; ++value_index) { - int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; - bool overflow = Eidos_sub_overflow(operand1_value, operand2_value, &operand1_value); + int64_t &int_vec_value = int_data[value_index]; + bool overflow = Eidos_sub_overflow(int_vec_value, operand2_value, &int_vec_value); if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): integer subtraction overflow with the binary '-' operator." << EidosTerminate(rvalue_node->token_); - goto compoundAssignmentSuccess; } - case EidosTokenType::kTokenMult: + goto compoundAssignmentSuccess; + } + case EidosTokenType::kTokenMult: + { + for (int value_index = 0; value_index < lvalue_count; ++value_index) { - int64_t &operand1_value = int_singleton->IntData_Mutable()[0]; - bool overflow = Eidos_mul_overflow(operand1_value, operand2_value, &operand1_value); + int64_t &int_vec_value = int_data[value_index]; + bool overflow = Eidos_mul_overflow(int_vec_value, operand2_value, &int_vec_value); if (overflow) EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): integer multiplication overflow with the '*' operator." << EidosTerminate(rvalue_node->token_); - goto compoundAssignmentSuccess; - } - default: // div, mod, and exp always produce float, so we don't handle them for int; we can't change the type of x here - break; - } - } - else - { - int64_t *int_data = lvalue->IntData_Mutable(); - - switch (compound_operator) - { - case EidosTokenType::kTokenPlus: - { - for (int value_index = 0; value_index < lvalue_count; ++value_index) - { - int64_t &int_vec_value = int_data[value_index]; - bool overflow = Eidos_add_overflow(int_vec_value, operand2_value, &int_vec_value); - - if (overflow) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): integer addition overflow with the binary '+' operator." << EidosTerminate(rvalue_node->token_); - } - goto compoundAssignmentSuccess; } - case EidosTokenType::kTokenMinus: - { - for (int value_index = 0; value_index < lvalue_count; ++value_index) - { - int64_t &int_vec_value = int_data[value_index]; - bool overflow = Eidos_sub_overflow(int_vec_value, operand2_value, &int_vec_value); - - if (overflow) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): integer subtraction overflow with the binary '-' operator." << EidosTerminate(rvalue_node->token_); - } - goto compoundAssignmentSuccess; - } - case EidosTokenType::kTokenMult: - { - for (int value_index = 0; value_index < lvalue_count; ++value_index) - { - int64_t &int_vec_value = int_data[value_index]; - bool overflow = Eidos_mul_overflow(int_vec_value, operand2_value, &int_vec_value); - - if (overflow) - EIDOS_TERMINATION << "ERROR (EidosInterpreter::Evaluate_Assign): integer multiplication overflow with the '*' operator." << EidosTerminate(rvalue_node->token_); - } - goto compoundAssignmentSuccess; - } - default: // div, mod, and exp always produce float, so we don't handle them for int; we can't change the type of x here - break; + goto compoundAssignmentSuccess; } + default: // div, mod, and exp always produce float, so we don't handle them for int; we can't change the type of x here + break; } } } @@ -3864,99 +3823,51 @@ EidosValue_SP EidosInterpreter::Evaluate_Assign(const EidosASTNode *p_node) EidosValue *cached_operand2 = rvalue_node->children_[1]->cached_literal_value_.get(); // the numeric constant EidosTokenType compound_operator = rvalue_node->token_->token_type_; double operand2_value = cached_operand2->NumericAtIndex_NOCAST(0, nullptr); // might be an int64_t and get converted + double *float_data = lvalue->FloatData_Mutable(); - if ((lvalue_count == 1) && lvalue->IsSingleton()) + switch (compound_operator) { - EidosValue_Float *float_singleton = static_cast(lvalue); - - switch (compound_operator) - { - case EidosTokenType::kTokenPlus: - float_singleton->FloatData_Mutable()[0] += operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenMinus: - float_singleton->FloatData_Mutable()[0] -= operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenMult: - float_singleton->FloatData_Mutable()[0] *= operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenDiv: - float_singleton->FloatData_Mutable()[0] /= operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenMod: + case EidosTokenType::kTokenPlus: + for (int value_index = 0; value_index < lvalue_count; ++value_index) + float_data[value_index] += operand2_value; + goto compoundAssignmentSuccess; + + case EidosTokenType::kTokenMinus: + for (int value_index = 0; value_index < lvalue_count; ++value_index) + float_data[value_index] -= operand2_value; + goto compoundAssignmentSuccess; + + case EidosTokenType::kTokenMult: + for (int value_index = 0; value_index < lvalue_count; ++value_index) + float_data[value_index] *= operand2_value; + goto compoundAssignmentSuccess; + + case EidosTokenType::kTokenDiv: + for (int value_index = 0; value_index < lvalue_count; ++value_index) + float_data[value_index] /= operand2_value; + goto compoundAssignmentSuccess; + + case EidosTokenType::kTokenMod: + for (int value_index = 0; value_index < lvalue_count; ++value_index) { - double &operand1_value = float_singleton->FloatData_Mutable()[0]; + double &float_vec_value = float_data[value_index]; - operand1_value = fmod(operand1_value, operand2_value); - goto compoundAssignmentSuccess; + float_vec_value = fmod(float_vec_value, operand2_value); } - - case EidosTokenType::kTokenExp: + goto compoundAssignmentSuccess; + + case EidosTokenType::kTokenExp: + for (int value_index = 0; value_index < lvalue_count; ++value_index) { - double &operand1_value = float_singleton->FloatData_Mutable()[0]; + double &float_vec_value = float_data[value_index]; - operand1_value = pow(operand1_value, operand2_value); - goto compoundAssignmentSuccess; + float_vec_value = pow(float_vec_value, operand2_value); } - - default: - // CODE COVERAGE: This is dead code - break; - } - - } - else - { - double *float_data = lvalue->FloatData_Mutable(); - - switch (compound_operator) - { - case EidosTokenType::kTokenPlus: - for (int value_index = 0; value_index < lvalue_count; ++value_index) - float_data[value_index] += operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenMinus: - for (int value_index = 0; value_index < lvalue_count; ++value_index) - float_data[value_index] -= operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenMult: - for (int value_index = 0; value_index < lvalue_count; ++value_index) - float_data[value_index] *= operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenDiv: - for (int value_index = 0; value_index < lvalue_count; ++value_index) - float_data[value_index] /= operand2_value; - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenMod: - for (int value_index = 0; value_index < lvalue_count; ++value_index) - { - double &float_vec_value = float_data[value_index]; - - float_vec_value = fmod(float_vec_value, operand2_value); - } - goto compoundAssignmentSuccess; - - case EidosTokenType::kTokenExp: - for (int value_index = 0; value_index < lvalue_count; ++value_index) - { - double &float_vec_value = float_data[value_index]; - - float_vec_value = pow(float_vec_value, operand2_value); - } - goto compoundAssignmentSuccess; - - default: - // CODE COVERAGE: This is dead code - break; - } + goto compoundAssignmentSuccess; + + default: + // CODE COVERAGE: This is dead code + break; } goto compoundAssignmentSuccess; diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index d2021808f..413a9ceb1 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -321,7 +321,7 @@ int EidosValue::valueTrackingCount; std::vector EidosValue::valueTrackingVector; #endif -EidosValue::EidosValue(EidosValueType p_value_type, bool p_singleton) : intrusive_ref_count_(0), cached_type_(p_value_type), constant_(false), invisible_(false), is_singleton_(p_singleton), dim_(nullptr) +EidosValue::EidosValue(EidosValueType p_value_type) : intrusive_ref_count_(0), cached_type_(p_value_type), constant_(false), invisible_(false), dim_(nullptr) { #ifdef EIDOS_TRACK_VALUE_ALLOCATION valueTrackingCount++; @@ -968,7 +968,7 @@ void EidosValue_NULL::Sort(bool p_ascending) #pragma mark EidosValue_Logical #pragma mark - -EidosValue_Logical::EidosValue_Logical(const std::vector &p_logicalvec) : EidosValue(EidosValueType::kValueLogical, false) +EidosValue_Logical::EidosValue_Logical(const std::vector &p_logicalvec) : EidosValue(EidosValueType::kValueLogical) { size_t count = p_logicalvec.size(); const eidos_logical_t *values = p_logicalvec.data(); @@ -979,12 +979,12 @@ EidosValue_Logical::EidosValue_Logical(const std::vector &p_log set_logical_no_check(values[index], index); } -EidosValue_Logical::EidosValue_Logical(eidos_logical_t p_logical1) : EidosValue(EidosValueType::kValueLogical, false) // protected +EidosValue_Logical::EidosValue_Logical(eidos_logical_t p_logical1) : EidosValue(EidosValueType::kValueLogical) // protected { push_logical(p_logical1); } -EidosValue_Logical::EidosValue_Logical(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueLogical, false) +EidosValue_Logical::EidosValue_Logical(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueLogical) { reserve(p_init_list.size()); @@ -992,7 +992,7 @@ EidosValue_Logical::EidosValue_Logical(std::initializer_list p_ push_logical_no_check(init_item); } -EidosValue_Logical::EidosValue_Logical(const eidos_logical_t *p_values, size_t p_count) : EidosValue(EidosValueType::kValueLogical, false) +EidosValue_Logical::EidosValue_Logical(const eidos_logical_t *p_values, size_t p_count) : EidosValue(EidosValueType::kValueLogical) { resize_no_initialize(p_count); @@ -1168,17 +1168,17 @@ void EidosValue_Logical::erase_index(size_t p_index) #pragma mark EidosValue_String #pragma mark - -EidosValue_String::EidosValue_String(const std::vector &p_stringvec) : EidosValue(EidosValueType::kValueString, false), values_(p_stringvec) +EidosValue_String::EidosValue_String(const std::vector &p_stringvec) : EidosValue(EidosValueType::kValueString), values_(p_stringvec) { } -EidosValue_String::EidosValue_String(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueString, false) +EidosValue_String::EidosValue_String(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueString) { for (const auto &init_item : p_init_list) values_.emplace_back(init_item); } -EidosValue_String::EidosValue_String(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueString, false) +EidosValue_String::EidosValue_String(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueString) { for (const auto &init_item : p_init_list) values_.emplace_back(init_item); @@ -1314,7 +1314,7 @@ void EidosValue_String::Sort(bool p_ascending) #pragma mark EidosValue_Int #pragma mark - -EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_intvec.size(); const int16_t *values = p_intvec.data(); @@ -1325,7 +1325,7 @@ EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValu set_int_no_check(values[index], index); } -EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_intvec.size(); const int32_t *values = p_intvec.data(); @@ -1336,7 +1336,7 @@ EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValu set_int_no_check(values[index], index); } -EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValue(EidosValueType::kValueInt), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_intvec.size(); const int64_t *values = p_intvec.data(); @@ -1347,7 +1347,7 @@ EidosValue_Int::EidosValue_Int(const std::vector &p_intvec) : EidosValu set_int_no_check(values[index], index); } -EidosValue_Int::EidosValue_Int(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Int::EidosValue_Int(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueInt), values_(&singleton_value_), count_(0), capacity_(1) { reserve(p_init_list.size()); @@ -1355,7 +1355,7 @@ EidosValue_Int::EidosValue_Int(std::initializer_list p_init_list) : Eid push_int_no_check(init_item); } -EidosValue_Int::EidosValue_Int(const int64_t *p_values, size_t p_count) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Int::EidosValue_Int(const int64_t *p_values, size_t p_count) : EidosValue(EidosValueType::kValueInt), values_(&singleton_value_), count_(0), capacity_(1) { resize_no_initialize(p_count); @@ -1536,7 +1536,7 @@ void EidosValue_Int::erase_index(size_t p_index) #pragma mark EidosValue_Float #pragma mark - -EidosValue_Float::EidosValue_Float(const std::vector &p_doublevec) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Float::EidosValue_Float(const std::vector &p_doublevec) : EidosValue(EidosValueType::kValueFloat), values_(&singleton_value_), count_(0), capacity_(1) { size_t count = p_doublevec.size(); const double *values = p_doublevec.data(); @@ -1547,7 +1547,7 @@ EidosValue_Float::EidosValue_Float(const std::vector &p_doublevec) : Eid set_float_no_check(values[index], index); } -EidosValue_Float::EidosValue_Float(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Float::EidosValue_Float(std::initializer_list p_init_list) : EidosValue(EidosValueType::kValueFloat), values_(&singleton_value_), count_(0), capacity_(1) { reserve(p_init_list.size()); @@ -1555,7 +1555,7 @@ EidosValue_Float::EidosValue_Float(std::initializer_list p_init_list) : push_float_no_check(init_item); } -EidosValue_Float::EidosValue_Float(const double *p_values, size_t p_count) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) +EidosValue_Float::EidosValue_Float(const double *p_values, size_t p_count) : EidosValue(EidosValueType::kValueFloat), values_(&singleton_value_), count_(0), capacity_(1) { resize_no_initialize(p_count); @@ -1756,7 +1756,7 @@ void EidosValue_Float::erase_index(size_t p_index) // See comments on EidosValue_Object::EidosValue_Object() below. Note this is shared by all species. std::vector gEidosValue_Object_Mutation_Registry; -EidosValue_Object::EidosValue_Object(const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject, false), +EidosValue_Object::EidosValue_Object(const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject), class_(p_class), values_(&singleton_value_), count_(0), capacity_(1) { class_uses_retain_release_ = (class_ == gEidosObject_Class ? true : class_->UsesRetainRelease()); diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index a8d5594fb..cbfc0ac6e 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -182,7 +182,6 @@ class EidosValue const EidosValueType cached_type_; // allows Type() to be an inline function; cached at construction (uint8_t) unsigned int constant_ : 1; // if set, this EidosValue is a constant and cannot be modified unsigned int invisible_ : 1; // as in R; if true, the value will not normally be printed to the console - unsigned int is_singleton_ : 1; // allows Count() and IsSingleton() to be inline; cached at construction unsigned int registered_for_patching_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; declared here for reasons of memory packing unsigned int class_uses_retain_release_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; cached from UsesRetainRelease() of class_; true until class_ is set @@ -191,15 +190,13 @@ class EidosValue virtual void _CopyDimensionsFromValue(const EidosValue *p_value); // do not call directly; called by CopyDimensionsFromValue() void PrintMatrixFromIndex(int64_t p_ncol, int64_t p_nrow, int64_t p_start_index, std::ostream &p_ostream, const std::string &p_indent = std::string()) const; - virtual int Count_Virtual(void) const = 0; // the number of values in the vector - public: EidosValue(const EidosValue &p_original) = delete; // no copy-construct EidosValue& operator=(const EidosValue&) = delete; // no copying - EidosValue(void) = delete; // no null constructor - EidosValue(EidosValueType p_value_type, bool p_singleton); // must construct with a type identifier and singleton flag, which will be cached + EidosValue(void) = delete; // no null constructor + EidosValue(EidosValueType p_value_type); // must construct with a type identifier, which will be cached virtual ~EidosValue(void); // methods that raise due to various causes, used to avoid duplication and allow efficient inlining @@ -211,13 +208,12 @@ class EidosValue // basic methods inline __attribute__((always_inline)) EidosValueType Type(void) const { return cached_type_; } // the type of the vector, cached at construction - inline __attribute__((always_inline)) bool IsSingleton(void) const { return is_singleton_; } // true is the subclass is a singleton subclass (not just if Count()==1) - inline __attribute__((always_inline)) int Count(void) const { return (is_singleton_ ? 1 : Count_Virtual()); } // avoid the virtual function call for singletons // constness; note that the internal state of object elements is NOT const, just the EidosValue containing the object elements inline __attribute__((always_inline)) void MarkAsConstant(void) { constant_ = true; } inline __attribute__((always_inline)) bool IsConstant(void) const { return constant_; } + virtual int Count(void) const = 0; // the only real casualty of removing the singleton/vector distinction: this is now a virtual function virtual const std::string &ElementType(void) const = 0; // the type of the elements contained by the vector void Print(std::ostream &p_ostream, const std::string &p_indent = std::string()) const; // standard printing; same as operator<< void PrintStructure(std::ostream &p_ostream, int max_values) const; // print structure; no newline @@ -386,16 +382,14 @@ class EidosValue_VOID final : public EidosValue private: typedef EidosValue super; -protected: - virtual int Count_Virtual(void) const override { return 0; } - public: EidosValue_VOID(const EidosValue_VOID &p_original) = delete; // no copy-construct EidosValue_VOID& operator=(const EidosValue_VOID&) = delete; // no copying - inline EidosValue_VOID(void) : EidosValue(EidosValueType::kValueVOID, false) { } + inline EidosValue_VOID(void) : EidosValue(EidosValueType::kValueVOID) { } inline virtual ~EidosValue_VOID(void) override { } + virtual int Count(void) const override { return 0; } virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; @@ -424,16 +418,14 @@ class EidosValue_NULL final : public EidosValue private: typedef EidosValue super; -protected: - virtual int Count_Virtual(void) const override { return 0; } - public: EidosValue_NULL(const EidosValue_NULL &p_original) = delete; // no copy-construct EidosValue_NULL& operator=(const EidosValue_NULL&) = delete; // no copying - inline EidosValue_NULL(void) : EidosValue(EidosValueType::kValueNULL, false) { } + inline EidosValue_NULL(void) : EidosValue(EidosValueType::kValueNULL) { } inline virtual ~EidosValue_NULL(void) override { } + virtual int Count(void) const override { return 0; } virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; @@ -473,18 +465,17 @@ class EidosValue_Logical final : public EidosValue // protected to encourage use of gStaticEidosValue_LogicalT / gStaticEidosValue_LogicalF explicit EidosValue_Logical(eidos_logical_t p_logical1); - virtual int Count_Virtual(void) const override { return (int)count_; } - public: EidosValue_Logical(const EidosValue_Logical &p_original) = delete; // no copy-construct EidosValue_Logical& operator=(const EidosValue_Logical&) = delete; // no copying - inline EidosValue_Logical(void) : EidosValue(EidosValueType::kValueLogical, false) { } + inline EidosValue_Logical(void) : EidosValue(EidosValueType::kValueLogical) { } explicit EidosValue_Logical(const std::vector &p_logicalvec); explicit EidosValue_Logical(std::initializer_list p_init_list); explicit EidosValue_Logical(const eidos_logical_t *p_values, size_t p_count); inline virtual ~EidosValue_Logical(void) override { free(values_); } + virtual int Count(void) const override { return (int)count_; } virtual const std::string &ElementType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; virtual nlohmann::json JSONRepresentation(void) const override; @@ -565,13 +556,11 @@ class EidosValue_String final : public EidosValue inline void UncacheScript(void) { if (cached_script_) { delete cached_script_; cached_script_ = nullptr; } } - virtual int Count_Virtual(void) const override { return (int)values_.size(); } - public: EidosValue_String(const EidosValue_String &p_original) = delete; // no copy-construct EidosValue_String& operator=(const EidosValue_String&) = delete; // no copying - inline EidosValue_String(void) : EidosValue(EidosValueType::kValueString, false) { } - explicit EidosValue_String(const std::string &p_string1) : EidosValue(EidosValueType::kValueString, false), values_({p_string1}) { } + inline EidosValue_String(void) : EidosValue(EidosValueType::kValueString) { } + explicit EidosValue_String(const std::string &p_string1) : EidosValue(EidosValueType::kValueString), values_({p_string1}) { } explicit EidosValue_String(const std::vector &p_stringvec); explicit EidosValue_String(std::initializer_list p_init_list); explicit EidosValue_String(std::initializer_list p_init_list); @@ -581,6 +570,7 @@ class EidosValue_String final : public EidosValue virtual std::string *StringData_Mutable(void) override { WILL_MODIFY(this); UncacheScript(); return values_.data(); } std::vector &StringVectorData(void) { WILL_MODIFY(this); UncacheScript(); return values_; } // to get the std::vector for direct modification + virtual int Count(void) const override { return (int)values_.size(); } virtual const std::string &ElementType(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; @@ -629,14 +619,12 @@ class EidosValue_Int final : public EidosValue int64_t *values_ = nullptr; size_t count_, capacity_; - virtual int Count_Virtual(void) const override { return (int)count_; } - public: EidosValue_Int(const EidosValue_Int &p_original) = delete; // no copy-construct EidosValue_Int& operator=(const EidosValue_Int&) = delete; // no copying - explicit inline EidosValue_Int(void) : EidosValue(EidosValueType::kValueInt, false), values_(&singleton_value_), count_(0), capacity_(1) { } - explicit inline EidosValue_Int(int64_t p_int1) : EidosValue(EidosValueType::kValueInt, false), singleton_value_(p_int1), values_(&singleton_value_), count_(1), capacity_(1) { } + explicit inline EidosValue_Int(void) : EidosValue(EidosValueType::kValueInt), values_(&singleton_value_), count_(0), capacity_(1) { } + explicit inline EidosValue_Int(int64_t p_int1) : EidosValue(EidosValueType::kValueInt), singleton_value_(p_int1), values_(&singleton_value_), count_(1), capacity_(1) { } explicit EidosValue_Int(const std::vector &p_intvec); explicit EidosValue_Int(const std::vector &p_intvec); explicit EidosValue_Int(const std::vector &p_intvec); @@ -647,6 +635,7 @@ class EidosValue_Int final : public EidosValue virtual const int64_t *IntData(void) const override { return values_; } virtual int64_t *IntData_Mutable(void) override { WILL_MODIFY(this); return values_; } + virtual int Count(void) const override { return (int)count_; } virtual const std::string &ElementType(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; @@ -739,14 +728,12 @@ class EidosValue_Float final : public EidosValue double *values_; size_t count_, capacity_; - virtual int Count_Virtual(void) const override { return (int)count_; } - public: EidosValue_Float(const EidosValue_Float &p_original) = delete; // no copy-construct EidosValue_Float& operator=(const EidosValue_Float&) = delete; // no copying - explicit inline EidosValue_Float(void) : EidosValue(EidosValueType::kValueFloat, false), values_(&singleton_value_), count_(0), capacity_(1) { } - explicit inline EidosValue_Float(double p_float1) : EidosValue(EidosValueType::kValueFloat, false), singleton_value_(p_float1), values_(&singleton_value_), count_(1), capacity_(1) { } + explicit inline EidosValue_Float(void) : EidosValue(EidosValueType::kValueFloat), values_(&singleton_value_), count_(0), capacity_(1) { } + explicit inline EidosValue_Float(double p_float1) : EidosValue(EidosValueType::kValueFloat), singleton_value_(p_float1), values_(&singleton_value_), count_(1), capacity_(1) { } explicit EidosValue_Float(const std::vector &p_doublevec); explicit EidosValue_Float(std::initializer_list p_init_list); explicit EidosValue_Float(const double *p_values, size_t p_count); @@ -755,6 +742,7 @@ class EidosValue_Float final : public EidosValue virtual const double *FloatData(void) const override { return values_; } virtual double *FloatData_Mutable(void) override { WILL_MODIFY(this); return values_; } + virtual int Count(void) const override { return (int)count_; } virtual const std::string &ElementType(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; @@ -862,8 +850,6 @@ class EidosValue_Object final : public EidosValue //unsigned int registered_for_patching_ : 1; // for mutation pointer patching; see EidosValue_Object::EidosValue_Object() //unsigned int class_uses_retain_release_ : 1; // cached from UsesRetainRelease() of class_; true until class_ is set - virtual int Count_Virtual(void) const override { return (int)count_; } - // check the type of a new element being added to an EidosValue_Object, and update class_uses_retain_release_ inline __attribute__((always_inline)) void DeclareClassFromElement(const EidosObject *p_element, bool p_undeclared_is_error = false) { @@ -908,6 +894,7 @@ class EidosValue_Object final : public EidosValue inline __attribute__((always_inline)) const EidosClass *Class(void) const { return class_; } inline __attribute__((always_inline)) bool UsesRetainRelease(void) const { return class_uses_retain_release_; } + virtual int Count(void) const override { return (int)count_; } virtual const std::string &ElementType(void) const override; virtual EidosValue_SP NewMatchingType(void) const override; virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; From ce167dda980d58a51086e8d6b0bb4f95ecc50345 Mon Sep 17 00:00:00 2001 From: Ben Haller Date: Sat, 23 Dec 2023 15:57:08 -0500 Subject: [PATCH 18/18] fixes to QtSLiM for previous changes --- QtSLiM/QtSLiM_SLiMgui.cpp | 4 ++-- eidos/eidos_value.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/QtSLiM/QtSLiM_SLiMgui.cpp b/QtSLiM/QtSLiM_SLiMgui.cpp index 3f56b7167..eb8624db9 100644 --- a/QtSLiM/QtSLiM_SLiMgui.cpp +++ b/QtSLiM/QtSLiM_SLiMgui.cpp @@ -39,7 +39,7 @@ SLiMgui::SLiMgui(Community &p_community, QtSLiMWindow *p_controller) : community_(p_community), controller_(p_controller), - self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMgui_Class))) + self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMgui_Class))) { } @@ -73,7 +73,7 @@ EidosValue_SP SLiMgui::GetProperty(EidosGlobalStringID p_property_id) // constants case gID_pid: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(getpid())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(getpid())); } // variables diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 413a9ceb1..8eb440f23 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1757,7 +1757,7 @@ void EidosValue_Float::erase_index(size_t p_index) std::vector gEidosValue_Object_Mutation_Registry; EidosValue_Object::EidosValue_Object(const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject), - class_(p_class), values_(&singleton_value_), count_(0), capacity_(1) + values_(&singleton_value_), count_(0), capacity_(1), class_(p_class) { class_uses_retain_release_ = (class_ == gEidosObject_Class ? true : class_->UsesRetainRelease());