File: STBytecodes.h

package info (click to toggle)
steptalk 0.10.0%2Bgit20200629-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,732 kB
  • sloc: objc: 12,182; yacc: 400; makefile: 40; sh: 34; csh: 4; awk: 3; lisp: 3
file content (96 lines) | stat: -rw-r--r-- 3,304 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
    STBytecodes.h
 
    Copyright (c) 2002 Free Software Foundation
 
    This file is part of the StepTalk project.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 */

#import <Foundation/NSObject.h>


/* Bytecode table */
/*
#define STReceiverConstant  0x00
#define STTrueConstant      0x01
#define STFalseConstant     0x02
#define STNilConstant       0x03
*/
#define STPushReceiverBytecode         0x00 /* push self */
#define STPushNilBytecode              0x01 
#define STPushTrueBytecode             0x02
#define STPushFalseBytecode            0x03 
/*                                     0x00 - 0x07 receiver,true,false,nil,
                                                   -1,0,1,2 */
#define STPushRecVarBytecode           0x08 /* recvar index */
#define STPushExternBytecode           0x09 /* extern index */
#define STPushTemporaryBytecode        0x0a /* temp index */
#define STPushLiteralBytecode          0x0b /* lit index */
#define STPopAndStoreRecVarBytecode    0x0c /* recvar index */
#define STPopAndStoreExternBytecode    0x0d /* extern index */
#define STPopAndStoreTempBytecode      0x0e /* temp index */
/*                                     0x0f reserved */
#define STSendSelectorBytecode         0x10 /* lit index, arg count  */
#define STSuperSendSelectorBytecode    0x11 /* lit index, arg count  */
#define STBlockCopyBytecode            0x12
#define STLongJumpBytecode             0x13 /* byte 1, byte 2 */
#define STDupBytecode                  0x14
#define STPopStackBytecode             0x15
#define STReturnBytecode               0x16
#define STReturnBlockBytecode          0x17
/*                                     0x18-0x27 reserved single bytecodes */
/*                                     0x27-0xfe reserved */
#define STBreakpointBytecode           0xff

/*
#define STLongJumpOffset(arg1, arg2) \
            ( (((arg1) & 0xff) << 8) | ((arg2) & 0xff) )
#define STLongJumpFirstByte(offset)\
            ( ((offset) >> 8) & 0xff )
#define STLongJumpSecondByte(offset)\
            ( (offset) & 0xff )
*/
#define STLongJumpBytecodeSize 3

@class NSArray;
@class NSString;

typedef struct
{
    unsigned short code;
    unsigned short arg1;
    unsigned short arg2;
    NSUInteger pointer;
} STBytecode;

extern NSArray *STBytecodeNames;
extern NSString *STBytecodeName(unsigned short code);
extern NSString *STDissasembleBytecode(STBytecode bytecode);

@interface STBytecodes:NSObject
{
    NSData *bytes;
}
- (id) initWithData: (NSData *)data;
- (STBytecode)fetchNextBytecodeAtPointer:(NSUInteger *)pointer;
- (NSData *) data;
- (NSUInteger) length;
@end