Changeset 80
- Timestamp:
- 07/20/07 16:10:14 (1 year ago)
- Files:
-
- branches/1.9/documentation/methods.html (modified) (6 diffs)
- branches/1.9/source/methods.d (modified) (11 diffs)
- branches/1.9/source/value.d (modified) (3 diffs)
- branches/1.9/walnut.exe (modified) (previous)
- branches/1.9/walnut.lib (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.9/documentation/methods.html
r79 r80 60 60 <dt><big>static Value <u>Global_parseInt</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 61 61 </big></dt> 62 <dd><font color=red>BUGS:</font><br> 63 Does not yet allow a non-decimal radix 64 <br><br> 65 <b>Standards:</b><br> 62 <dd><b>Standards:</b><br> 66 63 ECMA 15.1.2.2 67 64 <br><br> 68 65 <b>Arguments:</b><br> 69 <i>arguments</i>[0] = string to be parsed 66 <i>arguments</i>[0] = string to be parsed<br> 67 <i>arguments</i>[1] = radix (between 2 and 36) to parse the string by 70 68 <br><br> 71 69 <b>Returns:</b><br> … … 79 77 <dt><big>static Value <u>Global_parseFloat</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 80 78 </big></dt> 81 <dd><font color=red>BUGS:</font><br> 82 Does not yet allow a non-decimal radix 83 <br><br> 84 <b>Standards:</b><br> 79 <dd><b>Standards:</b><br> 85 80 ECMA 15.1.2.3 86 81 <br><br> … … 962 957 <br><br> 963 958 <b>Arguments:</b><br> 964 <br><br> 965 <b>Returns:</b><br> 966 <br><br> 967 <b>Synopsis:</b><br> 959 <i>arguments</i>[0] = Value to be made into a boolean. 960 <br><br> 961 <b>Returns:</b><br> 962 Value boolean 963 <br><br> 964 <b>Synopsis:</b><br> 965 returns a boolean value for the value provided. 968 966 <br><br> 969 967 … … 971 969 <dt><big>static Value <u>Boolean_prototype_constructor</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 972 970 </big></dt> 973 <dd><font color=red>BUGS:</font><br> 974 Incomplete! 975 <br><br> 976 <b>Standards:</b><br> 971 <dd><b>Standards:</b><br> 977 972 ECMA 15.6.2 978 973 <br><br> 979 974 <b>Arguments:</b><br> 980 <br><br> 981 <b>Returns:</b><br> 982 <br><br> 983 <b>Synopsis:</b><br> 975 <i>arguments</i>[0] = Value to be made into a boolean. 976 <br><br> 977 <b>Returns:</b><br> 978 Value Object containing boolean as it's value. 979 <br><br> 980 <b>Synopsis:</b><br> 981 Creates an Object containing a boolean value. 984 982 <br><br> 985 983 … … 991 989 <br><br> 992 990 <b>Arguments:</b><br> 993 <br><br> 994 <b>Returns:</b><br> 995 <br><br> 996 <b>Synopsis:</b><br> 991 <i>arguments</i>[0] = Value to be made into a number. 992 <br><br> 993 <b>Returns:</b><br> 994 Value number 995 <br><br> 996 <b>Synopsis:</b><br> 997 returns a numerical value for the value provided. 997 998 <br><br> 998 999 … … 1000 1001 <dt><big>static Value <u>Number_prototype_constructor</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 1001 1002 </big></dt> 1002 <dd><font color=red>BUGS:</font><br> 1003 Returns a primitive Number, rather than a Number Object 1004 <br><br> 1005 <b>Standards:</b><br> 1003 <dd><b>Standards:</b><br> 1006 1004 ECMA 15.7.2 1007 1005 <br><br> 1008 1006 <b>Arguments:</b><br> 1009 <br><br> 1010 <b>Returns:</b><br> 1011 <br><br> 1012 <b>Synopsis:</b><br> 1007 <i>arguments</i>[0] = Value to be made into a number. 1008 <br><br> 1009 <b>Returns:</b><br> 1010 Value Object containing a number as it's value. 1011 <br><br> 1012 <b>Synopsis:</b><br> 1013 Creates an Object containing a numerical value. 1013 1014 <br><br> 1014 1015 branches/1.9/source/methods.d
r79 r80 19 19 20 20 /** 21 Standards: non-standard , but acceptable in a conformant implementation of ECMA 26221 Standards: non-standard 22 22 Arguments: none 23 23 Returns: manipulates the static Global object before evaluating code, as necessary by the implementation. … … 49 49 size_t line; 50 50 /* 51 this algorithm interprets globally executed code, but can compile loops and functions to52 machine code using D inline assembler before executing it.51 this algorithm interprets (not compiles) source code provided to it, but 52 defers (to do nothing atm) on the contents of loops and functions. 53 53 */ 54 54 for(p = &source[0]; ; p++) { … … 63 63 case 0x1C: 64 64 return FALSE; 65 case 0x05:66 case 0x06:67 case 0x07:68 case 0x08:69 case 0x10:70 case 0x11:71 case 0x12:72 case 0x13:73 case 0x14:74 case 0x15:75 case 0x16:76 case 0x1D:77 case 0x1E:78 case 0x1F:79 case '#':80 case '@':81 case '\\':82 case '^':83 case '`':84 case 0x7F:85 break;86 65 case 0x0D: 87 66 if(p[1] != '\n') … … 271 250 default: 272 251 { 273 // it is either:274 275 252 // a letter 276 253 if( (0x41 <= *p && *p <= 0x5A) 277 254 || (0x61 <= *p && *p <= 0x7A) 278 ) cbuffer ~= *p; 255 ) { 256 cbuffer ~= *p; 257 continue; 258 } 279 259 280 260 // a number 281 if(0x30 <= *p && *p <= 0x39) 261 if(0x30 <= *p && *p <= 0x39) { 282 262 printf("number!"); 263 continue; 264 } 283 265 284 266 // or above 127 285 267 if(*p > 0x7F) { 286 268 printf("%c",*p); 287 break;269 return UNDEFINED; 288 270 } 271 272 // whoa! 273 printf("Unrecognized character: %c",*p); 274 return UNDEFINED; 289 275 } 290 276 } … … 295 281 /** 296 282 Standards: ECMA 15.1.2.2 297 Arguments: arguments[0] = string to be parsed 283 Arguments: arguments[0] = string to be parsed<br> 284 arguments[1] = radix (between 2 and 36) to parse the string by 298 285 Returns: integer Value or NaN if the value is not a valid integer. 299 286 Synopsis: Global_parseInt is called to cast a string into an integer. … … 433 420 static Value Object_prototype_constructor(inout Value self, inout Value cc, Value[] arguments ...) { 434 421 Value v; 435 v.keys = [];436 v.values = [];437 422 v.type = TYPE.OBJECT; 438 423 return v; … … 460 445 char[] buffer = "{"; 461 446 bool any = false; 462 foreach(char[] key; self.keys){ 463 if(self[key].access & ACCESS.ENUMERATE){ 447 Value v; 448 for(int i = 0; i < self.length; i++) { 449 if(self.values[i].access & ACCESS.ENUMERATE) { 464 450 if(any) 465 451 buffer ~= ','; 466 452 any = true; 467 buffer ~= key ~ ':' ~ self[key].toString();453 buffer ~= self.keys[i] ~ ':' ~ self.values[i].toString(); 468 454 } 469 455 } … … 945 931 /** 946 932 Standards: ECMA 15.6.1 947 Arguments: 948 Returns: 949 Synopsis: 933 Arguments: arguments[0] = Value to be made into a boolean. 934 Returns: Value boolean 935 Synopsis: returns a boolean value for the value provided. 950 936 */ 951 937 static Value Global_Boolean(inout Value self, inout Value cc, Value[] arguments ...){ … … 954 940 955 941 /** 956 BUGS: Incomplete!957 942 Standards: ECMA 15.6.2 958 Arguments: 959 Returns: 960 Synopsis: 943 Arguments: arguments[0] = Value to be made into a boolean. 944 Returns: Value Object containing boolean as it's value. 945 Synopsis: Creates an Object containing a boolean value. 961 946 */ 962 947 static Value Boolean_prototype_constructor(inout Value self, inout Value cc, Value[] arguments ...){ 963 return UNDEFINED; 948 Value o; 949 o.type = TYPE.OBJECT; 950 o[TEXT_prototype] = Global[TEXT_Boolean][TEXT_prototype]; 951 o[TEXT___value__] = Global_Boolean(self,cc,arguments); 952 return o; 964 953 } 965 954 966 955 /** 967 956 Standards: ECMA 15.7.1 968 Arguments: 969 Returns: 970 Synopsis: 957 Arguments: arguments[0] = Value to be made into a number. 958 Returns: Value number 959 Synopsis: returns a numerical value for the value provided. 971 960 */ 972 961 static Value Global_Number(inout Value self, inout Value cc, Value[] arguments ...) { … … 975 964 976 965 /** 977 BUGS: Returns a primitive Number, rather than a Number Object978 966 Standards: ECMA 15.7.2 979 Arguments: 980 Returns: 981 Synopsis: 967 Arguments: arguments[0] = Value to be made into a number. 968 Returns: Value Object containing a number as it's value. 969 Synopsis: Creates an Object containing a numerical value. 982 970 */ 983 971 static Value Number_prototype_constructor(inout Value self, inout Value cc, Value[] arguments ...) { 984 return cast(Value) (arguments.length? arguments[0].toDouble() : 0.0); 972 Value o; 973 o.type = TYPE.OBJECT; 974 o[TEXT_prototype] = Global[TEXT_Number][TEXT_prototype]; 975 o[TEXT___value__] = cast(Value) (arguments.length? arguments[0].toDouble() : 0.0); 976 return o; 985 977 } 986 978 … … 2088 2080 2089 2081 /** 2090 BUGS: Incomplete!2091 2082 Standards: ECMA 15.11.2.1 2092 2083 Arguments: branches/1.9/source/value.d
r78 r80 56 56 union { 57 57 struct { 58 char[][] keys; 59 Value[] values; 58 uint length; 59 char[]* keys; 60 Value* values; 60 61 } 61 62 struct { … … 105 106 } 106 107 } 107 /// OPTIMIZE: one at a time reallocs 108 keys.length = keys.length + 1; 109 values.length = values.length + 1; 110 keys[$] = key; 111 values[$] = v; 108 /// BUG: need to realloc because these aren't official D arrays anymore 109 /+ keys ~= key; 110 values ~= v; 111 +/ 112 112 } 113 113 … … 288 288 } 289 289 } 290 291 static assert(Value.sizeof == 16);
