Skip to content

Commit af3ef8b

Browse files
authored
Merge pull request #106 from ortus-boxlang/development
1.0.0-Beta13
2 parents acca7a0 + afd2eb3 commit af3ef8b

File tree

129 files changed

+2449
-1268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+2449
-1268
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ dependencies {
9898
testImplementation "org.wiremock:wiremock:3.9.1"
9999
// https://mvnrepository.com/artifact/org.apache.derby/derby
100100
testImplementation 'org.apache.derby:derby:10.17.1.0'
101-
testImplementation 'io.undertow:undertow-core:2.3.16.Final'
101+
testImplementation 'io.undertow:undertow-core:2.3.17.Final'
102102

103103
// Antlr
104104
antlr "org.antlr:antlr4:$antlrVersion"
@@ -107,9 +107,9 @@ dependencies {
107107
// https://mvnrepository.com/artifact/commons-io/commons-io
108108
implementation "commons-io:commons-io:2.16.1"
109109
// https://mvnrepository.com/artifact/com.github.javaparser/javaparser-symbol-solver-core
110-
implementation 'com.github.javaparser:javaparser-symbol-solver-core:3.26.1'
110+
implementation 'com.github.javaparser:javaparser-symbol-solver-core:3.26.2'
111111
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
112-
implementation 'org.apache.commons:commons-lang3:3.16.0'
112+
implementation 'org.apache.commons:commons-lang3:3.17.0'
113113
// https://mvnrepository.com/artifact/org.apache.commons/commons-text
114114
// Many of these classes ( e.g. StringEscapeUtils ) are currently deprecated in commons-lang and others will be moved in the future
115115
implementation 'org.apache.commons:commons-text:1.12.0'

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Fri Aug 30 16:29:10 UTC 2024
1+
#Fri Aug 30 16:46:29 UTC 2024
22
antlrVersion=4.13.1
33
jdkVersion=21
4-
version=1.0.0-beta12
4+
version=1.0.0-beta13

src/main/antlr/BoxScriptGrammar.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ rethrow: RETHROW
407407
;
408408

409409
// throw Exception;
410-
throw: THROW expression
410+
throw: { isThrow(_input) }? THROW expression
411411
;
412412

413413
/*

src/main/antlr/CFScriptGrammar.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ rethrow: RETHROW
392392
;
393393

394394
// throw Exception;
395-
throw: THROW expression
395+
throw: { isThrow(_input) }? THROW expression
396396
;
397397

398398
/*

src/main/antlr/DocLexer.g4

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
2-
3-
41
lexer grammar DocLexer;
52

6-
NAME: [a-zA-Z.0-9]+;
3+
NAME: [a-zA-Z.0-9:]+;
74

85
NEWLINE:
9-
'\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)?
10-
| '\r\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)?
11-
| '\r' (SPACE? (STAR {_input.LA(1) != '/'}?)+)?
12-
;
6+
'\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)?
7+
| '\r\n' (SPACE? (STAR {_input.LA(1) != '/'}?)+)?
8+
| '\r' (SPACE? (STAR {_input.LA(1) != '/'}?)+)?;
139

1410
SPACE: (' ' | '\t')+;
1511

src/main/java/ortus/boxlang/compiler/asmboxpiler/AsmHelper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ public static void methodWithContextAndClassLocator( ClassNode classNode,
282282
Type returnType,
283283
boolean isStatic,
284284
Transpiler transpiler,
285+
boolean implicityReturnNull,
285286
Supplier<List<AbstractInsnNode>> supplier ) {
286287
MethodContextTracker tracker = new MethodContextTracker( isStatic );
287288
transpiler.addMethodContextTracker( tracker );
@@ -302,6 +303,7 @@ public static void methodWithContextAndClassLocator( ClassNode classNode,
302303
Type.getMethodDescriptor( Type.getType( ClassLocator.class ) ),
303304
false );
304305
tracker.storeNewVariable( Opcodes.ASTORE ).nodes().forEach( ( node ) -> node.accept( methodVisitor ) );
306+
305307
// methodVisitor.visitVarInsn( Opcodes.ASTORE, isStatic ? 1 : 2 );
306308
List<AbstractInsnNode> nodes = supplier.get();
307309
if ( !nodes.isEmpty() && ( nodes.get( nodes.size() - 1 ).getOpcode() == Opcodes.POP || nodes.get( nodes.size() - 1 ).getOpcode() == Opcodes.POP2 ) ) {
@@ -310,6 +312,11 @@ public static void methodWithContextAndClassLocator( ClassNode classNode,
310312
nodes.forEach( node -> node.accept( methodVisitor ) );
311313
}
312314

315+
if ( implicityReturnNull ) {
316+
// push a null onto the stack so that we can return it if there isn't an explicity return
317+
new InsnNode( Opcodes.ACONST_NULL ).accept( methodVisitor );
318+
}
319+
313320
methodVisitor.visitInsn( returnType.getOpcode( Opcodes.IRETURN ) );
314321
methodVisitor.visitMaxs( 0, 0 );
315322

src/main/java/ortus/boxlang/compiler/asmboxpiler/AsmTranspiler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public ClassNode transpile( BoxScript boxScript ) throws BoxRuntimeException {
262262
returnType,
263263
false,
264264
this,
265+
false,
265266
() -> AsmHelper.transformBodyExpressions( this, boxScript.getStatements(), TransformerContext.NONE,
266267
returnType == Type.VOID_TYPE ? ReturnValueContext.EMPTY : ReturnValueContext.VALUE_OR_NULL )
267268
);
@@ -626,12 +627,12 @@ public ClassNode transpile( BoxClass boxClass ) throws BoxRuntimeException {
626627
Type.getType( Key.class ), Type.getType( Map.class ), Type.getType( Boolean.class ) );
627628
AsmHelper.boxClassSupport( classNode, "registerInterface", Type.VOID_TYPE, Type.getType( BoxInterface.class ) );
628629

629-
AsmHelper.methodWithContextAndClassLocator( classNode, "_pseudoConstructor", Type.getType( IBoxContext.class ), Type.VOID_TYPE, false, this,
630+
AsmHelper.methodWithContextAndClassLocator( classNode, "_pseudoConstructor", Type.getType( IBoxContext.class ), Type.VOID_TYPE, false, this, true,
630631
() -> boxClass.getBody().stream().flatMap( statement -> transform( statement, TransformerContext.NONE, ReturnValueContext.EMPTY ).stream() )
631632
.toList()
632633
);
633634

634-
AsmHelper.methodWithContextAndClassLocator( classNode, "staticInitializer", Type.getType( IBoxContext.class ), Type.VOID_TYPE, true, this,
635+
AsmHelper.methodWithContextAndClassLocator( classNode, "staticInitializer", Type.getType( IBoxContext.class ), Type.VOID_TYPE, true, this, true,
635636
List::of
636637
);
637638

src/main/java/ortus/boxlang/compiler/asmboxpiler/transformer/expression/BoxClosureTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public List<AbstractInsnNode> transform( BoxNode node, TransformerContext contex
140140
Type.getType( BoxSourceType.class ) );
141141

142142
AsmHelper.methodWithContextAndClassLocator( classNode, "_invoke", Type.getType( FunctionBoxContext.class ), Type.getType( Object.class ), false,
143-
transpiler,
143+
transpiler, false,
144144
() -> boxClosure.getBody().getChildren().stream().flatMap( statement -> transpiler.transform( statement, TransformerContext.NONE ).stream() )
145145
.toList() );
146146

src/main/java/ortus/boxlang/compiler/asmboxpiler/transformer/expression/BoxLambdaTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public List<AbstractInsnNode> transform( BoxNode node, TransformerContext contex
117117
Type.getType( BoxSourceType.class ) );
118118

119119
AsmHelper.methodWithContextAndClassLocator( classNode, "_invoke", Type.getType( FunctionBoxContext.class ), Type.getType( Object.class ), false,
120-
transpiler,
120+
transpiler, false,
121121
() -> boxLambda.getBody().getChildren().stream().flatMap( statement -> transpiler.transform( statement, TransformerContext.NONE ).stream() )
122122
.toList() );
123123

src/main/java/ortus/boxlang/compiler/asmboxpiler/transformer/expression/BoxMethodInvocationTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public List<AbstractInsnNode> transform( BoxNode node, TransformerContext contex
5454

5555
transpiler.getCurrentMethodContextTracker().ifPresent( tracker -> nodes.addAll( tracker.loadCurrentContext() ) );
5656

57-
nodes.addAll( transpiler.transform( invocation.getObj(), context, returnContext ) );
57+
nodes.addAll( transpiler.transform( invocation.getObj(), context, ReturnValueContext.VALUE ) );
5858

5959
if ( invocation.getUsedDotAccess() ) {
6060
nodes.addAll( transpiler.createKey( ( ( BoxIdentifier ) invocation.getName() ).getName() ) );

0 commit comments

Comments
 (0)