Changeset 75

Show
Ignore:
Timestamp:
07/13/07 07:25:41 (1 year ago)
Author:
dan.lewis
Message:

Object_prototype_constructor written.
Wrote a batch file processing main for Walnut.
Global_eval currently just dumps the file content.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.9/source/main.d

    r56 r75  
    1111import 
    1212    std.c.stdio, 
     13    std.path, 
     14    std.file, 
    1315    value, 
    1416    methods, 
     
    2224int main(char[][] arguments) { 
    2325     
     26    /// Fail hard if there's no script. 
     27    if(!arguments.length) { 
     28        return EXIT.FAILURE; 
     29    } 
     30     
    2431    /// Initialize the program state 
    2532    Value global = Global_init(); 
     33    char[] path, source; 
     34     
     35    /// Grab the files and collect the source 
     36    for(size_t i = 1; i < arguments.length; i++) { 
     37        path = std.path.defaultExt(arguments[i],"nut"); 
     38        source ~= cast(char[]) std.file.read(path); 
     39    } 
     40    source ~= 0x0A; 
     41     
     42    /// evaluate the source code. 
     43    Global_eval(global,global,cast(Value) source); 
    2644     
    2745    /// all done. 
  • branches/1.9/source/methods.d

    r74 r75  
    3737*/ 
    3838static Value Global_eval(inout Value self, inout Value cc, Value[] arguments ...) { 
    39  
     39    if(!arguments.length || arguments[0].type != TYPE.STRING) 
     40        return UNDEFINED; 
     41    printf("%.*s\n",arguments[0].toString()); 
    4042    return UNDEFINED; 
    4143} 
     
    174176static Value Object_prototype_constructor(inout Value self, inout Value cc, Value[] arguments ...) { 
    175177    Value v; 
     178    v.keys = []; 
     179    v.values = []; 
     180    v.type = TYPE.OBJECT; 
    176181    return v; 
    177182}