瀏覽代碼

ay better types

Nicolas Winkler 6 年之前
父節點
當前提交
7dddbd52af
共有 4 個文件被更改,包括 16 次插入3 次删除
  1. 13 0
      src/Builtin.cpp
  2. 1 1
      src/CodegenVisitor.cpp
  3. 1 1
      src/sem/Semantic.cpp
  4. 1 1
      src/test.qlw

+ 13 - 0
src/Builtin.cpp

@@ -3,6 +3,10 @@
 #include "Type.h"
 #include "Context.h"
 
+#ifdef DEBUGGING
+#include <llvm/Support/raw_os_ostream.h>
+#endif
+
 using namespace qlow;
 
 
@@ -229,6 +233,15 @@ llvm::Value* qlow::sem::BinaryNativeMethod::generateCode(llvm::IRBuilder<>& buil
 {
     if (arguments.size() != 2)
         throw "invalid binary operation";
+#ifdef DEBUGGING
+    Printer& p = Printer::getInstance();
+    llvm::raw_os_ostream pp(p);
+    p << "creating native binop with llvm-types ";
+    arguments[0]->getType()->print(pp); pp.flush();
+    p << ", ";
+    arguments[1]->getType()->print(pp); pp.flush();
+    p << std::endl;
+#endif
     return generator(builder, arguments[0], arguments[1]);
 }
 

+ 1 - 1
src/CodegenVisitor.cpp

@@ -222,7 +222,7 @@ llvm::Value* ExpressionCodegenVisitor::visit(sem::AddressExpression& node, llvm:
 llvm::Value* ExpressionCodegenVisitor::visit(sem::IntConst& node, llvm::IRBuilder<>& builder)
 {
     return llvm::ConstantInt::get(builder.getContext(),
-        llvm::APInt(32, std::to_string(node.value), 10));
+        llvm::APInt(64, std::to_string(node.value), 10));
 }
 
 

+ 1 - 1
src/sem/Semantic.cpp

@@ -107,7 +107,7 @@ std::pair<std::unique_ptr<Context>, std::unique_ptr<GlobalScope>>
     printf("created all method bodies\n");
 #endif
     
-    return std::make_pair(std::move(context), std::move(globalScope));
+    return { std::move(context), std::move(globalScope) };
 }
 
 }

+ 1 - 1
src/test.qlw

@@ -6,7 +6,7 @@ fast_fibonacci(i: Integer): Integer do
     count := i
     a := 0
     b := 1
-    while count do
+    while count != 0 do
         temp := a
         a := a + b
         b := temp