1 / 13

Статический анализатор для языка ECMA Script 4

Статический анализатор для языка ECMA Script 4. Власов В. А. Мат.-мех. Ф-т. Языки ECMA Script 4 . JavaScript 2 (Mozilla) ActionScript 3 (Adobe) class Greeter implements Greetings { public function hello() { print(“hello, world”) } public function goodmorning() {

gram
Download Presentation

Статический анализатор для языка ECMA Script 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Статический анализатор для языка ECMA Script 4 Власов В. А. Мат.-мех. Ф-т.

  2. Языки ECMA Script 4 • JavaScript 2 (Mozilla) • ActionScript 3 (Adobe)class Greeter implements Greetings { public function hello() { print(“hello, world”) } public function goodmorning() { print(“goodmorning, world”) } }

  3. ECMA: Variables • var x = 10 • const PI = 3.1415 • var x: Shape • var x: Shape = new Shape

  4. ECMA: Functions • Как статические функции.function hello() { print(“hello, world”)}hello() • Как методы классовpublic class Greeter { public function hello() { print(“hello, world”) } } • Анонимные функцииfunction (x: Integer, y: Integer) : Integer { return x + y }

  5. ECMA: Classes,Interfaces interface Greetings { function hello() function goodmorning() } class Greeter implements Greetings { public function hello() { print(“hello, world”) } public function goodmorning() { print(“goodmorning, world”) } } var greeter : Greetings = new Greeter() greeter.hello()

  6. ECMA: Прототипы • У каждого объекта есть прототип • Прототип подкласс класса dynamic class Object class A { prototype var x : int = 10 } var a1 = new A; var a2 = new A; trace(a1.x); trace(a2.prototype.x); var p1: Object; p1.prototype = a1; trace(p1.x); trace(p1.prototype.x); class A { prototype var f = function() { trace("A.f") }    // prototype function g() { trace("A.g") }  // не разрешено }

  7. ECMA: Dynamic • Расширение экземпляра класса с добавлением дополнительных полейdynamic class A { var x : String; var y; } var a : A = new A print(a.x) // null print(a.y) // undefined print(a.z) // undefined a.y = 10 a.z = 20 print(a.y) // 10 print(a.z) // 20

  8. ECMA: Анонимные классы class A { var x function A() { this.x = 10 } function m() { trace(this.x) } } var a = new A() var o = { x : 20 } o.m = a.m o.m() // traces 10

  9. ECMA: Class Members • Fieldsclass A {var __x : Integer;} • Methodsclass A {public function sum(x, y) : integer { return x + y; } • Property Emulationclass A {var __x : Integer;public function get x() {return __x;} public function set x(v) { __x = v;}

  10. ECMA: Packages package actors { public class Greeter { public function hello() { print(“hello, world”) } } } import actors.Greeter var greeter : Greeter = new Greeter greeter.hello()

  11. ECMA: Namespaces package actors { public namespace English public namespace French public class BilingualGreeter { English function hello() { print("hello, world") } French function hello() { print("bonjour, le monde") } } } import actors.* var greeter : BilingualGreeter = new BilingualGreeter use namespace English greeter.hello() greeter.French::hello()

  12. Статический анализ • Слаботипизированный язык. • Проверка типов только во время исполнения. • Функциональные переменные.

  13. Решение • Ecplipse plug-in: • Parser • Частичные интерпретатор • Find Usages • Проверка типов (статический анализ) • Refactoring tool: • Inline Variable • Introduce Variable • Rename

More Related