diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 7c0e6792fe..f7b825737d 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -1230,6 +1230,8 @@ class SymbolTableVisitor : public CommonVisitor { current_procedure_abi_type = ASR::abiType::BindC; } else if (name == "overload") { overload = true; + } else if (name == "interface") { + // TODO: Implement @interface } else { throw SemanticError("Decorator: " + name + " is not supported", x.base.base.loc); diff --git a/src/runtime/lpython_builtin.py b/src/runtime/lpython_builtin.py index 4f83e81179..ce58b24fce 100644 --- a/src/runtime/lpython_builtin.py +++ b/src/runtime/lpython_builtin.py @@ -148,6 +148,7 @@ def bool(c: c64) -> bool: pass +@interface def len(s: str) -> i32: """ Return the length of the string `s`. @@ -273,32 +274,41 @@ def round(b: bool) -> i32: #: complex() as a generic procedure. #: supported types for arguments: #: (i32, i32), (f64, f64), (i32, f64), (f64, i32) +@interface @overload def complex(x: f64, y: f64) -> c64: pass +@interface @overload def complex(x: i32, y: i32) -> c64: pass +@interface @overload def complex(x: i32, y: f64) -> c64: pass +@interface @overload def complex(x: f64, y: i32) -> c64: pass + +@interface def divmod(x: i32, y: i32) -> tuple[i32, i32]: #: TODO: Implement once we have tuple support in the LLVM backend pass + def lbound(x: i32[:], dim: i32) -> i32: pass + def ubound(x: i32[:], dim: i32) -> i32: pass + @ccall def _lfortran_caimag(x: c32) -> f32: pass diff --git a/src/runtime/ltypes/ltypes.py b/src/runtime/ltypes/ltypes.py index da5fe5ab70..7b8d166bde 100644 --- a/src/runtime/ltypes/ltypes.py +++ b/src/runtime/ltypes/ltypes.py @@ -92,6 +92,11 @@ def overload(f): return overloaded_f +def interface(f): + def inner_func(): + raise Exception("Unexpected to be called by CPython") + return inner_func + # C interoperation support