Skip to content

Commit

Permalink
gt can be used in filter, removed mappable booleans (does not seem li…
Browse files Browse the repository at this point in the history
…ke it woudl be used.)
  • Loading branch information
jweinst1 committed Jun 10, 2018
1 parent 5dfe8c0 commit 6abbdca
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
6 changes: 6 additions & 0 deletions include/WindComp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#define WindComp_LT_NUM(val1, val2) *(double*)(val1) < *(double*)(val2)

#define WindComp_GT_NUM(val1, val2) *(double*)(val1) > *(double*)(val2)

unsigned char* WindComp_begin(void);
const unsigned char* WindComp_end(void);

Expand Down Expand Up @@ -62,6 +64,10 @@ int WindComp_check_not(void);
// Unlike apply functions, this only supports a single argument.
int WindComp_check_lt(unsigned char** arg);

// Checks if item in comp buffer is greater than arg.
// Unlike apply functions, this only supports a single argument.
int WindComp_check_gt(unsigned char** arg);

// Maps an array of instructions onto the item in the comp buffer.
// Returns zero if error.
int WindComp_map(unsigned char* ins, const unsigned char* insEnd);
Expand Down
2 changes: 1 addition & 1 deletion src/code/WindRun.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int WindRun_exec(const char** code)
(void) WindExec_out();
break;
case WindCommand_push:
WindExec_push();
(void) WindExec_push();
break;
case WindCommand_clr:
WindExec_clr();
Expand Down
43 changes: 34 additions & 9 deletions src/flow/WindComp.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,41 @@ int WindComp_check_lt(unsigned char** arg)
}
}

int WindComp_check_gt(unsigned char** arg)
{
int result = 0;
switch(WindComp_BUF[0])
{
case WindType_Number:
switch(**arg)
{
case WindType_Number:
*arg += 1;
result = WindComp_GT_NUM(WindComp_BODY, *arg);
*arg += sizeof(double);
return result;
default:
return 0;
}
case WindType_Bool:
switch(**arg)
{
case WindType_Bool:
result = WindComp_BUF[1] > (*arg)[1];
*arg += 2;
return result;
}
default:
return 0;
}
}

/*Applies series of operations to item in comp*/
// THROWS with return of 0
int WindComp_map(unsigned char* ins, const unsigned char* insEnd)
{
unsigned moveChecker = 0;
int boolResult = 0;
//int boolResult = 0;
while(ins != insEnd)
{
switch(*ins)
Expand Down Expand Up @@ -284,14 +313,6 @@ int WindComp_map(unsigned char* ins, const unsigned char* insEnd)
ins++;
WindComp_clear();
return 1;
case WindType_Lt:
ins++;
// todo: refactor
boolResult = WindComp_check_lt(&ins);
WindComp_BUF[0] = WindType_Bool;
WindComp_BUF[1] = boolResult;
WindComp_ITEM_LEN = sizeof(unsigned char) + sizeof(unsigned char);
break;
case WindType_Sep:
ins++;
break;
Expand Down Expand Up @@ -320,6 +341,10 @@ int WindComp_filter(unsigned char* ins, const unsigned char* insEnd)
ins++;
if(!WindComp_check_lt(&ins)) goto FILTER_FAILURE;
break;
case WindType_Gt:
ins++;
if(!WindComp_check_gt(&ins)) goto FILTER_FAILURE;
break;
case WindType_Sep:
ins++;
break;
Expand Down
2 changes: 2 additions & 0 deletions src/flow/WindExec.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void WindExec_clr(void)

int WindExec_map(void)
{
if(!WindData_load_len()) return 1;
unsigned char* loadStart;
const unsigned char* loadStop;

Expand All @@ -50,6 +51,7 @@ int WindExec_map(void)

int WindExec_filter(void)
{
if(!WindData_load_len()) return 1;
unsigned char* loadStart;
const unsigned char* loadStop;

Expand Down
2 changes: 1 addition & 1 deletion src/util/IOUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void IOUtil_debug(void)
WindState_print_err(); //other func
printf("Mode: ");
WindState_print_mode();
printf("Command: ");
printf("\nCommand: ");
WindState_print_cmd();
puts("\n..........Data.........");
printf("Load Buffer: -> [ ");
Expand Down

0 comments on commit 6abbdca

Please sign in to comment.