Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More advanced custom function tutorial #1108

Merged
merged 32 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2889c31
Start writing a custom function example for GREET()
sequba Nov 23, 2022
0f4bcdf
Export FunctionArgumentType enum
sequba Nov 23, 2022
7b3c860
Move custom function tests from square-plugin-example.spec.ts to cust…
sequba Nov 23, 2022
6d0af2e
Add unit tests for custom functions implemented with runFunction
sequba Nov 23, 2022
70c1b49
WIP
sequba Nov 24, 2022
9e67e69
Update the code snippets in the custom functions guide to match the n…
sequba Dec 2, 2022
9e3dbb3
Add info about unit tests to the custom functions guide
sequba Dec 2, 2022
0f25ddf
Merge branch 'develop' into feature/issue-779
sequba Dec 6, 2022
82d0e8b
Rewrite custom function options section in custom functions guide
sequba Dec 6, 2022
fbc1ca9
Export ArraySize class
sequba Dec 10, 2022
60c0ce5
Update custom-functions guide after changes in the demo
sequba Dec 10, 2022
01144a9
Structural changes in the custom-functions guide
sequba Dec 10, 2022
f1615da
Move SimpleRangeValue from ./src/interpreter to ./src so that the typ…
sequba Dec 13, 2022
8d4fca3
Describe DOUBLE_RANGE function in the custom-functions guide
sequba Dec 13, 2022
6b5992d
Use ArraySize in the example of arraySizeMethod in the custom-functio…
sequba Dec 13, 2022
ee375f7
Add changelog entry
sequba Dec 13, 2022
0ab7465
Add the description for the arraySizeMethod option
sequba Dec 13, 2022
b9c6868
Rephrase a few sentences in the custom-functions guide
sequba Dec 14, 2022
fb5e5aa
Improve the description of returnNumberType option in the custom-func…
sequba Dec 14, 2022
befa807
Add default values to the custom function options description
sequba Dec 14, 2022
4f62223
Add possible values to the argumentType description in the custom-fuc…
sequba Dec 14, 2022
ea0f41b
Reduce content duplication on custom function name translations
sequba Dec 14, 2022
682f5d5
Minor improvements to custom-functions guide
sequba Dec 14, 2022
3fa9d33
Merge branch 'develop' into feature/issue-779
sequba Dec 14, 2022
bfbb0f0
grammarly fixes
sequba Dec 14, 2022
56fe511
Reformat table
sequba Dec 14, 2022
32556e4
Improve the description of the vectorization feature
sequba Dec 15, 2022
a6b1e57
Merge branch 'develop' into feature/issue-779
sequba Dec 20, 2022
aef856b
code review fixes
sequba Dec 20, 2022
f629630
Change translations object to be standalone instead of a static prope…
sequba Dec 20, 2022
efe66ef
Use FunctionArgumentType enum in custom functions guide
sequba Dec 20, 2022
318d094
Fix typo
sequba Dec 20, 2022
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
385 changes: 243 additions & 142 deletions docs/guide/custom-functions.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/ArraySize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {SimpleCellAddress} from './Cell'
import {Config} from './Config'
import {FunctionRegistry} from './interpreter/FunctionRegistry'
import {InterpreterState} from './interpreter/InterpreterState'
import {ArgumentTypes} from './interpreter/plugin/FunctionPlugin'
import {FunctionArgumentType} from './interpreter/plugin/FunctionPlugin'
import {Ast, AstNodeType, ProcedureAst} from './parser'

export class ArraySize {
Expand Down Expand Up @@ -156,7 +156,7 @@ export class ArraySizePredictor {
let maxWidth = 1
let maxHeight = 1
for (let i = 0; i < subChecks.length; i++) {
if (argumentDefinitions[i].argumentType !== ArgumentTypes.RANGE && argumentDefinitions[i].argumentType !== ArgumentTypes.ANY) {
if (argumentDefinitions[i].argumentType !== FunctionArgumentType.RANGE && argumentDefinitions[i].argumentType !== FunctionArgumentType.ANY) {
maxHeight = Math.max(maxHeight, subChecks[i].height)
maxWidth = Math.max(maxWidth, subChecks[i].width)
}
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {ArraySize} from './ArraySize'
import {CellError} from './Cell'
import {EmptyValue, InternalScalarValue, InterpreterValue} from './interpreter/InterpreterValue'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {SimpleRangeValue} from './SimpleRangeValue'

export interface IArray {
size: ArraySize,
Expand Down
2 changes: 1 addition & 1 deletion src/Cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isExtendedNumber,
NumberType,
} from './interpreter/InterpreterValue'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {Maybe} from './Maybe'
import {CellAddress} from './parser'
import {AddressWithSheet} from './parser/Address'
Expand Down
2 changes: 1 addition & 1 deletion src/ContentChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {addressKey, SimpleCellAddress} from './Cell'
import {InterpreterValue} from './interpreter/InterpreterValue'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {SimpleRangeValue} from './SimpleRangeValue'

export interface CellValueChange {
address: SimpleCellAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/DependencyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
InterpreterValue,
RawScalarValue
} from '../interpreter/InterpreterValue'
import {SimpleRangeValue} from '../interpreter/SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {LazilyTransformingAstService} from '../LazilyTransformingAstService'
import {Maybe} from '../Maybe'
import {NamedExpressions} from '../NamedExpressions'
Expand Down
2 changes: 1 addition & 1 deletion src/Evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {FormulaVertex} from './DependencyGraph/FormulaCellVertex'
import {Interpreter} from './interpreter/Interpreter'
import {InterpreterState} from './interpreter/InterpreterState'
import {EmptyValue, getRawValue, InterpreterValue} from './interpreter/InterpreterValue'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {LazilyTransformingAstService} from './LazilyTransformingAstService'
import {ColumnSearchStrategy} from './Lookup/SearchStrategy'
import {Ast, RelativeDependency} from './parser'
Expand Down
2 changes: 1 addition & 1 deletion src/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Config} from './Config'
import {CellValueChange, ChangeExporter} from './ContentChanges'
import {ErrorMessage} from './error-message'
import {EmptyValue, getRawValue, InterpreterValue, isExtendedNumber} from './interpreter/InterpreterValue'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {LazilyTransformingAstService} from './LazilyTransformingAstService'
import {NamedExpressions} from './NamedExpressions'
import {SheetIndexMappingFn, simpleCellAddressToString} from './parser/addressRepresentationConverters'
Expand Down
2 changes: 1 addition & 1 deletion src/Lookup/AdvancedFind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
RawInterpreterValue,
RawNoErrorScalarValue
} from '../interpreter/InterpreterValue'
import {SimpleRangeValue} from '../interpreter/SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {SearchOptions} from './SearchStrategy'
import {forceNormalizeString} from '../interpreter/ArithmeticHelper'
import {findLastOccurrenceInOrderedRange} from '../interpreter/binarySearch'
Expand Down
2 changes: 1 addition & 1 deletion src/Lookup/ColumnBinarySearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {SimpleCellAddress} from '../Cell'
import {CellValueChange} from '../ContentChanges'
import {DependencyGraph} from '../DependencyGraph'
import {RawNoErrorScalarValue, RawScalarValue} from '../interpreter/InterpreterValue'
import {SimpleRangeValue} from '../interpreter/SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {ColumnsSpan} from '../Span'
import {AdvancedFind} from './AdvancedFind'
import {ColumnSearchStrategy, SearchOptions} from './SearchStrategy'
Expand Down
2 changes: 1 addition & 1 deletion src/Lookup/ColumnIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
RawNoErrorScalarValue,
RawScalarValue
} from '../interpreter/InterpreterValue'
import {SimpleRangeValue} from '../interpreter/SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {LazilyTransformingAstService} from '../LazilyTransformingAstService'
import {ColumnsSpan, RowsSpan} from '../Span'
import {Statistics, StatType} from '../statistics'
Expand Down
2 changes: 1 addition & 1 deletion src/Lookup/RowSearchStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {DependencyGraph} from '../DependencyGraph'
import {RawNoErrorScalarValue} from '../interpreter/InterpreterValue'
import {SimpleRangeValue} from '../interpreter/SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {AdvancedFind} from './AdvancedFind'
import {SearchOptions, SearchStrategy} from './SearchStrategy'

Expand Down
2 changes: 1 addition & 1 deletion src/Lookup/SearchStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Config} from '../Config'
import {CellValueChange} from '../ContentChanges'
import {DependencyGraph} from '../DependencyGraph'
import {RawInterpreterValue, RawNoErrorScalarValue, RawScalarValue} from '../interpreter/InterpreterValue'
import {SimpleRangeValue} from '../interpreter/SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {ColumnsSpan} from '../Span'
import {Statistics} from '../statistics'
import {ColumnBinarySearch} from './ColumnBinarySearch'
Expand Down
15 changes: 8 additions & 7 deletions src/interpreter/SimpleRangeValue.ts → src/SimpleRangeValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* Copyright (c) 2022 Handsoncode. All rights reserved.
*/

import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {ArraySize} from '../ArraySize'
import {CellError, ErrorType, simpleCellAddress, SimpleCellAddress} from '../Cell'
import {DependencyGraph} from '../DependencyGraph'
import {ErrorMessage} from '../error-message'
import {InternalScalarValue, isExtendedNumber} from './InterpreterValue'
import {AbsoluteCellRange} from './AbsoluteCellRange'
import {ArraySize} from './ArraySize'
import {CellError, ErrorType, simpleCellAddress, SimpleCellAddress} from './Cell'
import {DependencyGraph} from './DependencyGraph'
import {ErrorMessage} from './error-message'
import {InternalScalarValue, isExtendedNumber} from './interpreter/InterpreterValue'


export class SimpleRangeValue {
public readonly size: ArraySize
Expand Down Expand Up @@ -135,6 +136,7 @@ export class SimpleRangeValue {
if (this._data !== undefined) {
return
}

this._hasOnlyNumbers = true
this._data = this.range!.addressesArrayMap(this.dependencyGraph!, cellFromRange => {
const value = this.dependencyGraph!.getCellValue(cellFromRange)
Expand All @@ -148,6 +150,5 @@ export class SimpleRangeValue {
return value as InternalScalarValue
}
})

}
}
15 changes: 12 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import {SimpleCellRange} from './AbsoluteCellRange'
import {ArraySize} from './ArraySize'
import {CellError, CellType, CellValueDetailedType, CellValueType, ErrorType, SimpleCellAddress} from './Cell'
import {RawCellContent} from './CellContentParser'
import {CellValue, DetailedCellError, NoErrorCellValue} from './CellValue'
Expand Down Expand Up @@ -47,15 +48,17 @@ import {ExportedCellChange, ExportedChange, ExportedNamedExpressionChange} from
import {HyperFormula} from './HyperFormula'
import {RawTranslationPackage} from './i18n'
import enGB from './i18n/languages/enGB'
import {FunctionArgument, FunctionPlugin, FunctionPluginDefinition} from './interpreter'
import {FunctionArgument, FunctionPlugin, FunctionPluginDefinition, FunctionArgumentType, ImplementedFunctions, FunctionMetadata} from './interpreter'
import {FormatInfo} from './interpreter/InterpreterValue'
import * as plugins from './interpreter/plugin'
import {SimpleRangeValue} from './interpreter/SimpleRangeValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {NamedExpression, NamedExpressionOptions} from './NamedExpressions'
import {SerializedNamedExpression} from './Serialization'
import {Sheet, SheetDimensions, Sheets} from './Sheet'

/** @internal */
/**
* Aggregate class for default export
*/
class HyperFormulaNS extends HyperFormula {
public static HyperFormula = HyperFormula
public static ErrorType = ErrorType
Expand All @@ -70,7 +73,9 @@ class HyperFormulaNS extends HyperFormula {
public static EvaluationSuspendedError = EvaluationSuspendedError
public static ExpectedOneOfValuesError = ExpectedOneOfValuesError
public static ExpectedValueOfTypeError = ExpectedValueOfTypeError
public static ArraySize = ArraySize
public static FunctionPlugin = FunctionPlugin
public static FunctionArgumentType = FunctionArgumentType
public static FunctionPluginValidationError = FunctionPluginValidationError
public static InvalidAddressError = InvalidAddressError
public static InvalidArgumentsError = InvalidArgumentsError
Expand Down Expand Up @@ -145,7 +150,11 @@ export {
EvaluationSuspendedError,
ExpectedOneOfValuesError,
ExpectedValueOfTypeError,
ArraySize,
FunctionPlugin,
ImplementedFunctions,
FunctionMetadata,
FunctionArgumentType,
FunctionPluginValidationError,
InvalidAddressError,
InvalidArgumentsError,
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/ArithmeticHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
RawScalarValue,
TimeNumber
} from './InterpreterValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import Collator = Intl.Collator

export type complex = [number, number]
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/CriterionFunctionCompute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {Maybe} from '../Maybe'
import {CriterionLambda, CriterionPackage} from './Criterion'
import {Interpreter} from './Interpreter'
import {getRawValue, InternalScalarValue, RawScalarValue} from './InterpreterValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'

const findSmallerRangeForMany = (dependencyGraph: DependencyGraph, conditionRanges: AbsoluteCellRange[], valuesRange: AbsoluteCellRange): { smallerRangeVertex?: RangeVertex, restConditionRanges: AbsoluteCellRange[], restValuesRange: AbsoluteCellRange } => {
if (valuesRange.end.row > valuesRange.start.row) {
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/Interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
InterpreterValue,
isExtendedNumber,
} from './InterpreterValue'
import {SimpleRangeValue} from './SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'

export class Interpreter {
public readonly criterionBuilder: CriterionBuilder
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/InterpreterValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import {CellError} from '../Cell'
import {SimpleRangeValue} from './SimpleRangeValue'
import {SimpleRangeValue} from '../SimpleRangeValue'

export const EmptyValue = Symbol('Empty value')
export type EmptyValueType = typeof EmptyValue
Expand Down
6 changes: 4 additions & 2 deletions src/interpreter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
FunctionMetadata,
FunctionPlugin,
FunctionPluginDefinition,
ImplementedFunctions
ImplementedFunctions,
FunctionArgumentType,
} from './plugin/FunctionPlugin'

export {
Expand All @@ -18,5 +19,6 @@ export {
FunctionPlugin,
ImplementedFunctions,
FunctionMetadata,
FunctionTranslationsPackage
FunctionTranslationsPackage,
FunctionArgumentType,
}
4 changes: 2 additions & 2 deletions src/interpreter/plugin/AbsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import {ProcedureAst} from '../../parser'
import {InterpreterState} from '../InterpreterState'
import {InterpreterValue} from '../InterpreterValue'
import {ArgumentTypes, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'
import {FunctionArgumentType, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'

export class AbsPlugin extends FunctionPlugin implements FunctionPluginTypecheck<AbsPlugin> {
public static implementedFunctions = {
'ABS': {
method: 'abs',
parameters: [
{argumentType: ArgumentTypes.NUMBER}
{argumentType: FunctionArgumentType.NUMBER}
]
},
}
Expand Down
18 changes: 10 additions & 8 deletions src/interpreter/plugin/ArrayPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {AstNodeType, ProcedureAst} from '../../parser'
import {coerceScalarToBoolean} from '../ArithmeticHelper'
import {InterpreterState} from '../InterpreterState'
import {InternalScalarValue, InterpreterValue} from '../InterpreterValue'
import {SimpleRangeValue} from '../SimpleRangeValue'
import {ArgumentTypes, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'
import {SimpleRangeValue} from '../../SimpleRangeValue'
import {FunctionArgumentType, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'

export class ArrayPlugin extends FunctionPlugin implements FunctionPluginTypecheck<ArrayPlugin> {
public static implementedFunctions = {
Expand All @@ -20,16 +20,16 @@ export class ArrayPlugin extends FunctionPlugin implements FunctionPluginTypeche
arraySizeMethod: 'arrayformulaArraySize',
arrayFunction: true,
parameters: [
{argumentType: ArgumentTypes.ANY}
{argumentType: FunctionArgumentType.ANY}
],
},
'ARRAY_CONSTRAIN': {
method: 'arrayconstrain',
arraySizeMethod: 'arrayconstrainArraySize',
parameters: [
{argumentType: ArgumentTypes.RANGE},
{argumentType: ArgumentTypes.INTEGER, minValue: 1},
{argumentType: ArgumentTypes.INTEGER, minValue: 1},
{argumentType: FunctionArgumentType.RANGE},
{argumentType: FunctionArgumentType.INTEGER, minValue: 1},
{argumentType: FunctionArgumentType.INTEGER, minValue: 1},
],
vectorizationForbidden: true,
},
Expand All @@ -38,8 +38,8 @@ export class ArrayPlugin extends FunctionPlugin implements FunctionPluginTypeche
arraySizeMethod: 'filterArraySize',
arrayFunction: true,
parameters: [
{argumentType: ArgumentTypes.RANGE},
{argumentType: ArgumentTypes.RANGE},
{argumentType: FunctionArgumentType.RANGE},
{argumentType: FunctionArgumentType.RANGE},
],
repeatLastArgs: 1,
}
Expand Down Expand Up @@ -101,9 +101,11 @@ export class ArrayPlugin extends FunctionPlugin implements FunctionPluginTypeche
return new CellError(ErrorType.NA, ErrorMessage.EqualLength)
}
}

if (rangeVals.width() > 1 && rangeVals.height() > 1) {
return new CellError(ErrorType.NA, ErrorMessage.WrongDimension)
}

const vals = rangeVals.data
const ret = []
for (let i = 0; i < rangeVals.height(); i++) {
Expand Down
10 changes: 5 additions & 5 deletions src/interpreter/plugin/BitShiftPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ErrorMessage} from '../../error-message'
import {ProcedureAst} from '../../parser'
import {InterpreterState} from '../InterpreterState'
import {InterpreterValue} from '../InterpreterValue'
import {ArgumentTypes, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'
import {FunctionArgumentType, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'

const MAX_48BIT_INTEGER = 281474976710655
const SHIFT_MIN_POSITIONS = -53
Expand All @@ -19,15 +19,15 @@ export class BitShiftPlugin extends FunctionPlugin implements FunctionPluginType
'BITLSHIFT': {
method: 'bitlshift',
parameters: [
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: ArgumentTypes.INTEGER, minValue: SHIFT_MIN_POSITIONS, maxValue: SHIFT_MAX_POSITIONS},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: SHIFT_MIN_POSITIONS, maxValue: SHIFT_MAX_POSITIONS},
]
},
'BITRSHIFT': {
method: 'bitrshift',
parameters: [
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: ArgumentTypes.INTEGER, minValue: SHIFT_MIN_POSITIONS, maxValue: SHIFT_MAX_POSITIONS},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: SHIFT_MIN_POSITIONS, maxValue: SHIFT_MAX_POSITIONS},
]
},
}
Expand Down
14 changes: 7 additions & 7 deletions src/interpreter/plugin/BitwiseLogicOperationsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
import {ProcedureAst} from '../../parser'
import {InterpreterState} from '../InterpreterState'
import {InterpreterValue} from '../InterpreterValue'
import {ArgumentTypes, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'
import {FunctionArgumentType, FunctionPlugin, FunctionPluginTypecheck} from './FunctionPlugin'

export class BitwiseLogicOperationsPlugin extends FunctionPlugin implements FunctionPluginTypecheck<BitwiseLogicOperationsPlugin> {
public static implementedFunctions = {
'BITAND': {
method: 'bitand',
parameters: [
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
]
},
'BITOR': {
method: 'bitor',
parameters: [
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
]
},
'BITXOR': {
method: 'bitxor',
parameters: [
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: ArgumentTypes.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
{argumentType: FunctionArgumentType.INTEGER, minValue: 0},
]
},
}
Expand Down
Loading