Next: Support code
Up: Expressions
Previous: Relational operators
Constant expressions[32]
:
ATTR Constant: int;
TREE SYMBOL Expression COMPUTE
SYNT.Constant=NoStrIndex;
END;
RULE: Expression ::= 'false' COMPUTE
Expression.Constant=MakeName("false");
END;
RULE: Expression ::= 'true' COMPUTE
Expression.Constant=MakeName("true");
END;
RULE: Expression ::= CharacterLiteral COMPUTE
Expression.Constant=CharacterLiteral;
END;
RULE: Expression ::= IntLiteral COMPUTE
Expression.Constant=IntLiteral;
END;
RULE: Expression ::= LongLiteral COMPUTE
Expression.Constant=LongLiteral;
END;
RULE: Expression ::= FloatLiteral COMPUTE
Expression.Constant=FloatLiteral;
END;
RULE: Expression ::= DoubleLiteral COMPUTE
Expression.Constant=DoubleLiteral;
END;
RULE: Expression ::= StringLiteral COMPUTE
Expression.Constant=StringLiteral;
END;
RULE: Expression ::= 'null' COMPUTE
Expression.Constant=MakeName("null");
END;
This macro is defined in definitions 32, 33, 37, 38, and 39.
This macro is invoked in definition 26.
Because a constant expression may depend on identifier values that are
defined by other constant expressions, a LIDO iteration must be used to
evaluate them during analysis.
Cluster.DoJinit is the iteration attribute:
Constant expressions[33]
:
RULE: Goal ::= Cluster COMPUTE
Cluster.DoJinit=HaveNoJinit() <- Goal.GotAllOpers;
Goal.GotAllConstants=
UNTIL NoJinit <- CONSTITUENTS Initializer.GotConstants
ITERATE Cluster.DoJinit=HaveNoJinit();
END;
This macro is defined in definitions 32, 33, 37, 38, and 39.
This macro is invoked in definition 26.
The general strategy is to set the global variable NoJinit to 1 at the
beginning of each iteration, and then set it to 0 at any point during the
iteration that an identifier obtains a value:
void HaveNoJinit(void)[34]
:
/* Signal that no field or variable has been initialized
* On exit-
* NoJinit=1
***/
{ NoJinit = 1; }
This macro is invoked in definition 43.
/* Signal that a field or variable was initialized
* On exit-
* NoJinit=0
***/
{ NoJinit = 0; }
This macro is invoked in definition 43.
HaveNoJinit is invoked prior to the start of each iteration by the code
of the LIDO iteration given above.
DidJinit is invoked when the Constant property of an identifier is
set for the first time:
Property definitions[36]
:
Constant: int [Jinit];
void Jinit(DefTableKey key, int v)
{ if (key == NoKey || v == NoStrIndex) return;
if (!ACCESS) DidJinit();
VALUE = v;
} "Context.h"
This macro is defined in definitions 10, 16, 22, 36, and 40.
This macro is invoked in definition 3.
The dependence stated in the UNTIL expression ensures that all
initialization nodes are visited on each iteration:
Constant expressions[37]
:
CHAIN IsFinal: int;
TREE SYMBOL TypeDeclaration COMPUTE CHAINSTART HEAD.IsFinal=0; END;
TREE SYMBOL FieldDeclaration COMPUTE CHAINSTART HEAD.IsFinal=0; END;
RULE: Modifier ::= 'final' COMPUTE Modifier.IsFinal=1; END;
RULE: LocalVariableDeclaration ::= 'final' Type VariableDeclarators COMPUTE
CHAINSTART Type.IsFinal=1;
END;
RULE: LocalVariableDeclaration ::= Type VariableDeclarators COMPUTE
CHAINSTART Type.IsFinal=0;
END;
TREE SYMBOL Initializer COMPUTE THIS.GotConstants="yes"; END;
RULE: FieldDeclarator ::= FieldDeclaratorId '=' Initializer COMPUTE
Initializer.GotConstants=
IF(FieldDeclaratorId.IsFinal,
JinitConstant(
FieldDeclaratorId CONSTITUENT FieldIdDef.Key,
Initializer.Constant))
<- INCLUDING Cluster.DoJinit;
END;
RULE: VariableDeclarator ::= VariableDeclaratorId '=' Initializer COMPUTE
Initializer.GotConstants=
IF(VariableDeclaratorId.IsFinal,
JinitConstant(VariableDeclaratorId.Key,Initializer.Constant))
<- INCLUDING Cluster.DoJinit;
END;
TREE SYMBOL VariableDeclaratorId: Key: DefTableKey;
RULE: VariableDeclaratorId ::= VariableDeclaratorId '[' ']' COMPUTE
VariableDeclaratorId[1].Key=VariableDeclaratorId[2].Key;
END;
RULE: VariableDeclaratorId ::= VariableIdDef COMPUTE
VariableDeclaratorId.Key=VariableIdDef.Key;
END;
RULE: Initializer ::= Expression COMPUTE
Initializer.Constant=
CastPrimitive(
Expression.Constant,
Expression.Type,
INCLUDING (FieldDeclarators.Type,VariableDeclarators.Type));
END;
RULE: Initializer ::= '{' Initializers '}' COMPUTE
Initializer.Constant=NoStrIndex;
END;
RULE: Expression ::= Name $pExpressionName COMPUTE
Expression.Constant=
GetConstant(pExpressionName.Key,NoStrIndex) <- INCLUDING Cluster.DoJinit;
END;
This macro is defined in definitions 32, 33, 37, 38, and 39.
This macro is invoked in definition 26.
A narrowing conversion of a signed integer to an integral type T
simply discards all but the n lowest order bits, where n is the number
of bits used to represent type T.
In addition to a possible loss of information about the magnitude of the
numeric value, this may cause the sign of the resulting value to differ
from the sign of the input value.
Constant expressions[38]
:
RULE: Expression ::= '(' PrimitiveType ')' Expression COMPUTE
Expression[1].Constant=
CastPrimitive(
Expression[2].Constant,
Expression[2].Type,
PrimitiveType.Type);
END;
This macro is defined in definitions 32, 33, 37, 38, and 39.
This macro is invoked in definition 26.
Constant expressions[39]
:
RULE: Expression ::= Operator Expression COMPUTE
Expression[1].Constant=
APPLY(GetMonadicOp(Operator.Oper,StrBad1),Expression[2].Constant);
END;
RULE: Expression ::= Expression Operator Expression COMPUTE
Expression[1].Constant=
APPLY(
GetDyadicOp(Operator.Oper,StrBad2),
Expression[2].Constant,
Expression[3].Constant);
END;
RULE: Expression ::= Expression '?' Expression ':' Expression COMPUTE
Expression[1].Constant=
IF(EQ(Expression[2].Constant,MakeName("true")),
Expression[3].Constant,
Expression[4].Constant);
END;
This macro is defined in definitions 32, 33, 37, 38, and 39.
This macro is invoked in definition 26.
Property definitions[40]
:
MonadicOp: StrOp1; "StrArith.h"
DyadicOp: StrOp2; "Math.h"
posOp -> MonadicOp={StrNop};
negOp -> MonadicOp={StrNeg};
invOp -> MonadicOp={StrNot};
addOp -> DyadicOp={StrAdd};
subOp -> DyadicOp={StrSub};
mulOp -> DyadicOp={StrMul};
divOp -> DyadicOp={StrDiv};
remOp -> DyadicOp={StrRem};
cmpleOp -> DyadicOp={StrLeq};
cmplsOp -> DyadicOp={StrLss};
cmpgeOp -> DyadicOp={StrGeq};
cmpgtOp -> DyadicOp={StrGtr};
cmpeqOp -> DyadicOp={StrEqu};
cmpneOp -> DyadicOp={StrNeq};
clseqOp -> DyadicOp={StrEqu};
clsneOp -> DyadicOp={StrNeq};
strprmOp -> DyadicOp={StrPrm};
prmstrOp -> DyadicOp={PrmStr};
strclsOp -> DyadicOp={StrStr};
clsstrOp -> DyadicOp={StrStr};
This macro is defined in definitions 10, 16, 22, 36, and 40.
This macro is invoked in definition 3.
Next: Support code
Up: Expressions
Previous: Relational operators
2008-09-11