I hereby claim:
- I am melix on github.
- I am melix (https://keybase.io/melix) on keybase.
- I have a public key whose fingerprint is 3312 24E1 D7BE 883D 16E8 A685 825C 06C8 27AF 6B66
To claim this, I am signing this object:
import groovy.transform.ASTTest | |
import groovy.transform.CompileStatic | |
import groovy.transform.Immutable | |
import org.codehaus.groovy.ast.ClassNode | |
import org.codehaus.groovy.control.CompilePhase | |
@ASTTest(phase=CompilePhase.INSTRUCTION_SELECTION,value={ | |
ClassNode cn = node | |
def config = cn.compileUnit.config | |
def cu = cn.compileUnit.classLoader.createCompilationUnit(config, null) |
// add this to build.gradle | |
gradle.taskGraph.whenReady { | |
allprojects { | |
tasks.withType(GroovyCompile) { task -> | |
logger.lifecycle("Task $task") | |
task.groovyOptions.forkOptions.jvmArgs=['-noverify'] | |
} | |
} | |
} |
import org.codehaus.groovy.reflection.ClassInfo | |
import org.codehaus.groovy.runtime.MethodRankHelper | |
trait FatFingers { | |
def methodMissing(String name, args) { | |
def ci = ClassInfo.getClassInfo(this.class) | |
def methods = [*ci.metaClass.methods,*ci.metaClass.metaMethods] | |
def sugg = MethodRankHelper.rankMethods(name,args,methods) | |
if (sugg) { | |
sugg[0].invoke(this, args) |
I hereby claim:
To claim this, I am signing this object:
// "macro" builds the AST of the corresponding block | |
def ast1 = macro { foo(a) + foo(a) } | |
def ast2 = macro { foo(a) + foo(foo(a)) } | |
// we build another AST which will be used as a pattern | |
def pattern = macro { | |
x + foo(x) | |
}.withConstraints { | |
// declare that x is not a variable, but a placeholder | |
placeholder x |
import groovy.transform.CompileStatic | |
public <T> T configure(@DelegatesTo.Target Class<T> clazz, @DelegatesTo(genericTypeIndex = 0) Closure<Void> conf) { | |
def result = clazz.newInstance() | |
result.with(conf) | |
result | |
} | |
class Person { | |
String name |
trait Configurable<ConfigObject> { | |
ConfigObject configObject | |
void configure(Closure<Void> configSpec) { | |
configSpec.resolveStrategy = Closure.DELEGATE_FIRST | |
configSpec.delegate = configObject | |
configSpec() | |
} | |
} |
void testRelaxedBinaryExpressionWithConstrainedToken() { | |
use(ASTMatcher) { | |
def ast1 = macro { a + b } | |
def ast2 = macro { a - b } | |
def ast3 = macro { a * b } | |
def ast4 = macro { a + c } | |
def pattern = macro { | |
a + b | |
}.withConstraints { | |
token { |
void testInlineMacroCombinationWithConstraints() { | |
use(ASTMatcher) { | |
def ast1 = macro { a + b } | |
def ast2 = macro { b + b } | |
def ast3 = macro { b + c } | |
def ast4 = macro { b - b } | |
def pattern = macro { | |
$v { macro { a }.withConstraints { placeholder a } } + b | |
}.withConstraints { | |
anyToken() |
# Run complete. Total time: 00:34:14 | |
Benchmark Mode Samples Score Error Units | |
o.g.m.f.FibonacciMicroBenchmark.groovy_primitive_cs avgt 30 1.961 ± 0.055 ms/op | |
o.g.m.f.FibonacciMicroBenchmark.baseline_java_30 avgt 30 2.004 ± 0.084 ms/op | |
o.g.m.f.FibonacciMicroBenchmark.baseline_java_boxing_30 avgt 30 5.504 ± 0.036 ms/op | |
o.g.m.f.FibonacciMicroBenchmark.groovy_primitive_30 avgt 30 5.733 ± 0.024 ms/op | |
o.g.m.f.FibonacciMicroBenchmark.groovy_indy_30 avgt 30 5.903 ± 0.033 ms/op | |
o.g.m.f.FibonacciMicroBenchmark.golo_30 avgt 30 6.545 ± 0.060 ms/op | |
o.g.m.f.FibonacciMicroBenchmark.nashorn_30 avgt 30 7.812 ± 0.061 ms/op |