forked from M-Labs/nac3
added aug assign for primitives
This commit is contained in:
parent
ff41cdb000
commit
007843c1ef
|
@ -17,8 +17,11 @@ fn impl_math(def: &mut TypeDef, ty: &Type) {
|
|||
result: result.clone(),
|
||||
};
|
||||
def.methods.insert("__add__", fun.clone());
|
||||
def.methods.insert("__iadd__", fun.clone());
|
||||
def.methods.insert("__sub__", fun.clone());
|
||||
def.methods.insert("__isub__", fun.clone());
|
||||
def.methods.insert("__mul__", fun.clone());
|
||||
def.methods.insert("__imul__", fun.clone());
|
||||
def.methods.insert(
|
||||
"__neg__",
|
||||
FnDef {
|
||||
|
@ -33,9 +36,21 @@ fn impl_math(def: &mut TypeDef, ty: &Type) {
|
|||
result: Some(PrimitiveType(FLOAT_TYPE).into()),
|
||||
},
|
||||
);
|
||||
if ty.as_ref() == &PrimitiveType(FLOAT_TYPE) {
|
||||
def.methods.insert(
|
||||
"__itruediv__",
|
||||
FnDef {
|
||||
args: vec![ty.clone()],
|
||||
result: Some(PrimitiveType(FLOAT_TYPE).into()),
|
||||
},
|
||||
);
|
||||
}
|
||||
def.methods.insert("__floordiv__", fun.clone());
|
||||
def.methods.insert("__ifloordiv__", fun.clone());
|
||||
def.methods.insert("__mod__", fun.clone());
|
||||
def.methods.insert("__pow__", fun);
|
||||
def.methods.insert("__imod__", fun.clone());
|
||||
def.methods.insert("__pow__", fun.clone());
|
||||
def.methods.insert("__ipow__", fun);
|
||||
}
|
||||
|
||||
fn impl_bits(def: &mut TypeDef, ty: &Type) {
|
||||
|
|
Loading…
Reference in New Issue