2 ** NetXMS - Network Management System
3 ** NetXMS Scripting Language Interpreter
4 ** Copyright (C) 2003-2010 Victor Kirhenshtein
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU Lesser General Public License as published by
8 ** the Free Software Foundation; either version 3 of the License, or
9 ** (at your option) any later version.
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU Lesser General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 ** File: instruction.cpp
31 NXSL_Instruction
::NXSL_Instruction(int nLine
, int nOpCode
)
34 m_nSourceLine
= nLine
;
38 NXSL_Instruction
::NXSL_Instruction(int nLine
, int nOpCode
, NXSL_Value
*pValue
)
41 m_nSourceLine
= nLine
;
42 m_operand
.m_pConstant
= pValue
;
46 NXSL_Instruction
::NXSL_Instruction(int nLine
, int nOpCode
, char *pszString
)
49 m_nSourceLine
= nLine
;
50 m_operand
.m_pszString
= pszString
;
54 NXSL_Instruction
::NXSL_Instruction(int nLine
, int nOpCode
, char *pszString
, int nStackItems
)
57 m_nSourceLine
= nLine
;
58 m_operand
.m_pszString
= pszString
;
59 m_nStackItems
= nStackItems
;
62 NXSL_Instruction
::NXSL_Instruction(int nLine
, int nOpCode
, DWORD dwAddr
)
65 m_nSourceLine
= nLine
;
66 m_operand
.m_dwAddr
= dwAddr
;
69 NXSL_Instruction
::NXSL_Instruction(int nLine
, int nOpCode
, int nStackItems
)
72 m_nSourceLine
= nLine
;
73 m_nStackItems
= nStackItems
;
76 NXSL_Instruction
::NXSL_Instruction(NXSL_Instruction
*pSrc
)
78 m_nOpCode
= pSrc
->m_nOpCode
;
79 m_nSourceLine
= pSrc
->m_nSourceLine
;
80 m_nStackItems
= pSrc
->m_nStackItems
;
83 case OPCODE_PUSH_CONSTANT
:
84 m_operand
.m_pConstant
= new NXSL_Value(pSrc
->m_operand
.m_pConstant
);
86 case OPCODE_PUSH_VARIABLE
:
88 case OPCODE_CALL_EXTERNAL
:
95 case OPCODE_GET_ATTRIBUTE
:
96 case OPCODE_SET_ATTRIBUTE
:
97 m_operand
.m_pszString
= strdup(pSrc
->m_operand
.m_pszString
);
100 m_operand
.m_dwAddr
= pSrc
->m_operand
.m_dwAddr
;
110 NXSL_Instruction
::~NXSL_Instruction()
114 case OPCODE_PUSH_VARIABLE
:
115 case OPCODE_CALL_EXTERNAL
:
123 case OPCODE_GET_ATTRIBUTE
:
124 case OPCODE_SET_ATTRIBUTE
:
125 safe_free(m_operand
.m_pszString
);
127 case OPCODE_PUSH_CONSTANT
:
128 delete m_operand
.m_pConstant
;