File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
packages/transpiler/src/expressions Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ export class NewObjectTranspiler implements IExpressionTranspiler {
5151 const clas = traversal . lookupClassOrInterface ( type . getIdentifierName ( ) , node . getFirstToken ( ) ) ;
5252 ret . appendString ( TranspileTypes . toType ( type ) + ".set(await (new " + clas + "()).constructor_(" + para + "))" ) ;
5353 } else {
54- throw new Error ( "NewObjectTranspiler: only ObjectReferenceType currently handled, todo" ) ;
54+ const source = node . findFirstExpression ( abaplint . Expressions . Source ) ;
55+ if ( source === undefined ) {
56+ throw new Error ( "NewObjectTranspiler: DataReference source not found" ) ;
57+ }
58+ const typeCode = TranspileTypes . toType ( type ) ;
59+ const sourceCode = traversal . traverse ( source ) . getCode ( ) ;
60+ ret . appendString ( "((() => {const r = new abap.types.DataReference(" + typeCode + "); r.assign(" + sourceCode + "); return r; })())" ) ;
5561 }
5662
5763 return ret ;
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ START-OF-SELECTION.
113113 await f ( abap ) ;
114114 } ) ;
115115
116- it . only ( "inline ref to data" , async ( ) => {
116+ it ( "inline ref to data" , async ( ) => {
117117 const code = `
118118FORM foo.
119119 TYPES ty TYPE i.
@@ -126,6 +126,7 @@ START-OF-SELECTION.
126126 const js = await run ( code ) ;
127127 const f = new AsyncFunction ( "abap" , js ) ;
128128 await f ( abap ) ;
129+ expect ( abap . console . get ( ) ) . to . equal ( "2" ) ;
129130 } ) ;
130131
131132} ) ;
You can’t perform that action at this time.
0 commit comments