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) {} |
150 |
VMIntRelPtr* ptr; |
VMIntRelPtr* ptr; |
151 |
public: |
public: |
152 |
BuiltInIntVariable(const String& name, VMIntRelPtr* ptr); |
BuiltInIntVariable(const String& name, VMIntRelPtr* ptr); |
153 |
|
bool isAssignable() const OVERRIDE { return !ptr->readonly; } |
154 |
void assign(Expression* expr); |
void assign(Expression* expr); |
155 |
int evalInt(); |
int evalInt(); |
156 |
void dump(int level = 0); |
void dump(int level = 0); |
323 |
virtual Statements* branch(uint i) const = 0; |
virtual Statements* branch(uint i) const = 0; |
324 |
}; |
}; |
325 |
|
|
326 |
|
class DynamicVariableCall : public Variable, virtual public IntExpr, virtual public StringExpr { |
327 |
|
VMDynVar* dynVar; |
328 |
|
String varName; |
329 |
|
public: |
330 |
|
DynamicVariableCall(const String& name, ParserContext* ctx, VMDynVar* v); |
331 |
|
ExprType_t exprType() const OVERRIDE { return dynVar->exprType(); } |
332 |
|
bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); } |
333 |
|
bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); } |
334 |
|
bool isPolyphonic() const OVERRIDE { return false; } |
335 |
|
void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); } |
336 |
|
int evalInt() OVERRIDE; |
337 |
|
String evalStr() OVERRIDE; |
338 |
|
String evalCastToStr() OVERRIDE; |
339 |
|
void dump(int level = 0) OVERRIDE; |
340 |
|
}; |
341 |
|
typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef; |
342 |
|
|
343 |
class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr { |
class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr { |
344 |
String functionName; |
String functionName; |
345 |
ArgsRef args; |
ArgsRef args; |
538 |
}; |
}; |
539 |
typedef Ref<Or,Node> OrRef; |
typedef Ref<Or,Node> OrRef; |
540 |
|
|
541 |
|
class BitwiseOr : virtual public BinaryOp, virtual public IntExpr { |
542 |
|
public: |
543 |
|
BitwiseOr(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
544 |
|
int evalInt(); |
545 |
|
void dump(int level = 0); |
546 |
|
}; |
547 |
|
typedef Ref<BitwiseOr,Node> BitwiseOrRef; |
548 |
|
|
549 |
class And : virtual public BinaryOp, virtual public IntExpr { |
class And : virtual public BinaryOp, virtual public IntExpr { |
550 |
public: |
public: |
551 |
And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
554 |
}; |
}; |
555 |
typedef Ref<And,Node> AndRef; |
typedef Ref<And,Node> AndRef; |
556 |
|
|
557 |
|
class BitwiseAnd : virtual public BinaryOp, virtual public IntExpr { |
558 |
|
public: |
559 |
|
BitwiseAnd(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {} |
560 |
|
int evalInt(); |
561 |
|
void dump(int level = 0); |
562 |
|
}; |
563 |
|
typedef Ref<BitwiseAnd,Node> BitwiseAndRef; |
564 |
|
|
565 |
class Not : virtual public IntExpr { |
class Not : virtual public IntExpr { |
566 |
IntExprRef expr; |
IntExprRef expr; |
567 |
public: |
public: |
573 |
}; |
}; |
574 |
typedef Ref<Not,Node> NotRef; |
typedef Ref<Not,Node> NotRef; |
575 |
|
|
576 |
|
class BitwiseNot : virtual public IntExpr { |
577 |
|
IntExprRef expr; |
578 |
|
public: |
579 |
|
BitwiseNot(IntExprRef expr) : expr(expr) {} |
580 |
|
int evalInt() { return ~expr->evalInt(); } |
581 |
|
void dump(int level = 0); |
582 |
|
bool isConstExpr() const { return expr->isConstExpr(); } |
583 |
|
bool isPolyphonic() const { return expr->isPolyphonic(); } |
584 |
|
}; |
585 |
|
typedef Ref<BitwiseNot,Node> BitwiseNotRef; |
586 |
|
|
587 |
class ParserContext : public VMParserContext { |
class ParserContext : public VMParserContext { |
588 |
public: |
public: |
589 |
struct Error { |
struct Error { |
633 |
IntVariableRef globalIntVar(const String& name); |
IntVariableRef globalIntVar(const String& name); |
634 |
StringVariableRef globalStrVar(const String& name); |
StringVariableRef globalStrVar(const String& name); |
635 |
VariableRef variableByName(const String& name); |
VariableRef variableByName(const String& name); |
636 |
void addErr(int line, const char* txt); |
void addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt); |
637 |
void addWrn(int line, const char* txt); |
void addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt); |
638 |
void createScanner(std::istream* is); |
void createScanner(std::istream* is); |
639 |
void destroyScanner(); |
void destroyScanner(); |
640 |
bool setPreprocessorCondition(const char* name); |
bool setPreprocessorCondition(const char* name); |
648 |
void registerBuiltInConstIntVariables(const std::map<String,int>& vars); |
void registerBuiltInConstIntVariables(const std::map<String,int>& vars); |
649 |
void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars); |
void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars); |
650 |
void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars); |
void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars); |
651 |
|
void registerBuiltInDynVariables(const std::map<String,VMDynVar*>& vars); |
652 |
}; |
}; |
653 |
|
|
654 |
class ExecContext : public VMExecContext { |
class ExecContext : public VMExecContext { |