/// <summary>Native method for Grace ||</summary> /// <param name="ctx">Current interpreter</param> /// <param name="other">Argument to the method</param> public GraceObject OrOr(EvaluationContext ctx, GraceObject other) { GraceBoolean oth = other as GraceBoolean; if (oth != null) { return(GraceBoolean.Create(this.Boolean || oth.Boolean)); } GraceObjectProxy op = other as GraceObjectProxy; if (op != null) { return(GraceBoolean.Create(this.Boolean || (dynamic)op.Object)); } ErrorReporting.RaiseError(ctx, "R2001", new Dictionary <string, string>() { { "method", "||" }, { "index", "1" }, { "part", "||" }, { "required", "Boolean" } }, "ArgumentTypeError: || requires a Boolean argument" ); return(GraceBoolean.False); }
/// <summary>Native method for Grace <=</summary> /// <param name="self">Receiver of the method</param> /// <param name="other">Argument to the method</param> private static GraceObject mLessEqual( GraceNumber self, GraceObject other ) { var oth = other.FindNativeParent <GraceNumber>(); return(GraceBoolean.Create(self.Value <= oth.Value)); }
private static GraceObject mNotEquals( GraceString self, GraceObject other ) { var oth = other.FindNativeParent <GraceString>(); return((oth == null) ? GraceBoolean.True : GraceBoolean.Create(self.nfc != oth.nfc)); }
private static GraceObject mGreaterThanEqual( GraceString self, GraceObject other ) { var oth = other.FindNativeParent <GraceString>(); return((oth == null) ? GraceBoolean.False : GraceBoolean.Create( compare(self, oth) >= 0 )); }
private static GraceObject mGTE(EvaluationContext ctx, MethodRequest req, CodepointObject self) { MethodHelper.CheckArity(ctx, req, 1); var other = req[0].Arguments[0] as CodepointObject; if (other == null) { return(GraceBoolean.False); } return(GraceBoolean.Create(self.codepoint >= other.codepoint)); }
private static GraceObject mNE(EvaluationContext ctx, MethodRequest req, StringCodepoints self) { MethodHelper.CheckArity(ctx, req, 1); var other = req[0].Arguments[0] as StringCodepoints; if (other == null) { return(GraceBoolean.True); } return(GraceBoolean.Create(cmp(self, other) != 0)); }
/// <summary>Native method for Grace !=</summary> /// <param name="self">Receiver of the method</param> /// <param name="other">Argument to the method</param> private static GraceObject mNotEquals( GraceNumber self, GraceObject other ) { var oth = other.FindNativeParent <GraceNumber>(); if (oth == null) { return(GraceBoolean.True); } return(GraceBoolean.Create(self.Value != oth.Value)); }
/// <summary>Make a proxy for an object</summary> /// <param name="o">Object to proxy</param> public static GraceObject Create(Object o) { if (o is bool) { return(GraceBoolean.Create((dynamic)o)); } if (o is int) { return(GraceNumber.Create((dynamic)o)); } var s = o as string; if (s != null) { return(GraceString.Create(s)); } return(new GraceObjectProxy(o)); }
private static GraceObject mMirrored(EvaluationContext ctx, MethodRequest req, CodepointObject self) { return(GraceBoolean.Create(self.parts[8] == "Y")); }
/// <summary>Native method supporting Grace !=</summary> /// <param name="ctx">Current interpreter</param> /// <param name="self">Receiver</param> /// <param name="other">Object to compare</param> private static GraceObject mNotEquals(EvaluationContext ctx, GraceObject self, GraceObject other) { return(GraceBoolean.Create(!object.ReferenceEquals(self, other))); }
private GraceObject mSucceeded() { return(GraceBoolean.Create(Success)); }