Module: Mirah::AST
- Defined in:
- lib/mirah/ast/call.rb,
lib/mirah/ast.rb,
lib/mirah/ast/flow.rb,
lib/mirah/ast/type.rb,
lib/mirah/ast/class.rb,
lib/mirah/ast/local.rb,
lib/mirah/ast/scope.rb,
lib/mirah/ast/method.rb,
lib/mirah/plugin/gwt.rb,
lib/mirah/ast/literal.rb,
lib/mirah/jvm/compiler.rb,
lib/mirah/ast/structure.rb,
lib/mirah/compiler/call.rb,
lib/mirah/compiler/flow.rb,
lib/mirah/compiler/type.rb,
lib/mirah/ast/intrinsics.rb,
lib/mirah/compiler/class.rb,
lib/mirah/compiler/local.rb,
lib/mirah/compiler/method.rb,
lib/mirah/compiler/literal.rb,
lib/mirah/transform/ast_ext.rb,
lib/mirah/compiler/structure.rb,
lib/mirah/jvm/source_generator/precompile.rb
Overview
Copyright © 2010 The Mirah project authors. All Rights Reserved. All contributing project authors may be found in the NOTICE file.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: Annotated, Binding, ClassScoped, Literal, Named, Scope, Scoped, Typed, Valued
Classes: AccessLevel, Annotation, Argument, Arguments, Array, BindingReference, Block, BlockArgument, BlockPass, Body, Boolean, Break, Builtin, Call, ClassAppendSelf, ClassDefinition, ClosureDefinition, Colon2, Condition, Constant, ConstructorDefinition, EmptyArray, EmtpyArray, Ensure, ErrorNode, Field, FieldAssignment, FieldDeclaration, Fixnum, Float, FunctionalCall, Hash, If, Implements, Import, Include, InlineCode, InterfaceDeclaration, JsniMethodDefinition, Local, LocalAssignment, LocalDeclaration, Loop, MacroDefinition, MethodDefinition, MirahErrorHandler, Next, Node, NodeProxy, Noop, Not, Null, OptionalArgument, Raise, Redo, Regexp, RequiredArgument, Rescue, RescueClause, RestArgument, Return, ScopedBody, Script, Self, StaticMethodDefinition, StaticScope, String, StringConcat, Super, Symbol, TempValue, ToString, TypeDefinition, TypeReference, Unquote, UnquoteAssign, UnquotedValue, UnquotedValueAssign
Class Attribute Summary collapse
Class Method Summary
collapse
-
.block_type ⇒ Object
-
.defmacro(name, &block) ⇒ Object
-
.error_type ⇒ Object
-
.fixnum(parent, position, literal) ⇒ Object
-
.float(parent, position, literal) ⇒ Object
-
.macro(name) ⇒ Object
-
.no_type ⇒ Object
-
.parse(src, filename = 'dash_e', raise_errors = false, transformer = nil) ⇒ Object
-
.parse_ruby(src, filename = '-') ⇒ Object
-
.type(scope, typesym, array = false, meta = false) ⇒ Object
Shortcut method to construct type references.
-
.type_factory ⇒ Object
-
.type_factory=(factory) ⇒ Object
-
.unreachable_type ⇒ Object
Class Attribute Details
.verbose ⇒ Object
Returns the value of attribute verbose.
24
25
26
|
# File 'lib/mirah/ast.rb', line 24
def verbose
@verbose
end
|
Class Method Details
.defmacro(name, &block) ⇒ Object
613
614
615
616
617
|
# File 'lib/mirah/ast.rb', line 613
def self.defmacro(name, &block)
@macros ||= {}
raise "Conflicting macros for #{name}" if @macros[name]
@macros[name] = block
end
|
.fixnum(parent, position, literal) ⇒ Object
605
606
607
|
# File 'lib/mirah/ast.rb', line 605
def self.fixnum(parent, position, literal)
Fixnum.new(parent, position, literal)
end
|
.float(parent, position, literal) ⇒ Object
609
610
611
|
# File 'lib/mirah/ast.rb', line 609
def self.float(parent, position, literal)
Float.new(parent, position, literal)
end
|
.macro(name) ⇒ Object
619
620
621
|
# File 'lib/mirah/ast.rb', line 619
def self.macro(name)
@macros[name]
end
|
.no_type ⇒ Object
579
580
581
582
583
584
585
586
|
# File 'lib/mirah/ast.rb', line 579
def self.no_type
factory = type_factory
if factory
factory.no_type
else
TypeReference::NoType
end
end
|
.parse(src, filename = 'dash_e', raise_errors = false, transformer = nil) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/mirah/transform/ast_ext.rb', line 28
def parse(src, filename='dash_e', raise_errors=false, transformer=nil)
ast = parse_ruby(src, filename)
transformer ||= Transform::Transformer.new(Mirah::Util::CompilationState.new)
transformer.filename = filename
ast = transformer.transform(ast, nil)
if raise_errors
transformer.errors.each do |e|
raise e.cause || e
end
end
ast
end
|
.parse_ruby(src, filename = '-') ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/mirah/transform/ast_ext.rb', line 42
def parse_ruby(src, filename='-')
raise ArgumentError if src.nil?
parser = MirahParser.new
parser.filename = filename
parser.errorHandler = MirahErrorHandler.new
begin
parser.parse(src)
rescue => ex
if ex.cause.kind_of? Java::Jmeta::SyntaxError
ex = SyntaxError.wrap ex.cause, nil
end
if ex.cause.respond_to? :position
position = ex.cause.position
Mirah.print_error(ex.cause.message, position)
end
raise ex
end
end
|
.type(scope, typesym, array = false, meta = false) ⇒ Object
Shortcut method to construct type references
570
571
572
573
574
575
576
577
|
# File 'lib/mirah/ast.rb', line 570
def self.type(scope, typesym, array = false, meta = false)
factory = type_factory
if factory
factory.type(scope, typesym, array, meta)
else
TypeReference.new(typesym, array, meta)
end
end
|
.type_factory ⇒ Object
561
562
563
|
# File 'lib/mirah/ast.rb', line 561
def self.type_factory
Thread.current[:ast_type_factory]
end
|
.type_factory=(factory) ⇒ Object
565
566
567
|
# File 'lib/mirah/ast.rb', line 565
def self.type_factory=(factory)
Thread.current[:ast_type_factory] = factory
end
|
.unreachable_type ⇒ Object
592
593
594
595
596
597
598
599
|
# File 'lib/mirah/ast.rb', line 592
def self.unreachable_type
factory = type_factory
if factory
factory.unreachable_type
else
TypeReference::UnreachableType
end
end
|