public void ExpressionVarNotFound() { var m = new Module(null); m.Block.Declarations.Add(new Declaration("a", m.Block.LookupType("BOOLEAN"))); var var = VariableReferenceExpression.Create(m.Block.LookupVar("b"), null); Assert.Null(var); }
public override void ExitExprSingleId(OberonGrammarParser.ExprSingleIdContext context) { var decl = _parser.currentBlock.LookupVar(context.id.Text); if (decl == null) { _parser.NotifyErrorListeners(context.id, "Unknown identifier: " + context.id.Text, null); context.expReturn = ConstantIntExpression.Zero; return; } context.expReturn = VariableReferenceExpression.Create(decl, context.s.vsRet); }
public void ExpressionNot2() { var m = new Module(null); m.Block.Declarations.Add(new Declaration("a", m.Block.LookupType("BOOLEAN"))); var e = BinaryExpression.Create( OberonGrammarLexer.NOT, VariableReferenceExpression.Create(m.Block.LookupVar("a"), null), null, m.Block); var result = ConstantSolver.Solve(e, m.Block) as BinaryExpression; Assert.NotNull(result); }
public void ExpressionRelVar() { var m = new Module(null); m.Block.Declarations.Add(new Declaration("a", m.Block.LookupType("INTEGER"))); var e = BinaryExpression.Create( OberonGrammarLexer.NOTEQUAL, VariableReferenceExpression.Create(m.Block.LookupVar("a"), null), ConstantExpression.Create(10), m.Block); var result = ConstantSolver.Solve(e, m.Block) as BinaryExpression; Assert.NotNull(result); Assert.False(result.IsConst); }