File: item_ext.cpp

package info (click to toggle)
falconpl 0.9.6.9-git20120606-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 46,176 kB
  • sloc: cpp: 181,389; ansic: 109,025; yacc: 2,310; xml: 1,218; sh: 403; objc: 245; makefile: 82; sql: 20
file content (1569 lines) | stat: -rw-r--r-- 46,985 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
/*
   FALCON - The Falcon Programming Language.
   FILE: item_ext.cpp

   Generic item handling
   -------------------------------------------------------------------
   Author: Giancarlo Niccolai
   Begin: Thu, 14 Aug 2008 00:17:31 +0200

   -------------------------------------------------------------------
   (C) Copyright 2008: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/

/*#
   @beginmodule core
*/

#include "core_module.h"
#include <falcon/format.h>
#include <falcon/corefunc.h>

namespace Falcon {
namespace core {

/*#
   @funset generic_item_api Type mangling
   @brief Functions managing item conversions, type detection, item structure
      management and generically manipulating Falcon items.

   @beginset generic_item_api
*/

/*#
   @function len
   @brief Retrieves the length of a collection
   @param item an item of any kind
   @return the count of items in the sequence, or 0.

   The returned value represent the "size" of the item passed as a parameter.
   The number is consistent with the object type: in case of a string, it
   represents the count of characters, in case of arrays or dictionaries it
   represents the number of elements, in all the other cases the returned
   value is 0.
*/

/*#
   @method len BOM

   @brief Retrieves the length of a collection
   @return the count of items in the sequence, or 0.

   The returned value represent the "size" of this item.
   @see len
*/
FALCON_FUNC  mth_len ( ::Falcon::VMachine *vm )
{
   Item *elem;
   if ( ! vm->self().isMethodic() )
      elem = vm->param( 0 );
   else
      elem = &vm->self();

  if ( elem == 0 ) {
      vm->retval( 0 );
      return;
   }

   switch( elem->type() ) {
      case FLC_ITEM_STRING:
         vm->retval( (int64) elem->asString()->length() );
      break;

      case FLC_ITEM_ARRAY:
         vm->retval( (int64) elem->asArray()->length() );
      break;

      case FLC_ITEM_MEMBUF:
         vm->retval( (int64) elem->asMemBuf()->length() );
      break;

      case FLC_ITEM_DICT:
         vm->retval( (int64) elem->asDict()->length() );
      break;

      case FLC_ITEM_RANGE:
         vm->retval( 3 );
      break;

      default:
         vm->retval( 0 );
   }
}

/*#
   @function isBound
   @param item

   @brief Determines if an item is bound or not.
   @return True if the item is bound.

   @see BOM.bound
*/
/*#
   @method bound BOM

   @brief Determines if an item is bound or not.
   @return True if the item is bound.

   @see isBound
*/
FALCON_FUNC  mth_bound( ::Falcon::VMachine *vm )
{
   Item *elem;
   if ( ! vm->self().isMethodic() )
   {
      elem = vm->param( 0 );
      if ( elem == 0 ) {
         vm->regA().setBoolean( false );
         return;
      }
   }
   else
      elem = &vm->self();

   vm->regA().setBoolean( ! elem->isUnbound() );
}


/*#
   @function int
   @brief Converts the given parameter to integer.
   @param item The item to be converted
   @return An integer value.
   @raise ParseError in case the given string cannot be converted to an integer.
   @raise MathError if a given floating point value is too large to be converted to an integer.

   Integer values are just copied. Floating point values are converted to long integer;
   in case they are too big to be represented a RangeError is raised.
   Strings are converted from base 10. If the string cannot be converted,
   or if the value is anything else, a MathError instance is raised.
*/
FALCON_FUNC  val_int ( ::Falcon::VMachine *vm )
{
   if ( vm->paramCount() == 0 ) {
      vm->retnil();
      return;
   }

   Item *to_int = vm->param(0);

   switch( to_int->type() ) {
      case FLC_ITEM_INT:
          vm->retval( to_int->asInteger() );
      break;

      case FLC_ITEM_NUM:
      {
         numeric num = to_int->asNumeric();
         if ( num > 9.223372036854775808e18 || num < -9.223372036854775808e18 )
         {
            throw new MathError( ErrorParam( e_domain, __LINE__ ).origin( e_orig_runtime ) );
         }

         vm->retval( (int64)num );
      }
      break;

      case FLC_ITEM_STRING:
      {
         String *cs = to_int->asString();
         int64 val;
         if ( ! cs->parseInt( val ) )
         {
            numeric nval;
            if ( cs->parseDouble( nval ) )
            {
               if ( nval > 9.223372036854775808e18 || nval < -9.223372036854775808e18 )
               {
                  throw new MathError( ErrorParam( e_domain, __LINE__ ).origin( e_orig_runtime ) );
               }
               vm->retval( (int64) nval );
               return;
            }

            throw new ParseError( ErrorParam( e_numparse, __LINE__ ).origin( e_orig_runtime ) );
         }
         vm->retval( val );
      }
      break;

      default:
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
            .origin( e_orig_runtime ).extra( "N|S" ) );
   }
}

/*#
   @function numeric
   @brief Converts the given parameter to numeric.
   @param item The item to be converted
   @return A numeric value.
   @raise ParseError in case the given string cannot be converted to an integer.
   @raise MathError if a given floating point value is too large to be converted to an integer.

   Floating point values are just copied. Integer values are converted to floating point;
   in case of very large integers, precision may be lost.
   Strings are converted from base 10. If the string cannot be converted,
   or if the value is anything else, a MathError instance is raised.
*/
FALCON_FUNC  val_numeric ( ::Falcon::VMachine *vm )
{
   if ( vm->paramCount() == 0 ) {
      vm->retnil();
      return;
   }

   Item *to_numeric = vm->param(0);

   switch( to_numeric->type() ) {
      case FLC_ITEM_NUM:
          vm->retval( to_numeric->asNumeric() );
      break;

      case FLC_ITEM_INT:
      {
         int64 num = to_numeric->asInteger();
         vm->retval( (numeric)num );
      }
      break;

      case FLC_ITEM_STRING:
      {
         String *cs = to_numeric->asString();
         numeric value;
         if ( ! cs->parseDouble( value ) )
         {
            throw new ParseError( ErrorParam( e_numparse, __LINE__ ).origin( e_orig_runtime ) );
         }
         vm->retval( value );
      }
      break;

      default:
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).origin( e_orig_runtime ).extra( "(N|S)" ) );
   }
}

/*#
   @function typeOf
   @param item An item of any kind.
   @brief Returns an integer indicating the type of an item.
   @return A constant indicating the type of the item.

   The typeId returned is an integer; the Falcon compiler is fed with a set of
   compile time constants that can be used to determine the type of an item.
   Those constants are always available at Falcon sources.

   The value returned may be one of the following:
   - @b NilType - the item is NIL
   - @b BooleanType - the item is true or false
   - @b NumericType - the item is a number
   - @b RangeType - the item is a range (a pair of two integers)
   - @b FunctionType - the item is a function
   - @b StringType - the item is a string
   - @b LBindType - the item is a late binding symbol
   - @b MemBufType - the item is a Memory Buffer Table
   - @b ArrayType - the item is an array
   - @b DictionaryType - the item is a dictionary
   - @b ObjectType - the item is an object
   - @b ClassType - the item is a class
   - @b MethodType - the item is a method
   - @b ClassMethodType - the item is a method inside a class
*/

/*#
   @method typeId BOM
   @brief Returns an integer indicating the type of this item.
   @return A constant indicating the type of the item.

   See @a typeOf() function for details.
*/
FALCON_FUNC  mth_typeId ( ::Falcon::VMachine *vm )
{
   byte type;
   if ( vm->self().isMethodic() )
      type = vm->self().dereference()->type();
   else {
      if ( vm->paramCount() > 0 )
         type = vm->param(0)->type();
      else
         throw new ParamError( ErrorParam( e_inv_params ).origin( e_orig_runtime ).extra( "X" ) );
   }

   vm->regA() = (int64) ( type == FLC_ITEM_INT ? FLC_ITEM_NUM : type );
}

/*#
   @function isCallable
   @brief Determines if an item is callable.
   @inset generic_item_api
   @param item The item to be converted
   @return true if the item is callable, false otheriwse.

   If the function returns true, then the call operator can be applied.
   If it returns false, the item is not a callable one, and trying to call
   it would cause an error.
*/
/*#
   @method isCallable BOM
   @brief Determines if an item is callable.
   @return true if the item is callable, false otheriwse.

   If the function returns true, then the call operator can be applied.
   If it returns false, the item is not a callable one, and trying to call
   it would cause an error.
*/

FALCON_FUNC  mth_isCallable ( ::Falcon::VMachine *vm )
{
   if ( vm->self().isMethodic() )
      vm->regA().setBoolean( vm->self().isCallable() );
   else {
      if ( vm->paramCount() > 0 )
         vm->regA().setBoolean( vm->param( 0 )->isCallable() ? 1 : 0 );
      else
         throw new ParamError( ErrorParam( e_inv_params ).origin( e_orig_runtime ).extra( "X" ) );
   }
}

/*#
   @function getProperty
   @brief Returns the value of a property in an object.
   @param obj the source object, array or (blessed) dictionary.
   @param propName A string representing the name of a property or a method inside the object.
   @return the property
   @raise AccessError if the property can't be found.

   An item representing the property is returned. The returned value is
   actually a copy of the property; assigning a new value to it won't have any
   effect on the original object.

   If the property is a method, a callable method item is returned.
   If the property is not found, an error of class RangeError is raised.
*/

/*#
   @method getProperty Object
   @brief Returns the value of a property in an object.
   @param propName A string representing the name of a property or a method inside the object.
   @return the property
   @raise AccessError if the property can't be found.

   An item representing the property is returned. The returned value is
   actually a copy of the property; assigning a new value to it won't have any
   effect on the original object.

   If the property is a method, a callable method item is returned.
   If the property is not found, an error of class RangeError is raised.
*/
FALCON_FUNC  mth_getProperty( ::Falcon::VMachine *vm )
{
   Item *obj_x, *prop_x;
   if( vm->self().isMethodic() ) {
      obj_x = &vm->self();
      prop_x = vm->param(0);
   }
   else {
      obj_x= vm->param(0);
      prop_x = vm->param(1);
   }

   if ( obj_x == 0 || ! obj_x->isDeep() || prop_x == 0 || ! prop_x->isString() ) {
      throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra( "O,S" ) );
   }

   obj_x->asDeepItem()->readProperty( *prop_x->asString(), vm->regA() );

   if ( vm->regA().isCallable() )
   {
      vm->regA().methodize( obj_x->asObjectSafe() );
   }
}

/*#
   @function setProperty
   @brief Sets the value of a proprety in a given object
   @param obj The source object.
   @param propName A string representing the name of a property or a method inside the object.
   @param value The property new value.
   @raise AccessError If the property can't be found.

   Alters the value of the property in the given object. If the required property is not present,
   an AccessError is raised.

*/
/*#
   @method setProperty Object
   @brief Sets the value of a proprety in this object
   @param propName A string representing the name of a property or a method inside the object.
   @param value The property new value.
   @raise AccessError If the property can't be found.

   Alters the value of the property in the given object. If the required property is not present,
   an AccessError is raised.

*/

/*#
   @method setProperty Array
   @brief Sets a binding (as a property) in the array.
   @param propName A string representing the name of a property or a method inside the array.
   @param value The property new value.
   @raise AccessError If the property can't be found.

   Alters the value of the property in the given array. If the required property is not present,
   an AccessError is raised.

*/
/*#
   @method setProperty Dictionary
   @brief Sets a property in dictionary based instances.
   @param propName A string representing the name of a property or a method inside the dictionary.
   @param value The property new value.
   @raise AccessError If the property can't be found.

   Alters the value of the property in the given dictionary. If the required property is not present,
   an AccessError is raised.

*/
FALCON_FUNC  mth_setProperty( ::Falcon::VMachine *vm )
{
   Item *obj_x, *prop_x, *new_item;
   if( vm->self().isMethodic() ) {
      obj_x = &vm->self();
      prop_x = vm->param(0);
      new_item = vm->param(1);
   }
   else {
      obj_x= vm->param(0);
      prop_x = vm->param(1);
      new_item = vm->param(2);
   }

   if ( obj_x == 0 || ! obj_x->isDeep() || prop_x == 0 || ! prop_x->isString() || new_item == 0) {
      throw new ParamError( ErrorParam( e_inv_params )
         .origin( e_orig_runtime ).extra( "O,S" ) );
   }

   obj_x->asDeepItem()->writeProperty( *prop_x->asString(), *new_item );
}


/*#
   @method properties Array
   @brief Returns an array of properties (bindings) in the array.
   @return An array with 0 or more strings.

   This methods returns all the properties in the given array,
   which represents the list of array bindings. If the array
   has no bindings, this method returns an empty array.

   The property list includes properties that refer to any kind
   of data, including functions (that is, methods), but it
   doesn't include properties in the metaclass of this item
   (FBOM properties).

   The returned list is ordered by UNICODE value of the property
   names.
*/

/*#
   @method properties Dictionary
   @brief Returns all the properties in the dictionary.
   @return An array of strings representing property names.

   This method returns all the property name in this dictionary.
   If the dictionary is not blessed, returns an empty array.

   The returned list contains all those keys that are suitable
   to be directly accessed as properties (that is, strings without
   spaces, puntaction and so on). You may use @a Dictionary.keys
   instead if you know that all the keys can be used as
   properties.

   The property list includes properties that refer to any kind
   of data, including functions (that is, methods), but it
   doesn't include properties in the metaclass of this item
   (FBOM properties).

   The returned list is ordered by UNICODE value of the property
   names.
*/

/*#
   @method properties Object
   @brief Returns all the properties in the object.
   @return An array of strings representing property names.

   This method returns all the properties in this object.

   The property list includes properties that refer to any kind
   of data, including functions (that is, methods), but it
   doesn't include properties in the metaclass of this item
   (FBOM properties).

   The returned list is ordered by UNICODE value of the property
   names.

   @note Subclasses are seen as properties, so they will returned
         in the list too.
*/

/*#
   @method properties Class
   @brief Returns all the properties in the class.
   @return An array of strings representing property names.

   This method returns all the properties in this class.

   The property list includes properties that refer to any kind
   of data, including functions (that is, methods), but it
   doesn't include properties in the metaclass of this item
   (FBOM properties).

   The returned list is ordered by UNICODE value of the property
   names.

   @note Subclasses are seen as properties, so they will returned
         in the list too.
*/

/*#
   @function properties
   @brief Returns all the properties in the given item.
   @param item An item that can be accessed via dot accessor.
   @return An array of strings representing property names.

   This function returns the properties offered by an item
   as a list of strings in an array. FBOM methods (item metaclass
   methods) are not returned; only explicitly declared properties
   are taken into account.

   The item susceptible of returning an array of properties
   are:
   - Objects (see @a Object.properties)
   - Dictionaries (if blessed, see @a Dictionary.properties)
   - Arrays (see @a Array.properties)
   - Classes (see @a Class.properties)

   This function, applied to any other item type, returns @b nil.
*/

FALCON_FUNC  mth_properties( ::Falcon::VMachine *vm )
{
   Item *obj_x;
   if( vm->self().isMethodic() ) {
      obj_x = &vm->self();
   }
   else {
      obj_x= vm->param(0);
      if ( obj_x == 0 ) {
         throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra( "X" ) );
      }
   }

   switch( obj_x->type() )
   {
      case FLC_ITEM_OBJECT:
      {
         CoreObject *obj = obj_x->asObjectSafe();
         const PropertyTable &pt = obj->generator()->properties();
         CoreArray *ret = new CoreArray(pt.added());

         for( uint32 count = 0; count < pt.added() ; count++ )
         {
            const String &propName = *pt.getKey( count );
            ret->append( new CoreString( propName ) );
         }
         vm->retval( ret );
      }
      break;

      case FLC_ITEM_CLASS:
      {
         CoreClass *cls= obj_x->asClass();
         const PropertyTable &pt = cls->properties();
         CoreArray *ret = new CoreArray(pt.added());

         for( uint32 count = 0; count < pt.added() ; count++ )
         {
            const String &propName = *pt.getKey( count );
            ret->append( new CoreString( propName ) );
         }
         vm->retval( ret );
      }
      break;

      case FLC_ITEM_DICT:
      {
         CoreDict *dict = obj_x->asDict();
         if ( dict->isBlessed() )
         {
            Iterator iter( &dict->items() );
            CoreArray *ret = new CoreArray( dict->length() );
            while( iter.hasCurrent() )
            {
               const Item& itm = iter.getCurrentKey();
               if ( itm.isString() )
               {
                  String* str = itm.asString();
                  //TODO Skip impossible strings.
                  ret->append( *str );
               }
               iter.next();
            }
            vm->retval( ret );
         }
      }
      break;

      case FLC_ITEM_ARRAY:
      {
         CoreArray *arr = obj_x->asArray();
         if ( arr->bindings() != 0 )
         {
            CoreDict* dict = arr->bindings();
            Iterator iter( &dict->items() );
            CoreArray *ret = new CoreArray( dict->length() );
            while( iter.hasCurrent() )
            {
               const Item& itm = iter.getCurrentKey();
               if ( itm.isString() )
               {
                  String* str = itm.asString();
                  //TODO Skip impossible strings.
                  ret->append( *str );
               }

               iter.next();
            }
            vm->retval( ret );
         }
      }
      break;
   }
}


static bool dop_internal( VMachine* vm )
{
   vm->self().asDict()->put( *vm->param(0), vm->regA() );
   // in A we already have the value
   return false;
}

/*#
   @method dop Dictionary
   @brief Dictionary default operation.
   @param key The key to be defaulted.
   @param dflt The default value to be applied.
   @optparam oper The operation to be applied.
   @return The value associated with @b key after the application of the
      operation.
   
   Given the @b key, @b dflt and @b oper parameters, this method 
   inserts a default value on a dictionary, eventually performing 
   a default operation. In short, if the @b key is not present in the
   dictionary, a new key is created and the @b dflt value is assigned to
   it. If a @b oper callable item (function) is given, then the current
   value associated with the key is passed to it as a parameter; in case
   that the key still doesn't exist, the @b dflt value is passed instead.
   In both case, the key is then associated with the return value of the
   @b oper function.
   
   Finally, this method return the value that has just been associated with
   the dictionary.
   
   More coinciserly the method works along the following pseudocode rules:
   
   @code
      function dop of dict, key, dflt and oper
         if key exists in dict
            if oper is a callable entity
               value = oper( dict[key] )
               dict[key] = value
            else
               value = dict[key]
            end
         else
            if oper is a callable entity
               value = oper( dflt )
               dict[key] = value
            else
               value = oper( dflt )
            end
         end
         
         return value
      end
   @endcode

   This function comes extremely convenient when in need to do some complex
   operations on a possibly uninitialized dictionary value. Suppose
   that an application stores the list of currently logged in-users in an
   array under the "users" key of a given prog_data dictionary. Then,
   
   @code
   // a new user comes in...
   newcomer = ...
   users = prog_data.dop( "users", [], { v => v += newcomer } )
   @endcode
   
   In one line, this code creates a "users" entry in prog_data, if it doesn't exists,
   which is initialized to an empty array. The empty array is then lenghtened and also
   returned, so that the program has already it handy without having to scan for it
   in program_data again.
   
*/

FALCON_FUNC  Dictionary_dop ( ::Falcon::VMachine *vm )
{
   Item *i_key = vm->param(0);
   Item *i_dflt = vm->param(1);
   Item *i_oper = vm->param(2);
   
   if( i_key == 0|| i_dflt == 0 || 
      ( i_oper != 0 && ! i_oper->isCallable() ) )
   {
      throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra( "X,X,[C]" ) );
   }


   CoreDict *cd = vm->self().asDict();
   
   // find our key -- will be 0 if not found
   Item *i_val = cd->find(*i_key);
      
   if( i_oper == 0 )
   {
      // if we have no operations, we're done here
      if( i_val == 0 )
      {
         // if the value was not found, set the default
         cd->put( *i_key, *i_dflt );
         vm->retval( *i_dflt );
      }
      else
      {
         // otherwise, don't do anything, but return the found value
         vm->retval( *i_val );
      }
   }
   else 
   {
      // we have to call our function
  
      vm->returnHandler( &dop_internal );
      vm->pushParam( i_val == 0 ? *i_dflt : *i_val );
      vm->callItem( *vm->param(2), 1 ); // stack may change -- use vm->param
   }
}



/*#
   @function chr
   @brief Returns a string containing a single character that corresponds to the given number.
   @inset generic_item_api
   @param number Numeric code of the desired character
   @return a single-char string.

   This function returns a single character string whose only character is the UNICODE
   equivalent for the given number. The number must be a valid UNICODE character,
   so it must be in range 0-0xFFFFFFFF.
*/

FALCON_FUNC  chr ( ::Falcon::VMachine *vm )
{
   uint32 val;
   Item *elem = vm->param(0);
   if ( elem == 0 ) return;
   if ( elem->type() == FLC_ITEM_INT )
      val = (uint32) elem->asInteger();
   else if ( elem->type() == FLC_ITEM_NUM )
      val = (uint32) elem->asNumeric();
   else {
      throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra( "N" ) );
   }

   CoreString *ret = new CoreString;
   ret->append( val );
   vm->retval( ret );
}

/*#
   @function ord
   @brief Returns the numeric UNICODE ID of a given character.
   @inset generic_item_api
   @param string The character for which the ID is requested.
   @return the UNICODE value of the first element in the string.

   The first character in string is taken, and it's numeric ID is returned.

   @see chr
*/
FALCON_FUNC  ord ( ::Falcon::VMachine *vm )
{
   Item *elem = vm->param(0);
   if ( elem == 0 || ! elem->isString() || elem->asString()->size() == 0 )
   {
      throw new ParamError( ErrorParam( e_inv_params).origin( e_orig_runtime ).extra( "S" ) );
      return;
   }

   vm->retval( (int64) elem->asString()->getCharAt(0) );
}

/*#
   @function toString
   @brief Returns a string representation of the item.
   @param item The item to be converted to string.
   @optparam format Specific object format.
   @return the string representation of the item.

   This function is useful to convert an unknown value in a string. The item may be any kind of Falcon
   item; the following rules apply:
      - Nil items are represented as "<NIL>"
      - Integers are converted in base 10.
      - Floating point values are converted in base 10 with a default precision of 6;
        numprec may be specified to change the default precision.
      - Array and dictionaries are represented as "Array of 'n' elements" or "Dictionary of 'n' elements".
      - Strings are copied.
      - Objects are represented as "Object 'name of class'", but if a toString() method is provided by the object,
        that one is called instead.
      - Classes and other kind of opaque items are rendered with their names.

   This function is not meant to provide complex applications with pretty-print facilities, but just to provide
   simple scripts with a simple and consistent output facility.

   If a @b format parameter is given, the format will be passed unparsed to toString() methods of underlying
   items.

   @see Format
*/

/*#
   @method toString BOM
   @brief Coverts the object to string.
   @optparam format Optional object-specific format string.

   Calling this BOM method is equivalent to call toString() core function
   passing the item as the first parameter.

   Returns a string representation of the given item. If applied on strings,
   it returns the string as is, while it converts numbers with default
   internal conversion. Ranges are represented as "[N:M:S]" where N and M are respectively
   lower and higher limits of the range, and S is the step. Nil values are represented as
   "Nil".

   The format parameter is not a Falcon format specification, but a specific optional
   object-specific format that may be passed to objects willing to use them.
   In example, the TimeStamp class uses this parameter to format its string
   representation.
*/

FALCON_FUNC  mth_ToString ( ::Falcon::VMachine *vm )
{
   Item *elem;
   Item *format;

   // methodic?
   if ( vm->self().isMethodic() )
   {
      elem = &vm->self();
      format = vm->param(0);
   }
   else {
      elem = vm->param(0);
      format = vm->param(1);
   }

   if(elem == 0)
   {
      throw new ParamError( ErrorParam( e_inv_params )
         .origin( e_orig_runtime ).extra( vm->self().isMethodic() ? "[S]" :  "X,[S]" ) );
   }

   CoreString *target = 0;

   if ( format != 0 )
   {
      if ( format->isString() )
      {
         Format fmt( *format->asString() );
         if ( ! fmt.isValid() )
         {
            throw new ParamError( ErrorParam( e_param_fmt_code ).
               extra( *format->asString() ) );
         }
         else
         {
            target = new CoreString;
            fmt.format( vm, *elem, *target );
         }
      }
      else
      {
         throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra( vm->self().isMethodic() ? "[S]" :  "X,[S]" ) );
      }
   }
   else {
      target = new CoreString;
      if ( vm->self().isMethodic() )
      {
         elem->toString( *target );
      }
      else
      {
         vm->itemToString( *target, elem );
      }
   }

   vm->retval( target );
}

/*#
   @method compare BOM
   @brief Performs a lexicographical comparison.
   @param item The item to which this object must be compared.
   @return -1, 0 or 1 depending on the comparation result.

   Performs a lexicographical comparison between the self item and the
   item passed as a parameter. If the item is found smaller than the parameter,
   it returns -1; if the item is greater than the parameter, it returns 1.
   If the two items are equal, it returns 0.

   The compare method, if overloaded, is used by the Virtual Machine to perform
   tests on unknown types (i.e. objects), and to sort dictionary keys.

   Item different by type are ordered by their type ID, as indicated in the
   documentation of the @a typeOf core function.

   By default, string comparison is performed in UNICODE character order,
   and objects, classes, vectors, and dictionaries are ordered by their
   internal pointer address.
*/
/*#
   @function compare
   @brief Performs a lexicographical comparison.
   @param operand1 The item to which this object must be compared.
   @param operand2 The item to which this object must be compared.
   @return -1, 0 or 1 depending on the comparation result.

   Performs a lexicographical comparison between the self item and the
   item passed as a parameter. If the item is found smaller than the parameter,
   it returns -1; if the item is greater than the parameter, it returns 1.
   If the two items are equal, it returns 0.

   The compare method, if overloaded, is used by the Virtual Machine to perform
   tests on unknown types (i.e. objects), and to sort dictionary keys.

   Item different by type are ordered by their type ID, as indicated in the
   documentation of the @a typeOf core function.

   By default, string comparison is performed in UNICODE character order,
   and objects, classes, vectors, and dictionaries are ordered by their
   internal pointer address.
*/

FALCON_FUNC mth_compare( VMachine *vm )
{
   Item *first;
   Item *second;

   if( vm->self().isMethodic() )
   {
      first = &vm->self();
      second = vm->param(0);
   }
   else
   {
      first = vm->param(0);
      second = vm->param(1);
   }

   if( first == 0 || second == 0 )
   {
      throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra( vm->self().isMethodic() ? "X" : "X,X" ) );
   }


   vm->retval( (int64) first->compare(*second) );
}


/*#
   @method clone BOM
   @brief Performs a deep copy of the item.
   @return A copy of the item.
   @raise CloneError if the item is not cloneable.

   Returns an item equal to the current one, but phisically separated.
   If the item is a sequence, only the first level of the item gets actually
   cloned: vectors and dictionaries gets cloned, but the items they store
   are just copied. This means that the new copy of the collection itself may
   change, and the older version will stay untouched, but if a deep item
   in the collection (as an object) is changed, its change will be reflected
   also in the original collection.

   Cloning objects causes each of their properties to be cloned. If they store
   an internal user data which is provided by extension modules or embedding
   applications, that data is cloned too. Behavior of user data is beyond the
   control of the script, and the data may actually be just referenced or
   it may also refuse to be cloned. In that case, this method will raise a
   CloneError, which indicates that a deep user data provided by an external
   module or application doesn't provide a cloning feature.

   @note Cloning objects that stores other objects referencing themselves in
   their properties may cause an endless loop in this version. To provide
   a safe duplicate of objects that may be organized in circular hierarcies,
   overload the clone method so that it creates a new instance of the item
   and just performs a flat copy of the properties.
*/

/*#
   @function clone
   @brief Performs a deep copy of the item.
   @param item The item to be copied.
   @return A copy of the item.
   @raise CloneError if the item is not cloneable.

   Returns an item equal to the @b item, but phisically separated.
   If the item is a sequence, only the first level of the item gets actually
   cloned: vectors and dictionaries gets cloned, but the items they store
   are just copied. This means that the new copy of the collection itself may
   change, and the older version will stay untouched, but if a deep item
   in the collection (as an object) is changed, its change will be reflected
   also in the original collection.

   Cloning objects causes each of their properties to be cloned. If they store
   an internal user data which is provided by extension modules or embedding
   applications, that data is cloned too. Behavior of user data is beyond the
   control of the script, and the data may actually be just referenced or
   it may also refuse to be cloned. In that case, this method will raise a
   CloneError, which indicates that a deep user data provided by an external
   module or application doesn't provide a cloning feature.

   @note Cloning objects that stores other objects referencing themselves in
   their properties may cause an endless loop in this version. To provide
   a safe duplicate of objects that may be organized in circular hierarcies,
   overload the clone method so that it creates a new instance of the item
   and just performs a flat copy of the properties.
*/

FALCON_FUNC mth_clone( VMachine *vm )
{
   bool result;
   if( vm->self().isMethodic() )
   {
      result = vm->self().clone( vm->regA() );
   }
   else
   {
      if( vm->paramCount() == 0 )
      {
         throw new ParamError( ErrorParam( e_inv_params ).origin( e_orig_runtime ).extra("X") );
      }
      else
      {
         result = vm->param(0)->clone( vm->regA() );
      }
   }

   if( ! result )
      throw new CloneError( ErrorParam( e_uncloneable, __LINE__ )
         .hard()
         .origin( e_orig_runtime ) );
}

/*#
   @method className BOM
   @brief Returns the name of the class an instance is instantiated from.
   @return The class name of an object (a string) or nil.

   If applied to objects, returns the name of the class of which the object
   is an instance. When applied to classes, it return the class symbolic name.
   In all other cases, return nil.

   @see className
*/

/*#
   @function className
   @brief Returns the name of the class an instance is instantiated from.
   @param The item to be checked.
   @return The class name of an object (a string) or nil.

   If applied to objects, returns the name of the class of which the object
   is an instance. When applied to classes, it return the class symbolic name.
   In all other cases, return nil.

   @see BOM.className
*/

FALCON_FUNC mth_className( VMachine *vm )
{
   Item *self;

   if ( vm->self().isMethodic() )
   {
      self = &vm->self();
   }
   else {
      self = vm->param(0);
      if ( self == 0 )
      {
         throw new ParamError( ErrorParam( e_inv_params )
            .origin( e_orig_runtime ).extra("X") );
         return;
      }
   }

   switch( self->type() )
   {
      case FLC_ITEM_OBJECT:
         vm->retval(
            new CoreString(  vm->self().asObject()->generator()->symbol()->name() ) );
         break;

      case FLC_ITEM_CLASS:
         vm->retval(
            new CoreString(  vm->self().asClass()->symbol()->name() ) );
         break;

      default:
         vm->retnil();
   }

}

/*#
   @method baseClass BOM
   @brief Returns the class item from which an object has been instantiated.
   @return A class item or nil.

   If applied on objects, returns the class item that has been used
   to instantiate an object. Calling the returned item is equivalent
   to call the class that instantiated this object.

   The returned item can be used to create another instance of the same class,
   or for comparisons on @b select branches.

   If the item on which this method is applied is not an object, it returns nil.

   @see baseClass
*/

/*#
   @function baseClass
   @brief Returns the class item from which an object has been instantiated.
   @param item
   @return A class item or nil.

   If applied on objects, returns the class item that has been used
   to instantiate an object. Calling the returned item is equivalent
   to call the class that instantiated this object.

   The returned item can be used to create another instance of the same class,
   or for comparisons on @b select branches.

   If the item on which this method is applied is not an object, it returns nil.

   @see BOM.baseClass
*/

FALCON_FUNC mth_baseClass( VMachine *vm )
{
   Item *self;

   if ( vm->self().isMethodic() )
   {
      self = &vm->self();
   }
   else {
      self = vm->param(0);
      if ( self == 0 )
      {
         throw new ParamError( ErrorParam( e_inv_params )
               .origin( e_orig_runtime ).extra("X") );
      }
   }

   if( self->isObject() )
   {
      CoreClass* cls = const_cast<CoreClass*>(self->asObject()->generator());
      if ( cls != 0 )
      {
         vm->retval( cls );
         return;
      }
   }

   vm->retnil();
}

/*#
   @method derivedFrom BOM
   @brief Checks if this item has a given parent.
   @param cls A symbolic class name or a class instance.
   @return true if the given class is one of the ancestors of this item.

   If applied on objects, returns true if the given parameter is the name
   of the one of the classes that compose the class hierarchy of the object.

   If applied on class instances, it returns true if the parameter is its name
   or the name of one of its ancestors.

   In all the other cases, it return false.

   It is also possible to use directly the class instance as a parameter, instead of
   a class name. In example:

   @code
   object MyError from Error
       //...
   end

   > "Is MyError derived from 'Error' (by name)?: ", \
         MyError.derivedFrom( "Error" )

   > "Is MyError derived from 'Error' (by class)?: ", \
         MyError.derivedFrom( Error )
   @endcode

   @see derivedFrom
*/

/*#
   @function derivedFrom
   @brief Checks if this item has a given parent.
   @param item The item to be checked.
   @param cls A symbolic class name or a class instance.
   @return true if the given class is one of the ancestors of this item.

   If applied on objects, returns true if the given parameter is the name
   of the one of the classes that compose the class hierarchy of the object.

   If applied on class instances, it returns true if the parameter is its name
   or the name of one of its ancestors.

   In all the other cases, it return false.

   It is also possible to use directly the class instance as a parameter, instead of
   a class name. In example:

   @code
   object MyError from Error
       //...
   end

   > "Is MyError derived from 'Error' (by name)?: ", \
         derivedFrom( MyError, "Error" )

   > "Is MyError derived from 'Error' (by class)?: ", \
         derivedFrom( MyError, Error )
   @endcode

   @see BOM.derivedFrom
*/

FALCON_FUNC mth_derivedFrom( VMachine *vm )
{
   Item *i_clsName;
   Item *self;

   if( vm->self().isMethodic() )
   {
      self = &vm->self();
      i_clsName = vm->param( 0 );
   }
   else {
      self = vm->param(0);
      i_clsName = vm->param(1);
   }

   if( i_clsName == 0 || ! (i_clsName->isString() || i_clsName->isClass()) )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
         .origin( e_orig_runtime ).extra( "S|C" ) );
   }

   if ( i_clsName->isString() )
   {
      const String *name = i_clsName->asString();

      switch( self->type() )
      {
         case FLC_ITEM_OBJECT:
            vm->regA().setBoolean( (bool)self->asObjectSafe()-> derivedFrom( *name ) );
            break;

         case FLC_ITEM_CLASS:
            vm->regA().setBoolean( (bool)self->asClass()->derivedFrom( *name ) );
            break;

         default:
            vm->regA().setBoolean( false );
      }
   }
   else
   {
      switch( self->type() )
      {
         case FLC_ITEM_OBJECT:
            vm->regA().setBoolean( (bool)self->asObjectSafe()->generator()->derivedFrom( i_clsName->asClass()->symbol() ) );
            break;

         case FLC_ITEM_CLASS:
            vm->regA().setBoolean( (bool)self->asClass()->derivedFrom( i_clsName->asClass()->symbol() ) );
            break;

         default:
            vm->regA().setBoolean( false );
      }
   }
}

/*#
   @method source Method
   @brief Returns the object associated with this method.
   @return The object from which this method was created.

   Returns an object (or an item, in case this is a BOM method) that
   gave birth to this method.
*/
FALCON_FUNC Method_source( VMachine *vm )
{
   Item *self = vm->self().dereference();
   vm->retval( self->isMethod() ? self->asMethodItem() : *self );
}

/*#
   @method base Method
   @brief Returns the function or the array associated with this method.
   @return The function or array that is applied on the associated object.

   Returns a function or a callable array that is associated with the object
   in this method.

   This method cannot return external functions; only function generated by
   Falcon native modules can be returned. This is because externa functions are
   not suited to be extracted from methods and eventually re-associated with other
   objects.

   This method will raise an error in case it refers to an external function. However,
   it can be safely used to extract base callable arrays.
*/
FALCON_FUNC Method_base( VMachine *vm )
{
   Item *self = vm->self().dereference();
   if ( self->isMethod() )
   {
      if ( ! self->asMethodFunc()->isFunc() )
      {
         // an array
         vm->retval( dyncast<CoreArray*>(self->asMethodFunc()) );
         return;
      }
      else
      {
         CoreFunc* func = dyncast<CoreFunc*>(self->asMethodFunc());
         if ( ! func->symbol()->isExtFunc() )
         {
            vm->regA().setFunction( func );
            return;
         }
      }
   }

   throw new AccessError( ErrorParam( e_acc_forbidden, __LINE__ )
         .origin( e_orig_runtime )
         .extra( "External function ") );
}

/*#
   @method metaclass BOM
   @brief Returns the metaclass associated with this item.
   @return The metaclass of this item.
*/
/*#
   @function metaclass
   @brief Returns the metaclass associated with the given item.
   @param item The item of which the metaclass must be found.
   @return The metaclass of this item.
*/
FALCON_FUNC mth_metaclass( VMachine *vm )
{
   Item *self;

   if ( vm->self().isMethodic() )
   {
      self = &vm->self();
   }
   else {
      self = vm->param(0);
      if ( self == 0 )
      {
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).origin( e_orig_runtime ).extra("X") );
      }
   }

   CoreClass* cls = vm->getMetaClass( self->type() );
   fassert( cls );
   vm->retval( cls );
}



/*#
   @method ptr BOM
   @brief Returns a raw memory pointer out of this data (as an integer).
   @return An integer containing a pointer to this data.

   The default behavior of this method is to return the value of
   the memory location where inner data is stored, if the data is
   deep, and 0 otherwise. The Integer metaclass overrides this
   method so that it returns a dereferenced pointer, that is,
   the pointer value at the location indicated by the integer
   value, and String items overload this so that a pointer to
   the raw character sequence is returned.
*/
FALCON_FUNC BOM_ptr( VMachine *vm )
{
   if ( vm->self().isDeep() )
   {
      vm->retval( (int64) vm->self().asDeepItem() );
   }
   vm->retval( (int64) 0 );
}

/*#
   @method ptr Integer
   @brief Returns the value itself.
   @return The value in this integer.

   Falcon integers can be used to store memory locations, as the are granted to be
   wide at least as the widest pointer on the target platform. For this reason, they
   can be used to transport raw pointers coming from external libraries.

   This function override ensures that .ptr() applied to an integer returns the original
   integer value (and doesn't get mangled as with other ptr overrides).
*/
FALCON_FUNC Integer_ptr( VMachine *vm )
{
   vm->retval( vm->self().asInteger() );
}

/*#
   @method ptr GarbagePointer
   @brief Returns the inner data stored in this pointer.
   @return Deep data (as a pointer).

   This function returns a pointer value (stored in a Falcon integer)
   pointing to the inner FalconData served this garbage pointer.
*/
FALCON_FUNC GarbagePointer_ptr( VMachine *vm )
{
   vm->retval( (int64) vm->self().asGCPointer() );
}

/*#
   @method ptr String
   @brief Returns a pointer to raw data contained in this string.
   @return A string pointer.

   This function returns a pointer value (stored in a Falcon integer)
   pointing to the raw data in the string. The string is not encoded
   in any format, and its character size can be 1, 2 or 4 bytes per
   character depending on the values previusly stored. The string
   is granted to be terminated by an appropriate "\\0" value of the
   correct size. The value exists and is valid only while the original
   string (this item) stays unchanged.
*/

FALCON_FUNC String_ptr( VMachine *vm )
{
   String *str = vm->self().asString();
   str->c_ize();
   vm->retval( (int64) str->getRawStorage() );
}

/*#
   @method ptr MemoryBuffer
   @brief Returns the pointer to the raw memory stored in this memory buffer.
   @return A memory pointer.

   This function returns a pointer (as a Falcon integer) to the memory
   area managed by this memory buffer.
*/

FALCON_FUNC MemoryBuffer_ptr( VMachine *vm )
{
   vm->retval( (int64) vm->self().asMemBuf()->data() );
}

/*#
   @method value LateBinding
   @brief Returns the value associated with a late binding.
   @return A value or nil if no value is associated.

   To determine if this binding has a "nil" value associated,
   use @a LateBinding.bound.
*/
FALCON_FUNC LateBinding_value( VMachine *vm )
{
   if ( vm->self().isFutureBind() )
      vm->retval( vm->self().asFutureBind() );
   else
      vm->retnil();
}

/*#
   @method symbol LateBinding
   @brief Returns the symbol name associated with a late binding.
   @return The symbol name
*/
FALCON_FUNC LateBinding_symbol( VMachine *vm )
{
   vm->retval( vm->self().asLBind() );
}

/*#
   @method bound LateBinding
   @brief Checks if the late binding is bound.
   @return True if this late binding has a bound value.
*/
FALCON_FUNC LateBinding_bound( VMachine *vm )
{
   vm->regA().setBoolean( vm->self().isFutureBind() );
}

FALCON_FUNC LateBinding_bind( VMachine *vm )
{
   Item* i_item = vm->param(0);

   if( i_item == 0 )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "X" ) );
   }

   vm->self().setLBind( vm->self().asLBind(), new GarbageItem( *i_item ) );
   vm->regA() = vm->self();
}

FALCON_FUNC LateBinding_unbind( VMachine *vm )
{
   vm->self().setLBind( vm->self().asLBind() );
}

}
}