Skip to content

Commit cad130a

Browse files
author
heineman
committed
Should have fixed O1OA issues
1. Cleaned up lots of scripts to autoamte 2. Fixed EIPs 3. Confirmed should work for Coco, Visitor, Algebra
1 parent a481a8f commit cad130a

40 files changed

+328
-1141
lines changed

Diff for: attic/M0Test.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package mathdomain
2+
3+
class M0Test() extends org.scalatest.funsuite.AnyFunSuite {
4+
5+
this.test("Test")(
6+
{
7+
assert (new mathdomain.m0.Add(new mathdomain.m0.Lit(1.0),new mathdomain.m0.Lit(2.0)).accept[Double](this.makeEval) == 3.0);
8+
assert (new mathdomain.m0.Lit(5.0).accept[Double](this.makeEval) == 5.0);
9+
}
10+
);
11+
12+
// this was this.test("makeEval") and that is wrong
13+
def makeEval()
14+
{
15+
return new mathdomain.m0.Eval()
16+
}
17+
18+
}

Diff for: build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ lazy val languageJava =
8383
standardLanguageProject("java")
8484
.settings(libraryDependencies += "com.github.javaparser" % "javaparser-core" % "3.19.0")
8585
.settings(
86-
Compile/run/mainClass := Some("org.combinators.ep.language.java.systemJ.DirectToDiskMainJ")
86+
Compile/run/mainClass := Some("org.combinators.ep.language.java.DirectToDiskMain")
8787
)
8888

8989
lazy val helloWorldProject: Project =
@@ -92,7 +92,7 @@ lazy val helloWorldProject: Project =
9292
.settings(
9393
moduleName := s"expression-problem-language-helloworld",
9494
)
95-
.dependsOn(core, languageJava)
95+
.dependsOn(core, languageJava, languageNewScala)
9696

9797
lazy val exitSBT =
9898
standardLanguageProject("java")

Diff for: core/src/main/scala/org/combinators/ep/approach/oo/ObjectAlgebras.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,9 @@ trait ObjectAlgebras extends ApproachImplementationProvider {
873873
) {
874874
return domain
875875
}
876-
if (orderedImplementers.isEmpty) {
877-
println(op + "," + domain.name)
878-
}
879876
orderedImplementers.head
880877

881-
878+
// LEAVE THIS HERE TO SHOW WHAT WAS REPLACED
882879
// // find type case where domainSpecific says you are implemented here.
883880
// val result = domain.flatten.typeCases.map(tpeCase =>
884881
// // are we implementing or overriding.

Diff for: core/src/main/scala/org/combinators/ep/approach/oo/OperationAsClass.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.combinators.ep.approach.oo /*DI:LI:AD*/
22

3+
import org.combinators.ep.domain.GenericModel
34
import org.combinators.ep.domain.abstractions.{DataType, DataTypeCase, Operation, Parameter}
45
import org.combinators.ep.generator.Command.Generator
56
import org.combinators.ep.generator.paradigm.AnyParadigm.syntax.forEach
@@ -21,6 +22,7 @@ trait OperationAsClass extends ApproachImplementationProvider {
2122
tpe: DataType,
2223
tpeCase: DataTypeCase,
2324
op: Operation,
25+
model: GenericModel,
2426
domainSpecific: EvolutionImplementationProvider[this.type]
2527
): Generator[MethodBodyContext, Option[Expression]]
2628

@@ -86,7 +88,7 @@ trait OperationAsClass extends ApproachImplementationProvider {
8688
* @return
8789
* @see makeImplementation
8890
*/
89-
def operationClass(methodName:Name, op:Operation, typeCases:Seq[DataTypeCase], base:DataType, domainSpecific: EvolutionImplementationProvider[this.type]): Generator[ClassContext, Unit] = {
91+
def operationClass(methodName:Name, op:Operation, model:GenericModel, typeCases:Seq[DataTypeCase], base:DataType, domainSpecific: EvolutionImplementationProvider[this.type]): Generator[ClassContext, Unit] = {
9092
import ooParadigm.classCapabilities._
9193

9294
for {
@@ -95,7 +97,7 @@ trait OperationAsClass extends ApproachImplementationProvider {
9597
_ <- addParamFields(op)
9698
_ <- addConstructor(makeOperationConstructor(op))
9799
_ <- forEach (typeCases) { tpe =>
98-
addMethod(methodName, makeImplementation(base, tpe, op, domainSpecific))
100+
addMethod(methodName, makeImplementation(base, tpe, op, model, domainSpecific))
99101
}
100102
} yield ()
101103
}

Diff for: core/src/main/scala/org/combinators/ep/approach/oo/RuntimeDispatch.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ trait RuntimeDispatch extends SharedOO with OperationAsClass {
199199
import ooParadigm.classCapabilities._
200200

201201
for {
202-
_ <- operationClass(names.addPrefix("_", names.mangle(names.instanceNameOf(op))), op, domain.typeCases, domain.baseDataType, domainSpecific)
202+
_ <- operationClass(names.addPrefix("_", names.mangle(names.instanceNameOf(op))), op, domain, domain.typeCases, domain.baseDataType, domainSpecific)
203203

204204
returnTpe <- toTargetLanguageType(op.returnType)
205205
_ <- resolveAndAddImport(returnTpe)
@@ -273,6 +273,7 @@ trait RuntimeDispatch extends SharedOO with OperationAsClass {
273273
override def makeImplementation(tpe: DataType,
274274
tpeCase: DataTypeCase,
275275
op: Operation,
276+
model: GenericModel,
276277
domainSpecific: EvolutionImplementationProvider[this.type]
277278
): Generator[MethodBodyContext, Option[Expression]] = {
278279
import paradigm.methodBodyCapabilities._

Diff for: core/src/main/scala/org/combinators/ep/approach/oo/SharedOO.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ trait SharedOO extends ApproachImplementationProvider {
114114
tpe: DataType,
115115
tpeCase: DataTypeCase,
116116
op: Operation,
117+
model: GenericModel,
117118
domainSpecific: EvolutionImplementationProvider[this.type]
118119
): Generator[MethodBodyContext, Option[Expression]] = {
119120
import paradigm.methodBodyCapabilities._
@@ -134,7 +135,8 @@ trait SharedOO extends ApproachImplementationProvider {
134135
tpeCase,
135136
thisRef,
136137
atts,
137-
Request(op, args)
138+
Request(op, args),
139+
Some(model)
138140
)
139141
)
140142
} yield result

Diff for: core/src/main/scala/org/combinators/ep/approach/oo/Traditional.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ trait Traditional extends SharedOO { // this had been sealed. not sure why
4242
* A constructor is generated, using [[makeConstructor]]. Fields are generates, using [[makeField]]. Each
4343
* operation is embedded as a method within each class, using [[makeImplementation]]
4444
*/
45-
def makeDerived(tpe: DataType, tpeCase: DataTypeCase, ops: Seq[Operation], domainSpecific: EvolutionImplementationProvider[this.type]): Generator[ProjectContext, Unit] = {
45+
def makeDerived(tpe: DataType, tpeCase: DataTypeCase, ops: Seq[Operation], domain:GenericModel, domainSpecific: EvolutionImplementationProvider[this.type]): Generator[ProjectContext, Unit] = {
4646
import ooParadigm.projectCapabilities._
4747
val makeClass: Generator[ClassContext, Unit] = {
4848
import classCapabilities._
@@ -53,7 +53,7 @@ trait Traditional extends SharedOO { // this had been sealed. not sure why
5353
_ <- forEach (tpeCase.attributes) { att => makeField(att) }
5454
_ <- addConstructor(makeConstructor(tpeCase))
5555
_ <- forEach (ops) { op =>
56-
addMethod(names.mangle(names.instanceNameOf(op)), makeImplementation(tpe, tpeCase, op, domainSpecific))
56+
addMethod(names.mangle(names.instanceNameOf(op)), makeImplementation(tpe, tpeCase, op, domain, domainSpecific))
5757
}
5858
} yield ()
5959
}
@@ -81,7 +81,7 @@ trait Traditional extends SharedOO { // this had been sealed. not sure why
8181

8282
_ <- makeBase(flatDomain.baseDataType, flatDomain.ops)
8383
_ <- forEach (flatDomain.typeCases.distinct) { tpeCase =>
84-
makeDerived(flatDomain.baseDataType, tpeCase, flatDomain.ops, domainSpecific)
84+
makeDerived(flatDomain.baseDataType, tpeCase, flatDomain.ops, gdomain, domainSpecific)
8585
}
8686
} yield ()
8787
}

0 commit comments

Comments
 (0)