Class: RBlade::CompilesStatements::CompilesStacks
- Inherits:
-
Object
- Object
- RBlade::CompilesStatements::CompilesStacks
- Defined in:
- lib/rblade/compiler/statements/compiles_stacks.rb
Instance Method Summary collapse
- #compileEndPrepend(args) ⇒ Object
- #compileEndPush(args) ⇒ Object
- #compilePrepend(args) ⇒ Object
- #compilePush(args) ⇒ Object
- #compileStack(args) ⇒ Object
-
#initialize ⇒ CompilesStacks
constructor
A new instance of CompilesStacks.
Constructor Details
#initialize ⇒ CompilesStacks
Returns a new instance of CompilesStacks.
4 5 6 |
# File 'lib/rblade/compiler/statements/compiles_stacks.rb', line 4 def initialize @push_counter = 0 end |
Instance Method Details
#compileEndPrepend(args) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rblade/compiler/statements/compiles_stacks.rb', line 30 def compileEndPrepend args if !args.nil? raise StandardError.new "End prepend statement: wrong number of arguments (given #{args&.count}, expecting 0)" end @push_counter -= 1 "RBlade::StackManager.prepend(_push_#{@push_counter + 1}_name, _out);_out=_push_#{@push_counter + 1}_buffer;" end |
#compileEndPush(args) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/rblade/compiler/statements/compiles_stacks.rb', line 54 def compileEndPush args if !args.nil? raise StandardError.new "End push statement: wrong number of arguments (given #{args&.count}, expecting 0)" end @push_counter -= 1 "RBlade::StackManager.push(_push_#{@push_counter + 1}_name, _out);_out=_push_#{@push_counter + 1}_buffer;" end |
#compilePrepend(args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rblade/compiler/statements/compiles_stacks.rb', line 16 def compilePrepend args if args.nil? || args.count > 2 raise StandardError.new "Prepend statement: wrong number of arguments (given #{args&.count}, expecting 1 or 2)" end if args.count == 2 "RBlade::StackManager.prepend(#{args[0]}, #{args[1]});" else @push_counter += 1 "_push_#{@push_counter}_name=#{args[0]};_push_#{@push_counter}_buffer=_out;_out='';" end end |
#compilePush(args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rblade/compiler/statements/compiles_stacks.rb', line 40 def compilePush args if args.nil? || args.count > 2 raise StandardError.new "Push statement: wrong number of arguments (given #{args&.count}, expecting 1 or 2)" end if args.count == 2 "RBlade::StackManager.push(#{args[0]}, #{args[1]});" else @push_counter += 1 "_push_#{@push_counter}_name=#{args[0]};_push_#{@push_counter}_buffer=_out;_out='';" end end |
#compileStack(args) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/rblade/compiler/statements/compiles_stacks.rb', line 8 def compileStack args if args&.count != 1 raise StandardError.new "Stack statement: wrong number of arguments (given #{args&.count}, expecting 1)" end "RBlade::StackManager.initialize(#{args[0]}, _out);_stacks.push(#{args[0]});_out = '';" end |