Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wsasm.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  WsAsmInsRec

Defines

#define WS_ASM_CLASS1P(op)   (((op) & 0x80) == 0x80)
#define WS_ASM_CLASS1_OP(op)   ((op) & 0xe0)
#define WS_ASM_CLASS1_ARG(op)   ((op) & 0x1f)
#define WS_ASM_CLASS2P(op)   (((op) & 0xe0) == 0x40)
#define WS_ASM_CLASS2_OP(op)   ((op) & 0xf0)
#define WS_ASM_CLASS2_ARG(op)   ((op) & 0x0f)
#define WS_ASM_CLASS3P(op)   (((op) & 0xe0) == 0x60)
#define WS_ASM_CLASS3_OP(op)   ((op) & 0x78)
#define WS_ASM_CLASS3_ARG(op)   ((op) & 0x07)
#define WS_ASM_CLASS4P(op)   (((op) & 0xc0) == 0x00)
#define WS_ASM_CLASS4_OP(op)   (op)
#define WS_ASM_OP(op)
#define WS_ASM_ARG(op)
#define WS_ASM_GLUE(op, arg)   ((WsByte) (((WsByte) (op)) | ((WsByte) (arg))))
#define WS_ASM_JUMP_FW_S   0x80
#define WS_ASM_JUMP_FW   0x01
#define WS_ASM_JUMP_FW_W   0x02
#define WS_ASM_JUMP_BW_S   0xa0
#define WS_ASM_JUMP_BW   0x03
#define WS_ASM_JUMP_BW_W   0x04
#define WS_ASM_TJUMP_FW_S   0xc0
#define WS_ASM_TJUMP_FW   0x05
#define WS_ASM_TJUMP_FW_W   0x06
#define WS_ASM_TJUMP_BW   0x07
#define WS_ASM_TJUMP_BW_W   0x08
#define WS_ASM_CALL_S   0x60
#define WS_ASM_CALL   0x09
#define WS_ASM_CALL_LIB_S   0x68
#define WS_ASM_CALL_LIB   0x0a
#define WS_ASM_CALL_LIB_W   0x0b
#define WS_ASM_CALL_URL   0x0c
#define WS_ASM_CALL_URL_W   0x0d
#define WS_ASM_LOAD_VAR_S   0xe0
#define WS_ASM_LOAD_VAR   0x0e
#define WS_ASM_STORE_VAR_S   0x40
#define WS_ASM_STORE_VAR   0x0f
#define WS_ASM_INCR_VAR_S   0x70
#define WS_ASM_INCR_VAR   0x10
#define WS_ASM_DECR_VAR   0x11
#define WS_ASM_LOAD_CONST_S   0x50
#define WS_ASM_LOAD_CONST   0x12
#define WS_ASM_LOAD_CONST_W   0x13
#define WS_ASM_CONST_0   0x14
#define WS_ASM_CONST_1   0x15
#define WS_ASM_CONST_M1   0x16
#define WS_ASM_CONST_ES   0x17
#define WS_ASM_CONST_INVALID   0x18
#define WS_ASM_CONST_TRUE   0x19
#define WS_ASM_CONST_FALSE   0x1a
#define WS_ASM_INCR   0x1b
#define WS_ASM_DECR   0x1c
#define WS_ASM_ADD_ASG   0x1d
#define WS_ASM_SUB_ASG   0x1e
#define WS_ASM_UMINUS   0x1f
#define WS_ASM_ADD   0x20
#define WS_ASM_SUB   0x21
#define WS_ASM_MUL   0x22
#define WS_ASM_DIV   0x23
#define WS_ASM_IDIV   0x24
#define WS_ASM_REM   0x25
#define WS_ASM_B_AND   0x26
#define WS_ASM_B_OR   0x27
#define WS_ASM_B_XOR   0x28
#define WS_ASM_B_NOT   0x29
#define WS_ASM_B_LSHIFT   0x2a
#define WS_ASM_B_RSSHIFT   0x2b
#define WS_ASM_B_RSZSHIFT   0x2c
#define WS_ASM_EQ   0x2d
#define WS_ASM_LE   0x2e
#define WS_ASM_LT   0x2f
#define WS_ASM_GE   0x30
#define WS_ASM_GT   0x31
#define WS_ASM_NE   0x32
#define WS_ASM_NOT   0x33
#define WS_ASM_SCAND   0x34
#define WS_ASM_SCOR   0x35
#define WS_ASM_TOBOOL   0x36
#define WS_ASM_POP   0x37
#define WS_ASM_TYPEOF   0x38
#define WS_ASM_ISVALID   0x39
#define WS_ASM_RETURN   0x3a
#define WS_ASM_RETURN_ES   0x3b
#define WS_ASM_DEBUG   0x3c
#define WS_ASM_P_LABEL   0x0100
#define WS_ASM_P_JUMP   0x0200
#define WS_ASM_P_TJUMP   0x0300
#define WS_ASM_P_CALL   0x0400
#define WS_ASM_P_CALL_LIB   0x0500
#define WS_ASM_P_CALL_URL   0x0600
#define WS_ASM_P_LOAD_VAR   0x0700
#define WS_ASM_P_STORE_VAR   0x0800
#define WS_ASM_P_INCR_VAR   0x0900
#define WS_ASM_P_LOAD_CONST   0x0a00
#define WS_ASM_P_BRANCH(ins)   ((ins)->type == WS_ASM_P_JUMP || (ins)->type == WS_ASM_P_TJUMP)
#define ws_label_idx   u.ivalues.i1
#define ws_label_refcount   u.ivalues.i2
#define ws_findex   u.ivalues.i1
#define ws_lindex   u.ivalues.i2
#define ws_args   u.ivalues.i3
#define ws_vindex   u.ivalues.i1
#define ws_cindex   u.ivalues.i1
#define ws_label   u.branch.label
#define ws_offset   u.branch.offset

Typedefs

typedef WsAsmInsRec WsAsmIns

Functions

void ws_asm_link (WsCompilerPtr compiler, WsAsmIns *ins)
void ws_asm_print (WsCompilerPtr compiler)
void ws_asm_dasm (WsCompilerPtr compiler, const unsigned char *code, size_t len)
void ws_asm_linearize (WsCompilerPtr compiler)
WsAsmInsws_asm_label (WsCompilerPtr compiler, WsUInt32 line)
WsAsmInsws_asm_branch (WsCompilerPtr compiler, WsUInt32 line, WsUInt16 ins, WsAsmIns *label)
WsAsmInsws_asm_call (WsCompilerPtr compiler, WsUInt32 line, WsUInt8 findex)
WsAsmInsws_asm_call_lib (WsCompilerPtr compiler, WsUInt32 line, WsUInt8 findex, WsUInt16 lindex)
WsAsmInsws_asm_call_url (WsCompilerPtr compiler, WsUInt32 line, WsUInt16 findex, WsUInt16 urlindex, WsUInt8 args)
WsAsmInsws_asm_variable (WsCompilerPtr compiler, WsUInt32 line, WsUInt16 ins, WsUInt8 vindex)
WsAsmInsws_asm_load_const (WsCompilerPtr compiler, WsUInt32 line, WsUInt16 cindex)
WsAsmInsws_asm_ins (WsCompilerPtr compiler, WsUInt32 line, WsUInt8 opcode)


Define Documentation

#define ws_args   u.ivalues.i3
 

Definition at line 247 of file wsasm.h.

#define WS_ASM_ADD   0x20
 

Definition at line 183 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_ADD_ASG   0x1d
 

Definition at line 180 of file wsasm.h.

Referenced by ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_ARG op   ) 
 

Value:

(WS_ASM_CLASS1P(op)         \
     ? WS_ASM_CLASS1_ARG(op)        \
     : (WS_ASM_CLASS2P(op)      \
       ? WS_ASM_CLASS2_ARG(op)      \
       : (WS_ASM_CLASS3P(op)        \
         ? WS_ASM_CLASS3_ARG(op)    \
         : 0)))

Definition at line 114 of file wsasm.h.

#define WS_ASM_B_AND   0x26
 

Definition at line 190 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_B_LSHIFT   0x2a
 

Definition at line 194 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_B_NOT   0x29
 

Definition at line 193 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_B_OR   0x27
 

Definition at line 191 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_B_RSSHIFT   0x2b
 

Definition at line 195 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_B_RSZSHIFT   0x2c
 

Definition at line 196 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_B_XOR   0x28
 

Definition at line 192 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_CALL   0x09
 

Definition at line 146 of file wsasm.h.

#define WS_ASM_CALL_LIB   0x0a
 

Definition at line 149 of file wsasm.h.

#define WS_ASM_CALL_LIB_S   0x68
 

Definition at line 148 of file wsasm.h.

#define WS_ASM_CALL_LIB_W   0x0b
 

Definition at line 150 of file wsasm.h.

#define WS_ASM_CALL_S   0x60
 

Definition at line 145 of file wsasm.h.

#define WS_ASM_CALL_URL   0x0c
 

Definition at line 152 of file wsasm.h.

#define WS_ASM_CALL_URL_W   0x0d
 

Definition at line 153 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_CLASS1_ARG op   )     ((op) & 0x1f)
 

Definition at line 81 of file wsasm.h.

#define WS_ASM_CLASS1_OP op   )     ((op) & 0xe0)
 

Definition at line 80 of file wsasm.h.

#define WS_ASM_CLASS1P op   )     (((op) & 0x80) == 0x80)
 

Definition at line 79 of file wsasm.h.

#define WS_ASM_CLASS2_ARG op   )     ((op) & 0x0f)
 

Definition at line 87 of file wsasm.h.

#define WS_ASM_CLASS2_OP op   )     ((op) & 0xf0)
 

Definition at line 86 of file wsasm.h.

#define WS_ASM_CLASS2P op   )     (((op) & 0xe0) == 0x40)
 

Definition at line 85 of file wsasm.h.

#define WS_ASM_CLASS3_ARG op   )     ((op) & 0x07)
 

Definition at line 93 of file wsasm.h.

#define WS_ASM_CLASS3_OP op   )     ((op) & 0x78)
 

Definition at line 92 of file wsasm.h.

#define WS_ASM_CLASS3P op   )     (((op) & 0xe0) == 0x60)
 

Definition at line 91 of file wsasm.h.

#define WS_ASM_CLASS4_OP op   )     (op)
 

Definition at line 98 of file wsasm.h.

#define WS_ASM_CLASS4P op   )     (((op) & 0xc0) == 0x00)
 

Definition at line 97 of file wsasm.h.

#define WS_ASM_CONST_0   0x14
 

Definition at line 170 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_CONST_1   0x15
 

Definition at line 171 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_CONST_ES   0x17
 

Definition at line 173 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_CONST_FALSE   0x1a
 

Definition at line 176 of file wsasm.h.

Referenced by ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_CONST_INVALID   0x18
 

Definition at line 174 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_CONST_M1   0x16
 

Definition at line 172 of file wsasm.h.

Referenced by opt_peephole(), and ws_asm_linearize().

#define WS_ASM_CONST_TRUE   0x19
 

Definition at line 175 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_DEBUG   0x3c
 

Definition at line 218 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_DECR   0x1c
 

Definition at line 179 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_DECR_VAR   0x11
 

Definition at line 164 of file wsasm.h.

Referenced by ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_DIV   0x23
 

Definition at line 186 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_EQ   0x2d
 

Definition at line 198 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_GE   0x30
 

Definition at line 201 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_GLUE op,
arg   )     ((WsByte) (((WsByte) (op)) | ((WsByte) (arg))))
 

Definition at line 125 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_GT   0x31
 

Definition at line 202 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_IDIV   0x24
 

Definition at line 187 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_INCR   0x1b
 

Definition at line 178 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_INCR_VAR   0x10
 

Definition at line 162 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_INCR_VAR_S   0x70
 

Definition at line 161 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_ISVALID   0x39
 

Definition at line 213 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_JUMP_BW   0x03
 

Definition at line 135 of file wsasm.h.

#define WS_ASM_JUMP_BW_S   0xa0
 

Definition at line 134 of file wsasm.h.

#define WS_ASM_JUMP_BW_W   0x04
 

Definition at line 136 of file wsasm.h.

#define WS_ASM_JUMP_FW   0x01
 

Definition at line 131 of file wsasm.h.

#define WS_ASM_JUMP_FW_S   0x80
 

Definition at line 130 of file wsasm.h.

#define WS_ASM_JUMP_FW_W   0x02
 

Definition at line 132 of file wsasm.h.

#define WS_ASM_LE   0x2e
 

Definition at line 199 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_LOAD_CONST   0x12
 

Definition at line 167 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_LOAD_CONST_S   0x50
 

Definition at line 166 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_LOAD_CONST_W   0x13
 

Definition at line 168 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_LOAD_VAR   0x0e
 

Definition at line 156 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_LOAD_VAR_S   0xe0
 

Definition at line 155 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_LT   0x2f
 

Definition at line 200 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_MUL   0x22
 

Definition at line 185 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_NE   0x32
 

Definition at line 203 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_NOT   0x33
 

Definition at line 205 of file wsasm.h.

Referenced by opt_conv(), ws_asm_linearize(), and yyparse().

#define WS_ASM_OP op   ) 
 

Value:

Definition at line 102 of file wsasm.h.

#define WS_ASM_P_BRANCH ins   )     ((ins)->type == WS_ASM_P_JUMP || (ins)->type == WS_ASM_P_TJUMP)
 

Definition at line 238 of file wsasm.h.

Referenced by opt_dead_code(), and opt_jumps_to_jumps().

#define WS_ASM_P_CALL   0x0400
 

Definition at line 228 of file wsasm.h.

#define WS_ASM_P_CALL_LIB   0x0500
 

Definition at line 229 of file wsasm.h.

#define WS_ASM_P_CALL_URL   0x0600
 

Definition at line 230 of file wsasm.h.

#define WS_ASM_P_INCR_VAR   0x0900
 

Definition at line 233 of file wsasm.h.

Referenced by ws_expr_linearize().

#define WS_ASM_P_JUMP   0x0200
 

Definition at line 226 of file wsasm.h.

Referenced by opt_dead_code(), ws_expr_linearize(), and ws_stmt_linearize().

#define WS_ASM_P_LABEL   0x0100
 

Definition at line 225 of file wsasm.h.

Referenced by opt_dead_code(), and opt_jumps_to_next_instruction().

#define WS_ASM_P_LOAD_CONST   0x0a00
 

Definition at line 234 of file wsasm.h.

Referenced by opt_peephole().

#define WS_ASM_P_LOAD_VAR   0x0700
 

Definition at line 231 of file wsasm.h.

Referenced by opt_peephole(), and ws_expr_linearize().

#define WS_ASM_P_STORE_VAR   0x0800
 

Definition at line 232 of file wsasm.h.

Referenced by linearize_variable_init(), and ws_expr_linearize().

#define WS_ASM_P_TJUMP   0x0300
 

Definition at line 227 of file wsasm.h.

Referenced by opt_conv(), ws_expr_linearize(), and ws_stmt_linearize().

#define WS_ASM_POP   0x37
 

Definition at line 210 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), ws_expr_linearize(), and ws_stmt_linearize().

#define WS_ASM_REM   0x25
 

Definition at line 188 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_RETURN   0x3a
 

Definition at line 215 of file wsasm.h.

Referenced by opt_dead_code(), opt_peephole(), ws_asm_linearize(), and ws_stmt_linearize().

#define WS_ASM_RETURN_ES   0x3b
 

Definition at line 216 of file wsasm.h.

Referenced by opt_peephole(), ws_asm_linearize(), and ws_stmt_linearize().

#define WS_ASM_SCAND   0x34
 

Definition at line 206 of file wsasm.h.

Referenced by opt_conv(), ws_asm_linearize(), and yyparse().

#define WS_ASM_SCOR   0x35
 

Definition at line 207 of file wsasm.h.

Referenced by opt_conv(), ws_asm_linearize(), and yyparse().

#define WS_ASM_STORE_VAR   0x0f
 

Definition at line 159 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_STORE_VAR_S   0x40
 

Definition at line 158 of file wsasm.h.

Referenced by ws_asm_linearize().

#define WS_ASM_SUB   0x21
 

Definition at line 184 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_linearize(), and yyparse().

#define WS_ASM_SUB_ASG   0x1e
 

Definition at line 181 of file wsasm.h.

Referenced by ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_TJUMP_BW   0x07
 

Definition at line 142 of file wsasm.h.

#define WS_ASM_TJUMP_BW_W   0x08
 

Definition at line 143 of file wsasm.h.

#define WS_ASM_TJUMP_FW   0x05
 

Definition at line 139 of file wsasm.h.

#define WS_ASM_TJUMP_FW_S   0xc0
 

Definition at line 138 of file wsasm.h.

#define WS_ASM_TJUMP_FW_W   0x06
 

Definition at line 140 of file wsasm.h.

#define WS_ASM_TOBOOL   0x36
 

Definition at line 208 of file wsasm.h.

Referenced by opt_conv(), ws_asm_linearize(), and ws_expr_linearize().

#define WS_ASM_TYPEOF   0x38
 

Definition at line 212 of file wsasm.h.

Referenced by ws_asm_linearize(), and yyparse().

#define WS_ASM_UMINUS   0x1f
 

Definition at line 182 of file wsasm.h.

Referenced by ws_asm_linearize(), ws_expr_unary(), and yyparse().

#define ws_cindex   u.ivalues.i1
 

Definition at line 249 of file wsasm.h.

#define ws_findex   u.ivalues.i1
 

Definition at line 245 of file wsasm.h.

#define ws_label   u.branch.label
 

Definition at line 250 of file wsasm.h.

#define ws_label_idx   u.ivalues.i1
 

Definition at line 243 of file wsasm.h.

#define ws_label_refcount   u.ivalues.i2
 

Definition at line 244 of file wsasm.h.

#define ws_lindex   u.ivalues.i2
 

Definition at line 246 of file wsasm.h.

#define ws_offset   u.branch.offset
 

Definition at line 251 of file wsasm.h.

#define ws_vindex   u.ivalues.i1
 

Definition at line 248 of file wsasm.h.


Typedef Documentation

typedef struct WsAsmInsRec WsAsmIns
 

Definition at line 289 of file wsasm.h.

Referenced by opt_conv(), opt_dead_code(), opt_jumps_to_jumps(), opt_jumps_to_next_instruction(), opt_peephole(), ws_expr_linearize(), and ws_stmt_linearize().


Function Documentation

WsAsmIns* ws_asm_branch WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt16  ins,
WsAsmIns label
 

Referenced by ws_expr_linearize(), and ws_stmt_linearize().

WsAsmIns* ws_asm_call WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt8  findex
 

Referenced by ws_expr_linearize().

WsAsmIns* ws_asm_call_lib WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt8  findex,
WsUInt16  lindex
 

Referenced by ws_expr_linearize().

WsAsmIns* ws_asm_call_url WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt16  findex,
WsUInt16  urlindex,
WsUInt8  args
 

Referenced by ws_expr_linearize().

void ws_asm_dasm WsCompilerPtr  compiler,
const unsigned char *  code,
size_t  len
 

Definition at line 498 of file wsasm.c.

Referenced by compile_stream(), and main().

00499                        {
00500                     /* The wider form. */
00501                     ins->type = WS_ASM_CALL;
00502                 }
00503                 break;
00504 
00505             case WS_ASM_P_CALL_LIB:
00506                 if (ins->ws_findex <= 7 && ins->ws_lindex <= 255) {
00507                     /* The most compact form. */
00508                     ins->type = WS_ASM_CALL_LIB_S;
00509                 } else if (ins->ws_findex <= 255 && ins->ws_lindex <= 255) {
00510                     /* The quite compact form. */
00511                     ins->type = WS_ASM_CALL_LIB;
00512                 } else {
00513                     /* The most liberal form. */
00514                     ins->type = WS_ASM_CALL_LIB_W;
00515                 }
00516                 break;
00517 
00518             case WS_ASM_P_CALL_URL:
00519                 if (ins->ws_findex <= 255 && ins->ws_lindex <= 255)
00520                     /* The compact form. */
00521                     ins->type = WS_ASM_CALL_URL;
00522                 else
00523                     ins->type = WS_ASM_CALL_URL_W;
00524                 break;
00525 
00526             case WS_ASM_P_LOAD_VAR:
00527                 if (ins->ws_vindex <= 31)
00528                     /* The compact form. */
00529                     ins->type = WS_ASM_LOAD_VAR_S;
00530                 else
00531                     ins->type = WS_ASM_LOAD_VAR;
00532                 break;
00533 
00534             case WS_ASM_P_STORE_VAR:
00535                 if (ins->ws_vindex <= 15)
00536                     ins->type = WS_ASM_STORE_VAR_S;
00537                 else
00538                     ins->type = WS_ASM_STORE_VAR;
00539                 break;
00540 
00541             case WS_ASM_P_INCR_VAR:
00542                 if (ins->ws_vindex <= 7)
00543                     ins->type = WS_ASM_INCR_VAR_S;
00544                 else
00545                     ins->type = WS_ASM_INCR_VAR;
00546                 break;
00547 
00548             case WS_ASM_P_LOAD_CONST:
00549                 if (ins->ws_cindex <= 15)
00550                     ins->type = WS_ASM_LOAD_CONST_S;
00551                 else if (ins->ws_cindex <= 255)
00552                     ins->type = WS_ASM_LOAD_CONST;
00553                 else
00554                     ins->type = WS_ASM_LOAD_CONST_W;
00555                 break;
00556             }
00557 
00558             gw_assert(ins->type == WS_ASM_P_LABEL || ins->type < 0x100);
00559 
00560             if (ins->type != WS_ASM_P_LABEL) {
00561                 gw_assert(operands[ins->type].name != NULL);
00562                 offset += operands[ins->type].size;
00563             }
00564         }
00565     }
00566 
00567     /* Ok, ready to linearize the byte-code. */
00568     for (ins = compiler->asm_head; ins; ins = ins->next) {
00569         if (ins->type == WS_ASM_P_LABEL)
00570             continue;
00571 
00572         gw_assert(ins->type <= 0xff);
00573 
00574         switch (ins->type) {
00575         case WS_ASM_JUMP_FW_S:
00576         case WS_ASM_JUMP_BW_S:
00577         case WS_ASM_TJUMP_FW_S:
00578             if (!ws_encode_buffer(&compiler->byte_code,
00579                                   WS_ENC_BYTE,
00580                                   WS_ASM_GLUE(ins->type, ins->ws_offset),
00581                                   WS_ENC_END))
00582                 goto error;
00583             break;
00584 
00585         case WS_ASM_JUMP_FW:
00586         case WS_ASM_JUMP_BW:
00587         case WS_ASM_TJUMP_FW:
00588         case WS_ASM_TJUMP_BW:
00589             if (!ws_encode_buffer(&compiler->byte_code,
00590                                   WS_ENC_BYTE, ins->type,
00591                                   WS_ENC_UINT8, (WsUInt8) ins->ws_offset,
00592                                   WS_ENC_END))
00593                 goto error;
00594             break;
00595 
00596         case WS_ASM_JUMP_FW_W:
00597         case WS_ASM_JUMP_BW_W:
00598         case WS_ASM_TJUMP_FW_W:
00599         case WS_ASM_TJUMP_BW_W:
00600             if (!ws_encode_buffer(&compiler->byte_code,
00601                                   WS_ENC_BYTE, ins->type,
00602                                   WS_ENC_UINT16, (WsUInt16) ins->ws_offset,
00603                                   WS_ENC_END))
00604                 goto error;
00605             break;
00606 
00607         case WS_ASM_CALL_S:
00608             if (!ws_encode_buffer(&compiler->byte_code,
00609                                   WS_ENC_BYTE,
00610                                   WS_ASM_GLUE(ins->type, ins->ws_findex),
00611                                   WS_ENC_END))
00612                 goto error;
00613             break;
00614 
00615         case WS_ASM_CALL:
00616             if (!ws_encode_buffer(&compiler->byte_code,
00617                                   WS_ENC_BYTE, (WsByte) ins->type,
00618                                   WS_ENC_UINT8, (WsUInt8) ins->ws_findex,
00619                                   WS_ENC_END))
00620                 goto error;
00621             break;
00622 
00623         case WS_ASM_CALL_LIB_S:
00624             if (!ws_encode_buffer(&compiler->byte_code,
00625                                   WS_ENC_BYTE,
00626                                   WS_ASM_GLUE(ins->type, ins->ws_findex),
00627                                   WS_ENC_UINT8, (WsUInt8) ins->ws_lindex,
00628                                   WS_ENC_END))
00629                 goto error;
00630             break;
00631 
00632         case WS_ASM_CALL_LIB:
00633             if (!ws_encode_buffer(&compiler->byte_code,
00634                                   WS_ENC_BYTE, (WsByte) ins->type,
00635                                   WS_ENC_UINT8, (WsUInt8) ins->ws_findex,
00636                                   WS_ENC_UINT8, (WsUInt8) ins->ws_lindex,
00637                                   WS_ENC_END))
00638                 goto error;
00639             break;
00640 
00641         case WS_ASM_CALL_LIB_W:
00642             if (!ws_encode_buffer(&compiler->byte_code,
00643                                   WS_ENC_BYTE, (WsByte) ins->type,
00644                                   WS_ENC_UINT8, (WsUInt8) ins->ws_findex,
00645                                   WS_ENC_UINT16, (WsUInt16) ins->ws_lindex,
00646                                   WS_ENC_END))
00647                 goto error;
00648             break;
00649 
00650         case WS_ASM_CALL_URL:

WsAsmIns* ws_asm_ins WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt8  opcode
 

Referenced by opt_peephole(), ws_expr_linearize(), and ws_stmt_linearize().

WsAsmIns* ws_asm_label WsCompilerPtr  compiler,
WsUInt32  line
 

Referenced by ws_expr_linearize(), and ws_stmt_linearize().

void ws_asm_linearize WsCompilerPtr  compiler  ) 
 

Referenced by compile_stream().

void ws_asm_link WsCompilerPtr  compiler,
WsAsmIns ins
 

Referenced by linearize_variable_init(), ws_expr_linearize(), and ws_stmt_linearize().

WsAsmIns* ws_asm_load_const WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt16  cindex
 

Referenced by ws_expr_linearize().

void ws_asm_print WsCompilerPtr  compiler  ) 
 

Referenced by compile_stream().

WsAsmIns* ws_asm_variable WsCompilerPtr  compiler,
WsUInt32  line,
WsUInt16  ins,
WsUInt8  vindex
 

Referenced by linearize_variable_init(), and ws_expr_linearize().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.