staccount::staccount (sfield::ref n, account const& v) : stblob (n) { peekvalue ().insert (peekvalue ().end (), v.begin (), v.end ()); }
bool staccount::isvalueh160 () const { return peekvalue ().size () == (160 / 8); }
int main(int argc, char* argv[]){ char *curr; char *endptr; double value; int operator; int i; int j; // int len; int state=VALUE_STATE; Stackframe *valuestack = NULL; Stackframe *opstack = NULL; if(argc==1){ printf("usage: %s [expression]\n",argv[0]); exit(1); } for(j=1; j<argc; j++){ curr=argv[j]; while((*curr) != 0){ curr = strip(curr); if(state==VALUE_STATE){ value = strtod(curr,&endptr); //try and read a number if(curr == endptr){ fprintf(stderr,"failed to read value at %s\n",curr); exit(1); } valuestack = pushtostack(valuestack,&value,sizeof(double)); curr = endptr; state=OP_STATE; }else if(state==OP_STATE){ operator = -1; i = 0; while(operators[i].symbol != NULL){ if(strncmp(operators[i].symbol,curr,operators[i].symbol_len) == 0){ operator = operators[i].number; opstack = evalAndPush(&opstack, &valuestack, operator); curr+=operators[i].symbol_len; break; } i++; } if(operator == -1){ fprintf(stderr,"invalid operator at %s\n",curr); exit(1); } state=VALUE_STATE; }else{ fprintf(stderr,"unknown state %d\n", state); exit(1); } } } while((valuestack != NULL) && (opstack != NULL)){ evaluateStackframe(&opstack,&valuestack); } printf("= %g\n",peekvalue(valuestack)); /* while(valuestack != NULL){ value = peekvalue(); printf("valuestack=%f %x\n",value,valuestack); valuestack = popfromstack(valuestack, (void**)&valueptr); printf("value==%f\n",*valueptr); } while(opstack != NULL){ operator = peekop(); printf("opstack=%d %x\n",operator,opstack); opstack = popfromstack(opstack, (void**)&opptr); printf("value==%d\n",*opptr); } */ exit(0); }