Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a6da8a9
redoing ops
izulin Mar 20, 2021
91b686c
matrix size
izulin Mar 20, 2021
3ff2031
unary minus
izulin Mar 20, 2021
697bb9d
renaming
izulin Mar 20, 2021
7b5dd07
binary wrapper
izulin Mar 20, 2021
1e92dd2
binary ops refactor
izulin Mar 20, 2021
1245175
bugfix
izulin Mar 20, 2021
b0d9a81
refactor for binary ops
izulin Mar 20, 2021
d57afaf
index
izulin Mar 20, 2021
8617f6b
index test
izulin Mar 21, 2021
4119f5a
binsearch fix
izulin Mar 21, 2021
456f088
refactor of searching
izulin Mar 22, 2021
559833a
.
izulin Mar 22, 2021
d78c0d8
fancy test
izulin Mar 22, 2021
8016acf
Merge branch 'develop' into pu/arrays
izulin Apr 9, 2021
8684bd5
refactor
izulin Apr 11, 2021
f557159
refactor of plugins to incorporate typecheck
izulin Apr 11, 2021
a6d29b5
arrayformula implementation + tests
izulin Apr 11, 2021
6144867
docs
izulin Apr 11, 2021
fc184da
linter
izulin Apr 12, 2021
978d729
doc
izulin Apr 13, 2021
a872106
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 13, 2021
4eeac48
doc
izulin Apr 13, 2021
ae7a64c
Merge branch 'develop' into pu/arrays
izulin Apr 14, 2021
8ee1f08
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 14, 2021
a0f8a29
Merge branch 'develop' into pu/arrays
izulin Apr 14, 2021
9e19d3c
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 14, 2021
989562e
Merge branch 'develop' into pu/arrays
izulin Apr 19, 2021
b6efef9
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 19, 2021
edb82bd
doc
izulin Apr 19, 2021
8157b77
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 19, 2021
2008e01
.
izulin Apr 25, 2021
a1652f5
Merge branch 'develop' into pu/arrays
izulin Apr 26, 2021
9c25116
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 26, 2021
952d6bd
Merge branch 'develop' into pu/arrays
izulin Apr 27, 2021
22d2359
Merge branch 'pu/arrays' into pu/arrays2
izulin Apr 27, 2021
2a97111
Merge branch 'develop' into pu/arrays
izulin May 14, 2021
49de246
Merge branch 'pu/arrays' into pu/arrays2
izulin May 14, 2021
eae15bf
Merge branch 'develop' into pu/arrays2
izulin May 14, 2021
825c286
Merge branch 'develop' into pu/arrays2
izulin May 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Added support for array arithmetic. (#628)
- Added ARRAYFORMULA function. (#630)
- Added performance improvements for array handling. (#629)
- Accepting time in JS Date() objects on the input. (#648)

Expand Down
6 changes: 3 additions & 3 deletions docs/guide/custom-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ export const myTranslations = {
For the simplicity of a basic example, you will not pass any
arguments. However, this method imposes a particular structure to
be used; there are two optional arguments, `ast` and
`formulaAddress`, and the function must return the results of
`state`, and the function must return the results of
the calculations.

```javascript
// arguments here are displayed just to show the structure
public hyper(ast, formulaAddress) {
public hyper(ast, state) {
return 'Hyperformula'.length;
}
};
Expand All @@ -152,7 +152,7 @@ export class CountHF extends FunctionPlugin {
}
};

public hyper(ast, formulaAddress) {
public hyper(ast, state) {
return 'Hyperformula'.length
}
};
Expand Down
19 changes: 10 additions & 9 deletions src/Evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {AbsoluteCellRange} from './AbsoluteCellRange'
import {absolutizeDependencies} from './absolutizeDependencies'
import {CellError, ErrorType, SimpleCellAddress} from './Cell'
import {InterpreterState} from './interpreter/InterpreterState'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {ColumnSearchStrategy} from './Lookup/SearchStrategy'
import {Config} from './Config'
Expand Down Expand Up @@ -60,7 +61,7 @@ export class Evaluator {
const address = vertex.getAddress(this.dependencyGraph.lazilyTransformingAstService)
const formula = vertex.getFormula(this.dependencyGraph.lazilyTransformingAstService)
const currentValue = vertex.isComputed() ? vertex.getCellValue() : null
const newCellValue = this.evaluateAstToCellValue(formula, address)
const newCellValue = this.evaluateAstToCellValue(formula, new InterpreterState(address, this.config.arrays))
vertex.setCellValue(newCellValue)
if (newCellValue !== currentValue) {
changes.addChange(newCellValue, address)
Expand All @@ -72,7 +73,7 @@ export class Evaluator {
const address = vertex.getAddress()
const formula = vertex.getFormula() as Ast
const currentValue = vertex.isComputed() ? vertex.getCellValue() : null
const newCellValue = this.evaluateAstToRangeValue(formula, address)
const newCellValue = this.evaluateAstToRangeValue(formula, new InterpreterState(address, this.config.arrays))
if (newCellValue instanceof SimpleRangeValue) {
const newCellMatrix = new Matrix(newCellValue.rawNumbers())
vertex.setCellValue(newCellMatrix)
Expand Down Expand Up @@ -123,7 +124,7 @@ export class Evaluator {
}
}
}
const ret = this.evaluateAstToCellValue(ast, address)
const ret = this.evaluateAstToCellValue(ast, new InterpreterState(address, this.config.arrays))

tmpRanges.forEach((rangeVertex) => {
this.dependencyGraph.rangeMapping.removeRange(rangeVertex)
Expand All @@ -145,13 +146,13 @@ export class Evaluator {
if (vertex instanceof FormulaCellVertex) {
const address = vertex.getAddress(this.dependencyGraph.lazilyTransformingAstService)
const formula = vertex.getFormula(this.dependencyGraph.lazilyTransformingAstService)
const newCellValue = this.evaluateAstToCellValue(formula, address)
const newCellValue = this.evaluateAstToCellValue(formula, new InterpreterState(address, this.config.arrays))
vertex.setCellValue(newCellValue)
this.columnSearch.add(getRawValue(newCellValue), address)
} else if (vertex instanceof MatrixVertex && vertex.isFormula()) {
const address = vertex.getAddress()
const formula = vertex.getFormula() as Ast
const newCellValue = this.evaluateAstToRangeValue(formula, address)
const newCellValue = this.evaluateAstToRangeValue(formula, new InterpreterState(address, this.config.arrays))
if (newCellValue instanceof SimpleRangeValue) {
const newCellMatrix = new Matrix(newCellValue.rawNumbers())
vertex.setCellValue(newCellMatrix)
Expand All @@ -166,8 +167,8 @@ export class Evaluator {
})
}

private evaluateAstToCellValue(ast: Ast, formulaAddress: SimpleCellAddress): InterpreterValue {
const interpreterValue = this.interpreter.evaluateAst(ast, formulaAddress)
private evaluateAstToCellValue(ast: Ast, state: InterpreterState): InterpreterValue {
const interpreterValue = this.interpreter.evaluateAst(ast, state)
if (interpreterValue instanceof SimpleRangeValue) {
return interpreterValue
} else if (interpreterValue === EmptyValue && this.config.evaluateNullToZero) {
Expand All @@ -177,8 +178,8 @@ export class Evaluator {
}
}

private evaluateAstToRangeValue(ast: Ast, formulaAddress: SimpleCellAddress): SimpleRangeValue | CellError {
const interpreterValue = this.interpreter.evaluateAst(ast, formulaAddress)
private evaluateAstToRangeValue(ast: Ast, state: InterpreterState): SimpleRangeValue | CellError {
const interpreterValue = this.interpreter.evaluateAst(ast, state)
if (interpreterValue instanceof CellError) {
return interpreterValue
} else if (interpreterValue instanceof SimpleRangeValue && interpreterValue.hasOnlyNumbers()) {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/csCZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#HODNOTA!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/daDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VÆRDI!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/deDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#WERT!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSHYP',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/enGB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VALUE!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/esES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const dictionary: RawTranslationPackage = {
VALUE: '#¡VALOR!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/fiFI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#ARVO!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ITSEISARVO',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/frFR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VALEUR!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/huHU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#ÉRTÉK!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/itIT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VALORE!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ASS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/nbNO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VERDI!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/nlNL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#WAARDE!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'BOOGCOS',
ACOSH: 'BOOGCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/plPL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#ARG!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'WART.BEZWGL',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/ptPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VALOR!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/ruRU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#ЗНАЧ!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/svSE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#VÄRDEFEL!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'ABS',
ACOS: 'ARCCOS',
ACOSH: 'ARCCOSH',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/languages/trTR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const dictionary: RawTranslationPackage = {
VALUE: '#DEĞER!',
},
functions: {
ARRAYFORMULA: 'ARRAYFORMULA',
ABS: 'MUTLAK',
ACOS: 'ACOS',
ACOSH: 'ACOSH',
Expand Down
18 changes: 9 additions & 9 deletions src/interpreter/FunctionRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class FunctionRegistry {
private readonly functions: Map<string, [string, FunctionPlugin]> = new Map()

private readonly volatileFunctions: Set<string> = new Set()
private readonly arrayFunctions: Set<string> = new Set()
private readonly structuralChangeFunctions: Set<string> = new Set()
private readonly functionsWhichDoesNotNeedArgumentsToBeComputed: Set<string> = new Set()

Expand Down Expand Up @@ -216,22 +217,21 @@ export class FunctionRegistry {
return Array.from(this.functions.keys())
}

public doesFunctionNeedArgumentToBeComputed = (functionId: string): boolean => {
return this.functionsWhichDoesNotNeedArgumentsToBeComputed.has(functionId)
}
public doesFunctionNeedArgumentToBeComputed = (functionId: string): boolean => this.functionsWhichDoesNotNeedArgumentsToBeComputed.has(functionId)

public isFunctionVolatile = (functionId: string): boolean => {
return this.volatileFunctions.has(functionId)
}
public isFunctionVolatile = (functionId: string): boolean => this.volatileFunctions.has(functionId)

public isFunctionDependentOnSheetStructureChange = (functionId: string): boolean => {
return this.structuralChangeFunctions.has(functionId)
}
public isArrayFunction = (functionId: string): boolean => this.arrayFunctions.has(functionId)

public isFunctionDependentOnSheetStructureChange = (functionId: string): boolean => this.structuralChangeFunctions.has(functionId)

private categorizeFunction(functionId: string, functionMetadata: FunctionMetadata): void {
if (functionMetadata.isVolatile) {
this.volatileFunctions.add(functionId)
}
if (functionMetadata.arrayFunction) {
this.arrayFunctions.add(functionId)
}
if (functionMetadata.doesNotNeedArgumentsToBeComputed) {
this.functionsWhichDoesNotNeedArgumentsToBeComputed.add(functionId)
}
Expand Down
Loading