NEURON
code.cpp File Reference
#include <../../nrnconf.h>
#include <errno.h>
#include "hoc.h"
#include "code.h"
#include "hocstr.h"
#include "parse.hpp"
#include "ocfunc.h"
#include "ocmisc.h"
#include "hocparse.h"
#include "equation.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <nrnmpi.h>
#include "nrnfilewrap.h"

Go to the source code of this file.

Classes

struct  Frame
 

Macros

#define BBSPOLL
 
#define STACKCHK
 
#define USEMACROS   1
 
#define tstkchk(i, j)   (((i) != (j)) ? tstkchk_actual(i, j) : 0)
 
#define pushxm(d)
 
#define pushsm(d)
 
#define nopopm()   (stackp -= 2) /*provision at use made to deal with OBJECTTMP*/
 
#define xpopm()   (tstkchk(stackp[-1].i, NUMBER), nopopm(), stackp->val)
 
#define spopm()   (tstkchk(stackp[-1].i, SYMBOL), nopopm(), stackp->sym)
 
#define EPS   hoc_epsilon
 
#define NSTACK   1000 /* default size */
 
#define nstack   hoc_nstack
 
#define stack   stlstack
 
#define NPROG   50000
 
#define NFRAME   512 /* default size */
 
#define nframe   hoc_nframe
 
#define DEBUG_GARBAGE   1
 
#define TOBJ_POOL_SIZE   50
 
#define MAXINITFCNS   10
 
#define HOC_TEMP_CHARPTR_SIZE   128
 
#define relative(pc)   (pc + (pc)->i)
 

Typedefs

typedef struct Frame Frame
 

Functions

void debugzz (Inst *)
 
int tstkchk_actual (int i, int j)
 
Object ** hoc_temp_objptr (Object *obj)
 
void hoc_tobj_unref (Object **p)
 
void hoc_unref_defer (void)
 
void hoc_pop_defer (void)
 
void hoc_stkobj_unref (Object *o, int stkindex)
 
static void frameobj_clean (Frame *f)
 
static void frame_objauto_recover_on_err (Frame *ff)
 
static void stack_obtmp_recover_on_err (int tcnt)
 
void hoc_init_space (void)
 
void hoc_prstack (void)
 
void hoc_on_init_register (Pfrv pf)
 
void initcode (void)
 
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 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)
 
int hoc_strgets_need (void)
 
char * hoc_strgets (char *cbuf, int nc)
 
static void rinitcode (void)
 
int hoc_ParseExec (int yystart)
 
int hoc_xopen_run (Symbol *sp, const char *str)
 
char ** hoc_temp_charptr (void)
 
int hoc_is_temp_charptr (char **cpp)
 
int hoc_stack_type (void)
 
void pushx (double d)
 
void hoc_pushobj (Object **d)
 
void hoc_push_object (Object *d)
 
void hoc_pushstr (char **d)
 
void hoc_push_string (void)
 
void hoc_pushpx (double *d)
 
void pushs (Symbol *d)
 
void pushi (int d)
 
int hoc_stacktype (void)
 
int hoc_argtype (int narg)
 
int hoc_is_double_arg (int narg)
 
int hoc_is_pdouble_arg (int narg)
 
int hoc_is_str_arg (int narg)
 
int hoc_is_object_arg (int narg)
 
int hoc_is_tempobj_arg (int narg)
 
Datumhoc_look_inside_stack (int i, int type)
 
Objecthoc_obj_look_inside_stack (int i)
 
int hoc_obj_look_inside_stack_index (int i)
 
int hoc_inside_stacktype (int i)
 
double xpop (void)
 
double * hoc_pxpop (void)
 
Symbolspop (void)
 
Object ** hoc_objpop (void)
 
Objecthoc_pop_object (void)
 
char ** hoc_strpop (void)
 
int ipop (void)
 
void nopop (void)
 
void constpush (void)
 
void pushzero (void)
 
void varpush (void)
 
void forcode (void)
 
static void warn_assign_dynam_unit (const char *name)
 
void shortfor (void)
 
void hoc_iterator (void)
 
void hoc_iterator_object (Symbol *sym, int argcount, Inst *beginpc, Inst *endpc, Object *ob)
 
void hoc_iterator_stmt (void)
 
static void for_segment2 (Symbol *sym, int mode)
 
void for_segment (void)
 
void for_segment1 (void)
 
void ifcode (void)
 
void Break (void)
 
void Continue (void)
 
void Stop (void)
 
void hoc_define (Symbol *sp)
 
void frame_debug (void)
 
void push_frame (Symbol *sp, int narg)
 
void pop_frame (void)
 
void call (void)
 
void hoc_fake_call (Symbol *s)
 
double hoc_call_func (Symbol *s, int narg)
 
void hoc_ret (void)
 
void funcret (void)
 
void procret (void)
 
void hocobjret (void)
 
void hoc_Numarg (void)
 
void hoc_Argtype (void)
 
int ifarg (int narg)
 
Object ** hoc_objgetarg (int narg)
 
char ** hoc_pgargstr (int narg)
 
double * hoc_pgetarg (int narg)
 
double * getarg (int narg)
 
int hoc_argindex (void)
 
void arg (void)
 
void hoc_stringarg (void)
 
double hoc_opasgn (int op, double dest, double src)
 
void argassign (void)
 
void hoc_argrefasgn (void)
 
void hoc_argref (void)
 
void hoc_argrefarg (void)
 
void bltin (void)
 
Symbolhoc_get_symbol (const char *var)
 
Symbolhoc_get_last_pointer_symbol (void)
 
void hoc_autoobject (void)
 
void eval (void)
 
void hoc_evalpointer (void)
 
void add (void)
 
void hoc_sub (void)
 
void mul (void)
 
void hoc_div (void)
 
void hoc_cyclic (void)
 
void negate (void)
 
void gt (void)
 
void lt (void)
 
void ge (void)
 
void le (void)
 
void eq (void)
 
void ne (void)
 
void hoc_and (void)
 
void hoc_or (void)
 
void hoc_not (void)
 
void power (void)
 
void assign (void)
 
void hoc_assign_str (char **cpp, const char *buf)
 
void assstr (void)
 
char * hoc_araystr (Symbol *sym, int index, Objectdata *obd)
 
int hoc_array_index (Symbol *sp, Objectdata *od)
 
int araypt (Symbol *sp, int type)
 
void print (void)
 
void prexpr (void)
 
void prstr (void)
 
void hoc_delete_symbol (void)
 
void hoc_newline (void)
 
void varread (void)
 
static Instcodechk (void)
 
InstCode (Pfrv f)
 
Instcodei (int f)
 
Insthoc_codeptr (void *vp)
 
void codesym (Symbol *f)
 
void codein (Inst *f)
 
void insertcode (Inst *begin, Inst *end, Pfrv f)
 
void execute (Inst *p)
 

Variables

int hoc_return_type_code = 0
 
static Datumstack
 
static Datumstackp
 
static Datumstacklast
 
Instprog
 
Instprogp
 
Instpc
 
Instprogbase
 
Instprog_parse_recover
 
int hoc_returning
 
static Frameframe
 
static Framefp
 
static Frameframelast
 
static Object ** hoc_temp_obj_pool_
 
static int obj_pool_index_
 
static int tobj_count
 
static Objectunref_defer_
 
static int maxinitfcns
 
static Pfrv initfcns [MAXINITFCNS]
 
static Framerframe
 
static Datumrstack
 
static const char * parsestr
 
static char * stmp [HOC_TEMP_CHARPTR_SIZE]
 
static int istmp = 0
 

Macro Definition Documentation

◆ BBSPOLL

#define BBSPOLL

Definition at line 38 of file code.cpp.

◆ DEBUG_GARBAGE

#define DEBUG_GARBAGE   1

Definition at line 181 of file code.cpp.

◆ EPS

#define EPS   hoc_epsilon

Definition at line 128 of file code.cpp.

◆ HOC_TEMP_CHARPTR_SIZE

#define HOC_TEMP_CHARPTR_SIZE   128

Definition at line 638 of file code.cpp.

◆ MAXINITFCNS

#define MAXINITFCNS   10

Definition at line 375 of file code.cpp.

◆ NFRAME

#define NFRAME   512 /* default size */

Definition at line 159 of file code.cpp.

◆ nframe

#define nframe   hoc_nframe

Definition at line 160 of file code.cpp.

◆ nopopm

#define nopopm ( )    (stackp -= 2) /*provision at use made to deal with OBJECTTMP*/

Definition at line 116 of file code.cpp.

◆ NPROG

#define NPROG   50000

Definition at line 142 of file code.cpp.

◆ NSTACK

#define NSTACK   1000 /* default size */

Definition at line 130 of file code.cpp.

◆ nstack

#define nstack   hoc_nstack

Definition at line 131 of file code.cpp.

◆ pushsm

#define pushsm (   d)
Value:
((stackp++)->sym = (d)); \
((stackp++)->i = SYMBOL)
static Datum * stackp
Definition: code.cpp:139
#define i
Definition: md1redef.h:12
#define SYMBOL
Definition: model.h:102

Definition at line 113 of file code.cpp.

◆ pushxm

#define pushxm (   d)
Value:
((stackp++)->val = (d)); \
((stackp++)->i = NUMBER)

Definition at line 110 of file code.cpp.

◆ relative

#define relative (   pc)    (pc + (pc)->i)

Definition at line 919 of file code.cpp.

◆ spopm

#define spopm ( )    (tstkchk(stackp[-1].i, SYMBOL), nopopm(), stackp->sym)

Definition at line 118 of file code.cpp.

◆ stack

#define stack   stlstack

Definition at line 135 of file code.cpp.

◆ STACKCHK

#define STACKCHK
Value:
if (stackp >= stacklast) \
execerror("Stack too deep.", "Increase with -NSTACK stacksize option");
static Datum * stacklast
Definition: code.cpp:140

Definition at line 45 of file code.cpp.

◆ TOBJ_POOL_SIZE

#define TOBJ_POOL_SIZE   50

Definition at line 182 of file code.cpp.

◆ tstkchk

#define tstkchk (   i,
  j 
)    (((i) != (j)) ? tstkchk_actual(i, j) : 0)

Definition at line 109 of file code.cpp.

◆ USEMACROS

#define USEMACROS   1

Definition at line 90 of file code.cpp.

◆ xpopm

#define xpopm ( )    (tstkchk(stackp[-1].i, NUMBER), nopopm(), stackp->val)

Definition at line 117 of file code.cpp.

Typedef Documentation

◆ Frame

typedef struct Frame Frame

Function Documentation

◆ add()

void add ( void  )

Definition at line 1989 of file code.cpp.

◆ araypt()

int araypt ( Symbol sp,
int  type 
)

Definition at line 2416 of file code.cpp.

◆ arg()

void arg ( void  )

Definition at line 1648 of file code.cpp.

◆ argassign()

void argassign ( void  )

Definition at line 1686 of file code.cpp.

◆ assign()

void assign ( void  )

Definition at line 2228 of file code.cpp.

◆ assstr()

void assstr ( void  )

Definition at line 2359 of file code.cpp.

◆ bltin()

void bltin ( void  )

Definition at line 1751 of file code.cpp.

◆ Break()

void Break ( void  )

Definition at line 1282 of file code.cpp.

◆ call()

void call ( void  )

Definition at line 1383 of file code.cpp.

◆ Code()

Inst* Code ( Pfrv  f)

Definition at line 2614 of file code.cpp.

◆ codechk()

static Inst* codechk ( void  )
static

Definition at line 2606 of file code.cpp.

◆ codei()

Inst* codei ( int  f)

Definition at line 2619 of file code.cpp.

◆ codein()

void codein ( Inst f)

Definition at line 2635 of file code.cpp.

◆ codesym()

void codesym ( Symbol f)

Definition at line 2630 of file code.cpp.

◆ constpush()

void constpush ( void  )

Definition at line 904 of file code.cpp.

◆ Continue()

void Continue ( void  )

Definition at line 1287 of file code.cpp.

◆ debugzz()

void debugzz ( Inst p)

Definition at line 23 of file debug.cpp.

◆ eq()

void eq ( void  )

Definition at line 2136 of file code.cpp.

◆ eval()

void eval ( void  )

Definition at line 1820 of file code.cpp.

◆ execute()

void execute ( Inst p)

Definition at line 2661 of file code.cpp.

◆ for_segment()

void for_segment ( void  )

Definition at line 1254 of file code.cpp.

◆ for_segment1()

void for_segment1 ( void  )

Definition at line 1258 of file code.cpp.

◆ for_segment2()

static void for_segment2 ( Symbol sym,
int  mode 
)
static

Definition at line 1138 of file code.cpp.

◆ forcode()

void forcode ( void  )

Definition at line 921 of file code.cpp.

◆ frame_objauto_recover_on_err()

static void frame_objauto_recover_on_err ( Frame ff)
static

Definition at line 308 of file code.cpp.

◆ frameobj_clean()

static void frameobj_clean ( Frame f)
static

Definition at line 292 of file code.cpp.

◆ funcret()

void funcret ( void  )

Definition at line 1497 of file code.cpp.

◆ ge()

void ge ( void  )

Definition at line 2120 of file code.cpp.

◆ gt()

void gt ( void  )

Definition at line 2104 of file code.cpp.

◆ hoc_and()

void hoc_and ( void  )

Definition at line 2196 of file code.cpp.

◆ hoc_argref()

void hoc_argref ( void  )

Definition at line 1724 of file code.cpp.

◆ hoc_argrefarg()

void hoc_argrefarg ( void  )

Definition at line 1740 of file code.cpp.

◆ hoc_argrefasgn()

void hoc_argrefasgn ( void  )

Definition at line 1703 of file code.cpp.

◆ hoc_Argtype()

void hoc_Argtype ( void  )

Definition at line 1550 of file code.cpp.

◆ hoc_array_index()

int hoc_array_index ( Symbol sp,
Objectdata od 
)

Definition at line 2399 of file code.cpp.

◆ hoc_autoobject()

void hoc_autoobject ( void  )

Definition at line 1808 of file code.cpp.

◆ hoc_codeptr()

Inst* hoc_codeptr ( void vp)

Definition at line 2625 of file code.cpp.

◆ hoc_cyclic()

void hoc_cyclic ( void  )

Definition at line 2071 of file code.cpp.

◆ hoc_define()

void hoc_define ( Symbol sp)

Definition at line 1297 of file code.cpp.

◆ hoc_delete_symbol()

void hoc_delete_symbol ( void  )

Definition at line 2542 of file code.cpp.

◆ hoc_div()

void hoc_div ( void  )

Definition at line 2050 of file code.cpp.

◆ hoc_evalpointer()

void hoc_evalpointer ( void  )

Definition at line 1909 of file code.cpp.

◆ hoc_get_last_pointer_symbol()

Symbol* hoc_get_last_pointer_symbol ( void  )

Definition at line 1780 of file code.cpp.

◆ hoc_init_space()

void hoc_init_space ( void  )

Definition at line 359 of file code.cpp.

◆ hoc_iterator()

void hoc_iterator ( void  )

Definition at line 1032 of file code.cpp.

◆ hoc_iterator_object()

void hoc_iterator_object ( Symbol sym,
int  argcount,
Inst beginpc,
Inst endpc,
Object ob 
)

Definition at line 1047 of file code.cpp.

◆ hoc_iterator_stmt()

void hoc_iterator_stmt ( void  )

Definition at line 1074 of file code.cpp.

◆ hoc_newline()

void hoc_newline ( void  )

Definition at line 2572 of file code.cpp.

◆ hoc_not()

void hoc_not ( void  )

Definition at line 2212 of file code.cpp.

◆ hoc_Numarg()

void hoc_Numarg ( void  )

Definition at line 1538 of file code.cpp.

◆ hoc_or()

void hoc_or ( void  )

Definition at line 2204 of file code.cpp.

◆ hoc_prstack()

void hoc_prstack ( void  )

Definition at line 379 of file code.cpp.

◆ hoc_push_string()

void hoc_push_string ( void  )

Definition at line 685 of file code.cpp.

◆ hoc_stack_type()

int hoc_stack_type ( void  )

Definition at line 654 of file code.cpp.

◆ hoc_strgets()

char* hoc_strgets ( char *  cbuf,
int  nc 
)

Definition at line 507 of file code.cpp.

◆ hoc_strgets_need()

int hoc_strgets_need ( void  )

Definition at line 503 of file code.cpp.

◆ hoc_stringarg()

void hoc_stringarg ( void  )

Definition at line 1658 of file code.cpp.

◆ hoc_sub()

void hoc_sub ( void  )

Definition at line 1998 of file code.cpp.

◆ hoc_unref_defer()

void hoc_unref_defer ( void  )

Definition at line 247 of file code.cpp.

◆ hocobjret()

void hocobjret ( void  )

Definition at line 1518 of file code.cpp.

◆ ifcode()

void ifcode ( void  )

Definition at line 1268 of file code.cpp.

◆ initcode()

void initcode ( void  )

Definition at line 403 of file code.cpp.

◆ insertcode()

void insertcode ( Inst begin,
Inst end,
Pfrv  f 
)

Definition at line 2640 of file code.cpp.

◆ ipop()

int ipop ( void  )

Definition at line 887 of file code.cpp.

◆ le()

void le ( void  )

Definition at line 2128 of file code.cpp.

◆ lt()

void lt ( void  )

Definition at line 2112 of file code.cpp.

◆ mul()

void mul ( void  )

Definition at line 2007 of file code.cpp.

◆ ne()

void ne ( void  )

Definition at line 2166 of file code.cpp.

◆ negate()

void negate ( void  )

Definition at line 2097 of file code.cpp.

◆ nopop()

void nopop ( void  )

Definition at line 895 of file code.cpp.

◆ oc_restore_code()

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 
)

Definition at line 469 of file code.cpp.

◆ oc_save_code()

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 
)

Definition at line 443 of file code.cpp.

◆ pop_frame()

void pop_frame ( void  )

Definition at line 1375 of file code.cpp.

◆ power()

void power ( void  )

Definition at line 2219 of file code.cpp.

◆ prexpr()

void prexpr ( void  )

Definition at line 2492 of file code.cpp.

◆ print()

void print ( void  )

Definition at line 2473 of file code.cpp.

◆ procret()

void procret ( void  )

Definition at line 1507 of file code.cpp.

◆ prstr()

void prstr ( void  )

Definition at line 2529 of file code.cpp.

◆ push_frame()

void push_frame ( Symbol sp,
int  narg 
)

Definition at line 1364 of file code.cpp.

◆ pushi()

void pushi ( int  d)

Definition at line 726 of file code.cpp.

◆ pushs()

void pushs ( Symbol d)

Definition at line 721 of file code.cpp.

◆ pushx()

void pushx ( double  d)

Definition at line 658 of file code.cpp.

◆ pushzero()

void pushzero ( void  )

Definition at line 909 of file code.cpp.

◆ rinitcode()

static void rinitcode ( void  )
static

Definition at line 516 of file code.cpp.

◆ shortfor()

void shortfor ( void  )

Definition at line 968 of file code.cpp.

◆ spop()

Symbol* spop ( void  )

Definition at line 846 of file code.cpp.

◆ stack_obtmp_recover_on_err()

static void stack_obtmp_recover_on_err ( int  tcnt)
static

Definition at line 340 of file code.cpp.

◆ Stop()

void Stop ( void  )

Definition at line 1292 of file code.cpp.

◆ tstkchk_actual()

int tstkchk_actual ( int  i,
int  j 
)

Definition at line 49 of file code.cpp.

◆ varpush()

void varpush ( void  )

Definition at line 914 of file code.cpp.

◆ varread()

void varread ( void  )

Definition at line 2577 of file code.cpp.

◆ warn_assign_dynam_unit()

static void warn_assign_dynam_unit ( const char *  name)
static

Definition at line 955 of file code.cpp.

◆ xpop()

double xpop ( void  )

Definition at line 788 of file code.cpp.

Variable Documentation

◆ fp

Frame * fp
static

Definition at line 161 of file code.cpp.

◆ frame

Frame* frame
static

Definition at line 161 of file code.cpp.

◆ framelast

Frame * framelast
static

Definition at line 161 of file code.cpp.

◆ hoc_return_type_code

int hoc_return_type_code = 0

Definition at line 42 of file code.cpp.

◆ hoc_temp_obj_pool_

Object** hoc_temp_obj_pool_
static

Definition at line 183 of file code.cpp.

◆ initfcns

Pfrv initfcns[MAXINITFCNS]
static

Definition at line 377 of file code.cpp.

◆ istmp

int istmp = 0
static

Definition at line 640 of file code.cpp.

◆ maxinitfcns

int maxinitfcns
static

Definition at line 376 of file code.cpp.

◆ obj_pool_index_

int obj_pool_index_
static

Definition at line 184 of file code.cpp.

◆ parsestr

const char* parsestr
static

Definition at line 441 of file code.cpp.

◆ pc

Inst* pc

Definition at line 145 of file code.cpp.

◆ prog

Inst* prog

Definition at line 143 of file code.cpp.

◆ prog_parse_recover

Inst* prog_parse_recover

Definition at line 147 of file code.cpp.

◆ progbase

Inst* progbase

Definition at line 146 of file code.cpp.

◆ progp

Inst* progp

Definition at line 144 of file code.cpp.

◆ rframe

Frame* rframe
static

Definition at line 439 of file code.cpp.

◆ rstack

Datum* rstack
static

Definition at line 440 of file code.cpp.

◆ stack

Datum* stack
static

Definition at line 138 of file code.cpp.

◆ stacklast

Datum* stacklast
static

Definition at line 140 of file code.cpp.

◆ stackp

Datum* stackp
static

Definition at line 139 of file code.cpp.

◆ stmp

char* stmp[HOC_TEMP_CHARPTR_SIZE]
static

Definition at line 639 of file code.cpp.

◆ tobj_count

int tobj_count
static

Definition at line 185 of file code.cpp.

◆ unref_defer_

Object* unref_defer_
static

Definition at line 245 of file code.cpp.