|
/// Public domain code by Christopher Diggins
/// http://www.cat-language.com
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Reflection;
namespace Cat
{
/// <summary>
/// By inheriting from this class, there are some utility functions
/// which are provided and can be called using an unqualified name.
/// </summary>
public class CatBase
{
public static void WriteLine(string s)
{
Console.WriteLine(s);
}
/// <summary>
/// If the condition is false, an exception is thrown. This represents
/// an internal error, such as a violated assumption.
/// </summary>
public static void Assert(bool b, string s)
{
if (!b)
{
throw new Exception("internal error " + s);
}
}
public static void Assert(bool b)
{
if (!b)
{
throw new Exception("internal error");
}
}
public static void Log(string s)
{
WriteLine(s);
}
public static void Throw(string s)
{
throw new Exception(s);
}
public static bool AreObjectsEqual(Object x, Object y)
{
if (x == y)
return true;
if (x is ArrayList)
{
if (!(y is ArrayList))
return false;
ArrayList a = x as ArrayList;
ArrayList b = y as ArrayList;
if (a.Count != b.Count)
{
return false;
}
else
{
for (int i=0; i < a.Count; ++i)
{
if (!AreObjectsEqual(a[i], b[i]))
return false;
}
return true;
}
}
else
{
return x.Equals(y);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.