public override HassiumObject Iter(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     for (int i = 0; i < BitArray.Length; i++)
         result.add(vm, new HassiumBool(BitArray.Get(i)));
     return result;
 }
Beispiel #2
0
 public HassiumList getCommandLineArgs(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     foreach (string arg in Environment.GetCommandLineArgs())
         result.add(vm, new HassiumString(arg));
     return result;
 }
        public HassiumList getProcessList(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumList list = new HassiumList(new HassiumObject[0]);
            foreach (Process process in Process.GetProcesses())
                list.add(vm, createFromProcess(process));

            return list;
        }
 public HassiumList getFiles(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     var files = DirectoryInfo.GetFiles();
     foreach (var file in files)
         result.add(vm, new HassiumString(file.ToString()));
     return result;
 }
 public HassiumList getObjectsByType(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     foreach (HassiumObject obj in HassiumObject.Attributes.Values)
         if (obj.Types.Contains(args[0].Type()))
             result.add(vm, obj);
     return result;
 }
 public HassiumList nextBytes(VirtualMachine vm, params HassiumObject[] args)
 {
     byte[] bytes = new byte[args[0].ToInt(vm).Int];
     Random.NextBytes(bytes);
     HassiumList list = new HassiumList(new HassiumObject[0]);
     foreach (byte b in bytes)
         list.add(vm, new HassiumInt(b));
     return list;
 }
        public HassiumList get_environmentVariables(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumList list = new HassiumList(new HassiumObject[0]);
            var variables = StartInfo.EnvironmentVariables;
            foreach (KeyValuePair<string, string> entry in variables)
                list.add(vm, new HassiumKeyValuePair(new HassiumString(entry.Key), new HassiumString(entry.Value)));

            return list;
        }
        public HassiumList getBytes(VirtualMachine vm, params HassiumObject[] args)
        {
            byte[] bytes = Encoding.GetBytes(args[0].ToString(vm).String);
            HassiumList list = new HassiumList(new HassiumObject[0]);
            foreach (byte b in bytes)
                list.add(vm, new HassiumChar((char)b));

            return list;
        }
 public HassiumList getImports(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     if (HassiumObject is HassiumModule)
     {
         foreach (string import in ((HassiumModule)HassiumObject).Imports)
             result.add(vm, new HassiumString(import));
     }
     return result;
 }
        public void Execute(HassiumModule module, string[] args, StackFrame.Frame frame = null)
        {
            Stack = new Stack<HassiumObject>();
            StackFrame = new StackFrame();
            CallStack = new Stack<string>();
            Handlers = new Stack<HassiumExceptionHandler>();
            ExceptionReturns = new Dictionary<HassiumMethod, int>();
            Globals = new Dictionary<string, HassiumObject>();
            CurrentModule = module;
            importGlobals();
            importInitials();

            HassiumList parameters = new HassiumList(new HassiumObject[0]);
            foreach (string arg in args)
                parameters.add(this, new HassiumString(arg));

            if (frame != null)
                StackFrame.Frames.Push(frame);
            else
                StackFrame.PushFrame();
            module.Attributes["main"].Invoke(this, parameters);
            StackFrame.PopFrame();
        }
Beispiel #11
0
        private HassiumList readTo(VirtualMachine vm, HassiumObject[] args)
        {
            byte[] bytes = new byte[args[0].ToInt(vm).Int];
            Stream.Read(bytes, 0, (int)args[0].ToInt(vm).Int);
            HassiumList list = new HassiumList(new HassiumObject[0]);

            foreach (byte b in bytes)
                list.add(vm, new HassiumChar((char)b));

            return list;
        }
Beispiel #12
0
 public HassiumList split(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     foreach (string s in String.Split(args[0].ToChar(vm).Char))
         result.add(vm, new HassiumString(s));
     return result;
 }
Beispiel #13
0
 public HassiumList readLines(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     StreamReader reader = new StreamReader(args[0].ToString(vm).String);
     while (reader.BaseStream.Position < reader.BaseStream.Length)
         result.add(vm, new HassiumString(reader.ReadLine()));
     reader.Close();
     return result;
 }
Beispiel #14
0
 public HassiumList readBytes(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     BinaryReader reader = new BinaryReader(new StreamReader(args[0].ToString(vm).String).BaseStream);
     while (reader.BaseStream.Position < reader.BaseStream.Length)
         result.add(vm, new HassiumChar((char)reader.ReadBytes(1)[0]));
     reader.Close();
     return result;
 }
Beispiel #15
0
 public HassiumList getFileList(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     foreach (string dir in Directory.GetFiles(args[0].ToString(vm).String))
         result.add(vm, new HassiumString(dir));
     return result;
 }
Beispiel #16
0
 public HassiumList split(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     int start = (int)args[0].ToInt(vm).Int;
     int end = args.Length == 2 ? (int)args[1].ToInt(vm).Int : List.Count;
     while (start < end)
         result.add(vm, List[start++]);
     return result;
 }
Beispiel #17
0
 public HassiumList reverse(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumList result = new HassiumList(new HassiumObject[0]);
     for (int i = List.Count - 1; i >= 0; i--)
         result.add(vm, List[i]);
     return result;
 }
        public static HassiumList map(VirtualMachine vm, params HassiumObject[] args)
        {
            HassiumList list = args[0].ToList(vm) as HassiumList;
            HassiumList result = new HassiumList(new HassiumObject[0]);

            for (int i = 0; i < list.List.Count; i++)
                result.add(vm, args[1].Invoke(vm, list.List[i]));

            return result;
        }
 public static HassiumList range(VirtualMachine vm, params HassiumObject[] args)
 {
     int start, end;
     switch (args.Length)
     {
         case 1:
             start = 0;
             end = (int)args[0].ToInt(vm).Int;
             break;
         default:
             start = (int)args[0].ToInt(vm).Int;
             end = (int)args[1].ToInt(vm).Int;
             break;
     }
     HassiumList result = new HassiumList(new HassiumObject[0]);
     while (start < end)
         result.add(vm, new HassiumInt(start++));
     return result;
 }