Please enable JavaScript.
Coggle requires JavaScript to display documents.
Abstract VM (Calculator Class (mathematics (add(), sub(), mul(), div(),…
Abstract VM
-
Operand
IOperand Class
functions
virtual int getPrecision( void ) const = 0; // Precision of the type of the instance
virtual eOperandType getType( void ) const = 0; // Type of the instance
virtual IOperand const operator+( IOperand const & rhs ) const = 0; // Sum
virtual IOperand const operator-( IOperand const & rhs ) const = 0; // Difference
virtual IOperand const operator( IOperand const & rhs ) const = 0; // Product
virtual IOperand const operator/( IOperand const & rhs ) const = 0; // Quotient
virtual IOperand const operator%( IOperand const & rhs ) const = 0; // Modulo
virtual std::string const & toString( void ) const = 0; // String representation of the instance
Operand Class
attributes
precision: 1(char), 2(short), 3(int) , 4(float), 5(double)
-
-
-
-
-
eOperandType enum
Int8, Int16, Int32, Float, Double
OperandFactory Class
IOperand const *createOperand(eOperandType type, std::string const &value) const
-
Lexer Class
-
:bulb:
- declare an array of strings to represent the assembly functions
-
- if no match stop and error
-
E.g:1 Input :book:
1. push int32(42)
2. push int32(33)
3. add
4. push float(44.55)
5. mul
6. push double(42.42)
7. push int32(42)
8. dump
9. pop
10. assert double(42.42)
11. exit
-