本文整理汇总了C#中org.mbarbon.p.runtime.Runtime类的典型用法代码示例。如果您正苦于以下问题:C# org.mbarbon.p.runtime.Runtime类的具体用法?C# org.mbarbon.p.runtime.Runtime怎么用?C# org.mbarbon.p.runtime.Runtime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
org.mbarbon.p.runtime.Runtime类属于命名空间,在下文中一共展示了org.mbarbon.p.runtime.Runtime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: P5MainSymbolTable
public P5MainSymbolTable(Runtime runtime, string name)
: base(runtime, name)
{
var stdout = GetStashGlob(runtime, "STDOUT", true);
stdout.Handle = new P5Handle(runtime, null, System.Console.Out);
var stdin = GetStashGlob(runtime, "STDIN", true);
stdin.Handle = new P5Handle(runtime, System.Console.In, null);
var stderr = GetStashGlob(runtime, "STDERR", true);
stderr.Handle = new P5Handle(runtime, null, System.Console.Error);
var dquote = GetStashGlob(runtime, "\"", true);
dquote.Scalar = new P5Scalar(runtime, " ");
var version = GetStashGlob(runtime, "]", true);
version.Scalar = new P5Scalar(runtime, 5.008);
// UNIVERSAL
universal = GetPackage(runtime, "UNIVERSAL", true);
var isa = universal.GetStashGlob(runtime, "isa", true);
isa.Code = new P5NativeCode("UNIVERSAL::isa", new P5Code.Sub(WrapIsa));
// Internals
var internals = GetPackage(runtime, "Internals", true);
var add_overload = internals.GetStashGlob(runtime, "add_overload", true);
add_overload.Code = new P5NativeCode("Internals::add_overload", new P5Code.Sub(WrapAddOverload));
// Internals::Net (TODO move to external assembly)
var internals_net = GetPackage(runtime, "Internals::Net", true);
var get_class = internals_net.GetStashGlob(runtime, "get_class", true);
get_class.Code = new P5NativeCode("Internals::Net::get_class", new P5Code.Sub(WrapGetClass));
var specialize_type = internals_net.GetStashGlob(runtime, "specialize_type", true);
specialize_type.Code = new P5NativeCode("Internals::Net::specialize_type", new P5Code.Sub(WrapSpecializeType));
var create = internals_net.GetStashGlob(runtime, "create", true);
create.Code = new P5NativeCode("Internals::Net::create", new P5Code.Sub(WrapCreate));
var call_method = internals_net.GetStashGlob(runtime, "call_method", true);
call_method.Code = new P5NativeCode("Internals::Net::call_mehtod", new P5Code.Sub(WrapCallMethod));
var call_static = internals_net.GetStashGlob(runtime, "call_static", true);
call_static.Code = new P5NativeCode("Internals::Net::call_static", new P5Code.Sub(WrapCallStatic));
var get_property = internals_net.GetStashGlob(runtime, "get_property", true);
get_property.Code = new P5NativeCode("Internals::Net::get_property", new P5Code.Sub(WrapGetProperty));
var set_property = internals_net.GetStashGlob(runtime, "set_property", true);
set_property.Code = new P5NativeCode("Internals::Net::set_property", new P5Code.Sub(WrapSetProperty));
var extend = internals_net.GetStashGlob(runtime, "extend", true);
extend.Code = new P5NativeCode("Internals::Net::extend", new P5Code.Sub(WrapExtend));
var compile = internals_net.GetStashGlob(runtime, "compile_assembly", true);
compile.Code = new P5NativeCode("Internals::Net::compile_assembly", new P5Code.Sub(WrapCompileAssembly));
}
示例2: Assign
public override P5Scalar Assign(Runtime runtime, IP5Any other)
{
var ob = other.AsScalar(runtime).Body;
var obr = ob as P5Reference;
var obb = ob as P5TypeglobBody;
if (obb != null)
body = globBody = obb;
else if (obr != null)
{
var referred = obr.Referred;
var code = referred as P5Code;
var scalar = referred as P5Scalar;
var array = referred as P5Array;
var hash = referred as P5Hash;
if (code != null)
globBody.Code = code;
else if (scalar != null)
globBody.Scalar = scalar;
else if (array != null)
globBody.Array = array;
else if (hash != null)
globBody.Hash = hash;
}
else
{
throw new System.NotImplementedException("Assign either glob or reference");
}
return this;
}
示例3: AsString
public string AsString(Runtime runtime)
{
if (reference != null)
return reference.AsString(runtime);
return Message;
}
示例4: P5StringNumber
private P5StringNumber(Runtime runtime, int f, int ival, string sval, double fval)
{
flags = f;
integerValue = ival;
stringValue = sval;
floatValue = fval;
}
示例5: AsInteger
public virtual int AsInteger(Runtime runtime)
{
if ((flags & HasString) != 0) return Builtins.ParseInteger(stringValue);
if ((flags & HasInteger) != 0) return integerValue;
if ((flags & HasFloat) != 0) return (int)floatValue;
throw new System.Exception();
}
示例6: Assign
public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
{
var osn = other as P5Reference;
if (osn == null)
return other.CloneBody(runtime);
referred = osn.referred;
return this;
}
示例7: AssignIterator
public override IP5Any AssignIterator(Runtime runtime, IEnumerator<IP5Any> e)
{
for (int i = 0; i < array.Count; ++i)
{
if (e.MoveNext())
array[i] = NetGlue.UnwrapValue<object>(runtime, e.Current);
else
array[i] = null;
}
return this;
}
示例8: AsInteger
public virtual int AsInteger(Runtime runtime)
{
if (referred as P5Scalar != null)
{
var wrapper = (referred as P5Scalar).Body as P5NetWrapper;
if (wrapper != null)
return (int)IdDispenser.GetId(wrapper.Object);
}
// TODO maybe use long everywhere
return (int)IdDispenser.GetId(referred);
}
示例9: AsBoolean
public bool AsBoolean(Runtime runtime)
{
var type = obj.GetType();
if (type == typeof(double))
return (double)obj != 0.0;
if (type == typeof(int))
return (int)obj != 0;
if (type == typeof(string))
return (string)obj != "";
if (type == typeof(bool))
return (bool)obj;
return obj != null;
}
示例10: Assign
public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
{
var osb = other as P5StringNumber;
if (osb == null)
return other.CloneBody(runtime);
flags = osb.flags;
pos = -1;
pos_set = false;
stringValue = osb.stringValue;
integerValue = osb.integerValue;
floatValue = osb.floatValue;
return this;
}
示例11: AsString
public virtual string AsString(Runtime runtime)
{
var rx = referred as IP5Regex;
// TODO use overloading
if (rx != null)
return rx.GetOriginal();
if (referred.IsBlessed(runtime))
return string.Format("{2:s}={0:s}(0x{1:x8})",
referred.ReferenceTypeString(runtime),
AsInteger(runtime),
referred.Blessed(runtime).GetName(runtime));
else
return string.Format("{0:s}(0x{1:x8})",
referred.ReferenceTypeString(runtime),
AsInteger(runtime));
}
示例12: AsInteger
public int AsInteger(Runtime runtime)
{
var type = obj.GetType();
if (type == typeof(int))
return (int)obj;
if (type == typeof(double))
return (int)(double)obj;
if (type == typeof(char))
return (int)(char)obj;
if (type == typeof(bool))
return (bool)obj ? 1 : 0;
if (type == typeof(string))
return Builtins.ParseInteger((string)obj);
if (type.IsEnum)
return System.Convert.ToInt32(obj);
throw new System.NotImplementedException(string.Format("Integer coercion not implemented for {0:S}", type));
}
示例13: AsFloat
public double AsFloat(Runtime runtime)
{
var type = obj.GetType();
if (type == typeof(double))
return (double)obj;
if (type == typeof(int))
return (double)(int)obj;
if (type == typeof(char))
return (double)(char)obj;
if (type == typeof(bool))
return (bool)obj ? 1.0 : 0.0;
if (type.IsEnum)
return System.Convert.ToDouble(obj);
// TODO string
throw new System.NotImplementedException(string.Format("Float coercion not implemented for {0:S}", type));
}
示例14: AssignArray
public override int AssignArray(Runtime runtime, IP5Value other)
{
// FIXME multiple dispatch
P5Scalar s = other as P5Scalar;
P5Array a = other as P5Array;
IEnumerator<IP5Any> e = null;
int c = 0;
if (s != null)
{
e = s.GetEnumerator(runtime);
c = 1;
}
else if (a != null)
{
e = a.GetEnumerator(runtime);
c = a.GetCount(runtime);
}
foreach (var i in array)
i.AssignIterator(runtime, e);
return c;
}
示例15: P5LvalueList
public P5LvalueList(Runtime runtime, params IP5Any[] data)
: base(runtime, data)
{
flattened = false;
}