First stab at operator overloading
When no built-in interpretation is found for one of the operators mentioned below, the typechecker will try to turn it into a method call with the name written next to it. For binary operators, the method will be called on the LHS with the RHS as only parameter. Binary: + op_add - op_sub * op_mul / op_div % op_rem & op_and | op_or ^ op_xor << op_shift_left >> op_shift_right >>> op_ashift_right Unary: - op_neg ! op_not Overloading of the indexing ([]) operator isn't finished yet. Issue #1520
This commit is contained in:
parent
1792d9ec96
commit
87b064b249
10 changed files with 269 additions and 142 deletions
|
@ -326,6 +326,11 @@ fn ident_to_path(s: span, i: ident) -> @path {
|
|||
@respan(s, {global: false, idents: [i], types: []})
|
||||
}
|
||||
|
||||
// Provides an extra node_id to hang callee information on, in case the
|
||||
// operator is deferred to a user-supplied method. The parser is responsible
|
||||
// for reserving this id.
|
||||
fn op_expr_callee_id(e: @expr) -> node_id { e.id - 1 }
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
// fill-column: 78;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue