@Test public void shouldGenerateNullaryConstructor() { compile( "module scotch.test", "data Maybe a = Nothing | Just a" ); assertThat(graph.getDefinition(dataRef(symbol("scotch.test.Maybe"))), is(Optional.of(data("scotch.test.Maybe", asList(var("a")), asList( constructor("scotch.test.Nothing", "scotch.test.Maybe", emptyList()), constructor("scotch.test.Just", "scotch.test.Maybe", asList( field("_0", var("a")) )) ))))); shouldHaveValue("scotch.test.Nothing", constantReference("scotch.test.Nothing", "scotch.test.Maybe", fieldSignature("scotch/test/Maybe$Nothing", ACC_PUBLIC | ACC_FINAL | ACC_STATIC, "INSTANCE", "Lscotch/runtime/Callable;"))); }
public IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField) { return Intermediates.constantReference(symbol, dataType, constantField); }
IntermediateGenerator { public IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField) { return Intermediates.constantReference(symbol, dataType, constantField); } }
IntermediateGenerator { public IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField) { return Intermediates.constantReference(symbol, dataType, constantField); } IntermediateGenerator(DefinitionGraph graph); }
IntermediateGenerator { public IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField) { return Intermediates.constantReference(symbol, dataType, constantField); } IntermediateGenerator(DefinitionGraph graph); void addArgument(String name); List<String> capture(); IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField); IntermediateConstructor createConstructor(Symbol symbol, String className, MethodSignature methodSignature, List<IntermediateValue> arguments); Optional<DefinitionReference> defineData(Symbol symbol, List<Type> parameters, List<IntermediateConstructorDefinition> constructors); DefinitionReference defineMembers(List<DefinitionReference> definitions); DefinitionReference defineModule(String symbol, Runnable importScopeRunner); DefinitionReference defineRoot(List<DefinitionReference> references); DefinitionReference defineValue(Symbol symbol, Type type, IntermediateValue body); IntermediateGraph generateIntermediateCode(); Optional<DefinitionReference> generateIntermediateCode(DefinitionReference reference); DataConstructorDescriptor getDataConstructor(Symbol constructor); String getFieldMethod(Symbol symbol, String field); MethodSignature instanceGetter(InstanceReference reference); void reference(String name); Optional<DefinitionReference> scoped(T scoped, Supplier<DefinitionReference> runnable); MethodSignature valueSignature(ValueReference reference); }
IntermediateGenerator { public IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField) { return Intermediates.constantReference(symbol, dataType, constantField); } IntermediateGenerator(DefinitionGraph graph); void addArgument(String name); List<String> capture(); IntermediateValue constantReference(Symbol symbol, Symbol dataType, FieldSignature constantField); IntermediateConstructor createConstructor(Symbol symbol, String className, MethodSignature methodSignature, List<IntermediateValue> arguments); Optional<DefinitionReference> defineData(Symbol symbol, List<Type> parameters, List<IntermediateConstructorDefinition> constructors); DefinitionReference defineMembers(List<DefinitionReference> definitions); DefinitionReference defineModule(String symbol, Runnable importScopeRunner); DefinitionReference defineRoot(List<DefinitionReference> references); DefinitionReference defineValue(Symbol symbol, Type type, IntermediateValue body); IntermediateGraph generateIntermediateCode(); Optional<DefinitionReference> generateIntermediateCode(DefinitionReference reference); DataConstructorDescriptor getDataConstructor(Symbol constructor); String getFieldMethod(Symbol symbol, String field); MethodSignature instanceGetter(InstanceReference reference); void reference(String name); Optional<DefinitionReference> scoped(T scoped, Supplier<DefinitionReference> runnable); MethodSignature valueSignature(ValueReference reference);  }