Changeset 80

Show
Ignore:
Timestamp:
07/20/07 16:10:14 (1 year ago)
Author:
dan.lewis
Message:

Changed Value.sizeof to 16 from 24. Introduced a couple bugs to object usage in the process - these need to be ironed out.

Some other trivial changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.9/documentation/methods.html

    r79 r80  
    6060<dt><big>static Value  <u>Global_parseInt</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 
    6161</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> 
    6663ECMA 15.1.2.2 
    6764<br><br> 
    6865<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 
    7068<br><br> 
    7169<b>Returns:</b><br> 
     
    7977<dt><big>static Value  <u>Global_parseFloat</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 
    8078</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> 
    8580ECMA 15.1.2.3 
    8681<br><br> 
     
    962957<br><br> 
    963958<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> 
     962Value boolean 
     963<br><br> 
     964<b>Synopsis:</b><br> 
     965returns a boolean value for the value provided. 
    968966<br><br> 
    969967 
     
    971969<dt><big>static Value  <u>Boolean_prototype_constructor</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 
    972970</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> 
    977972ECMA 15.6.2 
    978973<br><br> 
    979974<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> 
     978Value Object containing boolean as it's value. 
     979<br><br> 
     980<b>Synopsis:</b><br> 
     981Creates an Object containing a boolean value. 
    984982<br><br> 
    985983 
     
    991989<br><br> 
    992990<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> 
     994Value number 
     995<br><br> 
     996<b>Synopsis:</b><br> 
     997returns a numerical value for the value provided. 
    997998<br><br> 
    998999 
     
    10001001<dt><big>static Value  <u>Number_prototype_constructor</u>(inout Value <i>self</i>, inout Value <i>cc</i>, Value [] <i>arguments</i>...); 
    10011002</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> 
    10061004ECMA 15.7.2 
    10071005<br><br> 
    10081006<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> 
     1010Value Object containing a number as it's value. 
     1011<br><br> 
     1012<b>Synopsis:</b><br> 
     1013Creates an Object containing a numerical value. 
    10131014<br><br> 
    10141015 
  • branches/1.9/source/methods.d

    r79 r80  
    1919 
    2020/** 
    21     Standards: non-standard, but acceptable in a conformant implementation of ECMA 262 
     21    Standards: non-standard 
    2222    Arguments: none 
    2323    Returns: manipulates the static Global object before evaluating code, as necessary by the implementation. 
     
    4949    size_t line; 
    5050    /* 
    51         this algorithm interprets globally executed code, but can compile loops and functions to 
    52         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
    5353    */ 
    5454    for(p = &source[0]; ; p++) { 
     
    6363            case 0x1C: 
    6464                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; 
    8665            case 0x0D: 
    8766                if(p[1] != '\n') 
     
    271250            default: 
    272251            { 
    273                 // it is either: 
    274              
    275252                // a letter 
    276253                if( (0x41 <= *p && *p <= 0x5A) 
    277254                || (0x61 <= *p && *p <= 0x7A) 
    278                 )   cbuffer ~= *p; 
     255                ) { 
     256                    cbuffer ~= *p; 
     257                    continue; 
     258                } 
    279259                 
    280260                // a number 
    281                 if(0x30 <= *p && *p <= 0x39) 
     261                if(0x30 <= *p && *p <= 0x39) { 
    282262                    printf("number!"); 
     263                    continue; 
     264                } 
    283265                 
    284266                // or above 127 
    285267                if(*p > 0x7F) { 
    286268                    printf("%c",*p); 
    287                     break
     269                    return UNDEFINED
    288270                } 
     271                 
     272                // whoa! 
     273                printf("Unrecognized character: %c",*p); 
     274                return UNDEFINED; 
    289275            } 
    290276        } 
     
    295281/** 
    296282    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 
    298285    Returns: integer Value or NaN if the value is not a valid integer. 
    299286    Synopsis: Global_parseInt is called to cast a string into an integer. 
     
    433420static Value Object_prototype_constructor(inout Value self, inout Value cc, Value[] arguments ...) { 
    434421    Value v; 
    435     v.keys = []; 
    436     v.values = []; 
    437422    v.type = TYPE.OBJECT; 
    438423    return v; 
     
    460445    char[] buffer = "{"; 
    461446    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) { 
    464450            if(any) 
    465451                buffer ~= ','; 
    466452            any = true; 
    467             buffer ~= key ~ ':' ~ self[key].toString(); 
     453            buffer ~= self.keys[i] ~ ':' ~ self.values[i].toString(); 
    468454        } 
    469455    } 
     
    945931/** 
    946932    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. 
    950936*/ 
    951937static Value Global_Boolean(inout Value self, inout Value cc, Value[] arguments ...){ 
     
    954940 
    955941/** 
    956     BUGS: Incomplete! 
    957942    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. 
    961946*/ 
    962947static 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; 
    964953} 
    965954 
    966955/** 
    967956    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. 
    971960*/ 
    972961static Value Global_Number(inout Value self, inout Value cc, Value[] arguments ...) { 
     
    975964 
    976965/** 
    977     BUGS: Returns a primitive Number, rather than a Number Object 
    978966    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. 
    982970*/ 
    983971static 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; 
    985977} 
    986978 
     
    20882080 
    20892081/** 
    2090     BUGS: Incomplete! 
    20912082    Standards: ECMA 15.11.2.1 
    20922083    Arguments:  
  • branches/1.9/source/value.d

    r78 r80  
    5656    union {      
    5757        struct { 
    58             char[][] keys; 
    59             Value[] values; 
     58            uint length; 
     59            char[]* keys; 
     60            Value* values; 
    6061        } 
    6162        struct { 
     
    105106            } 
    106107        } 
    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        +/ 
    112112    } 
    113113 
     
    288288    } 
    289289} 
     290 
     291static assert(Value.sizeof == 16);