Giter Club home page Giter Club logo

Comments (6)

kopecs avatar kopecs commented on July 16, 2024 1

I don't think modifying the compiler is the right solution here. I can look at this a bit over break.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on July 16, 2024

This is an expected behavior. Since the project is actually running compiled bc0 bytecodes behind the curtain (you can see it if you open Settings (little gear on bottom) > Advanced Settings > Expose Bytecode

The compiled bytecode does not contain any type information so I'm doing lots of acrobatics to "reconstruct type" from bytecode and their comments.

image

While some information (like field name) is available by parsing through the bytecode file directly (regex match on comment), many information like type of field in struct is not available until we actually execute the aaddf pointer arithmetic command on some pointer. Therefore, all the fields that are not touched yet will be invisible from debug console. (We need type information to interpret the binary content in heap and display it properly on debug console!)

image

(^ This is what heap content looks like under the hood)

This is addressed a little bit, however, by "type reuse" (Settings > Advanced Settings > Experimental - Type Reuse). If you run the code to some intermediate breakpoint and click "Restart", the struct type information (offset, and type of field with that offset) is preserved. In this way, you can see the initial value of fields even before they are touched.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on July 16, 2024

It is possible, however, to directly parse the C0 source code and figure out the type, offset and name of each field in struct. In fact, such tokenizer & parser for C0 already exists right now (the syntax highlighting is based on it). Maybe, MAYBE, I will try to implement something like this in the future.

from c0vm-ts.

kopecs avatar kopecs commented on July 16, 2024

It really sounds like just implementing a tree-walk interpreter (or something else more complex, but that would seem to me to be sufficient) instead of trying to consume bytecode is what needs to be done, at least for the memory diagram relevant featureset.

Even if this is currently the expected behaviour, I would consider this a prerequisite to using this to show examples to students.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on July 16, 2024

Yeah... That makes sense. Or maybe I can ask iliano to dump more type information in the extended bytecode format (not exposed to students) by changing the behavior of cc0 compiler.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on July 16, 2024

I'm trying to fix this problem by searching through the syntax tree of source code and extract the type information of structs.

from c0vm-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.