Changeset 142

Show
Ignore:
Timestamp:
11/19/07 02:54:57 (11 months ago)
Author:
Don Clugston
Message:

* Bugfix (vector length check with for compounds).
* More sophisticated example.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/blade/Blade.d

    r141 r142  
    6969{ 
    7070    RevisedExpression revised = simplifySyntaxTree(tree); 
    71      
    7271    VecExpressionType exprType = categorizeExpression(tree, revised); 
    7372    if (exprType == VecExpressionType.SSE2Expression || exprType == VecExpressionType.SSE1Expression) { 
     
    145144        } 
    146145        if (r>'1') return VecExpressionType.DExpression; // can only do scalars and vectors right now. 
    147          
     146        
    148147        // At this point, all compounds are an original symbol + indexing/slicing. 
    149148        int x = revised.mapping[i]-'A'; 
    150149        int y = x; // for compounds, get the original type 
    151         if (x>tree.symbolTable.length) y = revised.compounds[x][0]-'A'; 
     150        if (x>tree.symbolTable.length) y = revised.compounds[x-tree.symbolTable.length][0]-'A'; 
    152151         
    153152        char [] t = tree.symbolTable[y].element; 
     
    239238        if (rnk=='0') result ~= SSE2? ",double" : ",float"; 
    240239        else result ~= SSE2? ",double*" : ",float*"; 
    241         vals ~= "," ~ getValueForSymbol(revised.mapping[i], tree, revised); 
     240        vals ~= ","; 
     241        if (rnk=='1') vals ~= "&"; 
     242        vals ~= getValueForSymbol(revised.mapping[i], tree, revised); 
    242243        // for vectors, we only need the pointer, not the length 
    243         if (rnk=='1') vals ~= ".ptr"; 
     244//        if (rnk=='1') vals ~= ".ptr"; 
     245        if (rnk=='1') vals ~= "[0]"; 
    244246    } 
    245247             
     
    328330        else v ~= d; 
    329331    } 
    330     return "(" ~ v ~ ")";     
     332    return v; //"(" ~ v ~ ")";     
    331333}  
    332334 
  • trunk/blade/BladeDemo.d

    r141 r142  
    2727    idouble [] p = [2.3i, 254i, 0.1i, 1.2i]; 
    2828    for(int i=0; i<r.length;++i) { 
    29 //        r[i]= q[i]+ a[i]*2213.3; 
    3029        r[i]= q[i]*2213.3L; 
    3130    } 
     31    double [4][] another = [[33.1, 4543, 43, 878.7], [5.14, 455, 554, 2.43]]; 
     32    real k=3.4; 
    3233 
    33     mixin(vectorize(" a   += d*2.01*a[2]-z")); 
    34     mixin(vectorize(" a   += r*2.01")); 
     34    mixin(vectorize(" a += d*2.01*a[2]-z+another[1]")); 
     35    mixin(vectorize(" a   -= 2.01*(3.04+k)*r")); 
    3536    mixin(vectorize(" q   += q*2.01")); 
    3637     
    37     writefln("a=", a); 
     38    writefln("a=", a);     
    3839}