Package: AstFactoryTC

AstFactoryTC

nameinstructionbranchcomplexitylinemethod
AstFactoryTC()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
newABusClassDefinition(ITypeCheckerAssistantFactory)
M: 0 C: 26
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
newACpuClassDefinition(ITypeCheckerAssistantFactory)
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
operationDefs()
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
operationDefsBus()
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * The VDM Type Checker
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ast.factory;
23:
24: import java.util.List;
25:
26: import org.overture.ast.definitions.ABusClassDefinition;
27: import org.overture.ast.definitions.ACpuClassDefinition;
28: import org.overture.ast.definitions.PDefinition;
29: import org.overture.ast.definitions.SClassDefinition;
30: import org.overture.ast.lex.Dialect;
31: import org.overture.ast.lex.LexLocation;
32: import org.overture.ast.lex.LexNameList;
33: import org.overture.ast.lex.LexNameToken;
34: import org.overture.parser.lex.LexException;
35: import org.overture.parser.lex.LexTokenReader;
36: import org.overture.parser.syntax.DefinitionReader;
37: import org.overture.parser.syntax.ParserException;
38: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
39:
40: public class AstFactoryTC extends AstFactory
41: {
42:
43:         public static SClassDefinition newACpuClassDefinition(
44:                         ITypeCheckerAssistantFactory assistantFactory)
45:                         throws ParserException, LexException
46:         {
47:                 ACpuClassDefinition result = new ACpuClassDefinition();
48:                 initClassDefinition(result, new LexNameToken("CLASS", "CPU", new LexLocation()), new LexNameList(), new AstFactoryTC().operationDefs());
49:
50:                 return result;
51:         }
52:
53:         public static SClassDefinition newABusClassDefinition(
54:                         ITypeCheckerAssistantFactory assistantFactory)
55:                         throws ParserException, LexException
56:         {
57:                 ABusClassDefinition result = new ABusClassDefinition();
58:                 initClassDefinition(result, new LexNameToken("CLASS", "BUS", new LexLocation()), new LexNameList(), new AstFactoryTC().operationDefsBus());
59:
60:                 result.setInstance(result);
61:
62:                 return result;
63:         }
64:         
65:         public static final long CPU_MAX_FREQUENCY = 1000000000; // 1GHz
66:         private String defs = "operations "
67:                         + "public CPU:(<FP>|<FCFS>) * real ==> CPU "
68:                         + "        CPU(policy, speed) == is not yet specified; "
69:                         + "public deploy: ? ==> () "
70:                         + "        deploy(obj) == is not yet specified; "
71:                         + "public deploy: ? * seq of char ==> () "
72:                         + "        deploy(obj, name) == is not yet specified; "
73:                         + "public setPriority: ? * nat ==> () "
74:                         + "        setPriority(opname, priority) == is not yet specified;";
75:
76:         public List<PDefinition> operationDefs() throws ParserException,
77:                         LexException
78:         {
79:                 LexTokenReader ltr = new LexTokenReader(defs, Dialect.VDM_PP);
80:                 DefinitionReader dr = new DefinitionReader(ltr);
81:                 dr.setCurrentModule("CPU");
82:                 return dr.readDefinitions();
83:         }
84:         
85:         
86:         private String defsBus = "operations "
87:                         + "public BUS:(<FCFS>|<CSMACD>) * real * set of CPU ==> BUS "
88:                         + "        BUS(policy, speed, cpus) == is not yet specified;";
89:
90:         public List<PDefinition> operationDefsBus() throws ParserException,
91:                         LexException
92:         {
93:                 LexTokenReader ltr = new LexTokenReader(defsBus, Dialect.VDM_PP);
94:                 DefinitionReader dr = new DefinitionReader(ltr);
95:                 dr.setCurrentModule("BUS");
96:                 return dr.readDefinitions();
97:         }
98:
99: }