AbstractInclusiveMetricsVisitor.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.data.experiment.scope.visitors;
00002
00003 import edu.rice.cs.hpc.data.experiment.Experiment;
00004 import edu.rice.cs.hpc.data.experiment.scope.AlienScope;
00005 import edu.rice.cs.hpc.data.experiment.scope.CallSiteScope;
00006 import edu.rice.cs.hpc.data.experiment.scope.FileScope;
00007 import edu.rice.cs.hpc.data.experiment.scope.GroupScope;
00008 import edu.rice.cs.hpc.data.experiment.scope.LineScope;
00009 import edu.rice.cs.hpc.data.experiment.scope.LoadModuleScope;
00010 import edu.rice.cs.hpc.data.experiment.scope.LoopScope;
00011 import edu.rice.cs.hpc.data.experiment.scope.ProcedureScope;
00012 import edu.rice.cs.hpc.data.experiment.scope.RootScope;
00013 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00014 import edu.rice.cs.hpc.data.experiment.scope.ScopeVisitType;
00015 import edu.rice.cs.hpc.data.experiment.scope.StatementRangeScope;
00016 import edu.rice.cs.hpc.data.experiment.scope.filters.InclusiveOnlyMetricPropagationFilter;
00017 import edu.rice.cs.hpc.data.experiment.scope.filters.MetricValuePropagationFilter;
00018
00019 public abstract class AbstractInclusiveMetricsVisitor implements IScopeVisitor {
00020
00021 protected MetricValuePropagationFilter filter;
00022
00023 public AbstractInclusiveMetricsVisitor(Experiment experiment, MetricValuePropagationFilter currentFilter) {
00024 this.filter = currentFilter;
00025 }
00026
00027
00028
00029
00030 public void visit(Scope scope, ScopeVisitType vt) { up(scope, vt); }
00031 public void visit(RootScope scope, ScopeVisitType vt) { }
00032 public void visit(LoadModuleScope scope, ScopeVisitType vt) { up(scope, vt); }
00033 public void visit(FileScope scope, ScopeVisitType vt) { up(scope, vt); }
00034 public void visit(ProcedureScope scope, ScopeVisitType vt) { up(scope, vt); }
00035 public void visit(AlienScope scope, ScopeVisitType vt) { up(scope, vt); }
00036 public void visit(LoopScope scope, ScopeVisitType vt) { up(scope, vt); }
00037 public void visit(LineScope scope, ScopeVisitType vt) { up(scope, vt); }
00038 public void visit(StatementRangeScope scope, ScopeVisitType vt) { up(scope, vt); }
00039 public void visit(CallSiteScope scope, ScopeVisitType vt) { up(scope, vt); }
00040 public void visit(GroupScope scope, ScopeVisitType vt) { up(scope, vt); }
00041
00042
00043
00044
00045
00046 protected void up(Scope scope, ScopeVisitType vt) {
00047 if (vt == ScopeVisitType.PostVisit) {
00048 Scope parent = scope.getParentScope();
00049 if (parent != null) {
00050 if (scope instanceof CallSiteScope) {
00051
00052 accumulateToParent( parent, scope );
00053 } else {
00054
00055
00056 if(parent instanceof LoopScope && scope instanceof LoopScope) {
00057
00058 if(filter instanceof InclusiveOnlyMetricPropagationFilter) {
00059
00060
00061 accumulateToParent( parent, scope );
00062 }
00063 return;
00064 }
00065 accumulateToParent( parent, scope );
00066 }
00067 }
00068 }
00069 }
00070
00071
00077 abstract protected void accumulateToParent(Scope parent, Scope source) ;
00078 }