Exemple #1
0
 public ScriptObject LoadSearchPathFile(String fileName)
 {
     for (int i = 0; i < m_SearchPath.Count; ++i)
     {
         string file = m_SearchPath[i] + "/" + fileName;
         if (ScriptExtensions.FileExist(file))
         {
             return(LoadFile(file));
         }
     }
     throw new ExecutionException(this, "require 找不到文件 : " + fileName);
 }
Exemple #2
0
 public Script()
 {
     Null              = new ScriptNull(this);
     True              = new ScriptBoolean(this, true);
     False             = new ScriptBoolean(this, false);
     m_UserdataFactory = new DefaultScriptUserdataFactory(this);
     m_GlobalTable     = CreateTable();
     m_GlobalTable.SetValue(GLOBAL_TABLE, m_GlobalTable);
     m_GlobalTable.SetValue(GLOBAL_VERSION, CreateString(Version));
     m_GlobalTable.SetValue(GLOBAL_SCRIPT, CreateObject(this));
     PushAssembly(ScriptExtensions.GetAssembly(typeof(object)));
     PushAssembly(ScriptExtensions.GetAssembly(GetType()));
 }
Exemple #3
0
 public ScriptObject LoadFile(String fileName, Encoding encoding)
 {
     try {
         byte[] buffer = ScriptExtensions.GetFileBuffer(fileName);
         if (buffer.Length > 0 && buffer[0] == 0)
         {
             return(LoadTokens(fileName, ScorpioMaker.Deserialize(buffer)));
         }
         else
         {
             return(LoadString(fileName, encoding.GetString(buffer, 0, buffer.Length)));
         }
     } catch (System.Exception e) {
         throw new ScriptException("load file [" + fileName + "] is error : " + e.ToString());
     }
 }
Exemple #4
0
 public ScriptObject LoadFile(String fileName, Encoding encoding)
 {
     return(LoadBuffer(fileName, ScriptExtensions.GetFileBuffer(fileName), encoding));
 }
Exemple #5
0
 public static bool IsEnum(Type type)
 {
     return(ScriptExtensions.IsEnum(type));
 }