Example #1
0
    def get_gwbasic_vars(self, dictionary):
        """ Read local variables """

        # Single variables
        for v in state.basic_state.variables:
            v_val = self.type_converter(var.get_var(v))
            v = self.name_converter(v)
            dictionary[v] = v_val

        # Arrays
        for v in state.basic_state.arrays:
            v_val = state.basic_state.arrays[v]

            dimensions = v_val[0]

            indexes = [list(xrange(d)) for d in dimensions]
            indexes = list(itertools.product(*indexes))

            values = np.empty(dimensions)
            for index in indexes:
                values[index] = self.type_converter(var.get_array(v, list(index)))

            values = values.tolist()
            v = self.name_converter(v)
            dictionary[v] = values
Example #2
0
def get_value_for_varptrstr(varptrstr):
    """ Get a value given a VARPTR$ representation. """
    if len(varptrstr) < 3:
        raise error.RunError(error.IFC)
    varptrstr = bytearray(varptrstr)
    varptr = vartypes.uint_to_value(bytearray(varptrstr[1:3]))
    found_name = ''
    for name in state.basic_state.var_memory:
        _, var_ptr = state.basic_state.var_memory[name]
        if var_ptr == varptr:
            found_name = name
            break
    if found_name == '':
        raise error.RunError(error.IFC)
    return var.get_var(found_name)