- Redefined `MStatementSearchable`
- Added `MStatementReplaceable`
- Added `Repr` (a kind-of `Expression`) which will be used as an example to test out the aforementioned two interfaces
This commit is contained in:
Tristan B. Velloza Kildaire 2023-05-09 09:27:58 +02:00
parent 66d600277d
commit 11d592c0fb
1 changed files with 25 additions and 31 deletions

View File

@ -13,41 +13,35 @@ public interface MTypeRewritable
public void setType(string type);
}
// TODO: Add an interface for MStatementSearchable which will allow
// ... us to search for a Statement anywhere in the tree. Useful,
// ... over plane resolution as we may want to find Expression's
// ... which are not Entity's meaning they have no name. We need
// ... a "searchByType" that can find us all such types of statements
// ... within the tree.
//
// For example, `searchByType(Expression)` on a `Variable` should
// search it's `VariableAssigmment` and return the `Expression`.
//
// This might require a static helper method in `MStatementSearchable`,
// that can be used then on known things like `Expression`'s sub-types
// such as BinaryOperator to search left-and-right.
//
// Thing is we need to do this in a non-instrusive manner. Mmmh, perhaps
// this is not the best way - not sure though.
//
// Okay, NO. Let's rather make a searcher ourselves honestly. I think it
// ... would be a lot easier to support these things ourselves. NO!
// ... Here is the problem however, replacing of items? ACTUALLY, we can
// ... still do that but damn an interface COULD help
/**
* Anything which implements this has the ability
* to search for objects of the provided type,
* and return a list of them
*/
public interface MStatementSearchable
{
/**
* Search for a kind-of `Statement` by its type and return a referenced variable
* (a `ref`) to it
*
* Params:
* statementType = the type of `Statemen` to look for
*
* Returns: a referenced variable to the found entity
*/
public ref Statement search(TypeInfo_Class statementType);
}
/**
* Anything which implements this has the ability
* to, given an object `x`, return a `ref x` to it
* hence allowing us to replace it
*/
public interface MStatementReplaceable
{
}
public class Repr : Expression
{
/**
* TODO: Add a MStatementSearchable implementation
*/
}
// FIXME: Make this inherit from IntegerLiteral and also,
// make `getLiteral/number` overridable such that we can
// actually evaluate it depending on the identifier (type)