mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
passing code position for a source map. #6
This commit is contained in:
parent
018fa3896a
commit
97b7b9dafd
@ -394,6 +394,14 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
function.typeId = typeId;
|
function.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void markCodePosition( int javaCodePosition ) {
|
||||||
|
function.markCodePosition( codeStream.size(), javaCodePosition );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 - 2018 Volker Berlin (i-net software)
|
* Copyright 2017 - 2019 Volker Berlin (i-net software)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -40,4 +40,16 @@ class Function extends SectionEntry {
|
|||||||
void writeSectionEntry( WasmOutputStream stream ) throws IOException {
|
void writeSectionEntry( WasmOutputStream stream ) throws IOException {
|
||||||
stream.writeVaruint32( this.typeId );
|
stream.writeVaruint32( this.typeId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add code position marker for a source map.
|
||||||
|
*
|
||||||
|
* @param streamPosition
|
||||||
|
* the position in the function stream
|
||||||
|
* @param javaCodePosition
|
||||||
|
* the position in the Java Source file
|
||||||
|
*/
|
||||||
|
void markCodePosition( int streamPosition, int javaCodePosition ) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,6 +369,8 @@ public class ModuleGenerator {
|
|||||||
|
|
||||||
List<WasmInstruction> instructions = codeBuilder.getInstructions();
|
List<WasmInstruction> instructions = codeBuilder.getInstructions();
|
||||||
optimizer.optimze( instructions );
|
optimizer.optimze( instructions );
|
||||||
|
|
||||||
|
int lastCodePosition = -1;
|
||||||
for( WasmInstruction instruction : instructions ) {
|
for( WasmInstruction instruction : instructions ) {
|
||||||
switch( instruction.getType() ) {
|
switch( instruction.getType() ) {
|
||||||
case Block:
|
case Block:
|
||||||
@ -388,6 +390,11 @@ public class ModuleGenerator {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
int codePosition = instruction.getCodePosition();
|
||||||
|
if( codePosition >= 0 && codePosition != lastCodePosition ) {
|
||||||
|
writer.markCodePosition( codePosition );
|
||||||
|
lastCodePosition = codePosition;
|
||||||
|
}
|
||||||
instruction.writeTo( writer );
|
instruction.writeTo( writer );
|
||||||
}
|
}
|
||||||
writer.writeMethodFinish();
|
writer.writeMethodFinish();
|
||||||
|
@ -126,6 +126,14 @@ public abstract class ModuleWriter implements Closeable {
|
|||||||
*/
|
*/
|
||||||
protected abstract void writeMethodParamFinish() throws IOException;
|
protected abstract void writeMethodParamFinish() throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the current output position with Java code position for crating of a source map.
|
||||||
|
*
|
||||||
|
* @param javaCodePosition
|
||||||
|
* the position in the Java code
|
||||||
|
*/
|
||||||
|
protected abstract void markCodePosition( int javaCodePosition );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the method
|
* Complete the method
|
||||||
*
|
*
|
||||||
|
@ -198,6 +198,14 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void markCodePosition( int javaCodePosition ) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user