Esempio n. 1
0
        private static GraceObject mBEndian(EvaluationContext ctx,
                                            MethodRequest req,
                                            UTF32CodepointsView self)
        {
            var enc = new UTF32Encoding(true, false);

            return(new ByteString(enc.GetBytes(self.stringData)));
        }
Esempio n. 2
0
        private static GraceObject mAt(EvaluationContext ctx,
                                       MethodRequest req,
                                       UTF32CodepointsView self)
        {
            MethodHelper.CheckArity(ctx, req, 1);
            var arg   = req[0].Arguments[0];
            var index = arg.FindNativeParent <GraceNumber>();
            var idx   = index.GetInt() - 1;

            if (idx < 0 || idx >= self.utf32.Count)
            {
                ErrorReporting.RaiseError(ctx, "R2013",
                                          new Dictionary <string, string> {
                    { "index", "" + (idx + 1) },
                    { "valid", self.utf32.Count > 0 ?
                      "1 .. " + self.utf32.Count
                                : "none (empty)" }
                }, "IndexError: Index out of range");
            }
            return(GraceNumber.Create(self.utf32[idx]));
        }
Esempio n. 3
0
 private static GraceObject mLEndian(EvaluationContext ctx,
                                     MethodRequest req,
                                     UTF32CodepointsView self)
 {
     return(new ByteString(Encoding.UTF32.GetBytes(self.stringData)));
 }