-
Notifications
You must be signed in to change notification settings - Fork 1
Newton API specs
The following will go into the header file for Newton API.
The caller of the API should call getPhysics
whenever an unknown type is detected and fill in
Physics
field of NewtonIrNode
with the returned value.
The caller should also call checkSingleConstraint
at appropriate times.
The Report
struct will contain the results of this call.
// COMPILE OR RUN TIME METHODS
Physics* getPhysics(char* physicsIdentifierString);
This method returns a Physics struct given the name of that Physics type.
What it does: NoisyState
contains a list of Physics
nodes that are identifiable by the name of that Physics
node and a prime number. This method simply iterates through that list and returns the Physics node with physicsIdentifierString.
For more information about the data structures, see noisy.h
Report* checkSingleConstraint(NewtonIrNode* subtreeRoot);
Note that Report
struct does not yet exist in the master branch. NewtonIrNode
is structurally equivalent to NoisyIrNode
, and as of 1/21/17, we use NoisyIrNode for both Noisy and Newton.
subtreeRoot
passed in is a representation of a host language program. Thus all that needs to be done is perform type checking on that subtree.
NewtonIrNode* getAST();
Returns the root NewtonIrNode
Dimension* getAllDimensions();
NoisyState
contains a list of all Dimension
s. Return the head of that list.
Dimension* getDimensionByName(char * dimensionName);
NoisyState
contains a list of all Dimension
s. Return the element that contains dimensionName
as the identifier.
Physics* getAllPhysics();
NoisyState
contains a list of all Physics
s. Return the head of that list.
Physics* getPhysicsByName(char * physicsName);
NoisyState
contains a list of all Physics
s. Return the element that contains physicsName
as the identifier.
The following are some of the data structures included in noisy.h
`struct Physics
{
char * identifier; // name of the physics quantity. of type kNoisyConfigType_Tidentifier
NoisyScope * scope;
NoisySourceInfo * sourceInfo;
bool isVector;
Physics * vectorCounterpart; // non-NULL if a scalar AND counterpart defined in vectorScalarPairScope
Physics * scalarCounterpart; // non-NULl if a vector AND counterpart defined in vectorScalarPairScope
Dimension * numeratorDimensions;
int numberOfNumerators;
int numeratorPrimeProduct;
Dimension * denominatorDimensions;
int numberOfDenominators;
int denominatorPrimeProduct;
char * dimensionAlias;
Physics * definition;
Physics * next;
};`
`struct NoisyIrNode { NoisyIrNodeType type; Physics * physicsType;
/*
* Syntactic (AST) information.
*/
char * tokenString;
NoisyToken * token;
NoisySourceInfo * sourceInfo;
NoisyIrNode * irParent;
NoisyIrNode * irLeftChild;
NoisyIrNode * irRightChild;
NoisySymbol * symbol;
/*
* Used for evaluating dimensions in expressions
*/
Physics * physics;
/*
* Used for returning integral list from noisyConfigParseIntegralList
*/
IntegralList * vectorIntegralList;
IntegralList * scalarIntegralList;
/*
* Used for coloring the IR tree, e.g., during Graphviz/dot generation
*/
NoisyIrNodeColor nodeColor;
}; `
NewtonIrNode
should have
dimension, physics, values, type, source info, ..
just reuse NoisyIrNode
minus all the scope nodes.
Newton API as of now will support only the following:
- 4 basic arithmetic operations and exponents
- decimals and integers
- strings
- statements and expressions of scalars and dimensions
which means the following (from Noisy
) are not supported
- channels and channel operations
- namegens
- matchseq, iter, and other control flow operations
For the Newton Standard AST, we will just reuse NoisyIrNode
minus all the scope nodes
NewtonIrNode
should have Dimension
, Physics
, numeric values, SourceInfo
, etc ...