1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 20 #ifndef INCLUDED_BASIC_SOURCE_INC_OPCODES_HXX 21 #define INCLUDED_BASIC_SOURCE_INC_OPCODES_HXX 22 23 #include "sbintern.hxx" 24 25 // An opcode can have a length of 1, 3 or 5 bytes, 26 // depending on its numeric value (see below). 27 28 enum class SbiOpcode { 29 // all opcodes without operands 30 NOP_ = 0, 31 32 SbOP0_START = NOP_, 33 34 // operators 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_, 40 CAT_, 41 // end of enum SbxVarOp 42 LIKE_, IS_, 43 // load/save 44 ARGC_, // establish new Argv 45 ARGV_, // TOS ==> current Argv 46 INPUT_, // Input ==> TOS 47 LINPUT_, // Line Input ==> TOS 48 GET_, // touch TOS 49 SET_, // save object TOS ==> TOS-1 50 PUT_, // TOS ==> TOS-1 51 PUTC_, // TOS ==> TOS-1, then ReadOnly 52 DIM_, // DIM 53 REDIM_, // REDIM 54 REDIMP_, // REDIM PRESERVE 55 ERASE_, // delete TOS 56 // branch 57 STOP_, // end of program 58 INITFOR_, // initialize FOR-variable 59 NEXT_, // increment FOR-variable 60 CASE_, // beginning CASE 61 ENDCASE_, // end CASE 62 STDERROR_, // standard error handling 63 NOERROR_, // no error handling 64 LEAVE_, // leave UP 65 // E/A 66 CHANNEL_, // TOS = channel number 67 BPRINT_, // print TOS 68 PRINTF_, // print TOS in field 69 BWRITE_, // write TOS 70 RENAME_, // Rename Tos+1 to Tos 71 PROMPT_, // TOS = Prompt for Input 72 RESTART_, // define restart point 73 CHAN0_, // I/O-channel 0 74 // miscellaneous 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 80 INITFOREACH_, 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 85 86 SbOP0_END = BYVAL_, 87 88 // all opcodes with one operand 89 90 NUMBER_ = 0x40, // loading a numeric constant (+ID) 91 92 SbOP1_START = NUMBER_, 93 94 SCONST_, // loading a string constant (+ID) 95 CONST_, // Immediate Load (+ value) 96 ARGN_, // saving a named Arg in Argv (+StringID) 97 PAD_, // bring string to a firm length (+length) 98 // branch 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) 109 // E/A 110 CLOSE_, // (+channel/0) 111 PRCHAR_, // (+char) 112 // management 113 SETCLASS_, // test set + class names (+StringId) 114 TESTCLASS_, // Check TOS class (+StringId) 115 LIB_, // set lib name for declare-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 120 121 SbOP1_END = VBASETCLASS_, 122 123 // all opcodes with two operands 124 125 RTL_ = 0x80, // load from the RTL (+StringID+Typ) 126 127 SbOP2_START = RTL_, 128 129 FIND_, // load (+StringID+Typ) 130 ELEM_, // load element (+StringID+Typ) 131 PARAM_, // parameters (+Offset+Typ) 132 // branch 133 CALL_, // call DECLARE-method (+StringID+Typ) 134 CALLC_, // call Cdecl-DECLARE-Method (+StringID+Typ) 135 CASEIS_, // case-test (+Test-Opcode+True-Target) 136 // management 137 STMNT_, // begin of a statement (+Line+Col) 138 // E/A 139 OPEN_, // (+StreamMode+Flags) 140 // objects 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) 155 156 SbOP2_END = FIND_STATIC_ 157 }; 158 159 #endif 160 161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 162
