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:
Richard Smith
2022-07-31 15:25:10 -07:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 52f80c25ab
commit ef96f60425
22 changed files with 770 additions and 266 deletions
+24
View File
@@ -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;
}