Skip to content

Instantly share code, notes, and snippets.

@mkrueger
Created December 12, 2011 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkrueger/1468424 to your computer and use it in GitHub Desktop.
Save mkrueger/1468424 to your computer and use it in GitHub Desktop.
public override object Visit (Constant constant)
{
if (constant.GetValue () == null)
return new NullReferenceExpression (Convert (constant.Location));
string literalValue;
if (constant is ILiteralConstant) {
literalValue = new string (((ILiteralConstant)constant).ParsedValue);
} else {
literalValue = constant.GetValueAsLiteral ();
}
object val = constant.GetValue ();
if (val is bool)
literalValue = (bool)val ? "true" : "false";
var result = new PrimitiveExpression (val, Convert (constant.Location), literalValue);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment