stack-based

How would I go about Implementing A Simple Stack-Based Programming Language

走远了吗. 提交于 2020-01-11 18:33:51
问题 I am interested in extending my knowledge of computer programming by implementing a stack-based programming language. I am seeking out advice on where to begin, as I intend for it to have functions like " pushint 1 " which would push an integer with value 1 on to the top of the stack and flow-control via labels like " L01: jump L01: ". So far I have made a C# implementation of what I want my language to act like (wanted to link to it but IDEOne is blocked), but it is very messy and needs

I need C++ array class template, which is fixed-size, stack-based and doesn't require default constructor

不打扰是莪最后的温柔 提交于 2020-01-03 02:31:09
问题 So, I've been looking at boost::array but it does require default constructor defined. I think the best way of filling this array with data, would be through a push_back(const T&) method. Calling it more times than SIZE (known at compile-time) would result in assert or exception, depending on build configuration. This way it would always contain meaningful data. Does anyone know efficient, portable, reliable implementation of this concept? 回答1: Well, I would have thought that someone would

Stack cookie instrumentation code detected a stack-based buffer overrun - Fixed

元气小坏坏 提交于 2019-12-23 12:26:09
问题 so I am having a few issues with this program used to pixelate an image. One issue is that I get a "Stack around the variable 'pixArray' was corrupted" and then, when I click continue after breaking it gives the error in the title. I'm not sure if it is acceptable to use pastebin, but I'll use it for the sake of having a "short" post. The Code The Image Being Used Also, when it runs through, all of the pixelated squares are one pixel too short on the left and top of the squares. It is just

.NET MSIL: How commands detect size of operands?

試著忘記壹切 提交于 2019-12-12 04:41:42
问题 There is a single add command in MSIL to add two arguments (pop from stack, add, push into stack). How does it know whether it has to pop 2 bytes or 4 or 8 bytes? In java different bytecodes (fadd, dadd, iadd, ...) but how do they handle this in .NET? 回答1: Java bytecode was optimized to be executed by an interpreter, early JVMs did not have Hotspot yet. .NET msil was designed from day one to always be jitted, no special opcodes for different operand types were necessary. The jitter knows the

something like stackbased objects in c++ for javascript

◇◆丶佛笑我妖孽 提交于 2019-12-07 05:53:59
问题 Looking for a construct in javascript which works like the destructor in stackbased or local object in c++, e.g. #include <stdio.h> class M { public: int cnt; M() {cnt=0;} void inc() {cnt++;} ~M() {printf ("Count is %d\n", cnt);} }; ... {M m; ... m.inc (); ... m.inc (); } // here the destructor of m will printf "Count is 2"); so this means I am looking for a construct which does an action when its scope is ending (when it "goes out of scope"). It should be robust in the way that it does not

something like stackbased objects in c++ for javascript

自作多情 提交于 2019-12-05 09:15:01
Looking for a construct in javascript which works like the destructor in stackbased or local object in c++, e.g. #include <stdio.h> class M { public: int cnt; M() {cnt=0;} void inc() {cnt++;} ~M() {printf ("Count is %d\n", cnt);} }; ... {M m; ... m.inc (); ... m.inc (); } // here the destructor of m will printf "Count is 2"); so this means I am looking for a construct which does an action when its scope is ending (when it "goes out of scope"). It should be robust in the way that it does not need special action at end of scope, like that destructor in c++ does (used for wrapping mutex-alloc and

registers vs stacks

廉价感情. 提交于 2019-12-03 00:16:36
问题 What exactly are the advantages and disadvantages to using a register-based virtual machine versus using a stack-based virtual machine? To me, it would seem as though a register based machine would be more straight-forward to program and more efficient. So why is it that the JVM, the CLR, and the Python VM are all stack-based? 回答1: This has already been answered, to a certain level, in the Parrot VM's FAQ and associated documents: A Parrot Overview The relevant text from that doc is this: the

How would I go about Implementing A Simple Stack-Based Programming Language

痞子三分冷 提交于 2019-12-02 19:44:20
I am interested in extending my knowledge of computer programming by implementing a stack-based programming language. I am seeking out advice on where to begin, as I intend for it to have functions like " pushint 1 " which would push an integer with value 1 on to the top of the stack and flow-control via labels like " L01: jump L01: ". So far I have made a C# implementation of what I want my language to act like (wanted to link to it but IDEOne is blocked), but it is very messy and needs optimization. It translates the input to XML and then parses it. My goals are to go to a lower level

registers vs stacks

天大地大妈咪最大 提交于 2019-12-02 14:00:50
What exactly are the advantages and disadvantages to using a register-based virtual machine versus using a stack-based virtual machine? To me, it would seem as though a register based machine would be more straight-forward to program and more efficient. So why is it that the JVM, the CLR, and the Python VM are all stack-based? This has already been answered, to a certain level, in the Parrot VM's FAQ and associated documents: A Parrot Overview The relevant text from that doc is this: the Parrot VM will have a register architecture, rather than a stack architecture. It will also have extremely