def add_const_spec(self, const_spec):
        """Adds a ConstSpec to the compliation scope.

        If the ConstSpec's ``save`` attribute is True, the constant will be
        added to the module at the top-level.
        """
        if const_spec.name in self.const_specs:
            raise ThriftCompilerError(
                'Cannot define constant "%s". That name is already taken.'
                % const_spec.name
            )
        self.const_specs[const_spec.name] = const_spec