Class Node
An abstract class representing an expression tree node.
Inheritance
Inherited Members
Namespace: SpiceSharpBehavioral.Parsers.Nodes
Assembly: SpiceSharpBehavioral.dll
Syntax
public abstract class Node
Remarks
This framework is loosely based on Linq expressions.
Constructors
Node(NodeTypes, NodeProperties)
Initializes a new instance of the Node class.
Declaration
protected Node(NodeTypes type, NodeProperties properties = NodeProperties.None)
Parameters
Type | Name | Description |
---|---|---|
NodeTypes | type | The type. |
NodeProperties | properties | The properties of the node. |
Fields
One
A constant that represents one. Can be used for simplifications.
Declaration
public static readonly Node One
Field Value
Type | Description |
---|---|
Node |
Two
A constant that represents two. Can be used for simplifications.
Declaration
public static readonly Node Two
Field Value
Type | Description |
---|---|
Node |
Zero
A constant that represents zero. Can be used for simplifications.
Declaration
public static readonly Node Zero
Field Value
Type | Description |
---|---|
Node |
Properties
NodeType
Gets the type of the node.
Declaration
public NodeTypes NodeType { get; }
Property Value
Type | Description |
---|---|
NodeTypes | The type of the node. |
Properties
Gets the properties.
Declaration
public virtual NodeProperties Properties { get; }
Property Value
Type | Description |
---|---|
NodeProperties | The properties. |
Methods
Add(Node, Node)
Creates an addition of two arguments.
Declaration
public static BinaryOperatorNode Add(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode | The node representing the added result. |
And(Node, Node)
Declaration
public static BinaryOperatorNode And(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Conditional(Node, Node, Node)
Creates a conditional value.
Declaration
public static TernaryOperatorNode Conditional(Node condition, Node ifTrue, Node ifFalse)
Parameters
Type | Name | Description |
---|---|---|
Node | condition | The condition that decides what the result should be. |
Node | ifTrue | The value if the condition is true. |
Node | ifFalse | The value if the condition is false. |
Returns
Type | Description |
---|---|
TernaryOperatorNode | The node representing the conditional value. |
Constant(Double)
Creates a constant.
Declaration
public static ConstantNode Constant(double literal)
Parameters
Type | Name | Description |
---|---|---|
System.Double | literal | The value of the constant. |
Returns
Type | Description |
---|---|
ConstantNode | The node representing the constant value. |
Current(String)
Creates a node voltage.
Declaration
public static VariableNode Current(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the node. |
Returns
Type | Description |
---|---|
VariableNode | The node representing the node voltage. |
Divide(Node, Node)
Creates a division of two arguments.
Declaration
public static BinaryOperatorNode Divide(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode | The node representing the divided result. |
Equals(Node, Node)
Declaration
public static BinaryOperatorNode Equals(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Function(String, Node[])
Creates a function call.
Declaration
public static FunctionNode Function(string name, params Node[] arguments)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the function. |
Node[] | arguments | The arguments of the function. |
Returns
Type | Description |
---|---|
FunctionNode | The node representing the function call. |
Function(String, IReadOnlyList<Node>)
Creates a function call.
Declaration
public static FunctionNode Function(string name, IReadOnlyList<Node> arguments)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the function. |
System.Collections.Generic.IReadOnlyList<Node> | arguments | The arguments of the function. |
Returns
Type | Description |
---|---|
FunctionNode | The node representing the function call. |
GreaterThan(Node, Node)
Declaration
public static BinaryOperatorNode GreaterThan(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
GreaterThanOrEqual(Node, Node)
Declaration
public static BinaryOperatorNode GreaterThanOrEqual(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
LessThan(Node, Node)
Declaration
public static BinaryOperatorNode LessThan(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
LessThanOrEqual(Node, Node)
Declaration
public static BinaryOperatorNode LessThanOrEqual(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Minus(Node)
Creates a unary minus operator for an argument.
Declaration
public static UnaryOperatorNode Minus(Node argument)
Parameters
Type | Name | Description |
---|---|---|
Node | argument | The argument. |
Returns
Type | Description |
---|---|
UnaryOperatorNode | The node representing the unary minus result. |
Modulo(Node, Node)
Declaration
public static BinaryOperatorNode Modulo(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Multiply(Node, Node)
Creates a multiplication of two arguments.
Declaration
public static BinaryOperatorNode Multiply(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode | The node representing the multiplied result. |
Not(Node)
Creates a unary bang (!) operator for an argument.
Declaration
public static UnaryOperatorNode Not(Node argument)
Parameters
Type | Name | Description |
---|---|---|
Node | argument | The argument. |
Returns
Type | Description |
---|---|
UnaryOperatorNode | The node representing the unary bang result. |
NotEquals(Node, Node)
Declaration
public static BinaryOperatorNode NotEquals(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Or(Node, Node)
Declaration
public static BinaryOperatorNode Or(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Plus(Node)
Creates a unary plus operator for an argument.
Declaration
public static UnaryOperatorNode Plus(Node argument)
Parameters
Type | Name | Description |
---|---|---|
Node | argument | The argument. |
Returns
Type | Description |
---|---|
UnaryOperatorNode | The node representing the unary plus result. |
Power(Node, Node)
Declaration
public static BinaryOperatorNode Power(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode |
Property(String, String)
Creates a node that returns the property of a behavior.
Declaration
public static PropertyNode Property(string name, string property)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the entity or behavior. |
System.String | property | The name of the property. |
Returns
Type | Description |
---|---|
PropertyNode | The node representing the property value. |
Subtract(Node, Node)
Creates a subtraction of two arguments.
Declaration
public static BinaryOperatorNode Subtract(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left argument. |
Node | right | The right argument. |
Returns
Type | Description |
---|---|
BinaryOperatorNode | The node representing the subtracted result. |
Variable(String)
Creates a variable.
Declaration
public static VariableNode Variable(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the variable. |
Returns
Type | Description |
---|---|
VariableNode | The node representing the variable. |
Voltage(String)
Creates a node voltage.
Declaration
public static VariableNode Voltage(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the node. |
Returns
Type | Description |
---|---|
VariableNode | The node representing the node voltage. |
Voltage(String, String)
Creates a node voltage.
Declaration
public static BinaryOperatorNode Voltage(string name, string reference)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the node. |
System.String | reference | The name of the reference node. |
Returns
Type | Description |
---|---|
BinaryOperatorNode | The node representing the node voltage. |
Operators
Addition(Node, Node)
Implements the operator +.
Declaration
public static Node operator +(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left. |
Node | right | The right. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |
Division(Node, Node)
Implements the operator /.
Declaration
public static Node operator /(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left. |
Node | right | The right. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |
Implicit(Double to Node)
Performs an implicit conversion from System.Double to Node.
Declaration
public static implicit operator Node(double literal)
Parameters
Type | Name | Description |
---|---|---|
System.Double | literal | The literal. |
Returns
Type | Description |
---|---|
Node | The result of the conversion. |
Modulus(Node, Node)
Implements the operator %.
Declaration
public static Node operator %(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left. |
Node | right | The right. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |
Multiply(Node, Node)
Implements the operator *.
Declaration
public static Node operator *(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left. |
Node | right | The right. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |
Subtraction(Node, Node)
Implements the operator -.
Declaration
public static Node operator -(Node left, Node right)
Parameters
Type | Name | Description |
---|---|---|
Node | left | The left. |
Node | right | The right. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |
UnaryNegation(Node)
Implements the operator -.
Declaration
public static Node operator -(Node arg)
Parameters
Type | Name | Description |
---|---|---|
Node | arg | The argument. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |
UnaryPlus(Node)
Implements the operator +.
Declaration
public static Node operator +(Node arg)
Parameters
Type | Name | Description |
---|---|---|
Node | arg | The argument. |
Returns
Type | Description |
---|---|
Node | The result of the operator. |