]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Interpreter.cpp
parse scripts
[l2e.git] / src / loader / Interpreter.cpp
index 5da1ff35a194f194606c573be575d797643e5486..8b9b56a2098eb9ae9a6a4002020f4973fdfa6675 100644 (file)
@@ -142,6 +142,8 @@ void Interpreter::ReadLiteral(int typeId, int id, char *object, const Literal &l
                        std::memcpy(object, literal.GetString().c_str(), literal.GetString().size());
                        object[literal.GetString().size()] = '\0';
                        break;
+               case Literal::SCRIPT:
+                       throw Error("script compiler not implemented");
                case Literal::STRING:
                        std::memcpy(object, literal.GetString().c_str(), literal.GetString().size());
                        object[literal.GetString().size()] = '\0';
@@ -151,7 +153,6 @@ void Interpreter::ReadLiteral(int typeId, int id, char *object, const Literal &l
                        break;
                case Literal::OBJECT:
                        throw Error("illogical branch: read literal object as non-object literal");
-                       break;
        }
 }
 
@@ -213,6 +214,8 @@ void *Interpreter::GetObject(int typeId, const Value &v) {
                                                values[typeId].push_back(str);
                                        }
                                        break;
+                               case Literal::SCRIPT:
+                                       throw Error("script compiler not implemented");
                                case Literal::STRING:
                                        {
                                                typeId = TypeDescription::GetTypeId("String");
@@ -295,6 +298,13 @@ void Interpreter::ReadObject(int typeId, int id, char *object, const PropertyLis
                                } else {
                                        throw Error("aggregate type fields must be referenced");
                                }
+                       } else if (i->second->IsLiteral() && !fd.IsReferenced()) {
+                               // inline literals
+                               if (i->second->GetLiteral().IsObject()) {
+                                       ReadObject(fd.TypeId(), -1, dest, *i->second->GetLiteral().GetProperties());
+                               } else {
+                                       ReadLiteral(fd.TypeId(), -1, dest, i->second->GetLiteral());
+                               }
                        } else {
                                char *src(reinterpret_cast<char *>(GetObject(fd.TypeId(), *i->second)));
                                if (fd.TypeId() == TypeDescription::GetTypeId("Image")) {