Remove dead and redundant code.

This commit is contained in:
Jeff Young 2023-02-21 19:55:47 +00:00
parent 814dcdab31
commit 90adc26b73
8 changed files with 13 additions and 34 deletions

View File

@ -876,15 +876,9 @@ wxPGProperty* DIALOG_SIM_MODEL<T_symbol, T_field>::newParamProperty( SIM_MODEL*
// Legacy due to the way we extracted the parameters from Ngspice. // Legacy due to the way we extracted the parameters from Ngspice.
#if wxCHECK_VERSION( 3, 1, 0 ) #if wxCHECK_VERSION( 3, 1, 0 )
if( param.isOtherVariant ) prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue ) );
prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValueOfOtherVariant ) );
else
prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue ) );
#else #else
if( param.isOtherVariant ) prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue.c_str() ) );
prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValueOfOtherVariant.c_str() ) );
else
prop->SetCell( 3, wxString::FromUTF8( param.info.defaultValue.c_str() ) );
#endif #endif
wxString typeStr; wxString typeStr;

View File

@ -711,9 +711,9 @@ int SIM_MODEL::FindModelPinIndex( const std::string& aSymbolPinNumber )
} }
void SIM_MODEL::AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant ) void SIM_MODEL::AddParam( const PARAM::INFO& aInfo )
{ {
m_params.emplace_back( aInfo, aIsOtherVariant ); m_params.emplace_back( aInfo );
// Enums are initialized with their default values. // Enums are initialized with their default values.
if( aInfo.enumValues.size() >= 1 ) if( aInfo.enumValues.size() >= 1 )
@ -1738,9 +1738,6 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
{ {
model->SetParamValue( ii, tokenizer.GetNextToken().ToStdString(), model->SetParamValue( ii, tokenizer.GetNextToken().ToStdString(),
SIM_VALUE_GRAMMAR::NOTATION::SPICE ); SIM_VALUE_GRAMMAR::NOTATION::SPICE );
if( !model->GetParam( ii ).value->HasValue() )
THROW_IO_ERROR( "fall back to raw SPICE" );
} }
spiceTypeInfo.m_Text = SIM_MODEL::TypeInfo( type ).fieldValue; spiceTypeInfo.m_Text = SIM_MODEL::TypeInfo( type ).fieldValue;

View File

@ -379,12 +379,10 @@ public:
std::unique_ptr<SIM_VALUE> value; std::unique_ptr<SIM_VALUE> value;
const INFO& info; const INFO& info;
bool isOtherVariant = false; // Legacy.
PARAM( const INFO& aInfo, bool aIsOtherVariant = false ) PARAM( const INFO& aInfo )
: value( SIM_VALUE::Create( aInfo.type ) ), : value( SIM_VALUE::Create( aInfo.type ) ),
info( aInfo ), info( aInfo )
isOtherVariant( aIsOtherVariant )
{} {}
}; };
@ -453,7 +451,7 @@ public:
void ClearPins(); void ClearPins();
int FindModelPinIndex( const std::string& aSymbolPinNumber ); int FindModelPinIndex( const std::string& aSymbolPinNumber );
void AddParam( const PARAM::INFO& aInfo, bool aIsOtherVariant = false ); void AddParam( const PARAM::INFO& aInfo );
DEVICE_INFO GetDeviceInfo() const { return DeviceInfo( GetDeviceType() ); } DEVICE_INFO GetDeviceInfo() const { return DeviceInfo( GetDeviceType() ); }
INFO GetTypeInfo() const { return TypeInfo( GetType() ); } INFO GetTypeInfo() const { return TypeInfo( GetType() ); }

View File

@ -72,12 +72,12 @@ SIM_MODEL_NGSPICE::SIM_MODEL_NGSPICE( TYPE aType ) :
if( paramInfo.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL if( paramInfo.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL
|| paramInfo.category == SIM_MODEL::PARAM::CATEGORY::GEOMETRY ) || paramInfo.category == SIM_MODEL::PARAM::CATEGORY::GEOMETRY )
{ {
AddParam( paramInfo, getIsOtherVariant() ); AddParam( paramInfo );
} }
} }
for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams ) for( const SIM_MODEL::PARAM::INFO& paramInfo : modelInfo.modelParams )
AddParam( paramInfo, getIsOtherVariant() ); AddParam( paramInfo );
} }

View File

@ -149,12 +149,12 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
SIM_VALUE_FLOAT min = dynamic_cast<SIM_VALUE_FLOAT&>( *m_model.FindParam( "max" )->value ); SIM_VALUE_FLOAT min = dynamic_cast<SIM_VALUE_FLOAT&>( *m_model.FindParam( "max" )->value );
if( !min.HasValue() ) if( !min.ToString().empty() )
min.FromString( "0" ); min.FromString( "0" );
SIM_VALUE_FLOAT max = dynamic_cast<SIM_VALUE_FLOAT&>( *m_model.FindParam( "min" )->value ); SIM_VALUE_FLOAT max = dynamic_cast<SIM_VALUE_FLOAT&>( *m_model.FindParam( "min" )->value );
if( !max.HasValue() ) if( !max.ToString().empty() )
max.FromString( "0" ); max.FromString( "0" );
SIM_VALUE_FLOAT range = max - min; SIM_VALUE_FLOAT range = max - min;
@ -257,7 +257,7 @@ void SIM_MODEL_SOURCE::SetParamValue( int aParamIndex, const SIM_VALUE& aValue )
{ {
// Sources are special. All preceding parameter values must be filled. If they are not, fill // Sources are special. All preceding parameter values must be filled. If they are not, fill
// them out automatically. If a value is nulled, delete everything after it. // them out automatically. If a value is nulled, delete everything after it.
if( !aValue.HasValue() ) if( aValue.ToString().empty() )
{ {
for( int paramIndex = static_cast<int>( aParamIndex ); for( int paramIndex = static_cast<int>( aParamIndex );
paramIndex < GetParamCount(); paramIndex < GetParamCount();

View File

@ -40,7 +40,7 @@ std::string SPICE_GENERATOR_TLINE::ModelLine( const SPICE_ITEM& aItem ) const
auto z0 = static_cast<const SIM_VALUE_FLOAT&>( *m_model.FindParam( "z0" )->value ); auto z0 = static_cast<const SIM_VALUE_FLOAT&>( *m_model.FindParam( "z0" )->value );
auto td = static_cast<const SIM_VALUE_FLOAT&>( *m_model.FindParam( "td" )->value ); auto td = static_cast<const SIM_VALUE_FLOAT&>( *m_model.FindParam( "td" )->value );
if( !z0.HasValue() || !td.HasValue() ) if( !z0.ToString().empty() || !td.ToString().empty() )
return fmt::format( ".model {} LTRA()\n", aItem.modelName ); return fmt::format( ".model {} LTRA()\n", aItem.modelName );
r = SIM_VALUE_FLOAT( 0 ).ToSpiceString(); r = SIM_VALUE_FLOAT( 0 ).ToSpiceString();

View File

@ -425,13 +425,6 @@ template <> SIM_VALUE::TYPE SIM_VALUE_FLOAT_VECTOR::GetType() const { return TYP
template <> SIM_VALUE::TYPE SIM_VALUE_COMPLEX_VECTOR::GetType() const { return TYPE_COMPLEX; }*/ template <> SIM_VALUE::TYPE SIM_VALUE_COMPLEX_VECTOR::GetType() const { return TYPE_COMPLEX; }*/
template <typename T>
bool SIM_VALUE_INST<T>::HasValue() const
{
return m_value.has_value();
}
template <> template <>
bool SIM_VALUE_BOOL::FromString( const std::string& aString, NOTATION aNotation ) bool SIM_VALUE_BOOL::FromString( const std::string& aString, NOTATION aNotation )
{ {

View File

@ -85,8 +85,6 @@ public:
virtual TYPE GetType() const = 0; virtual TYPE GetType() const = 0;
virtual bool HasValue() const = 0;
SIM_VALUE& operator=( const std::string& aString ); SIM_VALUE& operator=( const std::string& aString );
virtual SIM_VALUE& operator=( const SIM_VALUE& aValue ) = 0; virtual SIM_VALUE& operator=( const SIM_VALUE& aValue ) = 0;
virtual bool operator==( const SIM_VALUE& aOther ) const = 0; virtual bool operator==( const SIM_VALUE& aOther ) const = 0;
@ -109,7 +107,6 @@ public:
SIM_VALUE_INST( const T& aValue ); SIM_VALUE_INST( const T& aValue );
TYPE GetType() const override; TYPE GetType() const override;
bool HasValue() const override;
// TODO: Don't pass aNotation. Make a FromSpiceString() function instead. // TODO: Don't pass aNotation. Make a FromSpiceString() function instead.
// TODO: Don't use FromString(). Use assignment. Values should be immutable. // TODO: Don't use FromString(). Use assignment. Values should be immutable.