blob: 2328c28792060929a3b1529b1d3579ffc3782832 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package com.seaofnodes.simple.node;
import com.seaofnodes.simple.type.*;
import com.seaofnodes.simple.util.Utils;
public class NotNode extends Node {
public NotNode(Node in) { super(null, in); }
@Override public Tag serialTag() { return Tag.Not; }
@Override protected String format() { return "(!%1)"; }
@Override
public TypeInteger compute() {
Type t0 = in(1)._type;
if( t0.isHigh() ) return (TypeInteger)TypeInteger.BOOL.dual();
if( t0 == Type.NIL || t0 == TypeInteger.ZERO ) return TypeInteger.TRUE;
if( t0 instanceof TypeNil tn && tn.notNull() ) return TypeInteger.FALSE;
if( t0 instanceof TypeInteger i && (i._min > 0 || i._max < 0) ) return TypeInteger.FALSE;
return TypeInteger.BOOL;
}
@Override
public Node idealize() { return null; }
}
|