예제 #1
0
//----------------------------------------------------------------------------
void QuadraticFreeForm2D::OnDisplay ()
{
    ClearScreen();

    int dim0 = mTexture->GetDimension(0, 0);
    int dim1 = mTexture->GetDimension(1, 0);
    unsigned char* data = (unsigned char*)mTexture->GetData(0);

    const int numSamples = 2*mSize;
    const float invNumSamples = 1.0f/(float)numSamples;
    Vector2f param;
    for (int s = 0; s < numSamples; ++s)
    {
        int u = s*dim0/numSamples;
        param.X() = invNumSamples*s;
        for (int t = 0; t < numSamples; ++t)
        {
            int v = t*dim1/numSamples;
            param.Y() = invNumSamples*t;
            Vector2f result = Evaluate(param);

            int x = ControlToScreen(result.X());
            int y = ControlToScreen(result.Y());
            int index = 4*(u + dim0*v);
            unsigned char b = data[index++];
            unsigned char g = data[index++];
            unsigned char r = data[index++];
            ++index;

            SetPixel(x, y, ColorRGB(r, g, b));
        }
    }

    // Draw the control points.
    ColorRGB green(0, 255, 0);
    for (int row = 0; row <= 2; ++row)
    {
        for (int col = 0; col <= 2; ++col)
        {
            SetThickPixel(mCtrlX[row][col], mCtrlY[row][col], 2, green);
        }
    }

    WindowApplication2::OnDisplay();
}
예제 #2
0
int AlphaBeta(board state, int depth, int alpha, int beta, int player, int *
        bestX, int * bestY)	//AlphaBeta
{
    int X,Y, numacts, i, value;
    int Xacts[64], Yacts[64];	//maximum of 64 (actually 60) possible moves
    board child;

    if (timelimit1){
        currenttime = clock();
        if (deadline < currenttime) return 0;
    }

    if (CutoffTest(state, depth)) return Evaluate(state);
    numacts = Actions(state, player, Xacts, Yacts);

    if (player == 1){//the MAX player (us)
        for (i=0; i<numacts; i++) {
            Result(state, child, player, Xacts[i], Yacts[i]);
            value = AlphaBeta(child, depth-1, alpha, beta, -player, &X, &Y);
            if (timelimit1 && deadline < currenttime) return 0;
            //checking if we've reached the timelimit if applicable
            if (value > alpha) {
                alpha = value;
                *bestX = Xacts[i]; *bestY = Yacts[i];
            }
            if (beta <= alpha)//beta cut-off
                break;
        }
        return alpha;
    } else {
        for (i=0; i<numacts; i++) {
            Result(state, child, player, Xacts[i], Yacts[i]);
            value = AlphaBeta(child, depth-1, alpha, beta, -player, &X, &Y);
            if (timelimit1 && deadline < currenttime) return 0;
            //checking if we've reached the time limit if applicable
            if (value < beta) {
                beta = value;
                *bestX = Xacts[i]; *bestY = Yacts[i];
            }
            if (beta <= alpha)//alpha cutoff
                break;
        }
        return beta;
    }
}
예제 #3
0
bool DistanceEstimator::DoesIntersect(const Ray &r, float *tHit) const {
  Ray ray;
  (*WorldToObject)(r, &ray);
  float t = ray.mint;
  bool intersected = false;
  for (int itr = 0; ray.mint <= t && t <= ray.maxt && itr < DE_params.maxIters; itr++) {
    float dist = Evaluate(ray(t));
    if (fabs(dist) < DE_params.hitEpsilon) {
      intersected = true;
      break;
    }
    t += dist;
  }
  if (!intersected || t < ray.mint || t > ray.maxt) 
    return false;
  if (tHit) *tHit = t;
  return true;
}
예제 #4
0
void MainWindow::ReportJackpotFileDownloaded()
{
    if (!UpdateJackpots()) {
        QMessageBox msgBox(this);
        msgBox.setText("That does not appear to be a valid table. Jackpots file is invalid.");
        msgBox.exec();
        ui->tableName->setEnabled(true);
        ui->table_instructions->show();
        return;
    }
    if (m_gamestate == Login) {
        SetupMoney();
    }
    else if (m_gamestate == WaitingForPayout) {
        // let's try once more to make a payout, but with the new jackpot amounts
        Evaluate();
    }
}
예제 #5
0
size_w SetTypeGV(HWND hwndGridView, HGRIDITEM hItem, TypeDecl *typeDecl, size_w dwOffset)
{
	if(typeDecl->typeAlias == true)
		return dwOffset;

	if(typeDecl->declList.size() > 0)
	{
		Type *type = typeDecl->declList[0];
		ExprNode *offsetExpr;

		if(FindTag(typeDecl->tagList, TOK_OFFSET, &offsetExpr))
			dwOffset = Evaluate(offsetExpr);
			
		dwOffset += RecurseType(hwndGridView, hItem, type, dwOffset, typeDecl);
	}
	
	return dwOffset;
}
예제 #6
0
Value *
StdoutFn (const char *name, State * state, int argc, Expr * argv[])
{
  int i;

  for (i = 0; i < argc; ++i)
	  {
	    char *v = Evaluate (state, argv[i]);

	    if (v == NULL)
		    {
		      return NULL;
		    }
	    fputs (v, stdout);
	    free (v);
	  }
  return StringValue (strdup (""));
}
예제 #7
0
int ParameterScalar::SetValue(const string value, bool Eval)
{
	if (value.empty()) return -1;

	//check if string is only a plain double
	char *pEnd;
	double val = strtod(value.c_str(),&pEnd);
	if (*pEnd == 0)
		SetValue(val);

	ParameterMode=true;
	bModified=true;
	sValue=value;

	if (Eval) return Evaluate();

	return 0;
}
예제 #8
0
double EvalSubStatement (char *status, char *look, struct Variable *Vars) {
#ifdef DEBUG
	printf ("EvalSubStatement in; status: %i, look: %c;\n", *status, *look);
#endif
	char oldstatus = *status;
	*status = -1;					// pass on substatement status
	
	struct TokenStruct tmp;
//	tmp.Token = malloc (sizeof (char) * 2);
	tmp.Token = "+";
	tmp.type = TokenType ('+');
	tmp.priority = OpPriority ('+');
	
	double ret = Evaluate (0, tmp, status, look, Vars);
	if (!*status) { *status = oldstatus; }	// if no error occured during substatement evaluation, reset status

	return ret;
}
예제 #9
0
void CBDB_FileScanner::Scan(CBDB_Query& query)
{
    ResolveFields(query);
    CBDB_FileCursor cur(m_File);
    cur.SetCondition(CBDB_FileCursor::eFirst);

    while (cur.Fetch() == eBDB_Ok) {

        bool res = Evaluate(query);
        if (res) {
            EScanAction act = OnRecordFound();
            if (act == eStop) {
                break;
            }
        }
        query.ResetQueryClause();
    } // while
}
예제 #10
0
/*MATH_EXPRESSION FUNCTION Evaluate: EVALUATES EVERY OCCURANCE OF THE OPERATION*/
void MATH_EXPRESSION::Evaluate(int op1, int op2) {
  if( (op1==op)||(op2==op) ) {
    //Evaluate mathematical operation
    if(op=='^') {number = pow(number, next->number);} else
    if(op=='*') {number = number * next->number;} else
    if(op=='/') {number = number / next->number;} else
    if(op=='+') {number = number + next->number;} else
    if(op=='-') {number = number - next->number;} else
    {Log <<"Operation: "<<op<<" is undefined."<<endl;}
    //Reduce linked list by copying numbers and operators down one
    op = next->op;
    if(next->next==NULL) {
      delete next;
      next=NULL;
      return;
    }
    next->Copy();
    Evaluate(op1, op2);
  }
  if(next!=NULL) {next->Evaluate(op1, op2);}
  return;


  /*if(_op==op) {
    //Evaluate mathematical operation
    if(op=='^') {number = pow(number, next->number);} else
    if(op=='*') {number = number * next->number;} else
    if(op=='/') {number = number / next->number;} else
    if(op=='+') {number = number + next->number;} else
    if(op=='-') {number = number - next->number;} else
    {Log <<"Operation: "<<op<<" is undefined."<<endl;}
    //Reduce linked list by copying numbers and operators down one
    op = next->op;
    if(next->next==NULL) {
      delete next;
      next=NULL;
      return;
    }
    next->Copy();
    Evaluate(_op);
  }
  if(next!=NULL) {next->Evaluate(_op);}
  return;*/
}
예제 #11
0
int main(int argc, char** argv) {
    RegisterBuiltins();
    FinishRegistration();

    if (argc == 1) {
        return test() != 0;
    }

    FILE* f = fopen(argv[1], "r");
    if (f == NULL) {
        printf("%s: %s: No such file or directory\n", argv[0], argv[1]);
        return 1;
    }
    char buffer[8192];
    int size = fread(buffer, 1, 8191, f);
    fclose(f);
    buffer[size] = '\0';

    Expr* root;
    int error_count = 0;
    yy_scan_bytes(buffer, size);
    int error = yyparse(&root, &error_count);
    printf("parse returned %d; %d errors encountered\n", error, error_count);
    if (error == 0 || error_count > 0) {

        ExprDump(0, root, buffer);

        State state;
        state.cookie = NULL;
        state.script = buffer;
        state.errmsg = NULL;

        char* result = Evaluate(&state, root);
        if (result == NULL) {
            printf("result was NULL, message is: %s\n",
                   (state.errmsg == NULL ? "(NULL)" : state.errmsg));
            free(state.errmsg);
        } else {
            printf("result is [%s]\n", result);
        }
    }
    return 0;
}
예제 #12
0
파일: main.c 프로젝트: bju2000/MT6797
int expect(const char* expr_str, const char* expected, int* errors) {
    Expr* e;
    char* result;

    printf(".");

    int error_count = parse_string(expr_str, &e, &error_count);
    if (error_count > 0) {
        fprintf(stderr, "error parsing \"%s\" (%d errors)\n",
               expr_str, error_count);
        ++*errors;
        return 0;
    }

    State state;
    state.cookie = NULL;
    state.script = strdup(expr_str);
    state.errmsg = NULL;

    result = Evaluate(&state, e);
    free(state.errmsg);
    free(state.script);
    if (result == NULL && expected != NULL) {
        fprintf(stderr, "error evaluating \"%s\"\n", expr_str);
        ++*errors;
        return 0;
    }

    if (result == NULL && expected == NULL) {
        return 1;
    }

    if (strcmp(result, expected) != 0) {
        fprintf(stderr, "evaluating \"%s\": expected \"%s\", got \"%s\"\n",
               expr_str, expected, result);
        ++*errors;
        free(result);
        return 0;
    }

    free(result);
    return 1;
}
예제 #13
0
파일: PhaseFit.cpp 프로젝트: Jorges1000/TS
int PhaseFit::LevMarFit(int max_iter, int nParam, float *params) {
  unsigned int nRead = signal.size();
  int nData = nRead * nFlow;

  // Call LevMarFitter::Initialize() - the 3rd arg is null as we don't need access to
  // the LevMarFitter's internal x array in the calls to Evaluate
  Initialize(nParam,nData,NULL);

  // Update LevMarFitter::residualWeight array if we are using flow-specific weighting or
  // if we are ignoring homopolymers of size > 1
  if( (!ignoreHPs) || (flowWeight.size() > 0) || (hpWeight.size() > 0) )
    updateResidualWeight(ignoreHPs, flowWeight, hpWeight);

  // Gather the observed data into an array of floats
  float *y   = new float[nData];
  unsigned int iY=0;
  for(unsigned int iRead=0; iRead<nRead; iRead++)
    for(unsigned int iFlow=0; iFlow<nFlow; iFlow++)
      y[iY++] = (float) signal[iRead][iFlow];

  err.resize(nData);
  int nIter = LevMarFitter::Fit(max_iter, y, params);

  // Store the (possibly weighted) residuals
  float *fval = new float[len];
  Evaluate(fval,params);
  residual_raw_vec.resize(nRead);
  residual_weighted_vec.resize(nRead);
  for(unsigned int iRead=0,iY=0; iRead<nRead; iRead++) {
    residual_raw_vec[iRead].resize(nFlow);
    residual_weighted_vec[iRead].resize(nFlow);
    for(unsigned int iFlow=0; iFlow<nFlow; iFlow++, iY++) {
      weight_t res = y[iY] - fval[iY];
      residual_raw_vec[iRead][iFlow] = res;
      residual_weighted_vec[iRead][iFlow] = residualWeight[iY] * res;
    }
  }
  delete [] fval;

  delete [] y;

  return(nIter);
}
예제 #14
0
 AnimatedTranslateTransform2Impl(
     Number* ptime,
     RectValue* prect,
     int side,
     const Point& vecStart,
     const Point& vecEnd,
     float dtimeAnimation
 ) :
     AnimatedTranslateTransform2(ptime, prect),
     m_side(side),
     m_pointStart(vecStart),
     m_pointEnd(vecEnd),
     m_dtimeAnimation(dtimeAnimation),
     m_bGotoStart(true),
     m_bStationary(true),
     m_timeStart(ptime->GetValue() - dtimeAnimation)
 {
     Evaluate();
 }
예제 #15
0
// symlink target src1 src2 ...
//    unlinks any previously existing src1, src2, etc before creating symlinks.
Value* SymlinkFn(const char* name, State* state, int argc, Expr* argv[]) {
    if (argc == 0) {
        return ErrorAbort(state, "%s() expects 1+ args, got %d", name, argc);
    }
    char* target;
    target = Evaluate(state, argv[0]);
    if (target == NULL) return NULL;

    char** srcs = ReadVarArgs(state, argc-1, argv+1);
    if (srcs == NULL) {
        free(target);
        return NULL;
    }

    int bad = 0;
    int i;
    for (i = 0; i < argc-1; ++i) {
        if (unlink(srcs[i]) < 0) {
            if (errno != ENOENT) {
                fprintf(stderr, "%s: failed to remove %s: %s\n",
                        name, srcs[i], strerror(errno));
                ++bad;
            }
        }
        if (make_parents(srcs[i])) {
            fprintf(stderr, "%s: failed to symlink %s to %s: making parents failed\n",
                    name, srcs[i], target);
            ++bad;
        }
        if (symlink(target, srcs[i]) < 0) {
            fprintf(stderr, "%s: failed to symlink %s to %s: %s\n",
                    name, srcs[i], target, strerror(errno));
            ++bad;
        }
        free(srcs[i]);
    }
    free(srcs);
    if (bad) {
        return ErrorAbort(state, "%s: some symlinks failed", name);
    }
    return StringValue(strdup(""));
}
예제 #16
0
파일: calculator.cpp 프로젝트: Zplutor/zaf
static void CalculateExpression(
    const std::shared_ptr<SyntaxNode>& expression_node,
    const std::shared_ptr<CalculateResult>& result, 
    std::int64_t& integer_value) {

    auto evaluator = CreateValueEvaluator(expression_node);
    if (evaluator == nullptr) {
        result->error = CalculateResult::Error::SemanticsError;
        return;
    }

    std::shared_ptr<Value> value;
    auto evaluate_status = evaluator->Evaluate(value);
    if (evaluate_status != EvaluateStatus::Ok) {
        result->error = CalculateResult::Error::SemanticsError;
        return;
    }
    
    integer_value = value->integer_value;
}
예제 #17
0
Value *
AbortFn (const char *name, State * state, int argc, Expr * argv[])
{
  char *msg = NULL;

  if (argc > 0)
	  {
	    msg = Evaluate (state, argv[0]);
	  }
  free (state->errmsg);
  if (msg)
	  {
	    state->errmsg = msg;
	  }
  else
	  {
	    state->errmsg = strdup ("called abort()");
	  }
  return NULL;
}
예제 #18
0
파일: Template.cpp 프로젝트: kolyden/mirror
void TemplateDlg::Create()
{
	const PackageTemplate& tp = ActualTemplate();
	ArrayMap<String, EscValue> var = MakeVars();
	for(int i = 0; i < tp.file.GetCount(); i++) {
		const FileTemplate& ft = tp.file[i];
		if(IsNull(ft.condition) || IsTrue(Evaluate(ft.condition, var))) {
			String fn = Expand(ft.filename, var);
			if(!IsNull(fn)) {
				fn = AppendFileName(AppendFileName(~nest, (String)~package), fn);
				RealizePath(fn);
				SaveFile(fn, Expand(ft.text, var));
			}
		}
	}
	Package p;
	String f = AppendFileName(AppendFileName(~nest, (String)~package), (String)~package + ".upp");
	p.Load(f);
	p.description = ~description;
	p.Save(f);
}
예제 #19
0
Value *
GetPropFn (const char *name, State * state, int argc, Expr * argv[])
{
  if (argc != 1)
	  {
	    return ErrorAbort (state, "%s() expects 1 arg, got %d", name,
			       argc);
	  }
  char *key;

  key = Evaluate (state, argv[0]);
  if (key == NULL)
    return NULL;

  char value[PROPERTY_VALUE_MAX];

  property_get (key, value, "");
  free (key);

  return StringValue (strdup (value));
}
예제 #20
0
파일: Edge.cpp 프로젝트: Heeks/heekscad
void CEdge::GetGripperPositions(std::list<GripData> *list, bool just_for_endof){
	if(just_for_endof)
	{
		list->push_back(GripData(GripperTypeTranslate,m_start_x,m_start_y,m_start_z,NULL));
		list->push_back(GripData(GripperTypeTranslate,m_end_x,m_end_y,m_end_z,NULL));
	}
	else
	{
		// add a gripper in the middle, just to show the edge is selected
		if(!m_midpoint_calculated)
		{
			BRepAdaptor_Curve curve(m_topods_edge);
			double us = curve.FirstParameter();
			double ue = curve.LastParameter();
			double umiddle = (us+ue)/2;
			Evaluate(umiddle, m_midpoint, NULL);
		}

		list->push_back(GripData(GripperTypeTranslate,m_midpoint[0],m_midpoint[1],m_midpoint[2],NULL));
	}
}
void LevelSetOperator::EulerStep(LevelSetGrid & gridOut,float dt)
{
// Iterate over grid and compute the grid values for the next timestep
	gridOut = GetGrid();
  LevelSetGrid::Iterator iter = GetGrid().BeginNarrowBand();
  LevelSetGrid::Iterator iend = GetGrid().EndNarrowBand();
  while (iter != iend) {
    unsigned int i = iter.GetI();
    unsigned int j = iter.GetJ();
    unsigned int k = iter.GetK();

    // Compute rate of change
    float ddt = Evaluate(i,j,k);

    // Compute the next time step and store it in the grid
    gridOut.SetValue(i,j,k, GetGrid().GetValue(i,j,k) + ddt*dt);

    iter++;
  }

}
예제 #22
0
Value *
DeleteFn (const char *name, State * state, int argc, Expr * argv[])
{
  char **paths = malloc (argc * sizeof (char *));
  int i;

  for (i = 0; i < argc; ++i)
	  {
	    paths[i] = Evaluate (state, argv[i]);
	    if (paths[i] == NULL)
		    {
		      int j;

		      for (j = 0; j < i; ++i)
			      {
				free (paths[j]);
			      }
		      free (paths);
		      return NULL;
		    }
	  }

  bool recursive = (strcmp (name, "delete_recursive") == 0);

  int success = 0;

  for (i = 0; i < argc; ++i)
	  {
	    if ((recursive ? dirUnlinkHierarchy (paths[i]) :
		 unlink (paths[i])) == 0)
	      ++success;
	    free (paths[i]);
	  }
  free (paths);

  char buffer[10];

  sprintf (buffer, "%d", success);
  return StringValue (strdup (buffer));
}
예제 #23
0
int 
prefix (char *expr, int *result) 
{
	if (!expr) return -1;
	int len = strlen (expr) - 1;
	int n1=0, n2=0;

	while (len >= 0) 
	{
		if (isOperator(expr[len])) {
			n1 = pop (&s);
			n2 = pop (&s);
			r = Evaluate (expr[len], n1, n2);
			push (&s, r);
		} else {
			push (&s, expr[len] - '0');
		}
		len--;
	}
	*result = pop (&s);
	return 0;
}
예제 #24
0
ON_BOOL32 
ON_Surface::EvPoint( // returns false if unable to evaluate
       double s, double t, // evaluation parameters
       ON_3dPoint& point,
       int side,        // optional - determines which side to evaluate from
                       //         0 = default
                       //         1 from NE quadrant
                       //         2 from NW quadrant
                       //         3 from SW quadrant
                       //         4 from SE quadrant
       int* hint       // optional - evaluation hint (int[2]) used to speed
                       //            repeated evaluations
       ) const
{
  ON_BOOL32 rc = false;
  double ws[128];
  double* v;
  if ( Dimension() <= 3 ) {
    v = &point.x;
    point.x = 0.0;
    point.y = 0.0;
    point.z = 0.0;
  }
  else if ( Dimension() <= 128 ) {
    v = ws;
  }
  else {
    v = (double*)onmalloc(Dimension()*sizeof(*v));
  }
  rc = Evaluate( s, t, 0, Dimension(), v, side, hint );
  if ( Dimension() > 3 ) {
    point.x = v[0];
    point.y = v[1];
    point.z = v[2];
    if ( Dimension() > 128 )
      onfree(v);
  }
  return rc;
}
예제 #25
0
// Evaluate the expressions in argv, giving 'count' char* (the ... is
// zero or more char** to put them in).  If any expression evaluates
// to NULL, free the rest and return -1.  Return 0 on success.
int ReadArgs(State* state, Expr* argv[], int count, ...) {
    char** args = malloc(count * sizeof(char*));
    va_list v;
    va_start(v, count);
    int i;
    for (i = 0; i < count; ++i) {
        args[i] = Evaluate(state, argv[i]);
        if (args[i] == NULL) {
            va_end(v);
            int j;
            for (j = 0; j < i; ++j) {
                free(args[j]);
            }
            free(args);
            return -1;
        }
        *(va_arg(v, char**)) = args[i];
    }
    va_end(v);
    free(args);
    return 0;
}
예제 #26
0
Value* IfElseFn(const char* name, State* state, int argc, Expr* argv[]) {
    if (argc != 2 && argc != 3) {
        free(state->errmsg);
        state->errmsg = strdup("ifelse expects 2 or 3 arguments");
        return NULL;
    }
    char* cond = Evaluate(state, argv[0]);
    if (cond == NULL) {
        return NULL;
    }

    if (BooleanString(cond) == true) {
        free(cond);
        return EvaluateValue(state, argv[1]);
    } else {
        if (argc == 3) {
            free(cond);
            return EvaluateValue(state, argv[2]);
        } else {
            return StringValue(cond);
        }
    }
}
예제 #27
0
// A simple test to make sure function expressions are filled in correctly
TEST_F(ExpressionTests, FunctionExpressionTest) {
  // these will be gc'd by substr
  auto str = expression::ExpressionUtil::ConstantValueFactory(
      type::ValueFactory::GetVarcharValue("test123"));
  auto from = expression::ExpressionUtil::ConstantValueFactory(
      type::ValueFactory::GetIntegerValue(2));
  auto to = expression::ExpressionUtil::ConstantValueFactory(
      type::ValueFactory::GetIntegerValue(3));
  // these need unique ptrs to clean them
  auto substr =
      ExpPtr(new expression::FunctionExpression("substr", {str, from, to}));
  auto not_found = ExpPtr(new expression::FunctionExpression("", {}));
  // throw an exception when we cannot find a function
  EXPECT_THROW(
      expression::ExpressionUtil::TransformExpression(nullptr, not_found.get()),
      peloton::Exception);
  expression::ExpressionUtil::TransformExpression(nullptr, substr.get());
  // do a lookup (we pass null schema because there are no tuple value
  // expressions
  EXPECT_TRUE(substr->Evaluate(nullptr, nullptr, nullptr)
                  .CompareEquals(type::ValueFactory::GetVarcharValue("est")) ==
              type::CMP_TRUE);
}
예제 #28
0
파일: test.c 프로젝트: heisencoder/gnuchess
void TestEval (void)
/**************************************************************************
 *
 *  To test the evaluation routines,  read from the BK.epd test file.
 *  Print out the score.  This can be improved by being more verbose
 *  and printing out salient features of the board, e.g. King safety,
 *  double bishops, rook on seventh rank, weak pawns, doubled pawns,
 *  bad bishops, passwd pawns, etc etc.
 *
 ***************************************************************************/
{
   int score;

   SET (flags, TESTT);
   while (ReadEPDFile ("../test/wac.epd", 0))
   {
      ShowBoard ();
      score = Evaluate (-INFINITY, INFINITY);
      printf (board.side == white ? "W : " : "B : ");
      printf ("score = %d\n\n", score);
   }
   CLEAR (flags, TESTT);
}
예제 #29
0
double EvalFunction (struct TokenStruct val, char *status, char *look, struct Variable *Vars) {
#ifdef DEBUG
	printf ("EvalFunction in; Val: %s, status: %i, look: %c;\n", val.Token, *status, *look);
#endif

	// parse args
	double *Args = 0; int nargs = 0;
	char oldstatus = *status;
	struct TokenStruct tmp;
	//tmp.Token = malloc (sizeof (char) * 2);
	tmp.Token = "+";
	tmp.type = TokenType ('+');
	tmp.priority = OpPriority ('+');
//	tmp.index = 0;
	
	*status = -2;	// set status to indicate argument evaluation 
	if (*look != ')') {	// make sure there are more than zero arguments
		while (*status == -2) {
			Args = realloc (Args, sizeof (double) * ++nargs);			// make room for the next argument
			Args[nargs-1] = Evaluate (0.0, tmp, status, look, Vars);	// and add it to the argument vector
		}
		
		if (*status) {		// argument(s) invalid; return. Error in Evaluate, let it handle the error
			free (Args);
			return;
		}
	}
	else { NextToken (look); }
	*status = oldstatus;
	
	// resolve function
	double ret = GetFunction (val, Args, nargs, status);

	if (Args) { free (Args); }
//	if (*status > 0) { HandleError (val, *status, look); }	// Let Evaluate or Parse handle errors
	return ret;
}
예제 #30
0
파일: display.cpp 프로젝트: 4aiman/HexEdit
void PrintType(Type *type)
{
	if(type->ty == typeIDENTIFIER || type->ty == typeTYPEDEF)
		printf("'%s' :-  ", type->sym->name);

	while(type)
	{
		switch(type->ty)
		{
		case typePOINTER:	printf(" POINTER(*) -> "); break;
		case typeARRAY:		printf(" ARRAY[%d] -> ", (int)Evaluate(type->elements)); break;
		case typeTYPEDEF:	printf(" TYPEDEF(%s) -> ", type->sym->name); break;
		case typeSTRUCT:	printf(" STRUCT(%s) ", type->sptr->symbol->name);	break;
		case typeENUM:		printf(" ENUM(%s) ", type->eptr->symbol->name);		break;
		case typeFUNCTION:	printf(" FUNC-returning(%s)", type->fptr->symbol->name);		break;	

		case typeCHAR:		case typeWCHAR: 
		case typeBYTE:		case typeWORD:
		case typeDWORD:		case typeQWORD:
			printf("%s ", Parser::inenglish(TypeToToken(type->ty))); 
			break;

		case typeUNSIGNED:	printf(" UNSIGNED -> "); break;
		case typeSIGNED:	printf(" SIGNED -> "); break;
		case typeCONST:		printf(" CONST -> "); break;

		case typeIDENTIFIER:
			//printf("%s ", type->var->varName);
			//printf("ID(%s) > ", type->sym->name);
			break;
		}

		type = type->link;
	}

	//printf("\n");
}