Skip to content

Commit

Permalink
abolish the singleton/vector distinction for EidosValue_Int
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Dec 23, 2023
1 parent b85248c commit 3c2b978
Show file tree
Hide file tree
Showing 40 changed files with 586 additions and 732 deletions.
2 changes: 1 addition & 1 deletion SLiMgui/slim_gui.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions core/chromosome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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_;
}

Expand All @@ -1590,23 +1590,23 @@ 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:
{
if (!species_.IsNucleotideBased())
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:
{
if (!species_.IsNucleotideBased())
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:
Expand Down Expand Up @@ -1640,23 +1640,23 @@ 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:
{
if (species_.IsNucleotideBased())
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:
{
if (species_.IsNucleotideBased())
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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions core/community_eidos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions core/genome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions core/genomic_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions core/genomic_element_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
Loading

0 comments on commit 3c2b978

Please sign in to comment.