|
@@ -3233,76 +3233,6 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
- function factor_read_inline_if:tnode;
|
|
|
- var
|
|
|
- stat : tstatementnode;
|
|
|
- tempnode : ttempcreatenode;
|
|
|
- ifnode,
|
|
|
- condexpr,
|
|
|
- thenexpr,
|
|
|
- elseexpr : tnode;
|
|
|
- resdef : tdef;
|
|
|
- begin
|
|
|
- consume(_IF);
|
|
|
- condexpr:=comp_expr([ef_accept_equal]);
|
|
|
- consume(_THEN);
|
|
|
- thenexpr:=comp_expr([ef_accept_equal]);
|
|
|
- consume(_ELSE);
|
|
|
- elseexpr:=factor(false,[ef_accept_equal]);// comp_expr([ef_accept_equal]);
|
|
|
-
|
|
|
- typecheckpass(condexpr);
|
|
|
- typecheckpass(thenexpr);
|
|
|
- typecheckpass(elseexpr);
|
|
|
-
|
|
|
- if (condexpr.nodetype=errorn) or
|
|
|
- (thenexpr.nodetype=errorn) or
|
|
|
- (elseexpr.nodetype=errorn) then
|
|
|
- result:=cerrornode.create;
|
|
|
-
|
|
|
- { The result type of the expression is that of the then-expression; the
|
|
|
- else-expression is converted to that if possible (otherwise error)
|
|
|
- There are a few special cases however:
|
|
|
- - constant strings need to be converted to strings
|
|
|
- - chars need to be checked with strings
|
|
|
- }
|
|
|
-
|
|
|
- if is_conststringnode(thenexpr) then
|
|
|
- begin
|
|
|
- if is_constwidestringnode(elseexpr) or is_constwidecharnode(elseexpr) then
|
|
|
- resdef:=cwidestringtype
|
|
|
- else
|
|
|
- resdef:=cansistringtype;
|
|
|
- end
|
|
|
- else if is_constcharnode(thenexpr) then
|
|
|
- begin
|
|
|
- if is_constcharnode(elseexpr) then
|
|
|
- resdef:=cansichartype
|
|
|
- else if is_constwidecharnode(elseexpr) then
|
|
|
- resdef:=cwidechartype
|
|
|
- else if is_string(elseexpr.resultdef) then
|
|
|
- resdef:=elseexpr.resultdef
|
|
|
- else
|
|
|
- resdef:=thenexpr.resultdef;
|
|
|
- end
|
|
|
- else
|
|
|
- resdef:=thenexpr.resultdef;
|
|
|
-
|
|
|
- result:=internalstatements(stat);
|
|
|
-
|
|
|
- { create the tempnode that will hold our result }
|
|
|
- tempnode:=ctempcreatenode.create(resdef,resdef.size,tt_persistent,true);
|
|
|
- addstatement(stat,tempnode);
|
|
|
-
|
|
|
- ifnode:=cifnode.create(condexpr,
|
|
|
- cassignmentnode.create(ctemprefnode.create(tempnode),thenexpr),
|
|
|
- cassignmentnode.create(ctemprefnode.create(tempnode),elseexpr)
|
|
|
- );
|
|
|
- addstatement(stat,ifnode);
|
|
|
-
|
|
|
- addstatement(stat,ctempdeletenode.create_normal_temp(tempnode));
|
|
|
- addstatement(stat,ctemprefnode.create(tempnode));
|
|
|
- end;
|
|
|
-
|
|
|
{---------------------------------------------
|
|
|
Factor (Main)
|
|
|
---------------------------------------------}
|
|
@@ -3840,10 +3770,6 @@ implementation
|
|
|
consume(_RKLAMMER);
|
|
|
p1:=cinlinenode.create(in_objc_protocol_x,false,p1);
|
|
|
end;
|
|
|
- _IF:
|
|
|
- begin
|
|
|
- p1:=factor_read_inline_if;
|
|
|
- end;
|
|
|
|
|
|
else
|
|
|
begin
|