@@ -19,16 +19,9 @@ import scala.reflect.runtime.universe.typeOf
19
19
*/
20
20
class RuntimePropertyGeneratorBuilder (config : DataSynthConfig ) extends ExecutionPlanNonVoidVisitor [RuntimeClasses ] {
21
21
22
-
23
- def codePropertyTableClasses (executionPlan: Seq [ExecutionPlan .Table ]): RuntimeClasses = {
22
+ def codePropertyTableClasses (executionPlan : Seq [ExecutionPlan .Table ]) : RuntimeClasses = {
24
23
/** Writing .scala files **/
25
- /* val classes:Map[String,(String,String)] = executionPlan.foldLeft(
26
- Map[String,(String,String)]())( (currentDeclarations, nextNode) => currentDeclarations ++ nextNode.accept(this))
27
- classes
28
- */
29
- val classes2 : RuntimeClasses = executionPlan.foldLeft(new RuntimeClasses )((codeClassses, nextNode)=> codeClassses++ nextNode.accept(this ))
30
- classes2
31
-
24
+ executionPlan.foldLeft(new RuntimeClasses )((codeClassses, nextNode) => codeClassses++ nextNode.accept(this ))
32
25
}
33
26
34
27
/**
@@ -43,35 +36,38 @@ class RuntimePropertyGeneratorBuilder(config : DataSynthConfig) extends Executio
43
36
settings.nc.value = true
44
37
settings.usejavacp.value = true
45
38
settings.outputDirs.setSingleOutput(s " ${config.driverWorkspaceDir}" )
46
- val currentJarPath : String = getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
47
- println(currentJarPath)
39
+ val currentJarPath : String = getClass()
40
+ .getProtectionDomain()
41
+ .getCodeSource()
42
+ .getLocation()
43
+ .getPath()
48
44
settings.classpath.append(currentJarPath)
49
45
val g = new Global (settings)
50
46
val run = new g.Run
51
47
52
-
53
-
54
-
55
- val sourceFileNames : List [String ] = classes.toList.map({case (className,classCode)=> {
56
- val fileName : String = s " ${config.driverWorkspaceDir}/ $className.scala "
57
- val writer = new PrintWriter (new java.io.File (fileName))
58
- writer.write(classCode)
59
- writer.close()
60
-
61
- fileName
62
- }})
63
-
48
+ // Creating .scala source code files
49
+ val sourceFileNames : List [String ] = classes.toList.map(
50
+ {
51
+ case (className,classCode) => {
52
+ val fileName : String = s " ${config.driverWorkspaceDir}/ $className.scala "
53
+ val writer = new PrintWriter (new java.io.File (fileName))
54
+ writer.write(classCode)
55
+ writer.close()
56
+ fileName
57
+ }
58
+ }
59
+ )
60
+
61
+ // Compiling the .scala source code files
64
62
run.compile(sourceFileNames)
65
63
66
- /** Building JAR * */
64
+ // Building JAR
67
65
val jar : JarWriter = new JarWriter (new scala.reflect.io.File (new java.io.File (jarFileName)), new JManifest ())
68
- sourceFileNames.map( file => file.replace(" .scala" ," .class" )).foreach( file => jar.addFile(new scala.reflect.io.File ( new java.io.File (file))," " ))
66
+ sourceFileNames.map( file => file.replace(" .scala" ," .class" ))
67
+ .foreach( file => jar.addFile(new scala.reflect.io.File (new java.io.File (file)), " " ))
69
68
jar.close()
70
69
}
71
70
72
-
73
-
74
-
75
71
/**
76
72
* Generates the name of a generated proeprty generator given an original generator name
77
73
* @param name The name of the original property generator
@@ -113,7 +109,6 @@ class RuntimePropertyGeneratorBuilder(config : DataSynthConfig) extends Executio
113
109
}
114
110
val propertyGeneratorName : String = propertyGenerator.className
115
111
val generatedClassName : String = generateClassName(className)
116
- // val dependentGenerators = propertyGenerator.dependentPropertyTables.map(table => generateClassName(table.name))
117
112
val dependentGeneratorsCallList : String = propertyGenerator.dependentPropertyTables.zipWithIndex.foldLeft(" " )(
118
113
{case (current,(table,index)) => s " $current, ${mkMatch(table,index)}" })
119
114
@@ -126,54 +121,36 @@ class RuntimePropertyGeneratorBuilder(config : DataSynthConfig) extends Executio
126
121
}
127
122
128
123
override def visit (node : ExecutionPlan .StaticValue [_]): RuntimeClasses = {
129
- // Map.empty
130
124
throw new RuntimeException (" No code should be generated for StaticValue[_]" )
131
125
}
132
126
133
127
override def visit (node : ExecutionPlan .PropertyGenerator [_]): RuntimeClasses = {
134
- // Map.empty
135
128
throw new RuntimeException (" No code should be generated for PropertyGenerator[_]" )
136
129
}
137
130
138
131
override def visit (node : ExecutionPlan .StructureGenerator ): RuntimeClasses = {
139
- // Map.empty
140
132
throw new RuntimeException (" No code should be generated for StructureGenerator" )
141
133
}
142
134
143
- /* override def visit(node: ExecutionPlan.PropertyTable[_]): Map[String, (String,String)] = {
144
- val classTypeName = generateClassName(node.name)
145
- val classDeclaration = generatePGClassDefinition(classTypeName,node.generator)
146
- val dependants = node.generator.dependentPropertyTables.map( table => table.accept[Map[String,(String,String)]](this) ).
147
- foldLeft(Map[String,(String,String)]())( {case (accumulated, next) => accumulated ++ next} )
148
- dependants + (node.name -> (classTypeName,classDeclaration))
149
-
150
- }*/
151
-
152
135
override def visit (node : ExecutionPlan .PropertyTable [_]): RuntimeClasses = {
153
136
val classTypeName = generateClassName(node.name)
154
137
val classDeclaration = generatePGClassDefinition(classTypeName,node.generator)
155
138
156
-
157
139
val dependants : RuntimeClasses = node.generator.dependentPropertyTables.map(table => table.accept[RuntimeClasses ](this ) ).
158
140
foldLeft(new RuntimeClasses ())( {case (accumulated, next) => accumulated ++ next} )
159
141
val codeClass : RuntimeClass = new RuntimeClass (node.name,classTypeName,classDeclaration)
160
142
dependants + codeClass
161
- dependants
162
143
}
163
144
164
-
165
145
override def visit (node : ExecutionPlan .EdgeTable ): RuntimeClasses = {
166
- // Map.empty
167
- throw new RuntimeException (" No code should be generated for EdgeTable" )
146
+ new RuntimeClasses ()
168
147
}
169
148
170
149
override def visit (node : ExecutionPlan .TableSize ): RuntimeClasses = {
171
- // Map.empty
172
150
throw new RuntimeException (" No code should be generated for TableSize" )
173
151
}
174
152
175
153
override def visit (node : ExecutionPlan .Match ): RuntimeClasses = {
176
- // Map.empty
177
- throw new RuntimeException (" No code should be generated for Match" )
154
+ new RuntimeClasses ()
178
155
}
179
156
}
0 commit comments