blueloveTH 2 years ago
parent
commit
5416500642
2 changed files with 4 additions and 7 deletions
  1. 1 5
      src/codeobject.h
  2. 3 2
      src/error.h

+ 1 - 5
src/codeobject.h

@@ -167,7 +167,6 @@ struct CodeObject {
 
     void write(VM* vm, CodeObjectSerializer& ss) const{
         ss.write_begin_mark();          // [
-        ss.write_str(src->source);      // src->source
         ss.write_str(src->filename);    // src->filename
         ss.write_int(src->mode);        // src->mode
         ss.write_end_mark();            // ]
@@ -175,10 +174,7 @@ struct CodeObject {
         ss.write_bool(is_generator);    // is_generator
         ss.write_begin_mark();          // [
             for(Bytecode bc: codes){
-                if(StrName::is_valid(bc.arg)){
-                    // std::cout << bc.arg << StrName(bc.arg).sv() << std::endl;
-                    ss.names.insert(StrName(bc.arg));
-                }
+                if(StrName::is_valid(bc.arg)) ss.names.insert(StrName(bc.arg));
                 ss.write_bytes(bc);
             }
         ss.write_end_mark();            // ]

+ 3 - 2
src/error.h

@@ -43,10 +43,11 @@ struct SourceData {
         int index = 0;
         // Skip utf8 BOM if there is any.
         if (strncmp(source.begin(), "\xEF\xBB\xBF", 3) == 0) index += 3;
-        // Remove all '\r'
+        // Replace all '\r' with ' '
         std::stringstream ss;
         while(index < source.length()){
-            if(source[index] != '\r') ss << source[index];
+            if(source[index] == '\r') ss << ' ';
+            else ss << source[index];
             index++;
         }