[Pas2js] Disable optimization in specific units/blocks
warleyalex
warleyalex at yahoo.com.br
Fri Jan 11 17:37:59 CET 2019
OK. Another thing is
The pas2js compiler does neither parse, nor check the syntax of the JS, but
I thing pascal methods should be recognized within ASM block.
For instnce, pas2js compiler quickly figure out that is an Object Pascal
variable, you have to initialize the variables reference "before" you use
that reference iniside the ASM block. if you don't initialize the variable
reference beforehand, the smart linking will omit methods, you've got the
"Uncaught ReferenceError: ... is not defined"
----------------------
function Myfunction(const aValue: String): String;
begin
console.log(aValue);
result := aValue;
end;
type
TPerson = class external name 'Object'
public
constructor New;
Name: String;
Age: Integer;
Status: boolean;
end;
type
TProc = Function(const aValue: String): String;
var
P1: TPerson;
p: TProc;
begin
// Your code here
P1 := TPerson.new;
P1.Name:= 'John';
P1.Age:= 52;
P1.Status:= true;
p := @Myfunction; // we have to add this dummy variable to smart linking
include the Myfunction method.
ASM
window.Myfunction1 = this.Myfunction($mod.P1.Name);
END;
end.
----------------------
Maybe one day, pas2js should just recognize:
ASM
window.Myfunction1 = Myfunction(P1.Name);
END;
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list