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 .
22 // An opcode can have a length of 1, 3 or 5 bytes,
23 // depending on its numeric value (see below).
25 enum class SbiOpcode
{
26 // all opcodes without operands
32 // the following operators are ordered
33 // the same way as the enum SbxVarOp
34 EXP_
, MUL_
, DIV_
, MOD_
, PLUS_
, MINUS_
, NEG_
,
35 EQ_
, NE_
, LT_
, GT_
, LE_
, GE_
,
36 IDIV_
, AND_
, OR_
, XOR_
, EQV_
, IMP_
, NOT_
,
38 // end of enum SbxVarOp
41 ARGC_
, // establish new Argv
42 ARGV_
, // TOS ==> current Argv
43 INPUT_
, // Input ==> TOS
44 LINPUT_
, // Line Input ==> TOS
46 SET_
, // save object TOS ==> TOS-1
47 PUT_
, // TOS ==> TOS-1
48 PUTC_
, // TOS ==> TOS-1, then ReadOnly
51 REDIMP_
, // REDIM PRESERVE
54 STOP_
, // end of program
55 INITFOR_
, // initialize FOR-variable
56 NEXT_
, // increment FOR-variable
57 CASE_
, // beginning CASE
59 STDERROR_
, // standard error handling
60 NOERROR_
, // no error handling
63 CHANNEL_
, // TOS = channel number
65 PRINTF_
, // print TOS in field
67 RENAME_
, // Rename Tos+1 to Tos
68 PROMPT_
, // TOS = Prompt for Input
69 RESTART_
, // define restart point
70 CHAN0_
, // I/O-channel 0
72 EMPTY_
, // empty expression on stack
73 ERROR_
, // TOS = error code
74 LSET_
, // saving object TOS ==> TOS-1
75 RSET_
, // saving object TOS ==> TOS-1
76 REDIMP_ERASE_
, // Copies array to be later used by REDIM PRESERVE before erasing it
78 VBASET_
, // VBA-like Set
79 ERASE_CLEAR_
, // Erase array and clear variable
80 ARRAYACCESS_
, // Assign parameters to TOS and get value, used for array of arrays
81 BYVAL_
, // byref -> byval for lvalue parameter passed in call
85 // all opcodes with one operand
87 NUMBER_
= 0x40, // loading a numeric constant (+ID)
89 SbOP1_START
= NUMBER_
,
91 SCONST_
, // loading a string constant (+ID)
92 CONST_
, // Immediate Load (+ value)
93 ARGN_
, // saving a named Arg in Argv (+StringID)
94 PAD_
, // bring string to a firm length (+length)
96 JUMP_
, // jump (+target)
97 JUMPT_
, // evaluate TOS, conditional jump (+target)
98 JUMPF_
, // evaluate TOS, conditional jump (+target)
99 ONJUMP_
, // evaluate TOS, jump into JUMP-table (+MaxVal)
100 GOSUB_
, // UP-call (+Target)
101 RETURN_
, // UP-return (+0 or Target)
102 TESTFOR_
, // test FOR-variable, increment (+Endlabel)
103 CASETO_
, // Tos+1 <= Case <= Tos, 2xremove (+Target)
104 ERRHDL_
, // error handler (+Offset)
105 RESUME_
, // Resume after errors (+0 or 1 or Label)
107 CLOSE_
, // (+channel/0)
110 SETCLASS_
, // test set + class names (+StringId)
111 TESTCLASS_
, // Check TOS class (+StringId)
112 LIB_
, // set lib name for declare-procs (+StringId)
113 BASED_
, // TOS is incremented by BASE, BASE is pushed before (+base)
114 // type adjustment in the Argv
115 ARGTYP_
, // convert last parameter in Argv (+type)
116 VBASETCLASS_
, // VBA-like Set
118 SbOP1_END
= VBASETCLASS_
,
120 // all opcodes with two operands
122 RTL_
= 0x80, // load from the RTL (+StringID+Typ)
126 FIND_
, // load (+StringID+Typ)
127 ELEM_
, // load element (+StringID+Typ)
128 PARAM_
, // parameters (+Offset+Typ)
130 CALL_
, // call DECLARE-method (+StringID+Typ)
131 CALLC_
, // call Cdecl-DECLARE-Method (+StringID+Typ)
132 CASEIS_
, // case-test (+Test-Opcode+True-Target)
134 STMNT_
, // begin of a statement (+Line+Col)
136 OPEN_
, // (+StreamMode+Flags)
138 LOCAL_
, // define locals variables (+StringID+Typ)
139 PUBLIC_
, // module global variables (+StringID+Typ)
140 GLOBAL_
, // define global variables, public command (+StringID+Typ)
141 CREATE_
, // create object (+StringId+StringID)
142 STATIC_
, // static variable (+StringID+Typ) JSM
143 TCREATE_
, // create user-defined object
144 DCREATE_
, // create object-array (+StringId+StringID)
145 GLOBAL_P_
, // define global variable that's not overwritten on restarting
146 // the Basic, P=PERSIST (+StringID+Typ)
147 FIND_G_
, // finds global variable with special treatment due to GLOBAL_P_
148 DCREATE_REDIMP_
, // redimension object-array (+StringId+StringID)
149 FIND_CM_
, // Search inside a class module (CM) to enable global search in time
150 PUBLIC_P_
, // Module global Variable (persisted between calls)(+StringID+Typ)
151 FIND_STATIC_
, // local static var lookup (+StringID+Typ)
153 SbOP2_END
= FIND_STATIC_
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */