Changeset c012463 in git


Ignore:
Timestamp:
Jun 15, 2005, 11:38:16 AM (18 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
04f6a4e219c5180c44ff638afd7e63cc8ffa3699
Parents:
d0eb8c62a0f20ffc02130a688aabd569d1ac4430
Message:
*bricken: scope fixes, refactoring


git-svn-id: file:///usr/local/Singular/svn/trunk@8368 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
modules/openmathserver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/binding.py

    rd0eb8c rc012463  
    1 from objects import OMobject, OMsymbol
     1from objects import OMObjectBase, OMsymbol
    22from cd import *
    33from omexceptions import *
    44from itertools import izip
     5from copy import copy
    56cdFns1=OMcd("fns1")
    67lambdasym=OMsymbol("lambda",cdFns1)
     
    910    return lambdasym==sym
    1011   
    11 class OMbinding(OMobject):
     12class OMbinding(OMObjectBase):
     13    """hopefully fixed possible problems: reevaluation writes new scope, if it isn't
     14       meant so, references do not work correctly because of scopes
     15       solve this by first evaluation to bounded OMbinding"""
    1216    def __init__(self, binder,variables,block):
    1317        super(OMbinding,self).__init__()
     
    1519        self.binder=binder
    1620        self.variables=variables
     21        self.bounded=False
    1722    def evaluate(self,context):
    1823        assert islambda(self.binder)
    19         self.scope=context.scopeFromCurrentScope()
    20         return self
     24        if not self.bounded:
     25            mycopy=copy(self)
     26            mycopy.scope=context.scopeFromCurrentScope()
     27            mycopy.bounded=True
     28            return mycopy
     29        else:
     30            return self
    2131    def bind(self, args):
    2232        #print args, self.variables
  • modules/openmathserver/context.py

    rd0eb8c rc012463  
    5555        return erg
    5656    def package(self, val):
    57         if isinstance(val, OMobject):
     57        if isinstance(val, OMObjectBase):
    5858            return val
    5959        else:
  • modules/openmathserver/objects.py

    rd0eb8c rc012463  
    88    def encode(self, context):
    99        return "".join([self.name,"=\"",self.value,"\""])
    10 class OMobject(object):
     10class OMObjectBase(object):
    1111    """ at the moment only a base class"""
    1212    def __init__(self):
     
    3333            self.setChildren(children)
    3434        except AttributeError:
    35                 self.__children=children
     35                raise UnsupportedOperationError
    3636    def __getBody(self):
    3737        try:
     
    5555            self.setBody(body)
    5656        except AttributeError:
    57                 self.__body=body
     57                raise UnsupportedOperationError
    5858    def __getXMLattributes(self):
    5959        try:
     
    7878            self.setBody(XMLattributes)
    7979        except AttributeError:
    80                 self.__XMLattributes=XMLattributes
     80            raise UnsupportedOperationError
    8181    children=property(__getChildren, __setChildren,__delChildren,\
    8282                      """ children in an OMtree""")
     
    105105        closing="".join(["</"+self.XMLtag+">"])
    106106        return "".join([opening,body,closing])
    107 class OMvar(OMobject):
     107class OMvar(OMObjectBase):
    108108    def __init__(self,name):
    109109        super(OMvar,self).__init__()
     
    120120        return [XMLattribute("name", self.name)]
    121121       
    122 class OMapplication(OMobject):
     122class OMapplication(OMObjectBase):
    123123    def __init__(self, func, args):
    124124        super(OMapplication,self).__init__()
     
    142142        raise UnsupportedOperationError
    143143       
    144 class OMsymbol(OMobject):
     144class OMsymbol(OMObjectBase):
    145145    def __init__(self,name,cd=None):
    146146        super(OMsymbol,self).__init__()
     
    162162    def setXMLattributes(self):
    163163        raise UnsupportedOperationError
    164 class SimpleValue(OMobject):
     164class SimpleValue(OMObjectBase):
    165165    def __init__(self,value):
    166166        super(SimpleValue,self).__init__()
Note: See TracChangeset for help on using the changeset viewer.