def _make_primitive_type(name): tmp = LabelledValue(name) tmp.add_type(_type) default_context.bind(name, tmp) return tmp
# along with this program. If not, see <http://www.gnu.org/licenses/>. # from graph import NodePtr, PrimitiveNode, LabelledValue from utils import rset from context import Context, OperatorRecord default_context = Context() #---------------------------# # builtin type objects # #---------------------------# # type is a weird object; it is its own type _type = LabelledValue('type') _type.add_type(_type) default_context.bind('type', _type) def _make_primitive_type(name): tmp = LabelledValue(name) tmp.add_type(_type) default_context.bind(name, tmp) return tmp def _make_primitive_types(*names): return map(_make_primitive_type, names) int_type, char_type, str_type = _make_primitive_types('int', 'char', 'string') # The unit and bool types are special; instances of them are not constructed