Skip to content

Commit

Permalink
Perlito5 - javascript: add "p5" prefix to global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Apr 4, 2012
1 parent 21a8662 commit 85fa8e6
Show file tree
Hide file tree
Showing 9 changed files with 769 additions and 769 deletions.
2 changes: 1 addition & 1 deletion README-perlito5-js
Expand Up @@ -72,7 +72,7 @@ Class
- classes inherit from UNIVERSAL

Namespace
- namespaces are stored in the NAMESPACE global hash
- namespaces are stored in the p5pkg global hash
- current namespace object is in the PKG variable
- Namespace inherits from from CORE::GLOBAL, which inherits from CORE
- Namespace is a copy of the Class, but with a different inheritance
Expand Down
14 changes: 7 additions & 7 deletions html/perlito5.html
Expand Up @@ -87,24 +87,24 @@ <h1><a href="http://www.perlito.org">"Perlito" Perl 5 Compiler</a></h1>

function execute() {

NAMESPACE.CORE.print = function(List__) {
p5pkg.CORE.print = function(List__) {
var i;
for (i = 0; i < List__.length; i++) {
document.getElementById('print-result').value += p5str(List__[i]);
}
return true;
};
NAMESPACE.CORE.warn = function(List__) {
p5pkg.CORE.warn = function(List__) {
var i;
List__.push("\n");
for (i = 0; i < List__.length; i++) {
document.getElementById('log-result').value += p5str(List__[i]);
}
return true;
};
NAMESPACE["main"]["v_^O"] = "browser";
NAMESPACE["main"]["Hash_INC"]["Perlito5/strict.pm"] = "Perlito5/strict.pm";
NAMESPACE["main"]["Hash_INC"]["Perlito5/warnings.pm"] = "Perlito5/warnings.pm";
p5pkg["main"]["v_^O"] = "browser";
p5pkg["main"]["Hash_INC"]["Perlito5/strict.pm"] = "Perlito5/strict.pm";
p5pkg["main"]["Hash_INC"]["Perlito5/warnings.pm"] = "Perlito5/warnings.pm";

var source = document.getElementById('source').value;
var pos = 0;
Expand All @@ -117,7 +117,7 @@ <h1><a href="http://www.perlito.org">"Perlito" Perl 5 Compiler</a></h1>
// compile
document.getElementById('log-result').value += "Compiling.\n";
var start = new Date().getTime();
var js_source = NAMESPACE["Perlito5"].compile_p5_to_js([source]);
var js_source = p5pkg["Perlito5"].compile_p5_to_js([source]);
var end = new Date().getTime();
var time = end - start;
document.getElementById('log-result').value += "Compilation time: " + time + "ms\n";
Expand All @@ -129,7 +129,7 @@ <h1><a href="http://www.perlito.org">"Perlito" Perl 5 Compiler</a></h1>
end = new Date().getTime();
time = end - start;
document.getElementById('log-result').value += "Running time: " + time + "ms\n";
NAMESPACE.CORE.print(["\nDone.\n"]);
p5pkg.CORE.print(["\nDone.\n"]);
}
catch(err) {
document.getElementById('log-result').value += "Error:\n";
Expand Down

0 comments on commit 85fa8e6

Please sign in to comment.