/** Run the dummy info.nut. */
void Script_CreateDummyInfo(HSQUIRRELVM vm, const char *type, const char *dir)
{
	char dummy_script[4096];
	char *dp = dummy_script;
	dp += seprintf(dp, lastof(dummy_script), "class Dummy%s extends %sInfo {\n", type, type);
	dp += seprintf(dp, lastof(dummy_script), "function GetAuthor()      { return \"OpenTTD Developers Team\"; }\n");
	dp += seprintf(dp, lastof(dummy_script), "function GetName()        { return \"Dummy%s\"; }\n", type);
	dp += seprintf(dp, lastof(dummy_script), "function GetShortName()   { return \"DUMM\"; }\n");
	dp += seprintf(dp, lastof(dummy_script), "function GetDescription() { return \"A Dummy %s that is loaded when your %s/ dir is empty\"; }\n", type, dir);
	dp += seprintf(dp, lastof(dummy_script), "function GetVersion()     { return 1; }\n");
	dp += seprintf(dp, lastof(dummy_script), "function GetDate()        { return \"2008-07-26\"; }\n");
	dp += seprintf(dp, lastof(dummy_script), "function CreateInstance() { return \"Dummy%s\"; }\n", type);
	dp += seprintf(dp, lastof(dummy_script), "} RegisterDummy%s(Dummy%s());\n", type, type);

	const SQChar *sq_dummy_script = dummy_script;

	sq_pushroottable(vm);

	/* Load and run the script */
	if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, strlen(sq_dummy_script), "dummy", SQTrue))) {
		sq_push(vm, -2);
		if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) {
			sq_pop(vm, 1);
			return;
		}
	}
	NOT_REACHED();
}
void
ConsoleImpl::execute(const std::string& str_)
{
  std::string str = str_; //"return (" + str_ + ")";

  int i = str.length();
  const char* buffer = str.c_str();

  HSQUIRRELVM vm = script_manager->get_vm();
  int oldtop=sq_gettop(vm); 
  try {
    int retval = 1;

    if(i>0){
      if(SQ_SUCCEEDED(sq_compilebuffer(vm,buffer,i,_SC("interactive console"),SQTrue))){
        sq_pushroottable(vm);
        if(SQ_SUCCEEDED(sq_call(vm,1, retval, true))) 
          {
            if (sq_gettype(vm, -1) != OT_NULL)
              console << squirrel2string(vm, -1) << std::endl;
          }
      }
    }
  } catch(std::exception& e) {
    std::cerr << "Couldn't execute command '" << str_ << "': "
              << e.what() << "\n";
  }
  sq_settop(vm,oldtop);
}
Beispiel #3
0
SquirrelObject SquirrelVM::CompileBuffer(const SQChar *s)
{
	SquirrelObject ret(_VM);
	if(SUCCEEDED(sq_compilebuffer(_VM,s,(int)wcslen(s)*sizeof(SQChar),_SC("console buffer"),1))) {
		ret.AttachToStackObject(-1);
		sq_pop(_VM,1);
		return ret;
	}
	throw SquirrelError(_VM);
}
Beispiel #4
0
/*
 * Comple script buffers
 */
SQInteger sqCompileBuffer(HSQUIRRELVM v, const char* script, const char* sourcename) {
	if (SQ_SUCCEEDED(sq_compilebuffer(v, script, scstrlen(script), sourcename, SQTrue))) {
		sq_pushroottable(v);
		if (SQ_FAILED(sq_call(v, 1, SQFalse, SQTrue))) {
			return ERR_SCRIPT_CALL_ROOT;
		}
	} else {
		return ERR_SCRIPT_COMPILE;
	}
	return EMO_NO_ERROR;
}
/** Run the dummy AI and let it generate an error message. */
void Script_CreateDummy(HSQUIRRELVM vm, StringID string, const char *type)
{
	/* We want to translate the error message.
	 * We do this in three steps:
	 * 1) We get the error message
	 */
	char error_message[1024];
	GetString(error_message, string, lastof(error_message));

	/* Make escapes for all quotes and slashes. */
	char safe_error_message[1024];
	char *q = safe_error_message;
	for (const char *p = error_message; *p != '\0' && q < lastof(safe_error_message) - 2; p++, q++) {
		if (*p == '"' || *p == '\\') *q++ = '\\';
		*q = *p;
	}
	*q = '\0';

	/* 2) We construct the AI's code. This is done by merging a header, body and footer */
	char dummy_script[4096];
	char *dp = dummy_script;
	dp += seprintf(dp, lastof(dummy_script), "class Dummy%s extends %sController {\n  function Start()\n  {\n", type, type);

	/* As special trick we need to split the error message on newlines and
	 * emit each newline as a separate error printing string. */
	char *newline;
	char *p = safe_error_message;
	do {
		newline = strchr(p, '\n');
		if (newline != NULL) *newline = '\0';

		dp += seprintf(dp, lastof(dummy_script), "    %sLog.Error(\"%s\");\n", type, p);
		p = newline + 1;
	} while (newline != NULL);

	dp = strecpy(dp, "  }\n}\n", lastof(dummy_script));

	/* 3) We translate the error message in the character format that Squirrel wants.
	 *    We can use the fact that the wchar string printing also uses %s to print
	 *    old style char strings, which is what was generated during the script generation. */
	const SQChar *sq_dummy_script = dummy_script;

	/* And finally we load and run the script */
	sq_pushroottable(vm);
	if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, strlen(sq_dummy_script), "dummy", SQTrue))) {
		sq_push(vm, -2);
		if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) {
			sq_pop(vm, 1);
			return;
		}
	}
	NOT_REACHED();
}
Beispiel #6
0
bool Context::executeBuffer(const String& buffer, const String& source) const
{
    StackLock lock(*this);

    sq_pushroottable(vm_);

    if (SQ_FAILED( sq_compilebuffer(vm_, buffer.c_str(), buffer.size(), source.c_str(), SQTrue) ))
        return false;

    sq_push(vm_, -2);
    return SQ_SUCCEEDED( sq_call(vm_, 1, SQFalse, SQTrue) );
}
Beispiel #7
0
MyScript SqEnv::compile_buffer(const SQChar *s,  size_t length, const SQChar * debugInfo)const
{
    //AutoLock a(&_m);
    Sqrat::DefaultVM::Set(*_vm);

    SQObject obj;
    if(SQ_FAILED(sq_compilebuffer(*_vm, s,
                                  static_cast<SQInteger>(length),
                                  debugInfo, true)))
    {
        throw Sqrat::Exception(Sqrat::LastErrorString(*_vm));
    }
    sq_getstackobj(*_vm,-1,&obj);
    return MyScript(*_vm, obj);
}
Beispiel #8
0
static SQInteger base_compilestring(HSQUIRRELVM v)
{
	SQInteger nargs=sq_gettop(v);
	const SQChar *src=NULL,*name=_SC("unnamedbuffer");
	SQInteger size;
	sq_getstring(v,2,&src);
	size=sq_getsize(v,2);
	if(nargs>2){
		sq_getstring(v,3,&name);
	}
	if(SQ_SUCCEEDED(sq_compilebuffer(v,src,size,name,SQFalse)))
		return 1;
	else
		return SQ_ERROR;
}
Beispiel #9
0
static SQRESULT sq_slave_vm_compilestring(HSQUIRRELVM v)
{
    SQ_FUNC_VARS(v);
    GET_sq_slave_vm_INSTANCE(v, 1);
    SQ_GET_STRING(v, 2, func_name);
    SQ_GET_STRING(v, 3, str_script);
    SQ_OPT_BOOL(v, 4, printerror, false);
    SQ_OPT_BOOL(v, 5, show_warnings, false);
    SQInteger top = sq_gettop(self);
    SQRESULT result = SQ_ERROR;
    sq_pushroottable(self);
    sq_pushstring(self, func_name, func_name_size);
    if(sq_compilebuffer(self, str_script, str_script_size, func_name, printerror, show_warnings) >= 0)
    {
        result = sq_newslot(self, -3, SQFalse);
    }
    sq_settop(self, top);
    return result;
}
Beispiel #10
0
//------------------------------------------------------------------------------
bool Script::compileString(
    const std::string & sourceCode, 
    const std::string & scriptName)
{
    releaseObject();

    if(SQ_FAILED(sq_compilebuffer(m_vm, 
        sourceCode.c_str(), 
        static_cast<SQInteger>(sourceCode.size()),
        scriptName.c_str(), 
        true // raise error
        )))
    {
        return false;
    }

    sq_getstackobj(m_vm, -1, &m_object);
    sq_addref(m_vm, &m_object);
    sq_pop(m_vm, 1);

    return true;
}
static WasmResult run_squirrel_file(WasmAllocator* allocator,
                                    HSQUIRRELVM v,
                                    const char* filename) {
  WasmResult result;
  void* data;
  size_t size;
  result = wasm_read_file(allocator, filename, &data, &size);
  if (WASM_SUCCEEDED(result)) {
    if (SQ_SUCCEEDED(sq_compilebuffer(v, data, size, filename, RAISE_ERROR))) {
      sq_pushroottable(v);
      if (SQ_SUCCEEDED(sq_call(v, 1, WITHOUT_RETVAL, RAISE_ERROR))) {
        /* do some other stuff... */
        result = WASM_OK;
      } else {
        result = WASM_ERROR;
      }
    } else {
      result = WASM_ERROR;
    }
    wasm_free(allocator, data);
  }
  return result;
}
Beispiel #12
0
/**
 * load a JS file into context
 */
static int sqlang_load_file(HSQUIRRELVM J, const char *filename)
{
	if(!SQ_SUCCEEDED(sqstd_dofile(J, _SC(filename), 0, 1))) {
		/* prints syntax errors if any */
		LM_ERR("failed to load file: %s\n", filename);
		return -1;
    }
    LM_DBG("loaded file: %s\n", filename);
	return 0;
#if 0
	FILE *f;
	size_t len;
#define SQLANG_SCRIPT_MAX_SIZE 128*1024
	char buf[SQLANG_SCRIPT_MAX_SIZE];

	f = fopen(filename, "rb");
	if (f) {
		len = fread((void *) buf, 1, sizeof(buf)-1, f);
		fclose(f);
		if(len>0) {
			buf[len] = '\0';
			if(!SQ_SUCCEEDED(sq_compilebuffer(J, buf, len,
							_SC(filename), SQTrue))) {
				LM_ERR("failed to compile: %s\n", filename);
				return -1;
			}
		} else {
			LM_ERR("empty content in %s\n", filename);
			return -1;
		}
	} else {
		LM_ERR("cannot open file: %s\n", filename);
		return -1;
	}
	return 0;
#endif
}
Beispiel #13
0
int main (int argc, char** argv)
{
	ENABLE_LEAK_CHECK();

#if defined(SHELL_PLATFORM_WINDOWS)
	SetConsoleTitle("Squirrel Shell " SHELL_VERSION_STR " (" SHELL_CPUARCH ")");
#else
	stderrIsRedirected = !isatty(2);
#endif

	// Parse command line arguments.
	const char* fileName	= NULL;
	bool		interactive = argc == 1;
	int			firstArg	= 0,
				i;
	bool isDebug = false;
	int debuggerPort = 0;
	for (i = 1; argv[i]; ++i)
	{
		char* arg = argv[i];

		if (!strcmp(arg, "-h") || !strcmp(arg, "--help"))
		{
			printf("Squirrel Shell %s for %s on %s (" __DATE__ ")\n"
				   SHELL_VERSION_COPYRIGHT "\n"
				   "\n"
				   "This is free software, and comes WITHOUT ANY WARRANTY; without even the implied\n"
				   "warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
				   "General Public License for more details.\n"
				   "\n"
				   "MD5 hash calculation code (c) Colin Plumb\n"
				   "PCRE (c) University of Cambridge\n"
				   "Squirrel (c) Alberto Demichelis\n"
				   "zlib (c) Jean-loup Gailly and Mark Adler\n"
				   "\n"
				   "Usage:\n"
				   "   squirrelsh [options] [script_file] [script_arguments]\n"
				   "\n"
				   "Options:\n"
				   "   -h, --help          Display this text\n"
				   "   -d<PORT>            Enable the debugger, in the specified port\n"
				   "   -i, --interactive   Run shell in interactive mode\n"
				   "                       If script file is specified, it will be executed before\n"
				   "                       entering this mode\n"
				   "   -s, --silent        Do not display error and warning messages\n"
				   "   -v, --version       Display shell version number\n"
				   "\n"
				   "Examples:\n"
				   "   squirrelsh                    Run shell in interactive mode\n"
				   "   squirrelsh foo.nut            Run foo.nut script without arguments\n"
				   "   squirrelsh -i foo.nut 1 2 3   Run foo.nut script with arguments \"1\", \"2\"\n"
				   "                                 and \"3\", and switch into interactive mode\n",
				   SHELL_VERSION_STR,
				   SHELL_PLATFORM,
				   SHELL_CPUARCH);

			return EXIT_SUCCESS;
		}
		else if (!strncmp(arg, "-d", 2))
		{
			// RVF +
			isDebug = true;
			debuggerPort = std::atoi(arg + 2);
			if (debuggerPort == 0)
			{
				printf("No debugger port specified\n");
				return EXIT_FAILURE;
			}
			// RVF -
		}
		else if (!strcmp(arg, "-i") || !strcmp(arg, "--interactive"))
			interactive = true;
		else if (!strcmp(arg, "-v") || !strcmp(arg, "--version"))
		{
			printf("%s\n", SHELL_VERSION_STR);
			return EXIT_SUCCESS;
		}
		else if (!strcmp(arg, "-s") || !strcmp(arg, "--silent"))
			silent = true;
		else
		{
			// First unreserved argument will be treated as script file name.
			fileName = arg;
			firstArg = i;
			break;
		}
	}

	if (!fileName && !interactive)
	{
		PrintError("ERROR: Script file not specified.\n");
		return EXIT_FAILURE;
	}

	// Initialize Squirrel.
	sqvm = sq_open(1024);
	if (!sqvm)
	{
		PrintError("ERROR: Failed to create Squirrel VM.\n");
		return EXIT_FAILURE;
	}

	sqstd_seterrorhandlers(sqvm);

	HSQREMOTEDBG rdbg = nullptr;
	if (isDebug)
	{
		rdbg = sq_rdbg_init(sqvm, debuggerPort, SQTrue);
		sq_enabledebuginfo(sqvm, SQTrue);

		//!! SUSPENDS THE APP UNTIL THE DEBUGGER CLIENT CONNECTS
		scprintf("Waiting for the debugger to connect...\n");
		if (!SQ_SUCCEEDED(sq_rdbg_waitforconnections(rdbg)))
		{
			PrintError("ERROR: Failed to connect to the debugger.\n");
			return EXIT_FAILURE;
		}
		scprintf(_SC("Connected to the debugger\n"));
	}


	//sq_setcompilererrorhandler(sqvm, SquirrelCompileError);

	_RPT0(_CRT_WARN, "--- Squirrel initialized\n");

	// Register some globals.
	SetSqString("SHELL_VERSION", SHELL_VERSION_STR, SQTrue);
	SetSqString("SQUIRREL_VERSION", SQUIRREL_VERSION_SHORT, SQTrue);
	SetSqString("PLATFORM", SHELL_PLATFORM, SQTrue);
	SetSqString("CPU_ARCH", SHELL_CPUARCH, SQTrue);

	// Initialize libraries.
	Init_Base();
	Init_IO();
	Init_File();
	Init_Math();
	Init_Util();
	Init_Hash();
	Init_RegExp();

	_RPT0(_CRT_WARN, "--- Libraries initialized\n");

	// Set up global variables...
	sq_pushroottable(sqvm);

	// RVF +
	// Initialize squirrel std libraries
	//sqstd_register_bloblib(sqvm);
	sqstd_register_iolib(sqvm); // We need this one because of the handy "dofile" function
	sqstd_register_stringfunctions(sqvm); // This registers only some string functions that are useful and don't clash with Squirrel Shell
	// NOTE: Not registering the other libraries, because there are name clashing between Squirrel Shell and SqStdLib
	//sqstd_register_systemlib(sqvm);
	//sqstd_register_mathlib(sqvm);
	//sqstd_register_stringlib(sqvm);
	// RVF -


	// ... number of command line arguments...
	sq_pushstring(sqvm, "__argc", -1);
	sq_pushinteger(sqvm, SQInteger(argc - firstArg));
	if (SQ_FAILED(sq_newslot(sqvm, -3, SQFalse)))
	{
		PrintError("ERROR: Failed to create \"__argc\" integer value.\n");
		Shutdown();
		return EXIT_FAILURE;
	}

	// ... and arguments themselves.
	sq_pushstring(sqvm, "__argv", -1);
	sq_newarray(sqvm, 0);
	for (i = firstArg; argv[i]; ++i)
	{
		sq_pushstring(sqvm, argv[i], -1);
		sq_arrayappend(sqvm, -2);
	}
	if (SQ_FAILED(sq_newslot(sqvm, -3, SQFalse)))
	{
		PrintError("ERROR: Failed to create \"__argv\" array.\n");
		Shutdown();
		return EXIT_FAILURE;
	}
	sq_pop(sqvm, 1);

	// Load and run script.
	SQInteger result = EXIT_SUCCESS;
	if (fileName && LoadScript(fileName))
	{
		sq_pushroottable(sqvm);
		if (SQ_FAILED(sq_call(sqvm, 1, SQTrue, isDebug ? SQTrue : SQFalse)))
		{
			if (!silent)
			{
				const SQChar* errMsg = "Unknown error.";
				sq_getlasterror(sqvm);
				if (sq_gettype(sqvm, -1) == OT_STRING)
					sq_getstring(sqvm, -1, &errMsg);

				PrintError("ERROR: %s\n", errMsg);
			}
			Shutdown();
			return EXIT_FAILURE;
		}

		// Get script execution result.
		if (sq_getvmstate(sqvm) == SQ_VMSTATE_SUSPENDED)
			result = retCode;
		else
		{
			if (sq_gettype(sqvm, -1) == OT_INTEGER)
				sq_getinteger(sqvm, -1, &result);
		}

		// Pop everything except root table.
		sq_settop(sqvm, 1);
	}

	// Enter interactive mode (if necessary).
	if (interactive)
	{
		SQChar cmd[MAX_CMD_LENGTH + 1];
		do
		{
#if defined(SHELL_PLATFORM_WINDOWS)
			GetCurrentDirectory(sizeof(cmd), cmd);
#else
			getcwd(cmd, sizeof(cmd));
#endif
			cmd[sizeof(cmd) - 1] = 0;

			printf("%s> ", ConvPath(cmd, SQFalse));
			fgets(cmd, MAX_CMD_LENGTH, stdin);
			if (SQ_FAILED(sq_compilebuffer(sqvm, cmd, SQInteger(strlen(cmd)), "", SQTrue)))
				continue;

			sq_pushroottable(sqvm);
			if (SQ_FAILED(sq_call(sqvm, 1, SQFalse, SQFalse)) && !silent)
			{
				const SQChar* errMsg = "Unknown error.";
				sq_getlasterror(sqvm);
				if (sq_gettype(sqvm, -1) == OT_STRING)
					sq_getstring(sqvm, -1, &errMsg);

				PrintError("ERROR: %s\n", errMsg);
			}
		} while(sq_getvmstate(sqvm) != SQ_VMSTATE_SUSPENDED);
		result = retCode;
	}

	if (isDebug)
	{
		sq_rdbg_shutdown(rdbg);
	}

	Shutdown();
	return int(result);
}
Beispiel #14
0
// Load script from file
// Script is first read into memory buffer and then line beginning with "#!" (line with script interpreter specification in
// Linux) is converted into Squirrel comment. This line must be BEFORE actual script text
static bool LoadScript (const char* fileName)
{
	bool	res  = false;
	FILE*	file = NULL;
	SQChar* buf  = NULL;

	// RVF +
	std::string canonicalizedFilename = prepareFilename(fileName);
	fileName = canonicalizedFilename.c_str();
	// RVF -
	try
	{
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
		if (fopen_s(&file, ConvPath(fileName, SQTrue), "rb"))
			file = NULL;
#else
		file = fopen(ConvPath(fileName, SQTrue), "rb");
#endif
		if (!file)
			throw "Failed to open the file";

		fseek(file, 0, SEEK_END);
		SQInteger size = SQInteger(ftell(file));
		if (!size)
			throw "File is empty";

		buf = (SQChar*)malloc(size + 1);
		if (!buf)
			throw "Not enough memory for script";

		fseek(file, 0, SEEK_SET);
		if (!fread(buf, size, 1, file))
			throw "Failed to read script";

		buf[size - 1] = 0;

		for (SQChar* c = buf; *c; ++c)
		{
			if (!isspace(*c))
			{
				if ((c[0] == '#') && (c[1] == '!'))
					c[0] = c[1] = '/';
				break;
			}
		}

		if (SQ_FAILED(sq_compilebuffer(sqvm, buf, size, fileName, SQTrue)))
			throw "Failed to compile script";

		res = true;
	}

	catch (const char* errMsg)
	{
		PrintError("ERROR: %s: %s.\n", fileName, errMsg);
	}

	if (file)
		fclose(file);

	free(buf);

	return res;
}
Beispiel #15
0
inline SQRESULT loadScript(HSQUIRRELVM vm, const std::string& filename) {
    std::string script_contents = loadTextFile(filename);
    if (script_contents.empty())
        return SQ_ERROR;
    return sq_compilebuffer(vm, script_contents.c_str(), script_contents.size(), filename.c_str(), true);
}
Beispiel #16
0
void Interactive(HSQUIRRELVM v)
{
	
#define MAXINPUT 1024
	SQChar buffer[MAXINPUT];
	SQInteger blocks =0;
	SQInteger string=0;
	SQInteger retval=0;
	SQInteger done=0;
	PrintVersionInfos();
		
	sq_pushroottable(v);
	sq_pushstring(v,_SC("quit"),-1);
	sq_pushuserpointer(v,&done);
	sq_newclosure(v,quit,1);
	sq_setparamscheck(v,1,NULL);
	sq_newslot(v,-3,SQFalse);
	sq_pop(v,1);

	while (!done) 
	{
		SQInteger i = 0;
		scprintf(_SC("\nsq>"));
		for(;;) {
			int c;
			if(done)return;
			c = getchar();
			if (c == _SC('\n')) {
				if (i>0 && buffer[i-1] == _SC('\\'))
				{
					buffer[i-1] = _SC('\n');
				}
				else if(blocks==0)break;
				buffer[i++] = _SC('\n');
			}
			else if (c==_SC('}')) {blocks--; buffer[i++] = (SQChar)c;}
			else if(c==_SC('{') && !string){
					blocks++;
					buffer[i++] = (SQChar)c;
			}
			else if(c==_SC('"') || c==_SC('\'')){
					string=!string;
					buffer[i++] = (SQChar)c;
			}
			else if (i >= MAXINPUT-1) {
				scfprintf(stderr, _SC("sq : input line too long\n"));
				break;
			}
			else{
				buffer[i++] = (SQChar)c;
			}
		}
		buffer[i] = _SC('\0');
		
		if(buffer[0]==_SC('=')){
			scsprintf(sq_getscratchpad(v,MAXINPUT),_SC("return (%s)"),&buffer[1]);
			memcpy(buffer,sq_getscratchpad(v,-1),(scstrlen(sq_getscratchpad(v,-1))+1)*sizeof(SQChar));
			retval=1;
		}
		i=scstrlen(buffer);
		if(i>0){
			SQInteger oldtop=sq_gettop(v);
			if(SQ_SUCCEEDED(sq_compilebuffer(v,buffer,i,_SC("interactive console"),SQTrue))){
				sq_pushroottable(v);
				if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue)) &&	retval){
					scprintf(_SC("\n"));
					sq_pushroottable(v);
					sq_pushstring(v,_SC("print"),-1);
					sq_get(v,-2);
					sq_pushroottable(v);
					sq_push(v,-4);
					sq_call(v,2,SQFalse,SQTrue);
					retval=0;
					scprintf(_SC("\n"));
				}
			}
			
			sq_settop(v,oldtop);
		}
	}
}
Beispiel #17
0
bool SquirrelThread::loadScript(const String& code, const String& codeName)
{		
    m_oldTop = sq_gettop(m_thread);

    if (code.length() > 7 && 0 == wcsncmp((const wchar_t *)code.characters(), L"//#skip", 7))
        return true;
#if 0
    //int codeLen = wcslen(sCode);
    int codeLen = code.length();
    if (m_codeCache0.size() < (int)codeLen) {
        m_codeCache0.resize(codeLen * 2);
    }

    memset(&m_codeCache0[0], 0, m_codeCache0.size()*sizeof(UChar));

    if (EnumPBSuccess != SquirrelPrecompil(code, m_codeCache0)) {
        notImplemented();
        return false;
    }
    
    OutputDebugStringW((PWCHAR)m_codeCache0.data());

    const SQChar* codeNameString = codeName.charactersWithNullTermination();
    SQRESULT hr = sq_compilebuffer(m_thread, (const SQChar *)m_codeCache0.data(), 
        (int)wcslen((const wchar_t *)m_codeCache0.data()), codeNameString, SQTrue);
    if (SQ_FAILED(hr)) { 
        notImplemented();
        return false;
    }
#endif

#if 1
    String codeNameDummy = codeName;
    const SQChar* codeNameString = codeNameDummy.charactersWithNullTermination();
    SQRESULT hr = sq_compilebuffer(m_thread, (const SQChar *)code.characters(),
        code.length(), codeNameString, SQTrue);
    if (SQ_FAILED(hr)) {
        //raiseExceptionWhenLoadScript(m_thread, codeName, 14);
        //notImplemented();
        return false;
    }
#endif
    // start the script that was previously compiled
    sq_pushroottable(m_thread);
    if (SQ_FAILED(sq_call(m_thread, 1, SQFalse, SQTrue))) {
// 		if (isThrowSqException()) {
// 			raiseExceptionWhenLoadScript(m_thread, codeName, 15);
// 			notImplemented();
// 		}
        sq_pop(m_thread, 1); // pop the compiled closure
        return false;
    } else {
        if (sq_getvmstate(m_thread) != SQ_VMSTATE_IDLE) { 
            //raiseExceptionWhenLoadScript(m_thread, codeName, 16);
            //notImplemented();
            return false; 
        }

        sq_pop(m_thread, 1); // pop the compiled closure
    }
    
    return true;
}