Browse Source

this not pointer anymore

Nicolas Winkler 6 năm trước cách đây
mục cha
commit
b104edb8b5
5 tập tin đã thay đổi với 27 bổ sung3 xóa
  1. 5 0
      src/Driver.cpp
  2. 11 0
      src/ErrorReporting.cpp
  3. 9 0
      src/ErrorReporting.h
  4. 1 1
      src/sem/CodeGeneration.cpp
  5. 1 2
      src/sem/Semantic.h

+ 5 - 0
src/Driver.cpp

@@ -72,6 +72,11 @@ Driver::Driver(int argc, char** argv) :
 int Driver::run(void) try
 {
     Printer& printer = Printer::getInstance();
+    if (options.infiles.empty()) {
+        qlow::printError(ErrorCode::NO_INFILES, printer);   
+        return 1;     
+    }
+
 #ifdef DEBUGGING
     printer << "starting parser" << std::endl;
 #endif

+ 11 - 0
src/ErrorReporting.cpp

@@ -46,6 +46,17 @@ namespace qlow
         printer.removeFormatting();
         printer << msg << std::endl;
     }
+
+
+    void printError(ErrorCode ec, Printer& printer) noexcept
+    {
+        static const std::map<ErrorCode, std::string> error = {
+            { ErrorCode::NO_INFILES, "no files were provided" },
+        };
+
+        if (error.find(ec) != error.end())
+            printError(printer, error.at(ec));
+    }
 }
 
 

+ 9 - 0
src/ErrorReporting.h

@@ -6,6 +6,12 @@
 
 namespace qlow
 {
+    enum class ErrorCode
+    {
+        /// no files were given to process
+        NO_INFILES,
+    };
+
     struct CodePosition;
     
     class InternalError;
@@ -20,9 +26,12 @@ namespace qlow
     void reportError(const std::string& message) noexcept;
     void printError(Printer& printer, const std::string& message) noexcept;
     void printError(Printer& printer, const std::string& message, const CodePosition& where) noexcept;
+
+    void printError(ErrorCode ec, Printer& printer) noexcept;
 }
 
 
+
 /*!
  * \brief bison-compatible location struct
  */

+ 1 - 1
src/sem/CodeGeneration.cpp

@@ -273,7 +273,7 @@ void generateObjectFile(const std::string& filename, std::unique_ptr<llvm::Modul
 #endif
     targetMachine->addPassesToEmitFile(pm, dest,
 //        llvm::LLVMTargetMachine::CGFT_ObjectFile,
-//        nullptr,
+        nullptr,
         llvm::TargetMachine::CGFT_ObjectFile);
 
     pm.run(*module);

+ 1 - 2
src/sem/Semantic.h

@@ -190,8 +190,7 @@ struct qlow::sem::ThisExpression : public Variable
     inline ThisExpression(Method* method) :
         Variable{
             method->context,
-            method->context.createPointerType(method->context.createClassType(
-                            method->containingClass)),
+            method->context.createClassType(method->containingClass),
             "this"
         },
         method{ method }