mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2026-01-18 18:02:39 +01:00
Code renames
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Operand, ListOfNumbersExpression, SingleOperandExpression, MultipleOperandsExpression } from '../../expression';
|
||||
import { Operand, ListOfNumbersExpression, ExpressionOperand, MultipleOperandsExpression } from '../../expression';
|
||||
import formatter from '../../formatter';
|
||||
import BinaryStringView from './BinaryStringView';
|
||||
import BitwiseExpressionViewModel from './models/BitwiseExpressionViewModel';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Operand, SingleOperandExpression } from '../../../expression';
|
||||
import { Operand, ExpressionOperand } from '../../../expression';
|
||||
|
||||
export default class BitwiseExpressionViewModel {
|
||||
|
||||
@@ -74,12 +74,12 @@ export default class BitwiseExpressionViewModel {
|
||||
};
|
||||
|
||||
addExpression(expression) {
|
||||
this.maxNumberOfBits = Math.max(expression.operand1.apply().getLengthInBits(), this.maxNumberOfBits);
|
||||
this.maxNumberOfBits = Math.max(expression.operand.apply().getLengthInBits(), this.maxNumberOfBits);
|
||||
|
||||
this.items.push({
|
||||
sign: expression.sign,
|
||||
label: this.getLabel(expression.operand1),
|
||||
operand: expression.operand1,
|
||||
label: this.getLabel(expression.operand),
|
||||
operand: expression.operand,
|
||||
allowFlipBits: this.allowFlipBits
|
||||
});
|
||||
};
|
||||
@@ -87,7 +87,7 @@ export default class BitwiseExpressionViewModel {
|
||||
addShiftExpressionResult(expression, resultOperand) {
|
||||
this.maxNumberOfBits = Math.max(resultOperand.getLengthInBits(), this.maxNumberOfBits);
|
||||
this.items.push({
|
||||
sign: expression.sign + expression.operand1.toString(),
|
||||
sign: expression.sign + expression.operand.toString(),
|
||||
css: 'expression-result',
|
||||
operand: resultOperand,
|
||||
allowFlipBits: false
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Operand from './expression/Operand';
|
||||
import SingleOperandExpression from './expression/SingleOperandExpression'
|
||||
import ExpressionOperand from './expression/ExpressionOperand'
|
||||
|
||||
export { default as Operand } from './expression/Operand';
|
||||
export { default as ExpressionError } from './expression/ExpressionError';
|
||||
export { default as SingleOperandExpression } from './expression/SingleOperandExpression';
|
||||
export { default as ExpressionOperand } from './expression/ExpressionOperand';
|
||||
|
||||
var expression = {
|
||||
factories:[],
|
||||
@@ -90,7 +90,7 @@ var expression = {
|
||||
|
||||
var op = null;
|
||||
if(num.indexOf('~') == '0') {
|
||||
op = new SingleOperandExpression(input, Operand.parse(num.substring(1)), '~');
|
||||
op = new ExpressionOperand(input, Operand.parse(num.substring(1)), '~');
|
||||
}
|
||||
else {
|
||||
op = Operand.parse(num);
|
||||
@@ -99,7 +99,7 @@ var expression = {
|
||||
if(sign == null) {
|
||||
return op;
|
||||
} else {
|
||||
return new SingleOperandExpression(input, op, sign);
|
||||
return new ExpressionOperand(input, op, sign);
|
||||
}
|
||||
},
|
||||
normalizeString: function (string) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Operand from './Operand';
|
||||
|
||||
export default class SingleOperandExpression {
|
||||
export default class ExpressionOperand {
|
||||
constructor(expressionString, operand, sign) {
|
||||
this.expressionString = expressionString;
|
||||
this.operand1 = operand;
|
||||
this.operand = operand;
|
||||
this.sign = sign;
|
||||
this.isExpression = true;
|
||||
this.isShiftExpression = this.sign.indexOf('<') >= 0 || this.sign.indexOf('>')>= 0;
|
||||
@@ -11,7 +11,7 @@ export default class SingleOperandExpression {
|
||||
}
|
||||
|
||||
apply(operand) {
|
||||
if (operand instanceof SingleOperandExpression) {
|
||||
if (operand instanceof ExpressionOperand) {
|
||||
console.error("value shouldnt be expression", value);
|
||||
throw new Error('value shouldnt be expression');
|
||||
}
|
||||
@@ -20,21 +20,21 @@ export default class SingleOperandExpression {
|
||||
|
||||
var str = '';
|
||||
if(this.sign == '~'){
|
||||
str = '~' + this.operand1.apply().value;
|
||||
str = '~' + this.operand.apply().value;
|
||||
} else {
|
||||
str = operand.value + this.sign + this.operand1.apply().value;
|
||||
str = operand.value + this.sign + this.operand.apply().value;
|
||||
}
|
||||
|
||||
console.log('eval:' + str, this);
|
||||
const resultValue = eval(str);
|
||||
|
||||
var resultOp = Operand.create(eval(str), this.operand1.kind || this.operand1.operand1.kind);
|
||||
var resultOp = Operand.create(eval(str), this.operand.kind || this.operand.operand.kind);
|
||||
console.log(resultValue, resultOp);
|
||||
|
||||
return resultOp;
|
||||
};
|
||||
|
||||
toString() {
|
||||
return this.sign + this.operand1.toString();
|
||||
return this.sign + this.operand.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user