Anonymous avatar Anonymous committed b821765

Big Rewrite: Factored PM_FEATURES out of pmCoCreator.py and pmCoFilter.py.
- Inclusion of co_lnotab macro-ized; depends on pmfeatures.h

Comments (0)

Files changed (6)

src/platform/posix/SConscript

                   File("#src/platform/posix/build/pm_generated_types.h")]
 pm_generated_codeobjs = env.Command(generated_objs,
     platform_py_sources + pmlib_py_sources,
-    "src/tools/pmCoCreator.py %s src/platform/posix/build $SOURCES" % pmfeatures_py)
+    "src/tools/pmCoCreator.py src/platform/posix/build $SOURCES")
 Depends(pm_generated_codeobjs, pmfeatures_py)
 
 # Build pmvm library, a linker map and the executable

src/tests/system/SConscript

                   File("#src/tests/system/build/pm_generated_types.h")]
 pm_generated_codeobjs = env.Command(generated_objs,
     platform_py_sources + pmlib_py_sources,
-    "src/tools/pmCoCreator.py %s src/tests/system/build $SOURCES" % pmfeatures_py)
+    "src/tools/pmCoCreator.py src/tests/system/build $SOURCES")
 Depends(pm_generated_codeobjs, pmfeatures_py)#[pmfeatures_py, plat_h, plat_c])
 
 # Build pmvm library, a linker map and the executable

src/tools/pmCoCreator.py

     d['co_names'] = obj_to_cvar(fco['co_names'])
     d['co_consts'] = obj_to_cvar(fco['co_consts'])
     d['co_cellvars'] = obj_to_cvar(fco['co_cellvars'])
-
-    if PM_FEATURES['HAVE_DEBUG_INFO']:
-        d['lnotab_prefix'] = "(pPmString_t)&"
-        d['co_lnotab'] = obj_to_cvar(co.co_lnotab)
-    else:
-        d['lnotab_prefix'] = ""
-        d['co_lnotab'] = "C_NULL"
+    d['co_lnotab'] = obj_to_cvar(co.co_lnotab)
 
     # Format the CO structure definition
     crepr = bytearray(
         "%(hdr)s, "
         "(pPmString_t)&%(co_code)s, "
-        "%(lnotab_prefix)s%(co_lnotab)s, "
+        "PM_REFERENCE_LNOTAB(%(co_lnotab)s), "
         "(pPmTuple_t)&%(co_names)s, "
         "(pPmTuple_t)&%(co_consts)s, "
         "(pPmTuple_t)&%(co_cellvars)s, "
 
 
 if __name__ == "__main__":
-    # DWH TODO: REMOVE pmfeatures arg if HAVE_* features go away
-    pmfeatures_fn = sys.argv[1]
-    locs = {}
-    execfile(pmfeatures_fn, {}, locs)
-    global PM_FEATURES
-    PM_FEATURES = locs['PM_FEATURES']
-    assert type(PM_FEATURES) == dict
-
-    filter_co = co_filter_factory(pmfeatures_fn)
-    output_path = sys.argv[2]
+    filter_co = co_filter_factory()
+    output_path = sys.argv[1]
     assert os.path.isdir(output_path), "Expect an output path directory"
-    filenames = sys.argv[3:]
+    filenames = sys.argv[2:]
     assert len(filenames) > 0, "Expect list of .py files as args"
     process_and_print(filenames, output_path)
 

src/tools/pmCoFilter.py

 ]
 
 
-def co_filter_factory(pmfeatures_filename):
+def co_filter_factory():
     """Returns a filter function that raises an exception
     if any of the following filters fail:
 
     If all is well, return the filtered consts list,
     names list, code string and native code.
     """
-    # Issue #88: Consolidate HAVE_* platform feature definitions
-    # Execute the pmfeatures file to get the features dict
-    locs = {}
-    execfile(pmfeatures_filename, {}, locs)
-    PM_FEATURES = locs['PM_FEATURES']
-    assert type(PM_FEATURES) == dict
-
-    # Modify some globals based on the platform features
-    global UNIMPLEMENTED_BCODES
-
-    # Issue #13: Add support for Python 2.6 bytecodes.
-    # The *_TRUE_DIVIDE bytecodes require support for float type
-    if not PM_FEATURES["HAVE_FLOAT"]:
-        UNIMPLEMENTED_BCODES.extend([
-            "BINARY_TRUE_DIVIDE",
-            "INPLACE_TRUE_DIVIDE",
-            ])
 
     # Set invalid and unimplemented bcodes to None
     clear_invalid = lambda x: None if x[0] == '<' or x in UNIMPLEMENTED_BCODES \
             /* #213: Add support for Python 2.6 bytecodes */
             case BINARY_TRUE_DIVIDE:
             case INPLACE_TRUE_DIVIDE:
-
                 /* Perform division; float_op() checks for types and zero-div */
                 retval = float_op(TOS1, TOS, &pobj3, '/');
                 PM_BREAK_IF_ERROR(retval);
 
             default:
                 /* SystemError, unknown or unimplemented opcode */
+                t8 = bc;
                 PM_RAISE(retval, PM_RET_EX_SYS);
                 break;
         }
         pPmObj_t val[n]; \
     } PmTuple ## n ## _t
 
+/** Used by the code generator in pmCoCreator.py */
+#ifdef HAVE_DEBUG_INFO
+#define PM_REFERENCE_LNOTAB(s) (pPmString_t)&(s)
+#else
+#define PM_REFERENCE_LNOTAB(s) C_NULL
+#endif
+
 
 /* Types and globals that were generated by pmCoCreator.py */
 #include "pm_generated_types.h"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.