public void TestNull() { var f = new NullConstant(); var res = Util.NullConstant.Compile(f); HasValue(res, null); }
protected override Expression DoResolve(ResolveContext ec) { // // It's null when lifting non-nullable type // if (unwrap == null) { // S -> T? is wrap only if (type.IsNullableType) return Wrap.Create (expr, type); // S -> T can be simplified return expr; } // Wrap target for T? if (type.IsNullableType) { if (!expr.Type.IsNullableType) { expr = Wrap.Create (expr, type); if (expr == null) return null; } null_value = LiftedNull.Create (type, loc); } else if (TypeSpec.IsValueType (type)) { null_value = LiftedNull.Create (type, loc); } else { null_value = new NullConstant (type, loc); } eclass = ExprClass.Value; return this; }
public static void CompileNull(ParserContext parser, ByteBuffer buffer, NullConstant nullConstant, bool outputUsed) { if (!outputUsed) { throw new ParserException(nullConstant, "This expression doesn't do anything."); } buffer.Add(nullConstant.FirstToken, OpCode.LITERAL, parser.GetNullConstant()); }
public void TestNulls() { var a = new NullConstant(); var b = new NullConstant(); Assert.True(a.Equals(b)); Assert.True(b.Equals(a)); Assert.True(a.GetHashCode() == b.GetHashCode()); a.Alias = new Identifier("fasdf"); Assert.False(a.Equals(b)); Assert.False(b.Equals(a)); Assert.False(a.GetHashCode() == b.GetHashCode()); b.Alias = new Identifier("fasdf"); Assert.True(a.Equals(b)); Assert.True(b.Equals(a)); Assert.True(a.GetHashCode() == b.GetHashCode()); var c = new BooleanIsNull(new ColumnRef("col1"), false); var d = (BooleanIsNull)c.Clone(); Assert.True(c.left.Equals(d.left)); }
protected override Expression DoResolve (ResolveContext ec) { // // It's null when lifting non-nullable type // if (unwrap == null) { // S -> T? is wrap only if (type.IsNullableType) return Wrap.Create (expr, type); // S -> T can be simplified return expr; } // Wrap target for T? if (type.IsNullableType) { expr = Wrap.Create (expr, type); if (expr == null) return null; null_value = LiftedNull.Create (type, loc); } else if (TypeManager.IsValueType (type)) { null_value = LiftedNull.Create (type, loc); } else { null_value = new NullConstant (type, loc); } eclass = ExprClass.Value; return this; }
protected abstract void TranslateNullConstant(List <string> output, NullConstant nullConstant);
protected override void TranslateNullConstant(List <string> output, NullConstant nullConstant) { output.Add("null"); }
public void VisitNullConstant(NullConstant nullConstant) { _builder.Append("null"); }