104 |
}; |
}; |
105 |
typedef Ref<Args,Node> ArgsRef; |
typedef Ref<Args,Node> ArgsRef; |
106 |
|
|
107 |
class Variable : virtual public Expression { |
class Variable : virtual public VMVariable, virtual public Expression { |
108 |
public: |
public: |
109 |
virtual bool isConstExpr() const { return bConst; } |
bool isConstExpr() const OVERRIDE { return bConst; } |
110 |
|
bool isAssignable() const OVERRIDE { return !bConst; } |
111 |
virtual void assign(Expression* expr) = 0; |
virtual void assign(Expression* expr) = 0; |
112 |
|
void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); } |
113 |
protected: |
protected: |
114 |
Variable(ParserContext* ctx, int _memPos, bool _bConst) |
Variable(ParserContext* ctx, int _memPos, bool _bConst) |
115 |
: context(ctx), memPos(_memPos), bConst(_bConst) {} |
: context(ctx), memPos(_memPos), bConst(_bConst) {} |
322 |
virtual Statements* branch(uint i) const = 0; |
virtual Statements* branch(uint i) const = 0; |
323 |
}; |
}; |
324 |
|
|
325 |
|
class DynamicVariableCall : public Variable, virtual public IntExpr, virtual public StringExpr { |
326 |
|
VMDynVar* dynVar; |
327 |
|
String varName; |
328 |
|
public: |
329 |
|
DynamicVariableCall(const String& name, ParserContext* ctx, VMDynVar* v); |
330 |
|
ExprType_t exprType() const OVERRIDE { return dynVar->exprType(); } |
331 |
|
bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); } |
332 |
|
bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); } |
333 |
|
bool isPolyphonic() const OVERRIDE { return false; } |
334 |
|
void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); } |
335 |
|
int evalInt() OVERRIDE; |
336 |
|
String evalStr() OVERRIDE; |
337 |
|
String evalCastToStr() OVERRIDE; |
338 |
|
void dump(int level = 0) OVERRIDE; |
339 |
|
}; |
340 |
|
typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef; |
341 |
|
|
342 |
class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr { |
class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr { |
343 |
String functionName; |
String functionName; |
344 |
ArgsRef args; |
ArgsRef args; |
537 |
}; |
}; |
538 |
typedef Ref<Or,Node> OrRef; |
typedef Ref<Or,Node> OrRef; |
539 |
|
|
540 |
|
class BitwiseOr : virtual public BinaryOp, virtual public IntExpr { |
541 |
|
public: |
542 |
|
BitwiseOr(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
543 |
|
int evalInt(); |
544 |
|
void dump(int level = 0); |
545 |
|
}; |
546 |
|
typedef Ref<BitwiseOr,Node> BitwiseOrRef; |
547 |
|
|
548 |
class And : virtual public BinaryOp, virtual public IntExpr { |
class And : virtual public BinaryOp, virtual public IntExpr { |
549 |
public: |
public: |
550 |
And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
553 |
}; |
}; |
554 |
typedef Ref<And,Node> AndRef; |
typedef Ref<And,Node> AndRef; |
555 |
|
|
556 |
|
class BitwiseAnd : virtual public BinaryOp, virtual public IntExpr { |
557 |
|
public: |
558 |
|
BitwiseAnd(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
559 |
|
int evalInt(); |
560 |
|
void dump(int level = 0); |
561 |
|
}; |
562 |
|
typedef Ref<BitwiseAnd,Node> BitwiseAndRef; |
563 |
|
|
564 |
class Not : virtual public IntExpr { |
class Not : virtual public IntExpr { |
565 |
IntExprRef expr; |
IntExprRef expr; |
566 |
public: |
public: |
572 |
}; |
}; |
573 |
typedef Ref<Not,Node> NotRef; |
typedef Ref<Not,Node> NotRef; |
574 |
|
|
575 |
|
class BitwiseNot : virtual public IntExpr { |
576 |
|
IntExprRef expr; |
577 |
|
public: |
578 |
|
BitwiseNot(IntExprRef expr) : expr(expr) {} |
579 |
|
int evalInt() { return ~expr->evalInt(); } |
580 |
|
void dump(int level = 0); |
581 |
|
bool isConstExpr() const { return expr->isConstExpr(); } |
582 |
|
bool isPolyphonic() const { return expr->isPolyphonic(); } |
583 |
|
}; |
584 |
|
typedef Ref<BitwiseNot,Node> BitwiseNotRef; |
585 |
|
|
586 |
class ParserContext : public VMParserContext { |
class ParserContext : public VMParserContext { |
587 |
public: |
public: |
588 |
struct Error { |
struct Error { |
632 |
IntVariableRef globalIntVar(const String& name); |
IntVariableRef globalIntVar(const String& name); |
633 |
StringVariableRef globalStrVar(const String& name); |
StringVariableRef globalStrVar(const String& name); |
634 |
VariableRef variableByName(const String& name); |
VariableRef variableByName(const String& name); |
635 |
void addErr(int line, const char* txt); |
void addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt); |
636 |
void addWrn(int line, const char* txt); |
void addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt); |
637 |
void createScanner(std::istream* is); |
void createScanner(std::istream* is); |
638 |
void destroyScanner(); |
void destroyScanner(); |
639 |
bool setPreprocessorCondition(const char* name); |
bool setPreprocessorCondition(const char* name); |
647 |
void registerBuiltInConstIntVariables(const std::map<String,int>& vars); |
void registerBuiltInConstIntVariables(const std::map<String,int>& vars); |
648 |
void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars); |
void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars); |
649 |
void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars); |
void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars); |
650 |
|
void registerBuiltInDynVariables(const std::map<String,VMDynVar*>& vars); |
651 |
}; |
}; |
652 |
|
|
653 |
class ExecContext : public VMExecContext { |
class ExecContext : public VMExecContext { |