From b58fa9067d5d4bb6e1882dd1af97d4bc5d65ce9e Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 16 Jul 2015 14:57:44 +0300 Subject: [PATCH] Add attributes to TRange. Also make attributes an OrderedDict, for stable order during LLVM IR generation. --- artiq/compiler/builtins.py | 5 +++++ artiq/compiler/types.py | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/artiq/compiler/builtins.py b/artiq/compiler/builtins.py index 5fdd49708..4675c458c 100644 --- a/artiq/compiler/builtins.py +++ b/artiq/compiler/builtins.py @@ -36,6 +36,11 @@ class TRange(types.TMono): if elt is None: elt = types.TVar() super().__init__("range", {"elt": elt}) + self.attributes = OrderedDict([ + ("start", elt), + ("stop", elt), + ("step", elt), + ]) class TException(types.TMono): def __init__(self): diff --git a/artiq/compiler/types.py b/artiq/compiler/types.py index 4cff68161..5e69c399f 100644 --- a/artiq/compiler/types.py +++ b/artiq/compiler/types.py @@ -4,6 +4,7 @@ in :mod:`asttyped`. """ import string +from collections import OrderedDict def genalnum(): ident = ["a"] @@ -80,7 +81,7 @@ class TMono(Type): unlike all other :class:`Type` descendants. """ - attributes = {} + attributes = OrderedDict() def __init__(self, name, params={}): self.name, self.params = name, params @@ -124,7 +125,7 @@ class TTuple(Type): :ivar elts: (list of :class:`Type`) elements """ - attributes = {} + attributes = OrderedDict() def __init__(self, elts=[]): self.elts = elts @@ -168,7 +169,7 @@ class TFunction(Type): return type """ - attributes = {} + attributes = OrderedDict() def __init__(self, args, optargs, ret): self.args, self.optargs, self.ret = args, optargs, ret @@ -220,7 +221,7 @@ class TBuiltin(Type): def __init__(self, name): self.name = name - self.attributes = {} + self.attributes = OrderedDict() def find(self): return self