public static void Instantiate(Assembly a, Interpreter interp)
{
Hashtable table = interp.VarTable;
try
{
CodeChunk chunk = (CodeChunk)a.CreateInstance("CsiChunk");
chunk.Go(table);
// we display the type and value of expressions. The variable $_ is
// always set, which is useful if you want to save the result of the last
// calculation.
if (interp.returnsValue && DumpingValue)
{
string stype;
object val = table["_"];
if (val == null)
{
stype = null;
}
else
{
Type type = val.GetType();
stype = interp.GetPublicRuntimeTypeName(type, true);
stype = "(" + (stype ?? interp.GetTypeName(type, true)) + ")";
}
if (val == null)
{
Print("null");
}
else
if (val is string)
{
Print(stype, "'" + val + "'");
}
else
if (val is IEnumerable)
{
Print(stype);
Dumpl((IEnumerable)val);
}
else
{
Print(stype, val);
}
}
}
catch (Exception ex)
{
Print(ex.GetType() + " was thrown: " + ex.Message);
}
}