/* ASCEND modelling environment
Copyright (C) 2006 Carnegie Mellon University
Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
* 5 phase Algorithm (approximately. here we ignore failure modes): * Phase 1 * level * 1 get type * 1 create sim inst * 1 call real_instantiate_1 * 2 call instantiate_model_1 * 3 steal and return universal instance of type, or * 3 create model instance head * 3 process pending instances of model * 4 recursive instantiate, marking rels. logrels and whens done * in arrays/bitlists without actually doing them. * 4 if no pendings, * 4 else error message about parts missing, * and constants undefined. * ...return all the way up eventually. * Go back and mark all relation statements undone, put insts pending * Phase 2 * 1 call real_instantiate_2 * 2 call instantiate_model_2 * 3 process pending instances of model * 4 recursive instantiate, doing rels only and * marking logrels and whens as done. * Explain failed relations. * 4 All statements are now determinate, * All variables must be findable or they can't be. * ...return all the way up eventually. * Go back and mark all logrelation statements undone, put insts pending * Phase 3 * 1 call real_instantiate_3 * 2 call instantiate_model_3 * 3 process pending instances of model * 4 recursive instantiate, doing logrels only and * marking whens as done. In phase 3 there are * more than 1 iteration for the instantiation of * logrels, since logrels can reference logrels * (logrels inside conditional statements). * Explain failed logrelations. * 4 All logical variables and referenced rels and * logrels must be findable or they can't be. * ...return all the way up eventually. * Go back and mark all when statements undone, put insts pending * Phase 4 * 1 call real_instantiate_4 * 2 call instantiate_model_4 * 3 process pending instances of model * 4 recursive instantiate, doing whens only. * Explain failed whens. * 4 All conditional variables, rels or logrels * referenced by the whens must be findable or * they can't be * ...return all the way up eventually. * * DS: Added new Phase for LINK statements that need the final instances in order to be consistent * Phase 6 * 1 call real_instantiate_5 * 2 call instantiate_model_5 * 3 process pending instances of model * 4 recursive instantiate, doing LINKs only * * Phase 5 * Execution of default statements. (we would like to delete phase 5). * Phase 6 * Execute defmethod. **/ ASC_DLLSPEC void NewReInstantiate(struct Instance *i); /**< * This routine is used to resume execution of an instance with unexecuted * statements. It will reattempt to execute the unexecuted statement. * If it is able to complete the instance, it will execute the DEFAULT * assignments(assignments to reals and booleans). */ #if 0 && defined(DISUSED) ASC_DLLSPEC void UpdateInstance(struct Instance *root, struct Instance *target, CONST struct StatementList *slist); /**< * Update instance takes a pointer to the root of a simulation (ie the * instance tree), and will find instance target. It will then apply * the statementlist to the given to the target instance. * This is the start of some experimental encapsulation/parameterization * schemes. */ #endif #if 0 && defined(DISUSED) extern struct Instance *InstantiatePatch(symchar *patch, symchar *name, int intset); /**< * Instantiate patch takes the name of a patch that is supposed to be * applied to a type. It partially instantiates the instance, then * applies the patch. It returns the instance created. It uses * UpdateInstance to do the real work. The applicability of the patch is * hence determined by what that function supports. */ #endif extern void ConfigureInstFromArgs(struct Instance *inst, CONST struct Instance *arginst); /**< * inst and arginst must be of the same MODEL type. * inst should have NO executed statements -- it should be fresh * from CreateModelInstance. * Neither inst nor arginst should have any parents yet, if ever. * This function copies or references, depending on how declared * in the parameter list of the type for both models, the non-NULL * children of arginst into inst. */ extern void ReConfigureInstFromArgs(struct Instance *inst, CONST struct Instance *arginst); /**< * inst and arginst must be or are about to be of the same MODEL type. * inst should have been created from a less refined version of the type * and is in the process of being refined up to type of arginst. * arginst should not have any parents. * This function copies or references, depending on how declared * in the parameter list of the type for both models, the non-NULL * children of arginst into inst for the slots in inst that are not * already occupied. */ extern void LinkToParentByPos(struct Instance *parent, struct Instance *child, unsigned long childnum); /**< * Add child as childnumth child of parent and add parent to child. */ extern int IncompleteArray(CONST struct Instance *i); /**< * Given an array instance i, returns 1 if incomplete, 0 if ok. * This means all NONNULL children are done, with the possible * exception of arrays of relations/logical_relations. */ /* @} */ #endif /* ASC_INSTANTIATE_H */