Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhadeepJasu committed Nov 3, 2021
1 parent 61cd827 commit 59a59d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 264 deletions.
255 changes: 0 additions & 255 deletions src/Core/Programmer.vala

This file was deleted.

18 changes: 11 additions & 7 deletions src/Core/ProgrammerCalculator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
* Saunak Biswas <[email protected]>
*/
namespace Pebbles {

public errordomain CalcError {
DIVIDE_BY_ZERO
}


public class ProgrammerCalculator {
private const char[] HEXADECIMAL_DIGITS = { 'a', 'b', 'c', 'd', 'e', 'f'};
public enum TokenType {
Expand Down Expand Up @@ -570,8 +576,7 @@ namespace Pebbles {
}
}

public bool[] apply_op (Programmer prog_calc, char op, bool[] a_input, bool[] b_input, Pebbles.GlobalWordLength word_size) throws CalcError {
print ("finding...\n");
public bool[] apply_op (char op, bool[] a_input, bool[] b_input, Pebbles.GlobalWordLength word_size) throws CalcError {
bool[] ret_val = new bool[64];
if (word_size == GlobalWordLength.BYT) {
int8 a = 0;
Expand Down Expand Up @@ -850,10 +855,9 @@ namespace Pebbles {
return ret_val;
}

public string evaluate_exp (GlobalWordLength? wrd_length = GlobalWordLength.BYT, NumberSystem number_system, out bool[]? output_array = null) throws CalcError {
public string evaluate_exp (GlobalWordLength? wrd_length = GlobalWordLength.BYT, NumberSystem? number_system = NumberSystem.BINARY, out bool[]? output_array = null) throws CalcError {
CharStack ops = new CharStack (50);
BoolArrayStack values = new BoolArrayStack(50);
Programmer prog_calc = new Programmer();
for (int i = 0; i < stored_tokens.length; i++) {
if (stored_tokens[i].type == TokenType.OPERAND) {
//ops.push((char)(stored_tokens[i].token.get_char(0)));
Expand All @@ -865,7 +869,7 @@ namespace Pebbles {
else {
while (ops.peek() != '(') {
try {
bool[] tmp = apply_op(prog_calc, ops.pop(), values.pop(), values.pop(), wrd_length);
bool[] tmp = apply_op(ops.pop(), values.pop(), values.pop(), wrd_length);
values.push(tmp);
} catch (CalcError e) {
throw e;
Expand All @@ -876,7 +880,7 @@ namespace Pebbles {
} else if (stored_tokens[i].type == TokenType.OPERATOR) {
while (!ops.empty() && has_precedence_pemdas(stored_tokens[i].token.get(0), ops.peek())) {
try {
bool[] tmp = apply_op(prog_calc, ops.pop(), values.pop(), values.pop(), wrd_length);
bool[] tmp = apply_op(ops.pop(), values.pop(), values.pop(), wrd_length);
values.push(tmp);
} catch (CalcError e) {
throw e;
Expand All @@ -888,7 +892,7 @@ namespace Pebbles {
}
while (!ops.empty()) {
try {
bool[] tmp = apply_op(prog_calc, ops.pop(), values.pop(), values.pop(), wrd_length);
bool[] tmp = apply_op(ops.pop(), values.pop(), values.pop(), wrd_length);
values.push(tmp);
} catch (CalcError e) {
throw e;
Expand Down
2 changes: 1 addition & 1 deletion src/Test/TestUtil.vala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Pebbles {
private static void test_programmer_integration () {
var settings = Settings.get_default ();
settings.number_system = NumberSystem.DECIMAL;
ProgrammerCalculator prog_calc_front = new ProgrammerCalculator ();
// ProgrammerCalculator prog_calc_front = new ProgrammerCalculator ();
}
// private static void test_programmer(string input1, string input2) {
// Programmer prog_calc = new Programmer();
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ sources = files (
'Core/ScientificCalculator.vala',
'Core/Calculus.vala',
'Core/ProgrammerCalculator.vala',
'Core/Programmer.vala',
'Core/Statistics.vala',
'Core/Utils.vala',
'Core/Converter.vala',
Expand Down

0 comments on commit 59a59d3

Please sign in to comment.