PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/lscript/lscript_compile/lscript_bytecode.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 89 lines | 50 code | 14 blank | 25 comment | 0 complexity | f8aa74befabb6c6159b228bcc7778dfb MD5 | raw file
 1/** 
 2 * @file lscript_bytecode.h
 3 * @brief classes to build actual bytecode
 4 *
 5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LSCRIPT_BYTECODE_H
28#define LL_LSCRIPT_BYTECODE_H
29
30#include "lscript_byteconvert.h"
31#include "lscript_scope.h"
32
33class LLScriptJumpTable
34{
35public:
36	LLScriptJumpTable();
37	~LLScriptJumpTable();
38
39	void addLabel(char *name, S32 offset);
40	void addJump(char *name, S32 offset);
41
42	LLMap<char *, S32 *> mLabelMap;
43	LLMap<char *, S32 *> mJumpMap;
44};
45
46class LLScriptByteCodeChunk
47{
48public:
49	LLScriptByteCodeChunk(BOOL b_need_jumps);
50	~LLScriptByteCodeChunk();
51
52	void addByte(U8 byte);
53	void addU16(U16 data);
54	void addBytes(const U8 *bytes, S32 size);
55	void addBytes(const char *bytes, S32 size);
56	void addBytes(S32 size);
57	void addBytesDontInc(S32 size);
58	void addInteger(S32 value);
59	void addFloat(F32 value);
60	void addLabel(char *name);
61	void addJump(char *name);
62	void connectJumps();
63
64	U8					*mCodeChunk;
65	S32					mCurrentOffset;
66	LLScriptJumpTable	*mJumpTable;
67};
68
69class LLScriptScriptCodeChunk
70{
71public:
72	LLScriptScriptCodeChunk(S32 total_size);
73	~LLScriptScriptCodeChunk();
74
75	void build(LLFILE *efp, LLFILE *bcfp);
76
77	LLScriptByteCodeChunk				*mRegisters;	
78	LLScriptByteCodeChunk				*mGlobalVariables;	
79	LLScriptByteCodeChunk				*mGlobalFunctions;
80	LLScriptByteCodeChunk				*mStates;
81	LLScriptByteCodeChunk				*mHeap;
82	S32									mTotalSize;
83	U8									*mCompleteCode;
84};
85
86extern LLScriptScriptCodeChunk	*gScriptCodeChunk;
87
88#endif
89