| 1 |
/* ***** BEGIN LICENSE BLOCK ***** |
|---|
| 2 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
|---|
| 3 |
* |
|---|
| 4 |
* The contents of this file are subject to the Mozilla Public License Version |
|---|
| 5 |
* 1.1 (the "License"); you may not use this file except in compliance with |
|---|
| 6 |
* the License. You may obtain a copy of the License at |
|---|
| 7 |
* http://www.mozilla.org/MPL/ |
|---|
| 8 |
* |
|---|
| 9 |
* Software distributed under the License is distributed on an "AS IS" basis, |
|---|
| 10 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
|---|
| 11 |
* for the specific language governing rights and limitations under the |
|---|
| 12 |
* License. |
|---|
| 13 |
* |
|---|
| 14 |
* The Original Code is [Open Source Virtual Machine.]. |
|---|
| 15 |
* |
|---|
| 16 |
* The Initial Developer of the Original Code is |
|---|
| 17 |
* Adobe System Incorporated. |
|---|
| 18 |
* Portions created by the Initial Developer are Copyright (C) 2004-2006 |
|---|
| 19 |
* the Initial Developer. All Rights Reserved. |
|---|
| 20 |
* |
|---|
| 21 |
* Contributor(s): |
|---|
| 22 |
* Adobe AS3 Team |
|---|
| 23 |
* |
|---|
| 24 |
* Alternatively, the contents of this file may be used under the terms of |
|---|
| 25 |
* either the GNU General Public License Version 2 or later (the "GPL"), or |
|---|
| 26 |
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
|---|
| 27 |
* in which case the provisions of the GPL or the LGPL are applicable instead |
|---|
| 28 |
* of those above. If you wish to allow use of your version of this file only |
|---|
| 29 |
* under the terms of either the GPL or the LGPL, and not to allow others to |
|---|
| 30 |
* use your version of this file under the terms of the MPL, indicate your |
|---|
| 31 |
* decision by deleting the provisions above and replace them with the notice |
|---|
| 32 |
* and other provisions required by the GPL or the LGPL. If you do not delete |
|---|
| 33 |
* the provisions above, a recipient may use your version of this file under |
|---|
| 34 |
* the terms of any one of the MPL, the GPL or the LGPL. |
|---|
| 35 |
* |
|---|
| 36 |
* ***** END LICENSE BLOCK ***** */ |
|---|
| 37 |
|
|---|
| 38 |
#ifndef __avmshell__ |
|---|
| 39 |
#define __avmshell__ |
|---|
| 40 |
|
|---|
| 41 |
#include <stdio.h> |
|---|
| 42 |
#include <stdlib.h> |
|---|
| 43 |
|
|---|
| 44 |
#include "avmplus.h" |
|---|
| 45 |
|
|---|
| 46 |
// interactive shell requires functional external compiler, not yet |
|---|
| 47 |
// present in Tamarin. commented out for now. |
|---|
| 48 |
#define AVMPLUS_INTERACTIVE |
|---|
| 49 |
|
|---|
| 50 |
using namespace avmplus; |
|---|
| 51 |
|
|---|
| 52 |
// avmplus and NSPR both typedef some basic types: we must disambiguate |
|---|
| 53 |
using avmplus::uint64; |
|---|
| 54 |
using avmplus::uint32; |
|---|
| 55 |
using avmplus::uint16; |
|---|
| 56 |
using avmplus::uint8; |
|---|
| 57 |
|
|---|
| 58 |
namespace avmshell |
|---|
| 59 |
{ |
|---|
| 60 |
class ByteArrayObject; |
|---|
| 61 |
class ByteArray; |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
namespace avmplus |
|---|
| 65 |
{ |
|---|
| 66 |
class Dictionary; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
#include "FileInputStream.h" |
|---|
| 70 |
#include "ConsoleOutputStream.h" |
|---|
| 71 |
#include "SystemClass.h" |
|---|
| 72 |
#include "StringBuilderClass.h" |
|---|
| 73 |
#include "FileClass.h" |
|---|
| 74 |
#include "DomainClass.h" |
|---|
| 75 |
#include "DebugCLI.h" |
|---|
| 76 |
#include "Profiler.h" |
|---|
| 77 |
#include "DataIO.h" |
|---|
| 78 |
#include "ByteArrayGlue.h" |
|---|
| 79 |
#include "DictionaryGlue.h" |
|---|
| 80 |
#include "SamplerScript.h" |
|---|
| 81 |
#include "JavaGlue.h" |
|---|
| 82 |
|
|---|
| 83 |
#ifdef _MSC_VER |
|---|
| 84 |
#pragma warning(disable:4996) |
|---|
| 85 |
#endif |
|---|
| 86 |
|
|---|
| 87 |
namespace avmplus |
|---|
| 88 |
{ |
|---|
| 89 |
namespace NativeID |
|---|
| 90 |
{ |
|---|
| 91 |
#include "toplevel.h" |
|---|
| 92 |
} |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
namespace avmshell |
|---|
| 96 |
{ |
|---|
| 97 |
class ShellCodeContext : public CodeContext |
|---|
| 98 |
{ |
|---|
| 99 |
public: |
|---|
| 100 |
DWB(DomainEnv*) m_domainEnv; |
|---|
| 101 |
virtual ~ShellCodeContext() {} |
|---|
| 102 |
virtual DomainEnv *domainEnv() const { return m_domainEnv; } |
|---|
| 103 |
}; |
|---|
| 104 |
|
|---|
| 105 |
/** |
|---|
| 106 |
* A command-line shell around the avmplus core. This can be |
|---|
| 107 |
* used to execute and debug .abc files from the command line. |
|---|
| 108 |
*/ |
|---|
| 109 |
class Shell : public AvmCore |
|---|
| 110 |
{ |
|---|
| 111 |
public: |
|---|
| 112 |
Shell(MMgc::GC *gc); |
|---|
| 113 |
void usage(); |
|---|
| 114 |
int main(int argc, char *argv[]); |
|---|
| 115 |
|
|---|
| 116 |
void interrupt(MethodEnv *env); |
|---|
| 117 |
void stackOverflow(MethodEnv *env); |
|---|
| 118 |
|
|---|
| 119 |
void initShellPool(); |
|---|
| 120 |
Toplevel* initShellBuiltins(); |
|---|
| 121 |
|
|---|
| 122 |
void setEnv(Toplevel *toplevel, int argc, char *argv[]); |
|---|
| 123 |
|
|---|
| 124 |
SystemClass* systemClass; |
|---|
| 125 |
|
|---|
| 126 |
private: |
|---|
| 127 |
DECLARE_NATIVE_CLASSES() |
|---|
| 128 |
DECLARE_NATIVE_SCRIPTS() |
|---|
| 129 |
|
|---|
| 130 |
ConsoleOutputStream *consoleOutputStream; |
|---|
| 131 |
bool gracePeriod; |
|---|
| 132 |
bool inStackOverflow; |
|---|
| 133 |
PoolObject* shellPool; |
|---|
| 134 |
|
|---|
| 135 |
bool executeProjector(int argc, char *argv[], int& exitCode); |
|---|
| 136 |
|
|---|
| 137 |
void computeStackBase(); |
|---|
| 138 |
|
|---|
| 139 |
#ifdef DEBUGGER |
|---|
| 140 |
DebugCLI *debugCLI; |
|---|
| 141 |
#endif |
|---|
| 142 |
|
|---|
| 143 |
// for interactive |
|---|
| 144 |
#ifdef AVMPLUS_INTERACTIVE |
|---|
| 145 |
#ifdef DARWIN |
|---|
| 146 |
int addToIncludes(char* includes, char* addition); |
|---|
| 147 |
#endif |
|---|
| 148 |
int addToImports(char* imports, char* addition); |
|---|
| 149 |
#endif //AVMPLUS_INTERACTIVE |
|---|
| 150 |
}; |
|---|
| 151 |
|
|---|
| 152 |
class AvmplusScript : public ScriptObject |
|---|
| 153 |
{ |
|---|
| 154 |
|
|---|
| 155 |
public: |
|---|
| 156 |
AvmplusScript(VTable *vtable, ScriptObject* delegate) |
|---|
| 157 |
: ScriptObject(vtable, delegate) |
|---|
| 158 |
{ |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
DECLARE_NATIVE_SCRIPT(AvmplusScript) |
|---|
| 163 |
}; |
|---|
| 164 |
} |
|---|
| 165 |
|
|---|
| 166 |
#endif /* __avmshell__ */ |
|---|