Package: RootContext

RootContext

nameinstructionbranchcomplexitylinemethod
RootContext(IInterpreterAssistantFactory, ILexLocation, String, Context, Context)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getDepth()
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getFrame(int)
M: 16 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getRoot()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSelf()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getVisibleVariables()
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (C) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.interpreter.runtime;
25:
26: import org.overture.ast.intf.lex.ILexLocation;
27: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
28: import org.overture.interpreter.values.ObjectValue;
29:
30: /**
31: * A Context class, specialized to represent points in a context chain where name resolution does not proceed further
32: * down the chain, but rather jumps to the outermost level.
33: */
34:
35: @SuppressWarnings("serial")
36: public abstract class RootContext extends Context
37: {
38:         protected final Context freeVariables;
39:
40:         public RootContext(IInterpreterAssistantFactory af, ILexLocation location,
41:                         String title, Context freeVariables, Context outer)
42:         {
43:                 super(af, location, title, outer);
44:                 this.freeVariables = freeVariables;
45:         }
46:
47:         @Override
48:         public Context getVisibleVariables()
49:         {
50:                 Context visible = new Context(assistantFactory, location, title, null);
51:                 visible.putAll(this);
52:
53:•                if (freeVariables != null)
54:                 {
55:                         visible.putAll(freeVariables);
56:                 }
57:
58:                 return visible;
59:         }
60:
61:         @Override
62:         public RootContext getRoot()
63:         {
64:                 return this;
65:         }
66:
67:         @Override
68:         public final int getDepth()
69:         {
70:•                return outer == null ? 1 : outer.getDepth() + 1;
71:         }
72:
73:         @Override
74:         public final Context getFrame(int depth)
75:         {
76:•                return depth == 0 ? this : outer == null ? this
77:                                 : outer.getFrame(depth - 1);
78:         }
79:
80:         @Override
81:         public ObjectValue getSelf()
82:         {
83:                 return null; // Overridden in ObjectContext
84:         }
85: }