]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Interpreter.h
new object file format in compiler
[l2e.git] / src / loader / Interpreter.h
index 1a73d2dce69c54591354a2ae09fdd9234d03df91..3e9f661e56ccb53da7f5637315c5b1f5e5b9e1a4 100644 (file)
@@ -59,6 +59,7 @@ public:
        /// Error is thrown if the object is undefined or a cast
        /// was unsuccessful.
        void *GetObject(int typeId, const std::string &name);
+       const void *GetObject(int typeId, const std::string &name) const;
 
        /// Register the type descriptions of builtin types.
        /// This should be called before any interpretation (like
@@ -80,18 +81,21 @@ public:
        /// linked by its identifier.
        struct PostponedDefinition {
                PostponedDefinition(
+                               char *object,
                                char *dest,
-                               const char *identifier,
+                               const std::string &identifier,
                                int type,
                                bool inlined,
                                bool aggregate)
-               : dest(dest)
+               : object(object)
+               , dest(dest)
                , identifier(identifier)
                , type(type)
                , inlined(inlined)
                , aggregate(aggregate) { }
+               char *object;
                char *dest;
-               const char *identifier;
+               std::string identifier;
                int type;
                bool inlined;
                bool aggregate;
@@ -104,6 +108,7 @@ public:
        }
        /// Get the object definition for given identifier.
        const ParsedDefinition &GetDefinition(const std::string &identifier);
+       const ParsedDefinition &GetDefinition(const std::string &identifier) const;
        /// Get all images reference by he source.
        /// The returned map is indexed by filenames relative to
        /// the source file and contains ready-to-blit surfaces.
@@ -119,6 +124,14 @@ public:
        const std::map<int, std::vector<void *> > &Values() const {
                return values;
        }
+       struct Array {
+               void *data;
+               unsigned int size;
+               bool ref;
+       };
+       const std::vector<Array> &Arrays() const {
+               return arrays;
+       }
 
 private:
        /// Interpret given definition.
@@ -169,6 +182,7 @@ private:
        bool CanLink(const Value &) const;
        /// Defer linking of given object reference.
        void Postpone(
+                       char *object,
                        char *dest,
                        const std::string &identifier,
                        int type,
@@ -184,6 +198,7 @@ private:
        std::vector<PostponedDefinition> postponedDefinitions;
        std::map<std::string, SDL_Surface *> imageCache;
        std::map<int, std::vector<void *> > values;
+       std::vector<Array> arrays;
 
 };