Skip to content

Newton API specs

hyuglim edited this page Jan 21, 2017 · 10 revisions

Methods

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. The following is the Physicsstruct. `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;

};For more information about the data structures, seenoisy.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.

// SANITY MEHTODS

NewtonIrNode* getAST(); Returns the root NewtonIrNode

Dimension* getAllDimensions(); NoisyState contains a list of all Dimensions. Return the head of that list.

Dimension* getDimensionByName(char * dimensionName); NoisyState contains a list of all Dimensions. Return the element that contains dimensionName as the identifier.

Physics* getAllPhysics(); NoisyState contains a list of all Physicss. Return the head of that list.

Physics* getPhysicsByName(char * physicsName); NoisyState contains a list of all Physicss. Return the element that contains physicsName as the identifier.

A Side Note

NewtonIrNode should have dimension, physics, values, type, source info, .. just reuse NoisyIrNode minus all the scope nodes

For the Newton Standard AST, we will just reuse NoisyIrNode minus all the scope nodes NewtonIrNode should have Dimension, Physics, numeric values, SourceInfo, etc ...

Clone this wiki locally