public DebugSession (VirtualMachine vm, Socket socket) { virtualMachine = vm; baseStream = new NetworkStream (socket); requestStream = new StreamReader (baseStream); responseStream = new StreamWriter (baseStream); }
public override IodineObject Invoke (VirtualMachine vm, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); } if (args [0] is IodineFloat) { IodineFloat fp = args [0] as IodineFloat; return new IodineInteger ((long)fp.Value); } long value; NumberStyles style = NumberStyles.AllowLeadingSign; if (args.Length > 1) { IodineInteger basen = args [1] as IodineInteger; switch (basen.Value) { case 16: style = NumberStyles.HexNumber; break; } } if (!Int64.TryParse (args [0].ToString (), style, null, out value)) { vm.RaiseException (new IodineTypeCastException ("Int")); return null; } else { return new IodineInteger (value); } }
private IodineObject unzip (VirtualMachine vm, IodineObject self, IodineObject[] args) { var archiveName = args [0] as IodineString; var targetDir = args [1] as IodineString; ZipFile.ExtractToDirectory (archiveName.Value, targetDir.Value); return null; }
private IodineObject pow (VirtualMachine vm, IodineObject self, IodineObject[] args) { if (args.Length <= 1) { vm.RaiseException (new IodineArgumentException (2)); return null; } double a1 = 0; double a2 = 0; if (args [0] is IodineInteger) { a1 = (double)((IodineInteger)args [0]).Value; } else if (args [0] is IodineFloat) { a1 = ((IodineFloat)args [0]).Value; } else { vm.RaiseException (new IodineTypeException ("Float")); return null; } if (args [1] is IodineInteger) { a2 = (double)((IodineInteger)args [1]).Value; } else if (args [1] is IodineFloat) { a2 = ((IodineFloat)args [1]).Value; } else { vm.RaiseException (new IodineTypeException ("Float")); return null; } return new IodineFloat (Math.Pow (a1, a2)); }
private IodineObject listDirectories (VirtualMachine vm, IodineObject self, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); return null; } if (!(args [0] is IodineString)) { vm.RaiseException (new IodineTypeException ("Str")); return null; } if (!Directory.Exists (args [0].ToString ())) { vm.RaiseException (new IodineIOException ("Directory '" + args [0].ToString () + "' does not exist!")); return null; } IodineList ret = new IodineList (new IodineObject[]{ }); foreach (string dir in Directory.GetDirectories (args[0].ToString ())) { ret.Add (new IodineString (dir)); } return ret; }
private IodineObject push (VirtualMachine vm, IodineObject self, IodineObject[] args) { foreach (IodineObject obj in args) { Stack.Push (obj); } return null; }
public override IodineObject Invoke (VirtualMachine vm, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); } return IodineBool.Create (Boolean.Parse (args [0].ToString ())); }
public override IodineObject Invoke (VirtualMachine vm, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); } return new IodineBytes (args [0].ToString ()); }
public override void Exit (VirtualMachine vm) { if (!Closed) { File.Close (); File.Dispose (); } }
private IodineObject write (VirtualMachine vm, IodineObject self, IodineObject[] args) { if (Closed) { vm.RaiseException (new IodineIOException ("Stream has been closed!")); return null; } if (!CanWrite) { vm.RaiseException (new IodineIOException ("Can not write to stream!")); return null; } foreach (IodineObject obj in args) { if (obj is IodineString) { write (obj.ToString ()); } else if (obj is IodineBytes) { IodineBytes arr = obj as IodineBytes; File.Write (arr.Value, 0, arr.Value.Length); } else if (obj is IodineInteger) { IodineInteger intVal = obj as IodineInteger; write ((byte)intVal.Value); } else if (obj is IodineByteArray) { IodineByteArray arr = obj as IodineByteArray; File.Write (arr.Array, 0, arr.Array.Length); } else { vm.RaiseException (new IodineTypeException ("")); } } return null; }
private IodineObject randInt (VirtualMachine vm, IodineObject self, IodineObject[] args) { if (args.Length <= 0) { return new IodineInteger (rgn.Next (Int32.MinValue, Int32.MaxValue)); } else { int start = 0; int end = 0; if (args.Length <= 1) { IodineInteger integer = args [0] as IodineInteger; if (integer == null) { vm.RaiseException (new IodineTypeException ("Int")); return null; } end = (int)integer.Value; } else { IodineInteger startInteger = args [0] as IodineInteger; IodineInteger endInteger = args [1] as IodineInteger; if (startInteger == null || endInteger == null) { vm.RaiseException (new IodineTypeException ("Int")); return null; } start = (int)startInteger.Value; end = (int)endInteger.Value; } return new IodineInteger (rgn.Next (start, end)); } }
private IodineObject sha1 (VirtualMachine vm, IodineObject self, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); return null; } byte[] bytes = new byte[]{}; byte[] hash = null; SHA1Managed hashstring = new SHA1Managed(); if (args[0] is IodineString) { bytes = System.Text.Encoding.UTF8.GetBytes (args[0].ToString ()); hash = hashstring.ComputeHash(bytes); } else if (args[0] is IodineByteArray) { bytes = ((IodineByteArray)args[0]).Array; hash = hashstring.ComputeHash(bytes); } else if (args[0] is IodineStream) { hash = hashstring.ComputeHash(((IodineStream)args[0]).File); } else { vm.RaiseException (new IodineTypeException ("Str")); return null; } return new IodineByteArray (hash); }
private IodineObject append (VirtualMachine vm, IodineObject self, IodineObject[] args) { foreach (IodineObject obj in args) { buffer.Append (obj.ToString (vm)); } return null; }
public override bool IterMoveNext(VirtualMachine vm) { if (stackFrame.AbortExecution) { return false; } value = vm.InvokeMethod (baseMethod, stackFrame, self, arguments); return stackFrame.Yielded; }
private IodineObject getProcList(VirtualMachine vm, IodineObject self, IodineObject[] args) { IodineList list = new IodineList (new IodineObject[] { }); foreach (Process proc in Process.GetProcesses ()) { list.Add (new IodineProc (proc)); } return list; }
public override void SetAttribute (VirtualMachine vm, string name, IodineObject value) { if (!initializerInvoked) { initializerInvoked = true; Initializer.Invoke (vm, new IodineObject[] { }); } base.SetAttribute (vm, name, value); }
public override IodineObject Invoke (VirtualMachine vm, IodineObject[] args) { if (args.Length >= 1) { IodineList inputList = args [0] as IodineList; return new IodineTuple (inputList.Objects.ToArray ()); } return null; }
public override IodineObject GetAttribute(VirtualMachine vm, string name) { if (!initializerInvoked) { initializerInvoked = true; Initializer.Invoke (vm, new IodineObject[] { }); } return base.GetAttribute (vm, name); }
private IodineObject getValue (VirtualMachine vm, IodineObject self, IodineObject[] args) { string name = args [0].ToString (); IodineObject ioval = null; object val = Key.GetValue (name); //IodineTypeConverter.Instance.ConvertFromPrimative (val, out ioval); return ioval; }
public override IodineObject GetIndex (VirtualMachine vm, IodineObject key) { IodineInteger index = key as IodineInteger; if (index.Value < Objects.Length) return Objects [(int)index.Value]; vm.RaiseException (new IodineIndexException ()); return null; }
public override bool IterMoveNext(VirtualMachine vm) { if (iterIndex >= this.end) { return false; } iterIndex += this.step; return true; }
public IodineObject executeSql(VirtualMachine vm, IodineObject self, IodineObject[] args) { var db = (IodineMySQLConnection)self; var statement = (IodineString)args [0]; MySqlCommand cmd = new MySqlCommand (statement.Value, db.Connection); cmd.ExecuteNonQuery (); cmd.Dispose (); return null; }
public virtual IodineObject Add(VirtualMachine vm, IodineObject left) { if (Attributes.ContainsKey ("__add__")) { return GetAttribute (vm, "__add__").Invoke (vm, new IodineObject[] {left}); } vm.RaiseException (new IodineNotSupportedException ( "The requested binary operator has not been implemented")); return null; }
private IodineObject getValue(VirtualMachine vm, IodineObject self, IodineObject[] args) { string keyName = args [0].ToString (); string name = args [1].ToString (); object val = Registry.GetValue (keyName, name, null); IodineObject ioval = null; IodineTypeConverter.Instance.ConvertFromPrimative (val, out ioval); return ioval; }
private IodineObject setValue (VirtualMachine vm, IodineObject self, IodineObject[] args) { string name = args [0].ToString (); IodineObject ioval = args [1]; object val = null; //IodineTypeConverter.Instance.ConvertToPrimative (ioval, out val); Key.SetValue (name, val); return null; }
public override IodineObject Invoke (VirtualMachine vm, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); return null; } IodineInteger size = args [0] as IodineInteger; return new IodineByteArray (new byte [size.Value]); }
private IodineObject sleep(VirtualMachine vm, IodineObject self, IodineObject[] args) { if (args.Length <= 0) { vm.RaiseException (new IodineArgumentException (1)); } IodineInteger time = args [0] as IodineInteger; System.Threading.Thread.Sleep ((int)time.Value); return null; }
public override void SetIndex (VirtualMachine vm, IodineObject key, IodineObject value) { IodineInteger index = key as IodineInteger; IodineInteger val = value as IodineInteger; if (index.Value < Array.Length) Array [(int)index.Value] = (byte)(val.Value & 0xFF); else vm.RaiseException (new IodineIndexException ()); }
private static IEnumerator internalChain(VirtualMachine vm, IodineObject[] args) { foreach (IodineObject obj in args) { obj.IterReset (vm); while (obj.IterMoveNext (vm)) { yield return obj.IterGetCurrent (vm); } } }
public override IodineObject Equals(VirtualMachine vm, IodineObject right) { IodineBool boolVal = right as IodineBool; if (boolVal == null) { vm.RaiseException ("Right hand side expected to be Bool!"); return null; } return IodineBool.Create (boolVal.Value == Value); }
public override IodineObject Represent(VirtualMachine vm) { return(new IodineString(String.Format("b'{0}'", Encoding.ASCII.GetString(Value)))); }
public override IodineObject GetIterator(VirtualMachine vm) { return(new BytesIterator(Value)); }
public override IodineObject IterGetCurrent(VirtualMachine vm) { return(new IodineInteger((long)Value [iterIndex - 1])); }
public override void IterReset(VirtualMachine vm) { iterIndex = 0; }
public override IodineObject Len(VirtualMachine vm) { return(new IodineInteger(Value.Length)); }
public IodineObject Get(VirtualMachine vm) { return(getter(vm)); }
public IodineObject Set(VirtualMachine vm, IodineObject value) { setter(vm, value); return(null); }