Fix error when not showing shift expression results

This commit is contained in:
Borys_Levytskyi
2016-11-27 16:06:01 +02:00
parent 46a6833e43
commit 1a3ff0c9b5
5 changed files with 11 additions and 9 deletions

1
ds.bat Normal file
View File

@@ -0,0 +1 @@
npm run serv

View File

@@ -8,12 +8,9 @@ export default class AppRoot extends React.Component {
this.props.appState.onChange(() => this.refresh());
}
refresh() {
console.log(this.props.appState.commandResults);
this.setState(this.props.appState);
}
render() {
console.log('[AppRoot] render():this.state.commandResults', this.state.commandResults)
var results = this.state.commandResults.map((r, i) => <DisplayResultView key={i} content={r} input={r.input} inputHash={r.inputHash} />);
return <div>
<div className="header">

View File

@@ -10,7 +10,9 @@ export default class BitwiseOperationEpxressionView extends React.Component {
}
return <table className="expression">
<tbody>{rows}</tbody>
<tbody>
{rows}
</tbody>
</table>
}
@@ -24,6 +26,7 @@ export default class BitwiseOperationEpxressionView extends React.Component {
if(expr instanceof expression.MultipleOperandsExpression) {
const m = BitwiseExpressionViewModel.buildMultiple(expr);
console.log('Render model', m);
return m.items.map((itm, i) => <ExpressionRow key={i} {...itm} maxNumberOfBits={m.maxNumberOfBits} />);
}
@@ -35,12 +38,14 @@ class ExpressionRow extends React.Component {
render() {
const { sign, label, bin, other, css, maxNumberOfBits } = this.props;
return <tr className={css}>
var tr = <tr className={css}>
<td className="sign">{sign}</td>
<td className="label">{label}</td>
<td className="bin">{formatter.padLeft(bin, maxNumberOfBits, '0')}</td>
<td className="other">{other}</td>
</tr>;
return tr;
}
}
@@ -89,14 +94,14 @@ class BitwiseExpressionViewModel {
addExpression(expression) {
this.maxNumberOfBits = Math.max(expression.operand1.getLengthInBits(), this.maxNumberOfBits);
this.items.push({ sign: expression.sign, label: expression.operand1.input, bin: expression.operand1.bin, other: expression.operand1.other, css: ''});
this.items.push({ sign: expression.sign, label: expression.operand1.toString(), bin: expression.operand1.bin, other: expression.operand1.other, css: ''});
};
addShiftExpressionResult(expression, resultOperand) {
this.maxNumberOfBits = Math.max(resultOperand.getLengthInBits(), this.maxNumberOfBits);
this.items.push({
sign: expression.sign + expression.operand1.input,
label: resultOperand,
label: resultOperand.toString(),
bin: resultOperand.bin,
other: resultOperand.other,
css: 'expression-result'});

View File

@@ -36,7 +36,6 @@ var expression = {
this.factories.push(factory);
},
Operand:Operand,
TwoOperandExpression: TwoOperandExpression,
SingleOperandExpression: SingleOperandExpression,
ListOfNumbersExpression: ListOfNumbersExpression,
MultipleOperandsExpression: MultipleOperandsExpression

View File

@@ -10,7 +10,7 @@ commands.initialize(cmd);
// cmd.execute('1');
// cmd.execute('2');
cmd.execute('~3');
cmd.execute('1|2<<2');
var root = <AppRoot appState={appState} />;
ReactDOM.render(root, document.getElementById('root'));