예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <summary>Native method for Grace &lt;=</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));
        }
예제 #3
0
        private static GraceObject mNotEquals(
            GraceString self,
            GraceObject other
            )
        {
            var oth = other.FindNativeParent <GraceString>();

            return((oth == null) ? GraceBoolean.True
                                 : GraceBoolean.Create(self.nfc != oth.nfc));
        }
예제 #4
0
        private static GraceObject mGreaterThanEqual(
            GraceString self,
            GraceObject other
            )
        {
            var oth = other.FindNativeParent <GraceString>();

            return((oth == null) ? GraceBoolean.False
                                 : GraceBoolean.Create(
                       compare(self, oth) >= 0
                       ));
        }
예제 #5
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));
        }
예제 #6
0
        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));
        }
예제 #7
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));
        }
예제 #8
0
        /// <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));
        }
예제 #9
0
 private static GraceObject mMirrored(EvaluationContext ctx,
                                      MethodRequest req,
                                      CodepointObject self)
 {
     return(GraceBoolean.Create(self.parts[8] == "Y"));
 }
예제 #10
0
파일: GraceObject.cs 프로젝트: smarr/kernan
 /// <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)));
 }
예제 #11
0
파일: Matching.cs 프로젝트: mwh/kernan
 private GraceObject mSucceeded()
 {
     return(GraceBoolean.Create(Success));
 }