void initModel(_md) { /* initialize vectors */ initVect(preds_m, Pred); initVect(funcs_m, Func); initVect(axioms_m, Axiom); initVect(taskPtrs_m, Task*); initVect(tmpFacts_m, Fact); initVect(restrs_m, Restriction); initVect(types_m, DataType); /* create standart datatypes */ addDataType("Boolean", modelPtr); addDataType("Integer", modelPtr); addDataType("Real", modelPtr); /* CONST_TRUE, CONST_FALSE */ //~ DataType* boolPtr = ptr(DataType, types_m) + DT_BOOL; DataType* boolPtr = getTypePtr(DT_BOOL); addBack(boolPtr->constNames, char*, getDynamicStr("True")); addBack(boolPtr->constNames, char*, getDynamicStr("False")); /* create arithmetic fuctions */ size_t funcNum; DataTypeId paramTypes[] = {DT_INT, DT_INT}; for (funcNum = 0; funcNum < ARITHMETIC_FUNCTION_COUNT; ++funcNum) { Func func = createFunc( (char*)ARITH_FUNCTION_NAMES[funcNum], ARITH_FUNCTION_PAR_COUNTS[funcNum], paramTypes, DT_REAL); addFunc(func, modelPtr); } /* create arithmetic relations */ size_t predNum; for (predNum = 0; predNum < ARITHMETIC_RELATIONS_COUNT; ++predNum) { Pred pred = createFunc( (char*)ARITH_RELATION_NAMES[predNum], ARITH_RELATION_PAR_COUNTS[predNum], paramTypes, DT_BOOL); addPred(pred, modelPtr); } /* other initialization */ initVect(modelPtr->errors, Error); initVect(modelPtr->sources, Source); modelPtr->currSrcPtr = NULL; modelPtr->totalFactCt = 0; modelPtr->debugStream = modelPtr->errorStream = NULL; }
Task* createTask(Axiom* axPtr, supp* varValues) { Task* taskPtr = (Task*)malloc(sizeof(Task)); taskPtr->axPtr = axPtr; taskPtr->lastItNum = axPtr->mainCt; taskPtr->resultPtr = createExprResult(varValues, axPtr->vars.len, MD_NORMAL); initVect(taskPtr->tmpFacts, Fact); return taskPtr; }
Func createFunc(const char name[], size_t parCt, DataTypeId parTypes[], DataTypeId dataType) { Func func; func.name = getDynamicStr(name); func.parCt = parCt; func.oldFactId = 0; func.parTypes = (DataTypeId*) malloc(sizeof(DataTypeId) * parCt); memcpy(func.parTypes, parTypes, sizeof(DataTypeId) * parCt); func.dataType = dataType; initVect(func.data, supp); initVect(func.waitList, Task*); return func; }
int main(int argc, char** argv) { initVect(120,40); /* * Building level */ initLander(); addLine(createLine(0,20,10,25)); addLine(createLine(10,24,17,29)); addLine(createLine(17,29,23,35)); platform1 = addLine(createLine(22,35,32,35)); // <- first platform addLine(createLine(32,34,40,30)); line1 = addLine(createLine(40,30,43,20)); addLine(createLine(43,20,48,15)); line3 = addLine(createLine(48,15,58,20)); addLine(createLine(57,20,75,18)); line2 = addLine(createLine(75,18,85,26)); platform2 = addLine(createLine(84,26,94,26)); // <- second platform addLine(createLine(94,25,105,15)); addLine(createLine(105,14,120,11)); addText(createText("3X Score",24,36)); addText(createText("2X Score",86,27)); addText(createText("SCORE: ",1,1)); addText(createText("FUEL: ",2,2)); score = addText(createText("0",7,1)); fuel = addText(createText("1000",7,2)); mainLoop(); return 0; }
void initRestriction(Restriction* restrPtr) { restrPtr->root = NULL; initVect(restrPtr->vars, Variable); }