/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2002-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* C expression library evaluator
*
* Glenn Fowler
* AT&T Research
*/
#include "cxlib.h"
/*
* called once before the first cxeval()
* there can be multiple cxbeg ... cxeval ... cxend sequences
*/
int
{
int r;
char* oid;
char* s;
return 0;
goto head;
do
{
return -1;
return -1;
{
return -1;
}
{
(*cx->disc->errorf)(cx, cx->disc, 2, "%s: %s: method %s expected", expr->query->name, method, expr->query->method);
return -1;
}
{
head:
if (r)
return -1;
return 0;
}
return 0;
}
/*
* called once after the last cxeval()
* there can be multiple cxbeg ... cxeval ... cxend sequences
*/
int
{
return 0;
do
{
{
return -1;
}
{
return -1;
}
return -1;
return -1;
return 0;
}
/*
* execute program at pc
*/
static int
execute(Cx_t* cx, Cxexpr_t* expr, register Cxinstruction_t* pc, void* data, Cxoperand_t* rv, Cxdisc_t* disc)
{
register Cxcallout_f f;
Cxoperand_t r;
int i;
for (;;)
{
r.refs = 0;
{
if (i < -1)
return -1;
break;
}
*sp = r;
if (!so->refs && (f = cxcallout(cx, CX_DEL, so->type, cx->state->type_void, disc)) && (*f)(cx, pc, &r, NiL, so, data, disc))
break;
}
{
if (expr->reclaim && !sp->refs && (f = cxcallout(cx, CX_DEL, sp->type, cx->state->type_void, disc)))
{
}
}
}
/*
* evaluate expr
*/
static int
{
int r;
int t;
r = 0;
do
{
if ((t = expr->group ? eval(cx, expr->group, data, rv) : expr->query->sel ? (*expr->query->sel)(cx, expr, data, cx->disc) : expr->query->prog ? execute(cx, expr, expr->query->prog, data, rv, cx->disc) : 1) < 0)
return t;
if (t)
{
return t;
return t;
}
return t;
if (t)
r = 1;
return r;
}
/*
* evaluate expr
*/
int
{
int r;
if (!cx->evaluating++)
r = -(r + 2);
cx->evaluating--;
return r;
}