liquidscript 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/liquidscript/compiler/icr.rb +6 -1
- data/lib/liquidscript/compiler/icr/classes.rb +18 -2
- data/lib/liquidscript/compiler/icr/functions.rb +5 -10
- data/lib/liquidscript/compiler/icr/helpers.rb +2 -1
- data/lib/liquidscript/compiler/icr/literals.rb +19 -11
- data/lib/liquidscript/generator/javascript/literals.rb +26 -7
- data/lib/liquidscript/generator/javascript/objects.rb +10 -8
- data/lib/liquidscript/icr/context.rb +74 -20
- data/lib/liquidscript/icr/set.rb +12 -9
- data/lib/liquidscript/icr/variable.rb +12 -3
- data/lib/liquidscript/scanner/liquidscript/main.rb +2 -0
- data/lib/liquidscript/version.rb +1 -1
- data/spec/fixtures/class.compile.yml +4 -2
- data/spec/fixtures/class.generate.yml +47 -8
- data/spec/fixtures/combination.generate.yml +1 -0
- data/spec/fixtures/function.generate.yml +12 -1
- data/spec/fixtures/literals.generate.yml +1 -1
- data/spec/fixtures/main.compile.yml +8 -8
- data/spec/fixtures/string.compile.yml +4 -4
- data/spec/liquidscript/icr/context_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37763a0403a2c5970ed9af12838e06cd201098e7
|
4
|
+
data.tar.gz: 2f685296ac6651a7caf0cb4d632363ea60e31adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ff68b0b6dd56458726509b4e1a9660ea25ce7324d2bee3fee6b51f8a0d9dbe456085c6ef2e588c4cb56185c062160a3ff0e104075d335d2263e19c308aa8e54
|
7
|
+
data.tar.gz: e9655c95acdfb55f8b4da23ddbb66daffb3bf0ac9fd91633e3c62a27b896c7411340de41ea6c6de876d7762bd1a3471bdc13025143f9f36c82112d5f5dc52a21
|
@@ -29,6 +29,7 @@ module Liquidscript
|
|
29
29
|
@top = Liquidscript::ICR::Set.new
|
30
30
|
@top.context = Liquidscript::ICR::Context.new
|
31
31
|
@set = [@top]
|
32
|
+
@classes = {}
|
32
33
|
super
|
33
34
|
end
|
34
35
|
|
@@ -50,10 +51,14 @@ module Liquidscript
|
|
50
51
|
return unless @scanner.metadata[:directives]
|
51
52
|
|
52
53
|
@scanner.metadata[:directives].each do |meta|
|
53
|
-
case meta[:command]
|
54
|
+
case meta[:command].downcase
|
54
55
|
when "allow"
|
55
56
|
variables = meta[:args].split(' ')
|
56
57
|
variables.each { |v| top.context.allow(v.intern) }
|
58
|
+
when "cvar"
|
59
|
+
variables = meta[:args].split(' ')
|
60
|
+
variables.each { |v| top.context.set(v.intern,
|
61
|
+
:class => true).parameter! }
|
57
62
|
else
|
58
63
|
raise UnknownDirectiveError.new(meta[:command])
|
59
64
|
end
|
@@ -12,12 +12,24 @@ module Liquidscript
|
|
12
12
|
if peek?(:colon)
|
13
13
|
shift :colon
|
14
14
|
inherit = shift :identifier
|
15
|
-
ref
|
15
|
+
inherit = ref(inherit)
|
16
16
|
end
|
17
17
|
|
18
|
+
new_context = Liquidscript::ICR::Context.new
|
19
|
+
new_context.parents << top.context
|
20
|
+
new_context.class!
|
21
|
+
@classes[name.value] = new_context
|
22
|
+
|
23
|
+
new_context.parents << @classes[inherit.name.to_s] if inherit
|
24
|
+
|
25
|
+
top.context = new_context
|
18
26
|
body = _compile_class_body(false)
|
19
27
|
|
20
|
-
|
28
|
+
new_context.undefined.each do |f|
|
29
|
+
raise f[1]
|
30
|
+
end
|
31
|
+
|
32
|
+
code :class, name, inherit, body, top.contexts.pop
|
21
33
|
end
|
22
34
|
|
23
35
|
def compile_module
|
@@ -67,6 +79,10 @@ module Liquidscript
|
|
67
79
|
item = compile_property(item) if item.type == :identifier &&
|
68
80
|
peek?(:prop) && !mod
|
69
81
|
|
82
|
+
if item.type == :identifier && !mod
|
83
|
+
set(item)
|
84
|
+
end
|
85
|
+
|
70
86
|
shift :colon
|
71
87
|
item
|
72
88
|
end
|
@@ -11,9 +11,7 @@ module Liquidscript
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Just in case there is a property named 'class' or 'module'
|
14
|
-
|
15
|
-
|
16
|
-
v
|
14
|
+
expect [:identifier, :class, :module] => property
|
17
15
|
end
|
18
16
|
|
19
17
|
def compile_access(body)
|
@@ -21,9 +19,7 @@ module Liquidscript
|
|
21
19
|
key = compile_vexpression
|
22
20
|
shift :rbrack
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
v
|
22
|
+
code :access, body, key
|
27
23
|
end
|
28
24
|
|
29
25
|
def compile_call(subject)
|
@@ -36,8 +32,7 @@ module Liquidscript
|
|
36
32
|
arguments = collect_compiles :expression, :rparen,
|
37
33
|
:comma => action.shift
|
38
34
|
|
39
|
-
|
40
|
-
call
|
35
|
+
code :call, subject, *arguments
|
41
36
|
end
|
42
37
|
|
43
38
|
|
@@ -60,10 +55,10 @@ module Liquidscript
|
|
60
55
|
|
61
56
|
private
|
62
57
|
|
63
|
-
def _build_set(parameters)
|
58
|
+
def _build_set(parameters = [])
|
64
59
|
expressions = Liquidscript::ICR::Set.new
|
65
60
|
expressions.context = Liquidscript::ICR::Context.new
|
66
|
-
expressions.context.
|
61
|
+
expressions.context.parents << top.context
|
67
62
|
expressions[:arguments] = parameters
|
68
63
|
@set << expressions
|
69
64
|
|
@@ -20,7 +20,7 @@ module Liquidscript
|
|
20
20
|
shift :lbrace
|
21
21
|
collect_compiles(:expression, :rbrace)
|
22
22
|
else
|
23
|
-
compile_expression
|
23
|
+
[compile_expression]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,6 +30,7 @@ module Liquidscript
|
|
30
30
|
:equal => action { compile_assignment(v) },
|
31
31
|
:prop => action { compile_property(v) },
|
32
32
|
:lbrack => action { compile_access(v) },
|
33
|
+
:range => action { |_| compile_range(v) },
|
33
34
|
[:binop,
|
34
35
|
:minus,
|
35
36
|
:plus] => action { compile_binop(v) },
|
@@ -4,15 +4,16 @@ module Liquidscript
|
|
4
4
|
module Literals
|
5
5
|
|
6
6
|
def compile_number
|
7
|
-
#code :number, pop.value
|
8
7
|
n = shift(:number)
|
9
8
|
|
10
|
-
if peek?(:
|
11
|
-
shift(:
|
12
|
-
shift(:prop)
|
13
|
-
n2 = shift(:number)
|
9
|
+
if peek?(:range)
|
10
|
+
shift(:range)
|
14
11
|
|
15
|
-
|
12
|
+
if peek?(:number)
|
13
|
+
code :nrange, n.value, shift(:number).value
|
14
|
+
else
|
15
|
+
compile_range(code(:number, n.value))
|
16
|
+
end
|
16
17
|
else
|
17
18
|
code :number, n.value
|
18
19
|
end
|
@@ -22,6 +23,10 @@ module Liquidscript
|
|
22
23
|
code :action, shift(:action)
|
23
24
|
end
|
24
25
|
|
26
|
+
def compile_range(subject)
|
27
|
+
code :range, subject, compile_vexpression
|
28
|
+
end
|
29
|
+
|
25
30
|
def compile_while
|
26
31
|
shift :while
|
27
32
|
shift :lparen
|
@@ -46,6 +51,7 @@ module Liquidscript
|
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
54
|
+
|
49
55
|
def _compile_for_in(ident)
|
50
56
|
content = shift :identifier
|
51
57
|
unless content.value == "in"
|
@@ -55,9 +61,9 @@ module Liquidscript
|
|
55
61
|
obj = shift :identifier
|
56
62
|
shift :rparen
|
57
63
|
|
58
|
-
set
|
64
|
+
v = set(ident)
|
59
65
|
body = _compile_block
|
60
|
-
code :for_in,
|
66
|
+
code :for_in, v, ref(obj), body
|
61
67
|
end
|
62
68
|
|
63
69
|
def _compile_for_seg(first)
|
@@ -73,9 +79,11 @@ module Liquidscript
|
|
73
79
|
end
|
74
80
|
|
75
81
|
def compile_identifier(identifier)
|
76
|
-
|
77
|
-
|
78
|
-
|
82
|
+
if peek?(:equal)
|
83
|
+
identifier
|
84
|
+
else
|
85
|
+
ref(identifier)
|
86
|
+
end
|
79
87
|
end
|
80
88
|
|
81
89
|
def compile_regex
|
@@ -9,18 +9,33 @@ module Liquidscript
|
|
9
9
|
"!=" => "!==",
|
10
10
|
"!==" => "!=",
|
11
11
|
"or" => "||",
|
12
|
-
"and" => "&&"
|
12
|
+
"and" => "&&",
|
13
|
+
"is" => "===",
|
14
|
+
"isnt"=> "!=="
|
13
15
|
}.freeze
|
14
16
|
|
15
17
|
def generate_number(code)
|
16
18
|
"#{code.first}"
|
17
19
|
end
|
18
20
|
|
19
|
-
def
|
21
|
+
def generate_nrange(code)
|
20
22
|
start = code[1]
|
21
23
|
ending = code[2]
|
22
24
|
|
23
|
-
(start..ending).to_a.join(', ')
|
25
|
+
buffer << "[" << (start..ending).to_a.join(', ') << "]"
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_range(code)
|
29
|
+
out = buffer
|
30
|
+
out << "(function(a, b) {\n" <<
|
31
|
+
indent! << "var out, i;\n" <<
|
32
|
+
indent << "for(i = a; i <= b; i++) {\n" <<
|
33
|
+
indent! << "out.push(i);\n" <<
|
34
|
+
unindent! << "};\n" <<
|
35
|
+
indent << "return out;\n" <<
|
36
|
+
unindent! << "})(" << replace(code[1]) << ", " <<
|
37
|
+
replace(code[2]) << ")"
|
38
|
+
out
|
24
39
|
end
|
25
40
|
|
26
41
|
def generate_action(code)
|
@@ -48,11 +63,11 @@ module Liquidscript
|
|
48
63
|
|
49
64
|
def generate_for_in(code)
|
50
65
|
loop_body = buffer
|
51
|
-
loop_body << "for(#{code[1].
|
66
|
+
loop_body << "for(#{code[1].to_s} in #{code[2].name}) {\n"
|
52
67
|
indent!
|
53
68
|
insert_into(code[3], loop_body)
|
54
69
|
unindent!
|
55
|
-
loop_body <<
|
70
|
+
loop_body << indent << "}"
|
56
71
|
end
|
57
72
|
|
58
73
|
def generate_for_seg(code)
|
@@ -132,8 +147,12 @@ module Liquidscript
|
|
132
147
|
"#{replace(code[2])} #{op} #{replace(code[3])}"
|
133
148
|
end
|
134
149
|
|
135
|
-
def generate_identifier(code)
|
136
|
-
|
150
|
+
#def generate_identifier(code)
|
151
|
+
# code.value
|
152
|
+
#end
|
153
|
+
|
154
|
+
def generate_variable(code)
|
155
|
+
code.to_s
|
137
156
|
end
|
138
157
|
|
139
158
|
def generate_keyword(code)
|
@@ -26,7 +26,9 @@ module Liquidscript
|
|
26
26
|
|
27
27
|
case code[1].type
|
28
28
|
when :variable
|
29
|
-
prop << code[1].
|
29
|
+
prop << code[1].to_s
|
30
|
+
when :identifier
|
31
|
+
prop << code[1].value
|
30
32
|
else
|
31
33
|
prop << replace(code[1])
|
32
34
|
end
|
@@ -38,7 +40,7 @@ module Liquidscript
|
|
38
40
|
_context :name => code[1].value,
|
39
41
|
:inherit => code[2],
|
40
42
|
:parts => code[3],
|
41
|
-
:inheritance => "%{name}.prototype.__proto__ = %{inherit};\n",
|
43
|
+
:inheritance => "%{name}.prototype.__proto__ = %{inherit}.prototype;\n",
|
42
44
|
:identifier => "%{name}.prototype.%{value} = %{replace};\n",
|
43
45
|
:istring => "%{name}.prototype[\"%{value}\"] = %{replace};\n",
|
44
46
|
:property => "%{name}.%{value} = %{replace};\n",
|
@@ -83,7 +85,7 @@ module Liquidscript
|
|
83
85
|
end
|
84
86
|
|
85
87
|
if last_module
|
86
|
-
body << "#{last_module}.#{name} = #{name};\n"
|
88
|
+
body << indent << "#{last_module}.#{name} = #{name};\n"
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
@@ -100,13 +102,13 @@ module Liquidscript
|
|
100
102
|
opts[:value] = k.value
|
101
103
|
opts[:replace] = replace(v)
|
102
104
|
|
103
|
-
body << sprintf(options[k.type], opts)
|
105
|
+
body << indent << sprintf(options[k.type], opts)
|
104
106
|
when :property
|
105
107
|
opts[:value] = k[2]
|
106
108
|
opts[:replace] = replace(v)
|
107
109
|
|
108
110
|
if k[1].value == "this" && options[k.type]
|
109
|
-
body << sprintf(options[k.type], opts)
|
111
|
+
body << indent << sprintf(options[k.type], opts)
|
110
112
|
else
|
111
113
|
raise InvalidCodeError.new(k[1].value)
|
112
114
|
end
|
@@ -118,11 +120,11 @@ module Liquidscript
|
|
118
120
|
end
|
119
121
|
|
120
122
|
def _build_header(body, options, opts)
|
121
|
-
body << sprintf(options[:head], opts)
|
123
|
+
body << indent << sprintf(options[:head], opts)
|
122
124
|
|
123
125
|
if options[:inherit]
|
124
|
-
opts[:inherit] = options[:inherit].
|
125
|
-
body << sprintf(options[:inheritance], opts)
|
126
|
+
opts[:inherit] = options[:inherit].to_s
|
127
|
+
body << indent << sprintf(options[:inheritance], opts)
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
@@ -13,15 +13,21 @@ module Liquidscript
|
|
13
13
|
|
14
14
|
# The variables that are allowed to be used as a global scope,
|
15
15
|
# i.e. used in a `get` context without a previous `set`.
|
16
|
-
DEFAULT_ALLOWED_VARIABLES =
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
DEFAULT_ALLOWED_VARIABLES = %w(
|
17
|
+
window global exports console this arguments
|
18
|
+
Infinity NaN undefined eval isFinite isNaN parseFloat
|
19
|
+
parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent
|
20
|
+
Object Function Boolean Error EvalError InternalError RangeError
|
21
|
+
ReferenceError SyntaxError TypeError URIError Number Math
|
22
|
+
Date String RegExp Array Float32Array Float64Array Int16Array
|
23
|
+
Int32Array Int8Array Uint16Array Uint32Array Uint8Array
|
24
|
+
Uint8ClampedArray ArrayBuffer DataView JSON Intl
|
25
|
+
).map(&:intern)
|
20
26
|
|
21
27
|
# The parent of the current context.
|
22
28
|
#
|
23
29
|
# @return [Parent]
|
24
|
-
attr_accessor :
|
30
|
+
attr_accessor :parents
|
25
31
|
|
26
32
|
# The variables that are a part of this context.
|
27
33
|
#
|
@@ -35,12 +41,16 @@ module Liquidscript
|
|
35
41
|
# @return [Array<Symbol>]
|
36
42
|
attr_reader :allowed_variables
|
37
43
|
|
44
|
+
attr_reader :undefined
|
45
|
+
|
38
46
|
include Representable
|
39
47
|
|
40
48
|
# Initializes the context.
|
41
49
|
def initialize
|
50
|
+
@undefined = []
|
42
51
|
@variables = {}
|
43
52
|
@allowed_variables = [DEFAULT_ALLOWED_VARIABLES].flatten
|
53
|
+
@parents = []
|
44
54
|
end
|
45
55
|
|
46
56
|
# Returns a variable reference. If checks the local variables
|
@@ -53,17 +63,9 @@ module Liquidscript
|
|
53
63
|
# @param type [Symbol] the type of use. Should be `:get` or
|
54
64
|
# `:set`.
|
55
65
|
# @return [Variable]
|
56
|
-
def variable(name, type)
|
57
|
-
|
58
|
-
|
59
|
-
@variables[name] = Variable.new(self, name)
|
60
|
-
elsif allowed_variables.include?(name)
|
61
|
-
Variable.new(self, name)
|
62
|
-
elsif type == :get && parent
|
63
|
-
parent.get(name)
|
64
|
-
else
|
65
|
-
raise InvalidReferenceError.new(name)
|
66
|
-
end
|
66
|
+
def variable(name, type, options = {})
|
67
|
+
if [:get, :set].include?(type)
|
68
|
+
send(type, name, options = {})
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -86,21 +88,73 @@ module Liquidscript
|
|
86
88
|
# (see #variable).
|
87
89
|
#
|
88
90
|
# Passes `:get` as type.
|
89
|
-
def get(name)
|
90
|
-
|
91
|
+
def get(name, options = {})
|
92
|
+
@variables.fetch(name) do
|
93
|
+
case true
|
94
|
+
when allowed_variables.include?(name)
|
95
|
+
Variable.new(self, name)
|
96
|
+
when parents.any?
|
97
|
+
get_parent(name)
|
98
|
+
when @class
|
99
|
+
add_undefined(name)
|
100
|
+
else
|
101
|
+
raise InvalidReferenceError.new(name)
|
102
|
+
end
|
103
|
+
end
|
91
104
|
end
|
92
105
|
|
93
106
|
# (see #variable).
|
94
107
|
#
|
95
108
|
# Passes `:set` as type.
|
96
|
-
def set(name)
|
97
|
-
|
109
|
+
def set(name, options = {})
|
110
|
+
@variables.fetch(name) do
|
111
|
+
@undefined.reject! { |(n, _)| n == name }
|
112
|
+
@variables[name] =
|
113
|
+
Variable.new(self, name,
|
114
|
+
{:class => @class}.merge(options))
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def class!
|
119
|
+
@class = true
|
120
|
+
self
|
98
121
|
end
|
99
122
|
|
100
123
|
def to_a
|
101
124
|
@variables.keys
|
102
125
|
end
|
103
126
|
|
127
|
+
private
|
128
|
+
|
129
|
+
def get_parent(name)
|
130
|
+
results = parents.map do |parent|
|
131
|
+
begin
|
132
|
+
parent.get(name)
|
133
|
+
rescue InvalidReferenceError => e
|
134
|
+
e
|
135
|
+
end
|
136
|
+
end.compact
|
137
|
+
|
138
|
+
where = results.detect { |i|
|
139
|
+
not i.is_a?(InvalidReferenceError) }
|
140
|
+
|
141
|
+
if where
|
142
|
+
where
|
143
|
+
else
|
144
|
+
error = results.first
|
145
|
+
if @class
|
146
|
+
add_undefined(name, error)
|
147
|
+
else
|
148
|
+
raise error
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def add_undefined(name, e = InvalidReferenceError.new(name))
|
154
|
+
@undefined << [name, e]
|
155
|
+
Variable.new(self, name, :class => true)
|
156
|
+
end
|
104
157
|
end
|
158
|
+
|
105
159
|
end
|
106
160
|
end
|
data/lib/liquidscript/icr/set.rb
CHANGED
@@ -18,19 +18,22 @@ module Liquidscript
|
|
18
18
|
def initialize
|
19
19
|
@metadata = {}
|
20
20
|
@code = []
|
21
|
+
@contexts = []
|
21
22
|
@action = :exec
|
22
23
|
end
|
23
24
|
|
24
25
|
#
|
25
26
|
def context
|
26
|
-
@metadata.fetch(:context
|
27
|
-
|
28
|
-
|
27
|
+
contexts.last || @metadata.fetch(:parent).context
|
28
|
+
end
|
29
|
+
|
30
|
+
def contexts
|
31
|
+
@contexts
|
29
32
|
end
|
30
33
|
|
31
34
|
#
|
32
35
|
def context=(new_context)
|
33
|
-
|
36
|
+
contexts << new_context
|
34
37
|
end
|
35
38
|
|
36
39
|
# Adds a code to the code list. This is just a
|
@@ -89,11 +92,11 @@ module Liquidscript
|
|
89
92
|
#
|
90
93
|
# @return [Array]
|
91
94
|
def to_a
|
92
|
-
[
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
part = [@action]
|
96
|
+
part << [:_context, context] if contexts.any?
|
97
|
+
part.concat(@metadata.to_a.map { |(m, i)| [:"_#{m}", i] })
|
98
|
+
part.concat(@code)
|
99
|
+
part
|
97
100
|
end
|
98
101
|
|
99
102
|
# Outputs the codes in this set.
|
@@ -27,10 +27,11 @@ module Liquidscript
|
|
27
27
|
|
28
28
|
include Representable
|
29
29
|
|
30
|
-
def initialize(context, name)
|
30
|
+
def initialize(context, name, options = {})
|
31
31
|
@context = context
|
32
|
-
@name
|
33
|
-
@
|
32
|
+
@name = name
|
33
|
+
@options = options
|
34
|
+
@value = nil
|
34
35
|
end
|
35
36
|
|
36
37
|
# Make this class compatible with the #type based system.
|
@@ -57,6 +58,14 @@ module Liquidscript
|
|
57
58
|
@parameter
|
58
59
|
end
|
59
60
|
|
61
|
+
def to_s
|
62
|
+
if @options[:class]
|
63
|
+
"this.#{@name}"
|
64
|
+
else
|
65
|
+
@name
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
60
69
|
# Turns the variable into an array.
|
61
70
|
#
|
62
71
|
# @return [Array<(Symbol, Symbol)>]
|
@@ -57,6 +57,7 @@ module Liquidscript
|
|
57
57
|
& |
|
58
58
|
instanceof
|
59
59
|
or and
|
60
|
+
is isnt
|
60
61
|
)
|
61
62
|
|
62
63
|
set :keywords, %w(
|
@@ -124,6 +125,7 @@ module Liquidscript
|
|
124
125
|
on(")") { emit :rparen }
|
125
126
|
on("]") { emit :rbrack }
|
126
127
|
on(":") { emit :colon }
|
128
|
+
on("..") { emit :range }
|
127
129
|
on(".") { emit :prop }
|
128
130
|
on(",") { emit :comma }
|
129
131
|
on("-") { emit :minus }
|
data/lib/liquidscript/version.rb
CHANGED
@@ -1,24 +1,44 @@
|
|
1
1
|
data: |
|
2
|
+
#! allow require
|
3
|
+
|
4
|
+
assert = require('assert)
|
5
|
+
|
2
6
|
module Something {
|
3
7
|
class Test {
|
4
|
-
|
5
|
-
|
6
|
-
}
|
8
|
+
|
9
|
+
some-number: 2
|
7
10
|
|
8
11
|
initialize: -> {
|
9
12
|
"this should be init"
|
13
|
+
wee()
|
14
|
+
}
|
15
|
+
|
16
|
+
wee: -> {
|
17
|
+
console.log(some-number)
|
10
18
|
}
|
11
19
|
|
12
20
|
this.test: -> {
|
13
21
|
"class method!"
|
14
22
|
}
|
15
23
|
}
|
24
|
+
|
25
|
+
|
26
|
+
class AnotherTest : Test {
|
27
|
+
#! cvar another-thing
|
28
|
+
thing: -> {
|
29
|
+
console.log("[another test]", some-number, another-thing)
|
30
|
+
}
|
31
|
+
}
|
16
32
|
}
|
17
33
|
|
34
|
+
assert.equal(new AnotherTest().some-number, 2)
|
35
|
+
|
18
36
|
module.exports = Something
|
19
37
|
|
20
38
|
compiled: |
|
21
|
-
var Something, Test;
|
39
|
+
var assert, Something, Test, AnotherTest;
|
40
|
+
|
41
|
+
assert = require('assert');
|
22
42
|
|
23
43
|
Something = Something || {};
|
24
44
|
Test = Test || function Test() {
|
@@ -27,17 +47,36 @@ compiled: |
|
|
27
47
|
}
|
28
48
|
};
|
29
49
|
|
30
|
-
Test.prototype.
|
31
|
-
console.log(2);
|
32
|
-
};
|
50
|
+
Test.prototype.someNumber = 2;
|
33
51
|
|
34
52
|
Test.prototype.initialize = function() {
|
35
53
|
"this should be init";
|
54
|
+
this.wee();
|
55
|
+
};
|
56
|
+
|
57
|
+
Test.prototype.wee = function() {
|
58
|
+
console.log(this.someNumber);
|
36
59
|
};
|
37
60
|
|
38
61
|
Test.test = function() {
|
39
62
|
"class method!";
|
40
63
|
};
|
41
|
-
Something.Test = Test
|
64
|
+
Something.Test = Test;
|
65
|
+
|
66
|
+
AnotherTest = AnotherTest || function AnotherTest() {
|
67
|
+
if(this.initialize) {
|
68
|
+
this.initialize.apply(this, arguments);
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
AnotherTest.prototype.__proto__ = Test.prototype;
|
73
|
+
|
74
|
+
AnotherTest.prototype.thing = function() {
|
75
|
+
console.log("[another test]", this.someNumber, this.anotherThing);
|
76
|
+
};
|
77
|
+
|
78
|
+
Something.AnotherTest = AnotherTest;;
|
79
|
+
|
80
|
+
assert.equal(new AnotherTest().someNumber, 2);
|
42
81
|
|
43
82
|
module.exports = Something;
|
@@ -2,10 +2,21 @@ data: |
|
|
2
2
|
console = 2
|
3
3
|
some_function = ()-> {
|
4
4
|
console = 3
|
5
|
+
test = 0..console
|
5
6
|
}
|
6
7
|
|
7
8
|
compiled: |
|
8
9
|
var some_function;
|
9
10
|
console = 2;
|
10
11
|
|
11
|
-
some_function = function() {
|
12
|
+
some_function = function() {
|
13
|
+
var test;
|
14
|
+
console = 3;
|
15
|
+
test = (function(a, b) {
|
16
|
+
var out, i;
|
17
|
+
for(i = a; i <= b; i++) {
|
18
|
+
out.push(i);
|
19
|
+
};
|
20
|
+
return out;
|
21
|
+
})(0, console);
|
22
|
+
};
|
@@ -19,21 +19,21 @@ compiled:
|
|
19
19
|
- - :_arguments
|
20
20
|
- []
|
21
21
|
- - :for_in
|
22
|
-
- - :
|
23
|
-
- v
|
22
|
+
- - :_variable
|
23
|
+
- :v
|
24
24
|
- - :_variable
|
25
25
|
- :console
|
26
26
|
- - - :call
|
27
27
|
- - :property
|
28
|
-
- - :
|
29
|
-
- console
|
28
|
+
- - :_variable
|
29
|
+
- :console
|
30
30
|
- log
|
31
|
-
- - :
|
32
|
-
- v
|
31
|
+
- - :_variable
|
32
|
+
- :v
|
33
33
|
- - :call
|
34
34
|
- - :property
|
35
|
-
- - :
|
36
|
-
- console
|
35
|
+
- - :_variable
|
36
|
+
- :console
|
37
37
|
- log
|
38
38
|
- - :istring
|
39
39
|
- hello world
|
@@ -19,15 +19,15 @@ compiled:
|
|
19
19
|
- 1
|
20
20
|
- - :call
|
21
21
|
- - :property
|
22
|
-
- - :
|
23
|
-
- console
|
22
|
+
- - :_variable
|
23
|
+
- :console
|
24
24
|
- log
|
25
25
|
- - :href
|
26
26
|
- *heredoc
|
27
27
|
- - :interop
|
28
28
|
- - :istring_begin
|
29
29
|
- "hello "
|
30
|
-
- - :
|
31
|
-
- console
|
30
|
+
- - :_variable
|
31
|
+
- :console
|
32
32
|
- - :istring
|
33
33
|
- ""
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquidscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|