Changeset 56
- Timestamp:
- Jul 13, 2012, 2:10:18 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Target/Interpretter/UTargetInterpretter.pas
r52 r56 32 32 procedure RunAssignment(Assignment: TAssignment); 33 33 procedure RunCaseOfEnd(CaseOfEnd: TCaseOfEnd); 34 procedure RunFunction(FunctionCall: TFunctionCall);34 function RunFunction(FunctionCall: TFunctionCall): TValue; 35 35 procedure RunForToDo(ForToDo: TForToDo); 36 function Evaluate(Expression: TExpression): Boolean;36 function Evaluate(Expression: TExpression): TValue; 37 37 public 38 38 Variables: TListObject; … … 50 50 resourcestring 51 51 SUnknownCommandType = 'Unknown command type'; 52 SUnknownOperator = 'Unknown operator "%s"'; 52 53 53 54 { TExecutorInterpretter } … … 94 95 procedure TExecutorInterpretter.RunAssignment(Assignment: TAssignment); 95 96 begin 96 //Assignment.Target := Assignment.Source;97 Assignment.Target.Value := Evaluate(Assignment.Source); 97 98 end; 98 99 … … 111 112 end; 112 113 113 procedure TExecutorInterpretter.RunFunction(FunctionCall: TFunctionCall);114 function TExecutorInterpretter.RunFunction(FunctionCall: TFunctionCall): TValue; 114 115 begin 115 116 RunBeginEnd(FunctionCall.FunctionRef.Code); … … 126 127 end; 127 128 128 function TExecutorInterpretter.Evaluate(Expression: TExpression): Boolean;129 function TExecutorInterpretter.Evaluate(Expression: TExpression): TValue; 129 130 begin 130 // case Expression.NodeType of 131 // ntConstant: ; 132 // end; 131 with Expression do 132 case NodeType of 133 ntConstant: Result := Constant.Value; 134 ntFunction: Result := RunFunction(FunctionCall); 135 ntOperator: begin 136 if OperatorName = '>' then 137 Result := Evaluate(TExpression(SubItems.First)) > Evaluate(TExpression(SubItems.Last)) 138 else if OperatorName = '<' then 139 Result := Evaluate(TExpression(SubItems.First)) < Evaluate(TExpression(SubItems.Last)) 140 else if OperatorName = '+' then 141 Result := Evaluate(TExpression(SubItems.First)) + Evaluate(TExpression(SubItems.Last)) 142 else if OperatorName = '-' then 143 Result := Evaluate(TExpression(SubItems.First)) - Evaluate(TExpression(SubItems.Last)) 144 else if OperatorName = '*' then 145 Result := Evaluate(TExpression(SubItems.First)) * Evaluate(TExpression(SubItems.Last)) 146 else if OperatorName = 'div' then 147 Result := Evaluate(TExpression(SubItems.First)) div Evaluate(TExpression(SubItems.Last)) 148 else raise Exception.CreateFmt(SUnknownOperator, [OperatorName]); 149 end; 150 ntVariable: Result := Variable.Value; 151 end; 133 152 end; 134 153 -
trunk/Compiler/TranspascalCompiler.lpk
r44 r56 40 40 </Item3> 41 41 <Item4> 42 <Filename Value="UAnalyzer.pas"/> 43 <UnitName Value="UAnalyzer"/> 44 </Item4> 45 <Item5> 46 <Filename Value="UTarget.pas"/> 47 <UnitName Value="UTarget"/> 48 </Item5> 49 <Item6> 50 <Filename Value="UExecutor.pas"/> 51 <UnitName Value="UExecutor"/> 52 </Item6> 53 <Item7> 54 <Filename Value="Analyze\UAnalyzerPascal.pas"/> 55 <UnitName Value="UAnalyzerPascal"/> 56 </Item7> 57 <Item8> 58 <Filename Value="Target\Dynamic C\UProducerDynamicc.pas"/> 59 <UnitName Value="UProducerDynamicC"/> 60 </Item8> 61 <Item9> 42 62 <Filename Value="Target\ASM8051\UProducerASM8051.pas"/> 43 63 <UnitName Value="UProducerAsm8051"/> 44 </Item4> 45 <Item5> 46 <Filename Value="Target\Dynamic C\UProducerDynamicc.pas"/> 47 <UnitName Value="UProducerDynamicC"/> 48 </Item5> 49 <Item6> 64 </Item9> 65 <Item10> 66 <Filename Value="Target\GCC\UProducerGCC.pas"/> 67 <UnitName Value="UProducerGCC"/> 68 </Item10> 69 <Item11> 70 <Filename Value="Target\UTargets.pas"/> 71 <UnitName Value="UTargets"/> 72 </Item11> 73 <Item12> 50 74 <Filename Value="Target\Delphi\UProducerPascal.pas"/> 51 75 <UnitName Value="UProducerPascal"/> 52 </Item6>53 <Item7>54 <Filename Value="Target\GCC\UProducerGCC.pas"/>55 <UnitName Value="UProducerGCC"/>56 </Item7>57 <Item8>58 <Filename Value="UAnalyzer.pas"/>59 <UnitName Value="UAnalyzer"/>60 </Item8>61 <Item9>62 <Filename Value="Analyze\UAnalyzerPascal.pas"/>63 <UnitName Value="UAnalyzerPascal"/>64 </Item9>65 <Item10>66 <Filename Value="UTarget.pas"/>67 <UnitName Value="UTarget"/>68 </Item10>69 <Item11>70 <Filename Value="UExecutor.pas"/>71 <UnitName Value="UExecutor"/>72 </Item11>73 <Item12>74 <Filename Value="Target\UTargets.pas"/>75 <UnitName Value="UTargets"/>76 76 </Item12> 77 77 <Item13> -
trunk/Compiler/TranspascalCompiler.pas
r42 r56 8 8 9 9 uses 10 UCompiler, USourceCode, UProducer, U ProducerASM8051, UProducerDynamicc,11 U ProducerPascal, UProducerGCC, UAnalyzer, UAnalyzerPascal, UTarget,12 U Executor, UTargets, UTargetInterpretter, UTargetDelphi, UTargetPHP,10 UCompiler, USourceCode, UProducer, UAnalyzer, UTarget, UExecutor, 11 UAnalyzerPascal, UProducerDynamicc, UProducerASM8051, UProducerGCC, 12 UTargets, UProducerPascal, UTargetInterpretter, UTargetDelphi, UTargetPHP, 13 13 UTargetJava, UTargetXML, UTargetASM8051, UTargetGCC, LazarusPackageIntf; 14 14 -
trunk/Compiler/USourceCode.pas
r51 r56 253 253 DefaultValue: TValue; 254 254 Exported: Boolean; 255 Value: TValue; // runtime 255 256 end; 256 257 -
trunk/IDE/Forms/UFormProject.lfm
r55 r56 47 47 object ADelete: TAction 48 48 Caption = 'Delete' 49 OnExecute = ADeleteExecute 49 50 end 50 51 object ARename: TAction 51 52 Caption = 'Rename' 53 OnExecute = ARenameExecute 52 54 end 53 55 object AShow: TAction 54 56 Caption = 'Show' 57 OnExecute = AShowExecute 55 58 end 56 59 end -
trunk/IDE/Forms/UFormProject.pas
r55 r56 25 25 TreeViewProject: TTreeView; 26 26 procedure AAddExecute(Sender: TObject); 27 procedure ADeleteExecute(Sender: TObject); 28 procedure ARenameExecute(Sender: TObject); 29 procedure AShowExecute(Sender: TObject); 27 30 procedure TreeViewProjectChange(Sender: TObject; Node: TTreeNode); 28 31 private … … 90 93 end; 91 94 95 procedure TFormProject.ADeleteExecute(Sender: TObject); 96 begin 97 98 end; 99 100 procedure TFormProject.ARenameExecute(Sender: TObject); 101 begin 102 103 end; 104 105 procedure TFormProject.AShowExecute(Sender: TObject); 106 begin 107 108 end; 109 92 110 procedure TFormProject.UpdateProjectTree; 93 111 var
Note:
See TracChangeset
for help on using the changeset viewer.