summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-02-02 21:13:01 -0500
committerNathan Binkert <binkertn@umich.edu>2005-02-02 21:13:01 -0500
commita736a8fab6dd1ae0d5546939bc0c7fc4aec003e8 (patch)
tree8843b82f22ad52deb3b85599cca52b93b6367c35 /sim
parent45bb2bf14d501f4ccab0bb399f53f8b35f8c82e6 (diff)
downloadgem5-a736a8fab6dd1ae0d5546939bc0c7fc4aec003e8.tar.xz
Update config file language to take simobj and no longer use siminst
objects/AlphaConsole.mpy: objects/AlphaTLB.mpy: objects/BadDevice.mpy: objects/BaseCPU.mpy: objects/BaseCache.mpy: objects/BaseSystem.mpy: objects/Bus.mpy: objects/CoherenceProtocol.mpy: objects/Device.mpy: objects/DiskImage.mpy: objects/Ethernet.mpy: objects/Ide.mpy: objects/IntrControl.mpy: objects/MemTest.mpy: objects/Pci.mpy: objects/PhysicalMemory.mpy: objects/Platform.mpy: objects/Process.mpy: objects/Repl.mpy: objects/Root.mpy: objects/SimConsole.mpy: objects/SimpleDisk.mpy: objects/Tsunami.mpy: objects/Uart.mpy: simobj now requires a type= line if it is actually intended to be a type sim/pyconfig/SConscript: keep track of the filename of embedded files for better error messages. sim/pyconfig/m5config.py: Add support for the trickery done with the compiler to get the simobj language feature added to the importer. fix the bug that gave objects the wrong name in error messages. test/genini.py: Globals have been fixed and use execfile --HG-- extra : convert_revision : b74495fd6f3479a87ecea7f1234ebb6731279b2b
Diffstat (limited to 'sim')
-rw-r--r--sim/pyconfig/SConscript15
-rw-r--r--sim/pyconfig/m5config.py36
2 files changed, 30 insertions, 21 deletions
diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript
index 127b0efae..5708ac9a8 100644
--- a/sim/pyconfig/SConscript
+++ b/sim/pyconfig/SConscript
@@ -28,14 +28,15 @@
import os, os.path, re
-def WriteEmbeddedPyFile(target, source, path, name, ext):
+def WriteEmbeddedPyFile(target, source, path, name, ext, filename):
if isinstance(source, str):
source = file(source, 'r')
if isinstance(target, str):
target = file(target, 'w')
- print >>target, "AddModule(%s, %s, %s, '''\\" % (`path`, `name`, `ext`)
+ print >>target, "AddModule(%s, %s, %s, %s, '''\\" % \
+ (`path`, `name`, `ext`, `filename`)
for line in source:
line = line
@@ -105,7 +106,7 @@ def MakeEmbeddedPyFile(target, source, env):
name,ext = pyfile.split('.')
if name == '__init__':
node['.hasinit'] = True
- node[pyfile] = (src,name,ext)
+ node[pyfile] = (src,name,ext,src)
done = False
while not done:
@@ -136,12 +137,12 @@ def MakeEmbeddedPyFile(target, source, env):
raise NameError, 'package directory missing __init__.py'
populate(entry, path + [ name ])
else:
- pyfile,name,ext = entry
- files.append((pyfile, path, name, ext))
+ pyfile,name,ext,filename = entry
+ files.append((pyfile, path, name, ext, filename))
populate(tree)
- for pyfile, path, name, ext in files:
- WriteEmbeddedPyFile(target, pyfile, path, name, ext)
+ for pyfile, path, name, ext, filename in files:
+ WriteEmbeddedPyFile(target, pyfile, path, name, ext, filename)
CFileCounter = 0
def MakePythonCFile(target, source, env):
diff --git a/sim/pyconfig/m5config.py b/sim/pyconfig/m5config.py
index 4c5fc3bf9..5ba7542a0 100644
--- a/sim/pyconfig/m5config.py
+++ b/sim/pyconfig/m5config.py
@@ -221,6 +221,10 @@ def isParamContext(value):
return False
+class_decorator = '_M5M5_SIMOBJECT_'
+expr_decorator = '_M5M5_EXPRESSION_'
+dot_decorator = '_M5M5_DOT_'
+
# The metaclass for ConfigNode (and thus for everything that derives
# from ConfigNode, including SimObject). This class controls how new
# classes that derive from ConfigNode are instantiated, and provides
@@ -230,7 +234,6 @@ def isParamContext(value):
class MetaConfigNode(type):
keywords = { 'abstract' : types.BooleanType,
'check' : types.FunctionType,
- '_init' : types.FunctionType,
'type' : (types.NoneType, types.StringType) }
# __new__ is called before __init__, and is where the statements
@@ -246,6 +249,11 @@ class MetaConfigNode(type):
'_disable' : {} }
for key,val in dict.items():
+ del dict[key]
+
+ if key.startswith(expr_decorator):
+ key = key[len(expr_decorator):]
+
if mcls.keywords.has_key(key):
if not isinstance(val, mcls.keywords[key]):
raise TypeError, \
@@ -255,11 +263,9 @@ class MetaConfigNode(type):
if isinstance(val, types.FunctionType):
val = classmethod(val)
priv[key] = val
- del dict[key]
elif key.startswith('_'):
priv[key] = val
- del dict[key]
elif not isNullPointer(val) and isConfigNode(val):
dict[key] = val()
@@ -267,19 +273,22 @@ class MetaConfigNode(type):
elif isSimObjSequence(val):
dict[key] = [ v() for v in val ]
+ else:
+ dict[key] = val
+
# If your parent has a value in it that's a config node, clone it.
for base in bases:
if not isConfigNode(base):
continue
- for name,value in base._values.iteritems():
- if dict.has_key(name):
+ for key,value in base._values.iteritems():
+ if dict.has_key(key):
continue
if isConfigNode(value):
- priv['_values'][name] = value()
+ priv['_values'][key] = value()
elif isSimObjSequence(value):
- priv['_values'][name] = [ val() for val in value ]
+ priv['_values'][key] = [ val() for val in value ]
# entries left in dict will get passed to __init__, where we'll
# deal with them as params.
@@ -293,12 +302,12 @@ class MetaConfigNode(type):
cls._bases = [c for c in cls.__mro__ if isConfigNode(c)]
# initialize attributes with values from class definition
- for pname,value in dict.iteritems():
- setattr(cls, pname, value)
-
- if hasattr(cls, '_init'):
- cls._init()
- del cls._init
+ for key,value in dict.iteritems():
+ key = key.split(dot_decorator)
+ c = cls
+ for item in key[:-1]:
+ c = getattr(c, item)
+ setattr(c, key[-1], value)
def _isvalue(cls, name):
for c in cls._bases:
@@ -390,7 +399,6 @@ class MetaConfigNode(type):
raise AttributeError, \
"object '%s' has no attribute '%s'" % (cls.__name__, cls)
-
# Set attribute (called on foo.attr = value when foo is an
# instance of class cls).
def __setattr__(cls, attr, value):