Created
December 23, 2015 10:44
-
-
Save raph-amiard/57b1cc4b889ee8fec3bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INT_TYPES = (SignedIntTypeDef, ModIntTypeDef) | |
FLOAT_TYPES = (FloatingPointDef, OrdinaryFixedPointDef, | |
DecimalFixedPointDef) | |
@extend(CharLiteral) | |
class _: | |
name = Property(Self.tok) | |
@extend(BlockStatement) | |
class _: | |
env_actions = [AddEnv()] | |
@extend(NumLiteral) | |
class _: | |
is_float = Property(Any(".", Text(Self.f_tok))) | |
type_var = EquationVariable() | |
ref_eq = EquationContext( | |
If(Self.is_float, | |
In(FLOAT_TYPES, Self.type_var.node_type), | |
In(INT_TYPES, Self.type_var.node_type)) | |
) | |
@extend(ArrayTypeDef) | |
class _: | |
indices_types = Property(Map(Var.get_type, Self.indices)) | |
index_type = Property(FirstOrNil(Self.indices_types)) | |
element_type = Property(Self.stored_component.type_expr.get_type) | |
@extend(SubtypeDecl) | |
class _: | |
env_actions = [AddToEnv(Self.f_id, Self)] | |
get_type = Property(Self.type_expr.get_type) | |
base_type = Property(Self.get_type) | |
name = Property(self.f_id) | |
@extend(StringLiteral) | |
class _: | |
type_var = EquationVariable() | |
ref_eq = EquationContext( | |
And( | |
Eq(Self.type_var.base_type, ArrayTypeDef), | |
Eq(Self.type_var.base_type.name, 'Character') | |
) | |
) | |
@extend(ada.QualExpr) | |
class _: | |
ref_eq = EquationContext( | |
And( | |
Eq(Self.type_var, Self.prefix.type_var), | |
Eq(Self.ref_var, Self.prefix.ref_var), | |
Eq(Self.type_var, Self.prefix.get_type), | |
Eq(Self.ref_var, Self.prefix.get_type), | |
Eq(Self.type_var, Self.suffix.type_var) | |
), | |
depends=(Self.suffix.ref_eq,) | |
) | |
@extend(ada.Identifier) | |
class _: | |
resolve_type = EnvProperty( | |
FirstOrNil(FilterType((TypeDef, SubtypeDecl), Env.get(Self))) | |
) | |
get_type = Property(Self.resolve_type) | |
callexpr_parents = Property( | |
TakeWhile( | |
Self.parents, | |
Or(Eq(Var.node_type, CallExpr), | |
CastAnd(Var, Prefix, Eq(Var, Var.parent.suffix))) | |
) | |
) | |
has_callexpr = Property(Eq(LastOrNil(Self.callexpr_parents).node_type, CallExpr)) | |
get_entities = EnvProperty( | |
If(Self.has_callexpr, | |
Env.get(Self), | |
Filter( | |
Env.get(Self), | |
Or(Not(Eq(Var.node_type, SubprogramSpec)), | |
CastAnd(Var, SubprogramSpec, | |
And(Eq(Var.nb_min_params, 0), | |
Or(Var.is_dottable_subp, Eq(Var.nb_min_params, 1))))))) | |
) | |
ref_eq = EquationContext( | |
And(Domain(self.get_entities, self.ref_var), | |
Domain(Map(Var.get_type, self.get_entities), self.type_var)) | |
) | |
@extend(ada.AssignStatement) | |
class _: | |
ref_eq = EquationContext( | |
And(Eq(Self.expr.type_var, Self.dest.type_var), | |
Eq(Self.type_var, Self.dest.type_var), | |
Self.dest.ref_eq, | |
Self.expr.ref_eq) | |
) | |
@extend(ada.ObjectDecl) | |
class _: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment