|
|
@@ -1193,12 +1193,7 @@ PRODUCTIONS
|
|
|
[ FormalParams ]
|
|
|
[ ":" TypeIdent<t> (. IF NOT SymTab.SetProcRes(t) THEN
|
|
|
SemError(235) END;
|
|
|
- Lower.SetProcRes(t);
|
|
|
- IF (t #
|
|
|
- SymTab.InvalidType)
|
|
|
- AND (SymTab.ClassOf(t)
|
|
|
- = SymTab.ClClass) THEN
|
|
|
- SemError(230) END; .) ] .
|
|
|
+ Lower.SetProcRes(t); .) ] .
|
|
|
FormalParams
|
|
|
= "(" [ ParamSection { ";" ParamSection } ] ")" .
|
|
|
ParamSection (. VAR t: SymTab.TypeIndex;
|
|
|
@@ -1458,7 +1453,7 @@ PRODUCTIONS
|
|
|
q2, mg0: QbeGen.QVal;
|
|
|
isR, conv, wconv: BOOLEAN;
|
|
|
called, sfx: BOOLEAN;
|
|
|
- astLhs, astRes: AST.Node; .)
|
|
|
+ astLhs, astRes: AST.Node; mname: SymTab.Name; isM: BOOLEAN; .)
|
|
|
= Design<dt, dk, qd, qn, sfx>
|
|
|
(. astLhs := astCur; astNArgs := 0; .)
|
|
|
( ":="
|
|
|
@@ -1497,7 +1492,7 @@ PRODUCTIONS
|
|
|
| ArgList<qn, dt, qd, TRUE, TRUE, methCls, ct2, q2, called>
|
|
|
(. astRes := AstCallNode(astLhs);
|
|
|
sfx := FALSE; .)
|
|
|
- ( { ResultComp<ct2, q2, sfx, astRes> }
|
|
|
+ ( { ResultComp<ct2, q2, sfx, astRes, mname, methCls, isM> }
|
|
|
":=" Expr<et, qe> (. astStmt := AST.MakeBin(
|
|
|
AST.NkAssign, 0, astRes, astCur);
|
|
|
IF NOT sfx THEN
|
|
|
@@ -2194,7 +2189,9 @@ PRODUCTIONS
|
|
|
(a value, or a descriptor address for aggregates); each component
|
|
|
descends one level exactly like the Design components. *)
|
|
|
ResultComp<VAR t: SymTab.TypeIndex; VAR q: QbeGen.QVal;
|
|
|
- VAR sfx: BOOLEAN; VAR node: AST.Node> (. VAR it, eT, bt: SymTab.TypeIndex;
|
|
|
+ VAR sfx: BOOLEAN; VAR node: AST.Node;
|
|
|
+ VAR mname: SymTab.Name; VAR methCls: SymTab.TypeIndex;
|
|
|
+ VAR isM: BOOLEAN> (. VAR it, eT, bt: SymTab.TypeIndex;
|
|
|
iq, ql, qlo, qhi, qe, qb:
|
|
|
QbeGen.QVal;
|
|
|
lo, hi, fo: INTEGER;
|
|
|
@@ -2202,7 +2199,8 @@ PRODUCTIONS
|
|
|
fname: SymTab.Name;
|
|
|
astWrap, astSel: AST.Node; .)
|
|
|
= "[" Expr<it, iq>
|
|
|
- (. IF AST.Kind(node) # AST.NkDesignator THEN
|
|
|
+ (. isM := FALSE;
|
|
|
+ IF AST.Kind(node) # AST.NkDesignator THEN
|
|
|
astWrap := AST.MakeNode(
|
|
|
AST.NkDesignator);
|
|
|
AST.SetChild(astWrap, 0, node);
|
|
|
@@ -2226,7 +2224,8 @@ PRODUCTIONS
|
|
|
END; .)
|
|
|
"]"
|
|
|
| "." GetIdent<fname>
|
|
|
- (. IF AST.Kind(node) # AST.NkDesignator THEN
|
|
|
+ (. isM := FALSE;
|
|
|
+ IF AST.Kind(node) # AST.NkDesignator THEN
|
|
|
astWrap := AST.MakeNode(
|
|
|
AST.NkDesignator);
|
|
|
AST.SetChild(astWrap, 0, node);
|
|
|
@@ -2242,6 +2241,15 @@ PRODUCTIONS
|
|
|
AND (SymTab.ClassOf(t) # SymTab.ClClass) THEN
|
|
|
SemError(215);
|
|
|
t := SymTab.InvalidType
|
|
|
+ ELSIF (SymTab.ClassOf(t) =
|
|
|
+ SymTab.ClClass)
|
|
|
+ AND SymTab.MethodExists(t, fname) THEN
|
|
|
+ (* a method on the call result:
|
|
|
+ a following ArgList makes
|
|
|
+ the call *)
|
|
|
+ mname := fname;
|
|
|
+ methCls := t; isM := TRUE;
|
|
|
+ t := SymTab.InvalidType
|
|
|
ELSIF NOT SymTab.FieldExists(t,
|
|
|
fname) THEN
|
|
|
SemError(216);
|
|
|
@@ -2250,7 +2258,8 @@ PRODUCTIONS
|
|
|
t := SymTab.FieldType(t, fname);
|
|
|
sfx := TRUE
|
|
|
END; .)
|
|
|
- | "^" (. IF AST.Kind(node) # AST.NkDesignator THEN
|
|
|
+ | "^" (. isM := FALSE;
|
|
|
+ IF AST.Kind(node) # AST.NkDesignator THEN
|
|
|
astWrap := AST.MakeNode(
|
|
|
AST.NkDesignator);
|
|
|
AST.SetChild(astWrap, 0, node);
|
|
|
@@ -2542,7 +2551,7 @@ PRODUCTIONS
|
|
|
j: CARDINAL;
|
|
|
astArg2: AST.Node;
|
|
|
astBrace: AST.Node;
|
|
|
- astRes: AST.Node; .)
|
|
|
+ astRes: AST.Node; mname: SymTab.Name; isM: BOOLEAN; .)
|
|
|
= (. astIsLit := FALSE; .)
|
|
|
( integer (. LexString(s);
|
|
|
QbeGen.NormInt(s, q); IF twoPhase THEN astIsLit := TRUE; astCur := AST.MakeLeaf(AST.NkIntLit, s) END;
|
|
|
@@ -2611,7 +2620,14 @@ PRODUCTIONS
|
|
|
t := ct2;
|
|
|
QbeGen.CopyOp(q2, q);
|
|
|
sfx := FALSE; .)
|
|
|
- { ResultComp<t, q, sfx, astRes> }
|
|
|
+ { ResultComp<t, q, sfx, astRes, mname, methCls, isM>
|
|
|
+ [ (. astNArgs := 0; .)
|
|
|
+ ArgList<mname, t, q, TRUE, FALSE, methCls, ct2, q2, called>
|
|
|
+ (. astNode := AstCallNode(astRes);
|
|
|
+ astRes := astNode;
|
|
|
+ t := ct2;
|
|
|
+ QbeGen.CopyOp(q2, q);
|
|
|
+ sfx := FALSE; .) ] }
|
|
|
(. IF sfx THEN
|
|
|
IF t = SymTab.InvalidType THEN
|
|
|
QbeGen.CopyOp("0", q)
|