Implement adding expression and var decls
This commit is contained in:
@@ -16,6 +16,11 @@ export class MathPage {
|
||||
public readonly id: string,
|
||||
) {}
|
||||
|
||||
/** Get all defined statements. */
|
||||
getStatements(): MathStatement[] {
|
||||
return Object.values(this.statements)
|
||||
}
|
||||
|
||||
/** Get a statement by ID if it exists. */
|
||||
getStatement(id: StatementID): Maybe<MathStatement> {
|
||||
return this.statements[id]
|
||||
|
||||
@@ -324,4 +324,18 @@ export class MathStatement {
|
||||
uses(): math.SymbolNode[] {
|
||||
return (new RValSymbolWalk()).walk(this.parse())
|
||||
}
|
||||
|
||||
/** Returns true if the definition is correctly non-recursive. */
|
||||
isNotRecursive(): boolean {
|
||||
const uses = this.uses()
|
||||
const defines = this.defines()
|
||||
|
||||
for ( const define of defines ) {
|
||||
if ( uses.some(x => x.name === define.name) ) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user