mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 12:01:27 +01:00 
			
		
		
		
	MG: expressions types are now calculated
git-svn-id: trunk@646 -
This commit is contained in:
		
							parent
							
								
									ce0f3037ec
								
							
						
					
					
						commit
						74e824eddf
					
				| @ -2307,11 +2307,13 @@ var | |||||||
|    |    | ||||||
|   procedure ExecuteStack; |   procedure ExecuteStack; | ||||||
|   var NewOperand: TExpressionType; |   var NewOperand: TExpressionType; | ||||||
|  |     LastPos: integer; | ||||||
|   begin |   begin | ||||||
|     if StackPtr<=0 then begin |     if StackPtr<=0 then begin | ||||||
|       // only one element -> nothing to do |       // only one element -> nothing to do | ||||||
|       exit; |       exit; | ||||||
|     end; |     end; | ||||||
|  |     LastPos:=CurPos.StartPos; | ||||||
|     while (StackPtr>0) |     while (StackPtr>0) | ||||||
|     and (ExprStack[StackPtr].OperatorLvl>ExprStack[StackPtr-1].OperatorLvl) do |     and (ExprStack[StackPtr].OperatorLvl>ExprStack[StackPtr-1].OperatorLvl) do | ||||||
|     begin |     begin | ||||||
| @ -2325,6 +2327,7 @@ var | |||||||
|       ExprStack[StackPtr]:=ExprStack[StackPtr+1]; |       ExprStack[StackPtr]:=ExprStack[StackPtr+1]; | ||||||
|       ExprStack[StackPtr].Operand:=NewOperand; |       ExprStack[StackPtr].Operand:=NewOperand; | ||||||
|     end; |     end; | ||||||
|  |     MoveCursorToCleanPos(LastPos); | ||||||
|   end; |   end; | ||||||
|    |    | ||||||
| begin | begin | ||||||
| @ -2334,8 +2337,8 @@ writeln('[TFindDeclarationTool.FindExpressionResultType] ', | |||||||
| {$ENDIF} | {$ENDIF} | ||||||
|   Result:=CleanExpressionType; |   Result:=CleanExpressionType; | ||||||
|   // read the expression from left to right and calculate the type |   // read the expression from left to right and calculate the type | ||||||
|   MoveCursorToCleanPos(StartPos); |  | ||||||
|   StackPtr:=-1; |   StackPtr:=-1; | ||||||
|  |   MoveCursorToCleanPos(StartPos); | ||||||
|   repeat |   repeat | ||||||
|     // read operand |     // read operand | ||||||
|     CurExprType:=ReadOperandTypeAtCursor(Params); |     CurExprType:=ReadOperandTypeAtCursor(Params); | ||||||
| @ -2382,11 +2385,8 @@ writeln('[TFindDeclarationTool.FindExpressionResultType] ', | |||||||
|     // execute stack if possible |     // execute stack if possible | ||||||
|     ExecuteStack; |     ExecuteStack; | ||||||
|   until false; |   until false; | ||||||
| 
 |   ExecuteStack; | ||||||
|   // This is a quick hack: Just return the type of the last variable. |   Result:=ExprStack[0].Operand; | ||||||
|   MoveCursorToCleanPos(EndPos); |  | ||||||
|   Result.Desc:=xtContext; |  | ||||||
|   Result.Context:=FindContextNodeAtCursor(Params); |  | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| function TFindDeclarationTool.FindIdentifierInUsesSection( | function TFindDeclarationTool.FindIdentifierInUsesSection( | ||||||
| @ -2829,7 +2829,6 @@ writeln('[TFindDeclarationTool.ConvertNodeToExpressionType] B', | |||||||
|     // ToDo: ppu, ppw, dcu files |     // ToDo: ppu, ppw, dcu files | ||||||
| 
 | 
 | ||||||
|     MoveCursorToNodeStart(Node); |     MoveCursorToNodeStart(Node); | ||||||
|     ReadNextAtom; |  | ||||||
| 
 | 
 | ||||||
|     // ToDo: prevent circles |     // ToDo: prevent circles | ||||||
| 
 | 
 | ||||||
| @ -2898,6 +2897,7 @@ function TFindDeclarationTool.ReadOperandTypeAtCursor( | |||||||
| var EndPos, SubStartPos: integer; | var EndPos, SubStartPos: integer; | ||||||
| begin | begin | ||||||
|   Result:=CleanExpressionType; |   Result:=CleanExpressionType; | ||||||
|  |   if CurPos.StartPos=CurPos.EndPos then ReadNextAtom; | ||||||
|   // read unary operators which have no effect on the type: +, -, not |   // read unary operators which have no effect on the type: +, -, not | ||||||
|   while AtomIsChar('+') or AtomIsChar('-') or UpAtomIs('NOT') do |   while AtomIsChar('+') or AtomIsChar('-') or UpAtomIs('NOT') do | ||||||
|     ReadNextAtom; |     ReadNextAtom; | ||||||
| @ -3379,7 +3379,6 @@ writeln('[TFindDeclarationTool.IsCompatible] FindContext.Node.Desc=ctnSetType', | |||||||
|     // ToDo: ppu, ppw, dcu |     // ToDo: ppu, ppw, dcu | ||||||
|      |      | ||||||
|     FindContext.Tool.MoveCursorToNodeStart(FindContext.Node.FirstChild); |     FindContext.Tool.MoveCursorToNodeStart(FindContext.Node.FirstChild); | ||||||
|     ReadNextAtom; |  | ||||||
|     NodeExprType:=ReadOperandTypeAtCursor(Params); |     NodeExprType:=ReadOperandTypeAtCursor(Params); | ||||||
|     ExpressionType.Desc:=ExpressionType.SubDesc; |     ExpressionType.Desc:=ExpressionType.SubDesc; | ||||||
|     Result:=IsCompatible(NodeExprType,ExpressionType,Params); |     Result:=IsCompatible(NodeExprType,ExpressionType,Params); | ||||||
| @ -3452,7 +3451,7 @@ writeln('[TFindDeclarationTool.CreateParamExprList] ', | |||||||
|         if AtomIsChar(BracketClose) then break; |         if AtomIsChar(BracketClose) then break; | ||||||
|         if not AtomIsChar(',') then |         if not AtomIsChar(',') then | ||||||
|           RaiseException(BracketClose+' expected, but '+GetAtom+' found'); |           RaiseException(BracketClose+' expected, but '+GetAtom+' found'); | ||||||
|         ReadNextAtom; |         CurPos.StartPos:=CurPos.EndPos; | ||||||
|       end; |       end; | ||||||
|     end; |     end; | ||||||
|   end; |   end; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 lazarus
						lazarus