Unit pr_defs;

Interface

Uses math;

{Basic definitions:}
Type func_t     = LongInt;
     string_t   = LongInt;

Type etype_t = (ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer);
Const etypestr : array[0..7] Of String[8] = (
                             'void',
                             'string',
                             'float',
                             'vector',
                             'entity',
                             'field',
                             'function',
                             'pointer');

Var  	OFS_NULL,
      OFS_RETURN,
     	OFS_PARM0,
     	OFS_PARM1,
     	OFS_PARM2,
     	OFS_PARM3,
     	OFS_PARM4,
     	OFS_PARM5,
     	OFS_PARM6,
     	OFS_PARM7,
     	RESERVED_OFS  : Byte;

{All the opcodes in the assembly code:}
Type optypes = (
	OP_DONE,
	OP_MUL_F,
	OP_MUL_V,
	OP_MUL_FV,
	OP_MUL_VF,
  {5}
	OP_DIV_F,
	OP_ADD_F,
	OP_ADD_V,
	OP_SUB_F,
	OP_SUB_V,

	OP_EQ_F,
  {10}
	OP_EQ_V,
	OP_EQ_S,
	OP_EQ_E,
	OP_EQ_FNC,

	OP_NE_F,
  {15}
	OP_NE_V,
	OP_NE_S,
	OP_NE_E,
	OP_NE_FNC,

	OP_LE,
  {20}
	OP_GE,
	OP_LT,
	OP_GT,

	OP_LOAD_F,
	OP_LOAD_V,
  {25}
	OP_LOAD_S,
	OP_LOAD_ENT,
	OP_LOAD_FLD,
	OP_LOAD_FNC,

	OP_ADDRESS,
  {30}
	OP_STORE_F,
	OP_STORE_V,
	OP_STORE_S,
	OP_STORE_ENT,
	OP_STORE_FLD,
	OP_STORE_FNC,

	OP_STOREP_F,
	OP_STOREP_V,
	OP_STOREP_S,
	OP_STOREP_ENT,
	OP_STOREP_FLD,
	OP_STOREP_FNC,

	OP_RETURN,
	OP_NOT_F,
	OP_NOT_V,
	OP_NOT_S,
	OP_NOT_ENT,
	OP_NOT_FNC,
	OP_IF,
	OP_IFNOT,
	OP_CALL0,
	OP_CALL1,
	OP_CALL2,
	OP_CALL3,
	OP_CALL4,
	OP_CALL5,
	OP_CALL6,
	OP_CALL7,
	OP_CALL8,
	OP_STATE,
	OP_GOTO,
	OP_AND,
	OP_OR,

	OP_BITAND,
	OP_BITOR,

  OP_PWR_F,

  OP_INC,
  OP_DEC,

  OP_INCBY_F,
  OP_INCBY_V,

  OP_DECBY_F,
  OP_DECBY_V,

  OP_MULBY_F,
  OP_MULBY_V,
  OP_MULBY_FV,
  OP_MULBY_VF,

  OP_DIVBY,

  OP_SHL,
  OP_SHR
);

Type dstatement_tp = ^dstatement_t;
     dstatement_t = Record
                      op    : Word;
                      a,b,c : Integer;
                    End;

Type ddef_tp = ^ddef_t;
     ddef_t = Record
                dtype, ofs : Word;
                s_name     : LongInt;
              End;

Const	DEF_SAVEGLOBAL	= (1 Shl 15);
Const	MAX_PARMS	      = 8;

Type  dfunction_tp = ^dfunction_t;
      dfunction_t = Record
                      first_statement,
                      parm_start,
                      locals,
                      profile,
                      s_name,
                      s_file,
                      numparms   : LongInt;
                      parm_size  : Array[0..MAX_PARMS-1] Of Byte;
                    End;

Const	PROG_VERSION	= 6;

Type  dprograms_tp = ^dprograms_t;
			dprograms_t = Record
                      version, crc,
                      ofs_statements, numstatements,
                      ofs_globaldefs, numglobaldefs,
                      ofs_fielddefs, numfielddefs,
                      ofs_functions, numfunctions,
                      ofs_strings, numstrings,
                      ofs_globals, numglobals,
                      entityfields            : LongInt;
                    End;

Type  pr_tf = Array[0..31] Of Float;

      {Variables}
Var   pr_globals    : ^pr_tf;
      progsize      : LongInt;

Implementation

Begin
 	OFS_NULL	:=	0;
  OFS_RETURN:=  1;
 	OFS_PARM0	:=	4;
 	OFS_PARM1	:=	7;
 	OFS_PARM2	:=	10;
 	OFS_PARM3	:=	13;
 	OFS_PARM4	:=	16;
 	OFS_PARM5	:=	19;
 	OFS_PARM6	:=	22;
 	OFS_PARM7	:=	25;
 	RESERVED_OFS := 28;
End.
