Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2002-09-17 05:18:57 +0400
committerMiguel de Icaza <miguel@gnome.org>2002-09-17 05:18:57 +0400
commit9b1aad2b6fcc31dbec9c65a2424eceedb7e5364c (patch)
tree7aaec6525e9cd7d1c28ae81b84534cd199f864fa /mcs/class/Mono.PEToolkit/RVA.cs
parent501655c80dcc5c0593f07fe2657c778dc336018d (diff)
Add Sergey Chaban's Mono.PEToolkit
svn path=/trunk/mcs/; revision=7542
Diffstat (limited to 'mcs/class/Mono.PEToolkit/RVA.cs')
-rw-r--r--mcs/class/Mono.PEToolkit/RVA.cs117
1 files changed, 117 insertions, 0 deletions
diff --git a/mcs/class/Mono.PEToolkit/RVA.cs b/mcs/class/Mono.PEToolkit/RVA.cs
new file mode 100644
index 00000000000..14aee790781
--- /dev/null
+++ b/mcs/class/Mono.PEToolkit/RVA.cs
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>
+ */
+
+using System;
+
+namespace Mono.PEToolkit {
+
+ /// <summary>
+ /// Relative Virtual Address.
+ /// </summary>
+ public struct RVA {
+
+ public static readonly RVA Null;
+
+ public uint value;
+
+ static RVA()
+ {
+ Null = new RVA(0);
+ }
+
+
+ public RVA(uint val)
+ {
+ value = val;
+ }
+
+
+ public uint Value {
+ get {
+ return value;
+ }
+ set {
+ this.value = value;
+ }
+ }
+
+
+ public static implicit operator RVA (uint val)
+ {
+ return new RVA(val);
+ }
+
+ public static implicit operator uint (RVA rva)
+ {
+ return rva.value;
+ }
+
+ public override int GetHashCode()
+ {
+ return (int) value;
+ }
+
+ public override bool Equals(object o)
+ {
+ bool res = o is RVA;
+ if (res) res = (this.value == ((RVA)o).value);
+ return res;
+ }
+
+ public static bool operator == (RVA rva1, RVA rva2)
+ {
+ return rva1.Equals(rva2);
+ }
+
+ public static bool operator != (RVA rva1, RVA rva2)
+ {
+ return !rva1.Equals(rva2);
+ }
+
+ public static bool operator < (RVA rva1, RVA rva2)
+ {
+ return (rva1.value < rva2.value);
+ }
+
+ public static bool operator > (RVA rva1, RVA rva2) {
+ return (rva1.value > rva2.value);
+ }
+
+ public static bool operator <= (RVA rva1, RVA rva2)
+ {
+ return (rva1.value <= rva2.value);
+ }
+
+ public static bool operator >= (RVA rva1, RVA rva2)
+ {
+ return (rva1.value >= rva2.value);
+ }
+
+ public static RVA operator + (RVA rva, uint x)
+ {
+ return new RVA (rva.value + x);
+ }
+
+ public static RVA operator - (RVA rva, uint x)
+ {
+ return new RVA (rva.value - x);
+ }
+
+
+ public override string ToString()
+ {
+ if (this == Null) return "NULL";
+ return ("0x" + value.ToString("X"));
+ }
+
+ unsafe public static int Size {
+ get {
+ return sizeof (uint);
+ }
+ }
+
+ }
+
+}
+