mirror of
https://github.com/schibo/1964js.git
synced 2025-04-02 10:52:54 -04:00
git-svn-id: http://1964js.googlecode.com/svn/trunk@178 0378edba-076e-5dc0-2bb2-d87a714dcd81
38 lines
841 B
Dart
38 lines
841 B
Dart
library vm;
|
|
|
|
import 'dart:html';
|
|
|
|
/**
|
|
* Abstract base class for code generation. 1964js is a VM that
|
|
* dynamically generates code for the target platform. Since Dart can
|
|
* target JavaScript or the Dart VM, 1964js will also support these targets.
|
|
*/
|
|
abstract class VM {
|
|
Object _code;
|
|
|
|
VM() {}
|
|
|
|
/**
|
|
* Clears all the generated code
|
|
*/
|
|
void eraseAllCode();
|
|
|
|
/**
|
|
* Write generated code to the root of the DOM or into a new Object.
|
|
* Chrome is currently running faster when generated scripts are written to
|
|
* the root of the DOM.
|
|
*/
|
|
void reset(bool writeToDom) {
|
|
if (writeToDom === true) {
|
|
if (_code !== window) {
|
|
eraseAllCode();
|
|
_code = window;
|
|
}
|
|
} else {
|
|
if (_code === window || _code === null) {
|
|
eraseAllCode();
|
|
}
|
|
_code = new Object();
|
|
}
|
|
}
|
|
}
|