1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_BASIC_SOURCE_INC_OPCODES_HXX
21 #define INCLUDED_BASIC_SOURCE_INC_OPCODES_HXX
23 #include "sbintern.hxx"
25 // An opcode can have a length of 1, 3 or 5 bytes,
26 // depending on its numeric value (see below).
29 // all opcodes without operands
35 // the following operators are ordered
36 // the same way as the enum SbxVarOp
37 _EXP
, _MUL
, _DIV
, _MOD
, _PLUS
, _MINUS
, _NEG
,
38 _EQ
, _NE
, _LT
, _GT
, _LE
, _GE
,
39 _IDIV
, _AND
, _OR
, _XOR
, _EQV
, _IMP
, _NOT
,
41 // end of enum SbxVarOp
44 _ARGC
, // establish new Argv
45 _ARGV
, // TOS ==> current Argv
46 _INPUT
, // Input ==> TOS
47 _LINPUT
, // Line Input ==> TOS
49 _SET
, // save object TOS ==> TOS-1
50 _PUT
, // TOS ==> TOS-1
51 _PUTC
, // TOS ==> TOS-1, then ReadOnly
54 _REDIMP
, // REDIM PRESERVE
57 _STOP
, // end of program
58 _INITFOR
, // initialize FOR-variable
59 _NEXT
, // increment FOR-variable
60 _CASE
, // beginning CASE
62 _STDERROR
, // standard error handling
63 _NOERROR
, // no error handling
66 _CHANNEL
, // TOS = channel number
68 _PRINTF
, // print TOS in field
70 _RENAME
, // Rename Tos+1 to Tos
71 _PROMPT
, // TOS = Prompt for Input
72 _RESTART
, // define restart point
73 _CHAN0
, // I/O-channel 0
75 _EMPTY
, // empty expression on stack
76 _ERROR
, // TOS = error code
77 _LSET
, // saving object TOS ==> TOS-1
78 _RSET
, // saving object TOS ==> TOS-1
79 _REDIMP_ERASE
, // Copies array to be later used by REDIM PRESERVE before erasing it
81 _VBASET
, // VBA-like Set
82 _ERASE_CLEAR
, // Erase array and clear variable
83 _ARRAYACCESS
, // Assign parameters to TOS and get value, used for array of arrays
84 _BYVAL
, // byref -> byval for lvalue parameter passed in call
88 // all opcodes with one operand
90 _NUMBER
= 0x40, // loading a numeric constant (+ID)
92 SbOP1_START
= _NUMBER
,
94 _SCONST
, // loading a stringconstant (+ID)
95 _CONST
, // Immediate Load (+ value)
96 _ARGN
, // saving a named Arg in Argv (+StringID)
97 _PAD
, // bring string to a firm length (+length)
99 _JUMP
, // jump (+target)
100 _JUMPT
, // evaluate TOS, conditional jump (+target)
101 _JUMPF
, // evaluate TOS, conditional jump (+target)
102 _ONJUMP
, // evaluate TOS, jump into JUMP-table (+MaxVal)
103 _GOSUB
, // UP-call (+Target)
104 _RETURN
, // UP-return (+0 or Target)
105 _TESTFOR
, // test FOR-variable, increment (+Endlabel)
106 _CASETO
, // Tos+1 <= Case <= Tos, 2xremove (+Target)
107 _ERRHDL
, // error handler (+Offset)
108 _RESUME
, // Resume after errors (+0 or 1 or Label)
110 _CLOSE
, // (+channel/0)
113 _SETCLASS
, // test set + class names (+StringId)
114 _TESTCLASS
, // Check TOS class (+StringId)
115 _LIB
, // set lib name for declar-procs (+StringId)
116 _BASED
, // TOS is incremented by BASE, BASE is pushed before (+base)
117 // type adjustment in the Argv
118 _ARGTYP
, // convert last parameter in Argv (+type)
119 _VBASETCLASS
, // VBA-like Set
121 SbOP1_END
= _VBASETCLASS
,
123 // all opcodes with two operands
125 _RTL
= 0x80, // load from the RTL (+StringID+Typ)
129 _FIND
, // load (+StringID+Typ)
130 _ELEM
, // load element (+StringID+Typ)
131 _PARAM
, // parameters (+Offset+Typ)
133 _CALL
, // call DECLARE-method (+StringID+Typ)
134 _CALLC
, // call Cdecl-DECLARE-Method (+StringID+Typ)
135 _CASEIS
, // case-test (+Test-Opcode+True-Target)
137 _STMNT
, // begin of a statement (+Line+Col)
139 _OPEN
, // (+StreamMode+Flags)
141 _LOCAL
, // define locals variables (+StringID+Typ)
142 _PUBLIC
, // module global variables (+StringID+Typ)
143 _GLOBAL
, // define global variables, public command (+StringID+Typ)
144 _CREATE
, // create object (+StringId+StringID)
145 _STATIC
, // static variable (+StringID+Typ) JSM
146 _TCREATE
, // create user-defined object
147 _DCREATE
, // create object-array (+StringId+StringID)
148 _GLOBAL_P
, // define global variable that's not overwritten on restarting
149 // the Basic, P=PERSIST (+StringID+Typ)
150 _FIND_G
, // finds global variable with special treatment due to _GLOBAL_P
151 _DCREATE_REDIMP
, // redimension object-array (+StringId+StringID)
152 _FIND_CM
, // Search inside a class module (CM) to enable global search in time
153 _PUBLIC_P
, // Module global Variable (persisted between calls)(+StringID+Typ)
154 _FIND_STATIC
, // local static var lookup (+StringID+Typ)
156 SbOP2_END
= _FIND_STATIC
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */