Skip to content

Cleanup legacy methods in Val #643

@zasdfgbnm

Description

@zasdfgbnm

Current, Val has the following methods:

  // If this Val is an integer with a direct constant value associated with it,
  // will return the value of that constant integer. If this integer has
  // defining expressions it will return a std::nullopt. Those values should be
  // infered using evaluateInt.
  std::optional<int64_t> getInt() const;

  // If this Val is a double with a direct constant value associated with it,
  // will return the value of that constant double. If this double has
  // defining expressions it will return a std::nullopt. Those values should be
  // infered using evaluateDouble.
  std::optional<double> getDouble() const;

  // If this Val is a bool with a direct constant value associated with it,
  // will return the value of that constant bool. If this bool has defining
  // expressions it will return a std::nullopt. Those values should be infered
  // using evaluateBool.
  std::optional<bool> getBool() const;

  // If this Val is a constant integer, and its history is comprised only of
  // constant values, will return the value of that constant integer. Cannot
  // make constant as expression evaluator takes non-constant Vals.
  int64_t evaluateInt();

  // If this Val is a constant double, and its history is comprised only of
  // constant values, will return the value of that constant double. Cannot
  // make constant as expression evaluator takes non-constant Vals.
  double evaluateDouble();

  // If this Val is a constant bool, and its history is comprised only of
  // constant values, will return the value of that constant bool. Cannot
  // make constant as expression evaluator takes non-constant Vals.
  bool evaluateBool();

This was a legacy before we have a PolymorphicValue. With PolymorphicValue, we only need a single

const PolymorphicValue& value() const;

and a single

PolymorphicValue evaluate();

we should replace all uses of the above 6 legacy methods with the two new methods.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions