Ignore:
Timestamp:
Dec 31, 2019, 12:19:53 PM (4 years ago)
Author:
Dmitry Kobets <dkobets@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f8a8fb1
Parents:
94df8de
git-author:
Dmitry Kobets <dkobets@…> (12/31/19 12:13:34)
git-committer:
Dmitry Kobets <dkobets@…> (12/31/19 12:19:53)
Message:

Refactor vector library classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/vec/vec2.hfa

    r94df8de r250dbae  
    1010}
    1111
    12 
    1312forall (otype T) {
    1413    static inline {
     
    3130    }
    3231
    33     // Assignment
    3432    void ?=?(vec2(T)& vec, vec2(T) other) with (vec) {
    3533        [x,y] = other.[x,y];
     
    4240    // Primitive mathematical operations
    4341
     42    // -
    4443    forall(| subtract(T)) {
    45     vec2(T) ?-?(vec2(T) u, vec2(T) v) { // TODO( can't make this const ref )
     44    vec2(T) ?-?(vec2(T) u, vec2(T) v) {
    4645        return [u.x - v.x, u.y - v.y];
    4746    }
     
    6968    }
    7069
     70    // +
    7171    forall(| add(T)) {
    72     vec2(T) ?+?(vec2(T) u, vec2(T) v) { // TODO( can't make this const ref )
     72    vec2(T) ?+?(vec2(T) u, vec2(T) v) {
    7373        return [u.x + v.x, u.y + v.y];
    7474    }
     
    9292    }
    9393
     94    // *
    9495    forall(| multiply(T)) {
    95     vec2(T) ?*?(vec2(T) v, T scalar) with (v) { // TODO (can't make this const ref)
     96    vec2(T) ?*?(vec2(T) v, T scalar) with (v) {
    9697        return [x * scalar, y * scalar];
    9798    }
    98     vec2(T) ?*?(T scalar, vec2(T) v) { // TODO (can't make this const ref)
     99    vec2(T) ?*?(T scalar, vec2(T) v) {
    99100        return v * scalar;
    100101    }
     
    112113    }
    113114
     115    // /
    114116    forall(| divide(T)) {
    115117    vec2(T) ?/?(vec2(T) v, T scalar) with (v) {
     
    119121        return [u.x / v.x, u.y / v.y];
    120122    }
    121     vec2(T)& ?/=?(vec2(T)& v, T scalar) with (v) {
     123    vec2(T)& ?/=?(vec2(T)& v, T scalar) {
    122124        v = v / scalar;
    123125        return v;
     
    129131    }
    130132
     133    // %
    131134    forall(| { T ?%?(T,T); }) {
    132135    vec2(T) ?%?(vec2(T) v, T scalar) with (v) {
     
    146149    }
    147150
     151    // &
    148152    forall(| { T ?&?(T,T); }) {
    149153    vec2(T) ?&?(vec2(T) v, T scalar) with (v) {
     
    163167    }
    164168
     169    // |
    165170    forall(| { T ?|?(T,T); }) {
    166171    vec2(T) ?|?(vec2(T) v, T scalar) with (v) {
     
    180185    }
    181186
     187    // ^
    182188    forall(| { T ?^?(T,T); }) {
    183189    vec2(T) ?^?(vec2(T) v, T scalar) with (v) {
     
    197203    }
    198204
     205    // <<
    199206    forall(| { T ?<<?(T,T); }) {
    200207    vec2(T) ?<<?(vec2(T) v, T scalar) with (v) {
     
    214221    }
    215222
     223    // >>
    216224    forall(| { T ?>>?(T,T); }) {
    217225    vec2(T) ?>>?(vec2(T) v, T scalar) with (v) {
     
    231239    }
    232240
     241    // ~
    233242    forall(| { T ~?(T); })
    234243    vec2(T) ~?(vec2(T) v) with (v) {
     
    236245    }
    237246
    238     // Relational Operators
     247    // relational
    239248    forall(| equality(T)) {
    240249    bool ?==?(vec2(T) u, vec2(T) v) with (u) {
Note: See TracChangeset for help on using the changeset viewer.