Fixed: prevent recursive const definitions and assert for actual constancy.

This commit is contained in:
arookas 2015-12-28 14:31:51 -05:00
parent 54bd3618e3
commit 814282fa0d

View file

@ -74,6 +74,13 @@
: base(location) { }
public override void Compile(sunContext context) {
// analyze the expression first. this does two things:
// 1) prevents recursion (i.e. the const referencing itself)
// 2) asserts actual constness
var flags = Expression.Analyze(context);
if (flags.HasFlag(sunExpressionFlags.Dynamic)) {
throw new sunConstantExpressionException(Expression);
}
context.DeclareConstant(Constant, Expression);
}
}