Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
feat: Add support for typing annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed May 18, 2023
1 parent 1ecae6d commit 50fcb28
Show file tree
Hide file tree
Showing 25 changed files with 602 additions and 433 deletions.
2 changes: 1 addition & 1 deletion .makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ groups:
- target: build.release
args:
build-type: "debug"
extras: "-Ddev=enabled -Db_coverage=true -Doptimization=0" # -Db_sanitize=address
extras: "-Ddev=enabled -Db_coverage=true -Doptimization=0" # -Db_sanitize=address
clean: {{ args.clean }}
asan-options: "fast_unwind_on_malloc=0:verbosity=2:log_threads=1"
lsan-options: "fast_unwind_on_malloc=0:verbosity=2:log_threads=1"
Expand Down
2 changes: 1 addition & 1 deletion conda/pip.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
containers-sugar ==1.5
makim ==1.6.6
makim ==1.6.7
4 changes: 2 additions & 2 deletions examples/average.arx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
function average(x y):
(x + y) * 0.5;
fn average(x: float, y: float) -> float:
return (x + y) * 0.5;
4 changes: 2 additions & 2 deletions examples/constant.arx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
function get_constant(x):
x;
fn get_constant(x: float) -> float:
return x;
6 changes: 3 additions & 3 deletions examples/fibonacci.arx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function fib(x):
fn fib(x: float) -> float:
if x < 3:
1
return 1;
else:
fib(x-1)+fib(x-2)
return fib(x-1)+fib(x-2);
2 changes: 1 addition & 1 deletion examples/print-star.arx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern putchard(char);

function print_star(n):
fn print_star(n: float):
for i = 1, i < n, 1.0 in
putchard(42); # ascii 42 = '*'
2 changes: 1 addition & 1 deletion examples/sum.arx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
function sum(a b):
fn sum(a: float, b: float) -> float:
a + b;
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ project('arx', 'cpp', 'c',
license : 'Apache-2.0',
version : '1.6.0', # semantic-release
default_options : [
'warning_level=everything',
#'warning_level=everything',
'warning_level=1',
'cpp_std=c++20',
]
)
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/ast-to-llvm-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ auto ASTToLLVMIRVisitor::visit(PrototypeAST& expr) -> void {
* but keep a reference to it for use below.
*/
auto ASTToLLVMIRVisitor::visit(FunctionAST& expr) -> void {
auto& P = *(expr.Proto);
ArxLLVM::function_protos[expr.Proto->getName()] = std::move(expr.Proto);
auto& P = *(expr.proto);
ArxLLVM::function_protos[expr.proto->getName()] = std::move(expr.proto);
this->getFunction(P.getName());
llvm::Function* TheFunction = this->result_func;

Expand Down Expand Up @@ -250,9 +250,9 @@ auto ASTToLLVMIRVisitor::visit(FunctionAST& expr) -> void {
ArxLLVM::named_values[std::string(Arg.getName())] = Alloca;
}

this->emitLocation(*expr.Body.get());
this->emitLocation(*expr.body.get());

expr.Body->accept(*this);
expr.body->accept(*this);
llvm::Value* RetVal = this->result_val;

if (RetVal) {
Expand Down
Loading

0 comments on commit 50fcb28

Please sign in to comment.