• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Runtime.VirtualMachine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Iodine.Runtime.VirtualMachine的典型用法代码示例。如果您正苦于以下问题:C# VirtualMachine类的具体用法?C# VirtualMachine怎么用?C# VirtualMachine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VirtualMachine类属于Iodine.Runtime命名空间,在下文中一共展示了VirtualMachine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: listDirectories

			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;
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:25,代码来源:IOModule.cs


示例2: append

		private IodineObject append (VirtualMachine vm, IodineObject self, IodineObject[] args)
		{
			foreach (IodineObject obj in args) {
				buffer.Append (obj.ToString (vm));
			}
			return null;
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:IodineStringBuilder.cs


示例3: push

			private IodineObject push (VirtualMachine vm, IodineObject self, IodineObject[] args)
			{
				foreach (IodineObject obj in args) {
					Stack.Push (obj);
				}
				return null;
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:CollectionsModule.cs


示例4: write

		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;
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:30,代码来源:IodineStream.cs


示例5: randInt

		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));
			}
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:27,代码来源:RandomModule.cs


示例6: sha1

		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);
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:27,代码来源:HashModule.cs


示例7: Invoke

			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);
				}
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:30,代码来源:IodineInteger.cs


示例8: Invoke

			public override IodineObject Invoke (VirtualMachine vm, IodineObject[] args)
			{
				if (args.Length <= 0) {
					vm.RaiseException (new IodineArgumentException (1));
				}
				return new IodineBytes (args [0].ToString ());
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:IodineBytes.cs


示例9: DebugSession

		public DebugSession (VirtualMachine vm, Socket socket)
		{
			virtualMachine = vm;
			baseStream = new NetworkStream (socket);
			requestStream = new StreamReader (baseStream);
			responseStream = new StreamWriter (baseStream);
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:DebugSession.cs


示例10: Invoke

			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 ()));
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:IodineBool.cs


示例11: Exit

		public override void Exit (VirtualMachine vm)
		{
			if (!Closed) {
				File.Close ();
				File.Dispose ();
			}
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:IodineStream.cs


示例12: unzip

		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;
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:ZipModule.cs


示例13: pow

		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));
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:28,代码来源:MathModule.cs


示例14: getValue

			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;
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:8,代码来源:WinRegModule.cs


示例15: getProcList

 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;
 }
开发者ID:iwatakeshi,项目名称:Iodine,代码行数:8,代码来源:OSModule.cs


示例16: SetAttribute

		public override void SetAttribute (VirtualMachine vm, string name, IodineObject value)
		{
			if (!initializerInvoked) {
				initializerInvoked = true;
				Initializer.Invoke (vm, new IodineObject[] { });
			}
			base.SetAttribute (vm, name, value);
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:8,代码来源:IodineClass.cs


示例17: IterMoveNext

 public override bool IterMoveNext(VirtualMachine vm)
 {
     if (stackFrame.AbortExecution) {
         return false;
     }
     value = vm.InvokeMethod (baseMethod, stackFrame, self, arguments);
     return stackFrame.Yielded;
 }
开发者ID:iwatakeshi,项目名称:Iodine,代码行数:8,代码来源:IodineGenerator.cs


示例18: Invoke

			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;
			}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:8,代码来源:IodineTuple.cs


示例19: GetIndex

		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;
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:8,代码来源:IodineTuple.cs


示例20: IterMoveNext

 public override bool IterMoveNext(VirtualMachine vm)
 {
     if (iterIndex >= this.end) {
         return false;
     }
     iterIndex += this.step;
     return true;
 }
开发者ID:iwatakeshi,项目名称:Iodine,代码行数:8,代码来源:IodineRange.cs



注:本文中的Iodine.Runtime.VirtualMachine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Lang.IokeObject类代码示例发布时间:2022-05-26
下一篇:
C# Runtime.IodineObject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap