本文整理汇总了C#中ElaValue类的典型用法代码示例。如果您正苦于以下问题:C# ElaValue类的具体用法?C# ElaValue怎么用?C# ElaValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ElaValue类属于命名空间,在下文中一共展示了ElaValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddField
public ElaRecord AddField(string field, ElaValue value, ElaRecord rec)
{
var fieldList = new List<ElaRecordField>();
fieldList.AddRange(rec);
fieldList.Add(new ElaRecordField(field, value));
return new ElaRecord(fieldList.ToArray());
}
示例2: CallPoint
internal CallPoint(int modHandle, EvalStack stack, ElaValue[] locals, FastList<ElaValue[]> captures)
{
ModuleHandle = modHandle;
Locals = locals;
Captures = captures;
Stack = stack;
}
示例3: Divide
internal override ElaValue Divide(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.REA)
{
if (right.TypeId == ElaMachine.DBL)
return new ElaValue(left.DirectGetSingle() / right.Ref.AsDouble());
else if (right.TypeId == ElaMachine.INT)
return new ElaValue(left.DirectGetSingle() / right.I4);
else if (right.TypeId == ElaMachine.LNG)
return new ElaValue(left.DirectGetSingle() / right.Ref.AsLong());
else
{
NoOverloadBinary(TCF.SINGLE, right, "divide", ctx);
return Default();
}
}
if (right.DirectGetSingle() == 0)
{
ctx.DivideByZero(left);
return Default();
}
return new ElaValue(left.DirectGetSingle() / right.DirectGetSingle());
}
示例4: Force
internal ElaValue Force()
{
if (Value.Ref == null)
{
var fun = Function;
while (fun != null)
{
Value = fun.CallWithThrow(
fun.LastParameter.Ref != null ? fun.LastParameter :
new ElaValue(ElaUnit.Instance));
if (Value.Ref is ElaLazy)
{
var la = (ElaLazy)Value.Ref;
if (la.Value.Ref == null && la.Function != null)
fun = la.Function;
else
{
Value = la.Value;
fun = null;
}
}
else
fun = null;
}
}
return Value;
}
示例5: Quot
internal override ElaValue Quot(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.LNG)
{
if (right.TypeId == ElaMachine.INT)
{
if (right.I4 == 0)
{
ctx.DivideByZero(left);
return Default();
}
return new ElaValue(left.Ref.AsLong() / right.I4);
}
else
{
ctx.NoOverload(left.GetTypeName() + "->" + left.GetTypeName() + "->*", left.GetTypeName() + "->" + right.GetTypeName() + "->*", "quot");
return Default();
}
}
var r = right.Ref.AsLong();
if (r == 0)
{
ctx.DivideByZero(left);
return Default();
}
return new ElaValue(left.Ref.AsLong() / right.Ref.AsLong());
}
示例6: AvlTree
internal AvlTree(ElaValue key, ElaValue value, AvlTree left, AvlTree right)
{
Key = key;
Value = value;
Left = left;
Right = right;
TreeHeight = 1 + Math.Max(Height(left), Height(right));
}
示例7: GetValue
public ElaVariant GetValue(ElaValue key, ElaMap map)
{
if (map.Tree.IsEmpty)
return ElaVariant.None();
var res = map.Tree.Search(key);
return res.IsEmpty ? ElaVariant.None() : ElaVariant.Some(res.Value);
}
示例8: Convert
protected override ElaValue Convert(ElaValue @this, ElaTypeInfo type, ExecutionContext ctx)
{
if (type.ReflectedTypeCode == ElaTypeCode.String)
return new ElaValue(Value.ToString());
ctx.ConversionFailed(@this, type.ReflectedTypeName);
return Default();
}
示例9: False
internal override bool False(ElaValue @this, ExecutionContext ctx)
{
var ret = Force(ctx);
if (ctx.Failed)
return false;
return ret.Ref.False(ret, ctx);
}
示例10: Get
public ElaVariant Get(ElaValue key, ElaMutableMap map)
{
var val = default(ElaValue);
if (!map.Map.TryGetValue(key, out val))
return ElaVariant.None();
return ElaVariant.Some(val);
}
示例11: Lesser
internal override bool Lesser(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.STR)
{
NoOverloadBinary(TCF.STRING, right, "lesser", ctx);
return false;
}
return left.DirectGetString().CompareTo(right.DirectGetString()) > 0;
}
示例12: Equal
internal override bool Equal(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.STR)
{
NoOverloadBinary(TCF.STRING, right, "equal", ctx);
return false;
}
return left.DirectGetString() == right.DirectGetString();
}
示例13: Equal
internal override bool Equal(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.UNI)
{
NoOverloadBinary(TCF.UNIT, right, "equal", ctx);
return false;
}
return left.Ref == right.Ref;
}
示例14: LesserEqual
internal override bool LesserEqual(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.CHR)
{
NoOverloadBinary(TCF.CHAR, right, "lesserequal", ctx);
return false;
}
return left.I4 <= right.I4;
}
示例15: Greater
internal override bool Greater(ElaValue left, ElaValue right, ExecutionContext ctx)
{
if (right.TypeId != ElaMachine.CHR)
{
NoOverloadBinary(TCF.CHAR, right, "greater", ctx);
return false;
}
return left.I4 > right.I4;
}