/* * MathPlanner 3.0 - Mathematical design tool. * Copyright(C) 2002 Jarmo Nikkanen * * 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. * * You should have received a copy of the GNU General Public License with this program. * */ // Integer type and Integer Server #include #include #include "MathHeaders.h" #include "ServerHeaders.h" #include "Error.h" #include "Header.h" #include "ListOfGreekAlphabets.h" #include int_server::int_server() { position=0; space=MAX_INTEGERS; last_used=0; DeleteAllIntegers(); zero.mpl.m.R=0; zero.mpl.m.I=0; zero.mpl.m.J=0; zero.mpl.m.K=0; zero.type=MN_REAL; pii.mpl.m.R=PI; pii.type=MN_REAL; } void int_server::SetLocalValues(class m_function_object *lo) { int i,no; for (i=0;i<=last_used;i++) { if (integer[i].local==lo && integer[i].used) { no=GetIntegerNo(integer[i].name,NULL); if (no<0) integer[i].value=zero; else integer[i].value=integer[no].value; } } } void int_server::Protect(int no) { stack_integer_no[position]=no; if (no!=(-1)) stack_integer_value[position]=integer[no].value; position++; if (position>=space) ErrorReport("integer_server::Protect()","Stack overload"); } void int_server::UnProtect() { int no; position--; no=stack_integer_no[position]; if (no!=(-1)) integer[no].value=stack_integer_value[position]; if (position<0) ErrorReport("integer_server::UnProtect()","Stack size is negative"); } math_node *int_server::FindInteger(QString name,class m_function_object *lo) { int i,no=(-1); for(i=0;i<=last_used;i++) { if (integer[i].used && integer[i].local==lo) { if (integer[i].name.compare(name)==0) return(&integer[i].value); } } no=AddInteger(name,zero,lo); if (no<0) return(NULL); return(&integer[no].value); } int int_server::AddInteger(QString name,math_node value,class m_function_object *lo) { int no=last_used; if (no(-1)) return(integer[no].value); return(zero); }