Example #1
0
 private KecaknoahFunctionResult InstanceGetInteger(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args)
 {
     switch (args.Length)
     {
         case 0:
             return random.Next().AsKecaknoahInteger().NoResume();
         case 1:
             var a = args.ExpectInt32(1, false);
             return random.Next(a[0]).AsKecaknoahInteger().NoResume();
         default:
             var a2 = args.ExpectInt32(2, false);
             return random.Next(a2[0], a2[1]).AsKecaknoahInteger().NoResume();
     }
 }
Example #2
0
 private static KecaknoahFunctionResult ClassNew(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args)
 {
     switch(args.Length)
     {
         case 0:
             return new KecaknoahXorshift().NoResume();
         case 1:
             return new KecaknoahXorshift(args[0].ToInt32()).NoResume();
         case 4:
             var seeds = args.ExpectInt32(4, false);
             return new KecaknoahXorshift(seeds[0], seeds[1], seeds[2], seeds[3]).NoResume();
         default:
             return new KecaknoahXorshift().NoResume();
     }
 }