Forráskód Böngészése

Merge branch 'types'

Nicolas Winkler 6 éve
szülő
commit
c2669909f7
6 módosított fájl, 44 hozzáadás és 15 törlés
  1. 25 2
      src/CMakeLists.txt
  2. 4 4
      src/CodegenVisitor.cpp
  3. 2 0
      src/ast/AstVisitor.cpp
  4. 1 1
      src/some.qlw
  5. 10 7
      src/util/Path.cpp
  6. 2 1
      src/util/Path.h

+ 25 - 2
src/CMakeLists.txt

@@ -72,10 +72,33 @@ endif()
 #explicit_llvm_config(${PROJECT_NAME} STATIC_LIBRARY)
 llvm_config(${PROJECT_NAME})
 
-llvm_map_components_to_libnames(llvm_libs X86 passes)
+if (${BUILD_STATIC})
+    llvm_map_components_to_libnames(llvm_libs X86 passes)
+#    set(LLVM_LINK_COMPONENTS
+#      BitWriter
+#      BitReader
+#      AsmParser
+#      Analysis
+#      TransformUtils
+#      ScalarOpts
+#      Target
+#      Core
+#      IRReader
+#      Linker
+#      Support
+#      X86Disassembler
+#      X86AsmParser
+#      X86CodeGen
+#      Global
+#    )
+    target_link_libraries(${PROJECT_NAME} ${llvm_libs})
+else()
+    target_link_libraries(${PROJECT_NAME} LLVM)
+endif()
+
 
 #message( ${llvm_libs} )
-target_link_libraries(${PROJECT_NAME} LLVM) # ${llvm_libs})
+target_link_libraries(${PROJECT_NAME} ${llvm_libs})
 
 
 #    MIRParser

+ 4 - 4
src/CodegenVisitor.cpp

@@ -240,10 +240,10 @@ llvm::Value* ExpressionCodegenVisitor::visit(sem::FieldAccessExpression& access,
     llvm::Value* target = access.target->accept(fg.expressionVisitor, builder);
 
     int structIndex = access.accessed->llvmStructIndex;
-    llvm::ArrayRef<Value*> indexList = {
+    /*llvm::ArrayRef<Value*> indexList = {
         llvm::ConstantInt::get(builder.getContext(), llvm::APInt(32, structIndex, false)),
         llvm::ConstantInt::get(builder.getContext(), llvm::APInt(32, 0, false))
-    };
+    };*/
 
     //Value* ptr = builder.CreateGEP(type, target, indexList);
     Value* ptr = fg.builder.CreateStructGEP(type, target, structIndex);
@@ -374,10 +374,10 @@ llvm::Value* LValueVisitor::visit(sem::FieldAccessExpression& access, qlow::gen:
     llvm::Value* target = access.target->accept(fg.expressionVisitor, fg.builder);
     
     int structIndex = access.accessed->llvmStructIndex;
-    llvm::ArrayRef<Value*> indexList = {
+    /*llvm::ArrayRef<Value*> indexList = {
         llvm::ConstantInt::get(fg.builder.getContext(), llvm::APInt(32, structIndex, false)),
         llvm::ConstantInt::get(fg.builder.getContext(), llvm::APInt(32, 0, false))
-    };
+    };*/
     //Value* ptr = fg.builder.CreateGEP(type, target, indexList);
     Value* ptr = fg.builder.CreateStructGEP(type, target, structIndex);
     return ptr;

+ 2 - 0
src/ast/AstVisitor.cpp

@@ -468,7 +468,9 @@ std::unique_ptr<sem::SemanticObject> StructureVisitor::visit(ast::CastExpression
 std::unique_ptr<sem::Expression> StructureVisitor::createImplicitCast(
         std::unique_ptr<sem::Expression> expr, sem::Type* targetType, sem::Scope& scope)
 {
+#ifdef DEBUGGING
     Printer::getInstance() << "casting " << expr->type->asString() << " to " << targetType->asString() << std::endl;
+#endif
     if (expr->type->equals(*targetType))
         return expr;
     auto* exprType = expr->type;

+ 1 - 1
src/some.qlw

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

+ 10 - 7
src/util/Path.cpp

@@ -3,16 +3,18 @@
 using qlow::util::Path;
 
 #ifdef QLOW_TARGET_WINDOWS
-const std::string Path::dirSeparator = "\\";
+const std::string Path::dirSeparators = "\\/";
+const std::string Path::defaultDirSeparator = "\\";
 #else
-const std::string Path::dirSeparator = "/";
+const std::string Path::dirSeparators = "/";
+const std::string Path::defaultDirSeparator = "/";
 #endif
 
 
 void Path::append(const Path& other)
 {
     if (!endsWithSeparator())
-        path += dirSeparator;
+        path += defaultDirSeparator;
     path += other.path;
 }
 
@@ -21,7 +23,7 @@ Path Path::parentPath(void) const
 {
     Path parent = *this;
 
-    if (parent.path == dirSeparator)
+    if (parent.path == defaultDirSeparator)
         return parent;
 
     if (parent.endsWithSeparator()) {
@@ -33,7 +35,7 @@ Path Path::parentPath(void) const
         parent.path.pop_back();
     }
 
-    if (parent.path.size() > dirSeparator.size() && parent.endsWithSeparator())
+    if (parent.path.size() >= 2 && parent.endsWithSeparator())
         parent.path.pop_back();
 
     return parent;
@@ -68,6 +70,7 @@ const char* Path::c_str(void) const
 
 bool Path::endsWithSeparator(void) const
 {
-    return path.size() >= dirSeparator.size() &&
-        std::equal(dirSeparator.rbegin(), dirSeparator.rend(), path.rbegin());
+    return !path.empty() && dirSeparators.find(path[path.size() - 1]) != std::string::npos;
+    /*return path.size() >= dirSeparator.size() &&
+        std::equal(dirSeparator.rbegin(), dirSeparator.rend(), path.rbegin());*/
 }

+ 2 - 1
src/util/Path.h

@@ -14,7 +14,8 @@ class qlow::util::Path
 {
     std::string path;
 
-    static const std::string dirSeparator;
+    static const std::string dirSeparators;
+    static const std::string defaultDirSeparator;
 
 public: