mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 06:52:05 +01:00
extracted classes into their own files
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import Operand from './expression/Operand';
|
||||
import ExpressionOperand from './expression/ExpressionOperand'
|
||||
import ListOfNumbersExpression from './expression/ListOfNumbersExpression';
|
||||
import MultipleOperandsExpression from './expression/MultipleOperandsExpression';
|
||||
|
||||
export { default as Operand } from './expression/Operand';
|
||||
export { default as ExpressionError } from './expression/ExpressionError';
|
||||
export { default as ExpressionOperand } from './expression/ExpressionOperand';
|
||||
export { default as ListOfNumbersExpression } from './expression/ListOfNumbersExpression';
|
||||
export { default as MultipleOperandsExpression } from './expression/MultipleOperandsExpression';
|
||||
|
||||
var expression = {
|
||||
factories:[],
|
||||
@@ -112,24 +116,7 @@ var expression = {
|
||||
|
||||
// Expression like 1|2 or 4^5
|
||||
|
||||
export class MultipleOperandsExpression {
|
||||
constructor(expressionString, expressions) {
|
||||
this.expressionString = expressionString;
|
||||
this.expressions = expressions;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListOfNumbersExpression {
|
||||
constructor(expressionString, numbers) {
|
||||
this.expressionString = expressionString;
|
||||
this.numbers = numbers;
|
||||
this.maxBitsLegnth = numbers.map(n => n.lengthInBits).reduce((n , c) => n >= c ? n : c, 0);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.numbers.map(n => n.value.toString()).join(' ');
|
||||
}
|
||||
}
|
||||
|
||||
export var parser = expression;
|
||||
|
||||
|
||||
11
src/app/expression/ListOfNumbersExpression.js
Normal file
11
src/app/expression/ListOfNumbersExpression.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export default class ListOfNumbersExpression {
|
||||
constructor(expressionString, numbers) {
|
||||
this.expressionString = expressionString;
|
||||
this.numbers = numbers;
|
||||
this.maxBitsLegnth = numbers.map(n => n.lengthInBits).reduce((n , c) => n >= c ? n : c, 0);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.numbers.map(n => n.value.toString()).join(' ');
|
||||
}
|
||||
}
|
||||
6
src/app/expression/MultipleOperandsExpression.js
Normal file
6
src/app/expression/MultipleOperandsExpression.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default class MultipleOperandsExpression {
|
||||
constructor(expressionString, expressions) {
|
||||
this.expressionString = expressionString;
|
||||
this.expressions = expressions;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user