mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add support for bitwise operators. (#1809)
Following #1191, add initial support for bitwise operators. Support for both integer operations and for operator overloading via the interfaces specified in #1191 is provided. Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
52f80c25ab
commit
ef96f60425
@@ -0,0 +1,24 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// RUN: %{explorer} %s 2>&1 | \
|
||||
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
|
||||
// RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
|
||||
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
|
||||
// AUTOUPDATE: %{explorer} %s
|
||||
// CHECK: result: -6
|
||||
|
||||
package ExplorerTest api;
|
||||
|
||||
class A { var n: i32; }
|
||||
|
||||
external impl A as BitComplement where .Result == A {
|
||||
fn Op[me: Self]() -> A { return {.n = ^me.n}; }
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
var a: A = {.n = 5};
|
||||
a = ^a;
|
||||
return a.n;
|
||||
}
|
||||
Reference in New Issue
Block a user