1 #include <../../nrnconf.h>
32 if (--bbs_poll_ == 0) { \
46 if (stackp >= stacklast) \
47 execerror("Stack too deep.", "Increase with -NSTACK stacksize option");
53 for (
k = 0, l =
i;
k < 2;
k++, l =
j) {
77 s[
k] =
"(Object * already unreffed on stack)";
84 fprintf(stderr,
"bad stack access: expecting %s; really %s\n", s[1], s[0]);
85 execerror(
"interpreter stack type error", (
char*) 0);
109 #define tstkchk(i, j) (((i) != (j)) ? tstkchk_actual(i, j) : 0)
111 ((stackp++)->val = (d)); \
112 ((stackp++)->i = NUMBER)
114 ((stackp++)->sym = (d)); \
115 ((stackp++)->i = SYMBOL)
116 #define nopopm() (stackp -= 2)
117 #define xpopm() (tstkchk(stackp[-1].i, NUMBER), nopopm(), stackp->val)
118 #define spopm() (tstkchk(stackp[-1].i, SYMBOL), nopopm(), stackp->sym)
120 #define pushxm(d) pushx(d)
121 #define pushsm(d) pushs(d)
122 #define xpopm() xpop()
123 #define spopm() spop()
124 #define nopopm() nopop()
125 #define tstkchk(i, j) tstkchk_actual(i, j)
128 #define EPS hoc_epsilon
131 #define nstack hoc_nstack
135 #define stack stlstack
160 #define nframe hoc_nframe
181 #define DEBUG_GARBAGE 1
182 #define TOBJ_POOL_SIZE 50
299 for (
i = f->
nargs - 1;
i >= 0; --
i) {
310 for (f =
fp; f > ff; --f) {
335 stkp[-2 *
i + 1].
i = 0;
346 for (stkp =
stackp - 2; stkp >=
stack; stkp -= 2) {
353 printf(
"OBJECTTMP at stack index %ld already unreffed\n", stkp -
stack);
375 #define MAXINITFCNS 10
388 Printf(
"%d stacktype=%d\n",
i, s->
i);
398 fprintf(stderr,
"increase definition for MAXINITFCNS\n");
543 Inst *sprogbase, *sprogp, *spc, *sprog_parse_recover;
544 Datum *sstackp, *sstack;
567 "Maybe you were in the middle of a direct command.");
576 hoc_execerror(
"incomplete statement parse not allowed\n",
nullptr);
619 execerror(
"Nothing to parse", (
char*) 0);
638 #define HOC_TEMP_CHARPTR_SIZE 128
695 if (s->
type == CSTRING) {
785 return (
stackp - 2 *
i - 1)->i;
827 printf(
"(Object * already unreffed by hoc_stkobj_ref at stkindex %ld. Following name print may cause a crash if already freed.\n", d -
stack);
919 #define relative(pc) (pc + (pc)->i)
956 static int first = 1;
961 "Assignment to %s physical constant %s",
1037 Inst *stmtbegin, *stmtend;
1040 argcount = (
pc++)->
i;
1052 execerror(sym->
name,
"call nested too deeply, increase with -NFRAME framesize option");
1127 hoc_execerror(
"return from within an iterator statement not allowed.",
1128 "Set a flag and use break.");
1147 double *
pval = 0, dx;
1150 extern int _method3;
1153 switch (sym->
type) {
1187 for (
i = 0, *
pval = 0;
i <= imax;
i++) {
1188 if (mode == 0 && (
i == imax ||
i == 0)) {
1219 for (;
i <= imax;
i++) {
1242 }
else if (
i < imax) {
1250 execerror(
"for (var) {stmt} syntax only allowed in CABLE", (
char*) 0);
1264 mode = (
fabs(d) <
EPS) ? 0 : 1;
1276 else if ((savepc + 1)->
i)
1298 Inst *inst, *newinst;
1309 *newinst++ = *inst++;
1324 for (
i = 5, f =
fp; f !=
frame && --
i; f = f - 1) {
1325 for (
j =
i;
j;
j--) {
1340 if (strlen(s) > 15) {
1341 Fprintf(stderr,
"\"%.10s...\"", s);
1353 if (++j <= f->nargs) {
1360 Fprintf(stderr,
"and others\n");
1367 execerror(sp->
name,
"call nested too deeply, increase with -NFRAME framesize option");
1390 execerror(sp->
name,
"call nested too deeply, increase with -NFRAME framesize option");
1402 if (sp->
type == FUN_BLTIN || sp->
type == OBJECTFUNC || sp->
type == STRINGFUNC) {
1465 if (s->
type == BLTIN) {
1511 if (
fp->
sp->
type == HOCOBJFUNCTION)
1521 if (
fp->
sp->
type != HOCOBJFUNCTION)
1554 execerror(
"argtype can only be called in a func or proc", 0);
1556 iarg = (int)
chkarg(1, -1000., 100000.);
1557 if (iarg > f->
nargs || iarg < 1) {
1609 execerror(
"Expecting string argument", (
char*) 0);
1612 if (sym->
type == CSTRING) {
1617 execerror(
"Expecting string argument", (
char*) 0);
1755 d = (*((
pc++)->sym->u.ptr))(d);
1767 if (last[-2].pf ==
eval) {
1772 sym = last[-10].
sym;
1784 for (pcv =
pc; pcv; --pcv) {
1798 }
else if (pcv->
in ==
STOP) {
1814 printf(
"code for hoc_autoobject()\n");
1838 switch (sym->
type) {
1882 hoc_eval_nemonode(sym,
xpopm(), &d);
1885 hoc_eval_nemoarea(sym,
xpopm(), &d);
1927 switch (sym->
type) {
1973 execerror(
"can't use pointer to local variable", sym->
name);
1979 execerror(
"attempt to evaluate pointer to a non-variable", sym->
name);
2026 static int intdiv(
double x,
double y,
int* iptr) {
2030 if (
fabs(x) > (1 << 62) ||
fabs(y) > (1 << 62))
2032 if (x == (
long) x && y == (
long) y)
2035 x *= (
long double) 10;
2036 y *= (
long double) 10;
2042 if (ix == iz * iy) {
2055 execerror(
"division by zero", (
char*) 0);
2060 if (intdiv(d1, d2, &
i))
2083 }
else if (r <= -d2) {
2108 d1 = (double) (d1 > d2 +
EPS);
2116 d1 = (double) (d1 < d2 -
EPS);
2124 d1 = (double) (d1 >= d2 -
EPS);
2132 d1 = (double) (d1 <= d2 +
EPS);
2138 double d1 = 0.0, d2;
2146 d1 = (double) (d1 <= d2 + EPS && d1 >= d2 -
EPS);
2156 d1 = (double) (*o1 == *o2);
2161 hoc_execerror(
"don't know how to compare these types", (
char*) 0);
2168 double d1 = 0.0, d2;
2176 d1 = (double) (d1 < d2 - EPS || d1 > d2 +
EPS);
2186 d1 = (double) (*o1 != *o2);
2191 hoc_execerror(
"don't know how to compare these types", (
char*) 0);
2200 d1 = (double) (d1 != 0.0 && d2 != 0.0);
2208 d1 = (double) (d1 != 0.0 || d2 != 0.0);
2215 d = (double) (d == 0.0);
2248 switch (sym->
type) {
2258 *(sym->
u.
pval) = d2;
2317 hoc_asgn_nemonode(sym,
xpopm(), &d2, op);
2320 hoc_asgn_nemoarea(sym,
xpopm(), &d2, op);
2352 *cpp = (
char*)
emalloc((
unsigned) (strlen(
buf) + 1));
2369 static char name[100];
2370 char* cp =
name + 100;
2382 for (
i = a->
nsub - 1;
i >= 0; --
i) {
2390 for (
j = n1 - 1;
j >= 0; --
j) {
2420 if (
type == OBJECTVAR) {
2427 for (
i = 0;
i < aray->
nsub;
i++) {
2430 if (d < 0 || d >= aray->
sub[
i])
2432 total = total * (aray->
sub[
i]) + d;
2434 for (
i = 0;
i < aray->
nsub;
i++)
2446 int nrnpnt_araypt(
Symbol* sp,
int pi) {
2456 for (
i = 0;
i < aray->
nsub;
i++) {
2459 if (d < 0 || d >= aray->
sub[
i])
2461 total = total * (aray->
sub[
i]) + d;
2467 for (
i = 0;
i < aray->
nsub;
i++)
2475 #if defined(__GO32__)
2480 grx_output_some_chars(
buf, strlen(
buf));
2482 grx_output_some_chars(
"\n", 1);
2554 doomed = (
pc++)->sym;
2559 if (doomed->
type == UNDEF)
2560 fprintf(stderr,
"%s: no such variable\n", doomed->
name);
2562 fprintf(stderr,
"%s: can't be deleted\n", doomed->
name);
2608 execerror(
"procedure too big", (
char*) 0);
2642 for (
i = end - 1;
i !=
begin;
i--) {
2649 printf(
"insert code: what follows is the entire code so far\n");
2653 printf(
"end of insert code debugging\n");
2657 #if defined(DOS) || defined(__GO32__) || defined(WIN32) || (MAC && !defined(DARWIN))
2668 if (++ntimes > 10) {
2676 #if MAC && !defined(DARWIN)
2678 if (++ntimes > 100) {
int segment_limits(double *pdx)
const char * secaccessname(void)
double cable_prop_eval(Symbol *sym)
void cable_prop_assign(Symbol *sym, double *pd, int op)
void rangevarevalpointer(void)
double * cable_prop_eval_pointer(Symbol *sym)
static void warn_assign_dynam_unit(const char *name)
static Inst * codechk(void)
static void frameobj_clean(Frame *f)
void hoc_delete_symbol(void)
static char * stmp[HOC_TEMP_CHARPTR_SIZE]
#define HOC_TEMP_CHARPTR_SIZE
static Object ** hoc_temp_obj_pool_
static void for_segment2(Symbol *sym, int mode)
void hoc_push_string(void)
Symbol * hoc_get_last_pointer_symbol(void)
void push_frame(Symbol *sp, int narg)
int hoc_array_index(Symbol *sp, Objectdata *od)
static Pfrv initfcns[MAXINITFCNS]
void hoc_evalpointer(void)
char * hoc_strgets(char *cbuf, int nc)
void hoc_iterator_stmt(void)
int tstkchk_actual(int i, int j)
void oc_save_code(Inst **a1, Inst **a2, Datum **a3, Frame **a4, int *a5, int *a6, Inst **a7, Frame **a8, Datum **a9, Symlist **a10, Inst **a11, int *a12)
void hoc_init_space(void)
void hoc_argrefasgn(void)
int araypt(Symbol *sp, int type)
void hoc_iterator_object(Symbol *sym, int argcount, Inst *beginpc, Inst *endpc, Object *ob)
static void frame_objauto_recover_on_err(Frame *ff)
int hoc_strgets_need(void)
void insertcode(Inst *begin, Inst *end, Pfrv f)
static int obj_pool_index_
static void rinitcode(void)
void oc_restore_code(Inst **a1, Inst **a2, Datum **a3, Frame **a4, int *a5, int *a6, Inst **a7, Frame **a8, Datum **a9, Symlist **a10, Inst **a11, int *a12)
Inst * hoc_codeptr(void *vp)
static const char * parsestr
void hoc_autoobject(void)
Inst * prog_parse_recover
static Object * unref_defer_
static void stack_obtmp_recover_on_err(int tcnt)
void hoc_unref_defer(void)
void hoc_define(Symbol *sp)
void hoc_object_eval(void)
void hoc_ob_pointer(void)
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
double chkarg(int, double low, double high)
void hoc_execerror(const char *, const char *)
int hoc_is_object_arg(int narg)
Object ** hoc_objgetarg(int narg)
void hoc_pushstr(char **d)
double hoc_call_func(Symbol *s, int narg)
Symbol * hoc_get_symbol(const char *var)
Object * hoc_obj_look_inside_stack(int i)
double * getarg(int narg)
void hoc_pushpx(double *d)
int hoc_inside_stacktype(int i)
Object * hoc_pop_object(void)
void hoc_pushobj(Object **d)
void hoc_free_string(char *)
int hoc_ParseExec(int yystart)
int hoc_obj_look_inside_stack_index(int i)
int hoc_is_str_arg(int narg)
int hoc_errno_check(void)
int hoc_is_temp_charptr(char **cpp)
Objectdata * hoc_objectdata
void hoc_assign_str(char **cpp, const char *buf)
Object ** hoc_temp_objptr(Object *obj)
int hoc_argtype(int narg)
double hoc_opasgn(int op, double dest, double src)
void hoc_tobj_unref(Object **p)
void hoc_warning(const char *, const char *)
int hoc_is_double_arg(int narg)
int nrnpy_pr(const char *fmt,...)
char ** hoc_temp_charptr(void)
int hoc_xopen_run(Symbol *sp, const char *str)
void hoc_obj_ref(Object *obj)
char * hoc_object_name(Object *ob)
void hoc_on_init_register(Pfrv pf)
void hoc_fake_call(Symbol *s)
void hoc_stkobj_unref(Object *o, int stkindex)
Datum * hoc_look_inside_stack(int i, int type)
int hoc_is_pdouble_arg(int narg)
double * hoc_pgetarg(int narg)
void hoc_obj_unref(Object *obj)
char * hoc_araystr(Symbol *sym, int index, Objectdata *obd)
void hoc_push_object(Object *d)
int hoc_is_tempobj_arg(int narg)
char ** hoc_pgargstr(int narg)
Object ** hoc_objpop(void)
HocStr * hocstr_create(size_t size)
void hocstr_resize(HocStr *hs, size_t n)
Objectdata * hoc_objectdata_restore(Objectdata *obdsav)
Objectdata * hoc_objectdata_save(void)
Symlist * hoc_top_level_symlist
Objectdata * hoc_top_level_data
double var(InputIterator begin, InputIterator end)
void hoc_check_intupt(int intupt)
char * emalloc(unsigned n)
int const size_t const size_t n
int nrnmpi_numprocs_world
static philox4x32_key_t k
double Pow(double x, double y)
void free_list(Symlist **list)
void hoc_run_stmt(Symbol *)
Symbol * hoc_parse_stmt(const char *, Symlist **)
static double done(void *v)
void hoc_free_symspace(Symbol *)
short cpublic
Note: public is a reserved keyword.