Skip to content

Commit

Permalink
add whitespace, rm unneeded manual boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
baroquebobcat committed Aug 23, 2014
1 parent ba7ef3e commit 6a814e6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/org/mirah/jvm/compiler/annotation_collector.mirah
Expand Up @@ -34,12 +34,15 @@ class AnnotationCollector < NodeScanner
@context = context
@field_annotations = {}
end

def error(message:String, position:Position)
@context[DiagnosticListener].report(MirahDiagnostic.error(position, message))
end

def collect(node:Node):void
scan(node, nil)
end

def getAnnotations(field:String):AnnotationList
AnnotationList(@field_annotations[field])
end
Expand All @@ -61,9 +64,11 @@ class AnnotationCollector < NodeScanner
# Scan the children
true
end

def enterRescue(node, arg)
true
end

def enterDefault(node, arg)
# We only treat it as a declaration if it's at the top level
false
Expand Down
5 changes: 4 additions & 1 deletion src/org/mirah/jvm/compiler/annotation_compiler.mirah
Expand Up @@ -34,6 +34,7 @@ class ClassAnnotationFactory implements AnnotationVisitorFactory
def initialize(visitor:ClassVisitor)
@visitor = visitor
end

def create(type, runtime)
@visitor.visitAnnotation(type, runtime)
end
Expand All @@ -43,6 +44,7 @@ class MethodAnnotationFactory implements AnnotationVisitorFactory
def initialize(visitor:MethodVisitor)
@visitor = visitor
end

def create(type, runtime)
@visitor.visitAnnotation(type, runtime)
end
Expand All @@ -52,6 +54,7 @@ class FieldAnnotationFactory implements AnnotationVisitorFactory
def initialize(visitor:FieldVisitor)
@visitor = visitor
end

def create(type, runtime)
@visitor.visitAnnotation(type, runtime)
end
Expand Down Expand Up @@ -107,11 +110,11 @@ class AnnotationCompiler < BaseCompiler
end

def compileValues(anno:Annotation, visitor:AnnotationVisitor):void
type = getInferredType(anno)
anno.values_size.times do |i|
entry = anno.values(i)
name = Identifier(entry.key).identifier
value = entry.value
type = getInferredType(anno)
method = type.getMethod(name, Collections.emptyList)
unless method
reportError("No method #{type.name}.#{name}()", entry.key.position)
Expand Down
40 changes: 20 additions & 20 deletions src/org/mirah/jvm/compiler/base_compiler.mirah
Expand Up @@ -57,28 +57,28 @@ class BaseCompiler < SimpleNodeVisitor

def self.initialize:void
@@ACCESS = {
PUBLIC: Integer.valueOf(Opcodes.ACC_PUBLIC),
PRIVATE: Integer.valueOf(Opcodes.ACC_PRIVATE),
PROTECTED: Integer.valueOf(Opcodes.ACC_PROTECTED),
DEFAULT: Integer.valueOf(0)
PUBLIC: Opcodes.ACC_PUBLIC,
PRIVATE: Opcodes.ACC_PRIVATE,
PROTECTED: Opcodes.ACC_PROTECTED,
DEFAULT: 0
}
@@FLAGS = {
STATIC: Integer.valueOf(Opcodes.ACC_STATIC),
FINAL: Integer.valueOf(Opcodes.ACC_FINAL),
SUPER: Integer.valueOf(Opcodes.ACC_SUPER),
SYNCHRONIZED: Integer.valueOf(Opcodes.ACC_SYNCHRONIZED),
VOLATILE: Integer.valueOf(Opcodes.ACC_VOLATILE),
BRIDGE: Integer.valueOf(Opcodes.ACC_BRIDGE),
VARARGS: Integer.valueOf(Opcodes.ACC_VARARGS),
TRANSIENT: Integer.valueOf(Opcodes.ACC_TRANSIENT),
NATIVE: Integer.valueOf(Opcodes.ACC_NATIVE),
INTERFACE: Integer.valueOf(Opcodes.ACC_INTERFACE),
ABSTRACT: Integer.valueOf(Opcodes.ACC_ABSTRACT),
STRICT: Integer.valueOf(Opcodes.ACC_STRICT),
SYNTHETIC: Integer.valueOf(Opcodes.ACC_SYNTHETIC),
ANNOTATION: Integer.valueOf(Opcodes.ACC_ANNOTATION),
ENUM: Integer.valueOf(Opcodes.ACC_ENUM),
DEPRECATED: Integer.valueOf(Opcodes.ACC_DEPRECATED)
STATIC: Opcodes.ACC_STATIC,
FINAL: Opcodes.ACC_FINAL,
SUPER: Opcodes.ACC_SUPER,
SYNCHRONIZED: Opcodes.ACC_SYNCHRONIZED,
VOLATILE: Opcodes.ACC_VOLATILE,
BRIDGE: Opcodes.ACC_BRIDGE,
VARARGS: Opcodes.ACC_VARARGS,
TRANSIENT: Opcodes.ACC_TRANSIENT,
NATIVE: Opcodes.ACC_NATIVE,
INTERFACE: Opcodes.ACC_INTERFACE,
ABSTRACT: Opcodes.ACC_ABSTRACT,
STRICT: Opcodes.ACC_STRICT,
SYNTHETIC: Opcodes.ACC_SYNTHETIC,
ANNOTATION: Opcodes.ACC_ANNOTATION,
ENUM: Opcodes.ACC_ENUM,
DEPRECATED: Opcodes.ACC_DEPRECATED
}
end

Expand Down
5 changes: 2 additions & 3 deletions src/org/mirah/tool/mirah_compiler.mirah
Expand Up @@ -156,7 +156,7 @@ class MirahCompiler implements JvmBackend
end

def infer
@asts.each do |node:Node|
@asts.each do |node: Node|
begin
@typer.infer(node, false)
ensure
Expand Down Expand Up @@ -214,8 +214,7 @@ class MirahCompiler implements JvmBackend
end

def compile(generator:BytecodeConsumer)
@asts.each do |n|
node = Script(n)
@asts.each do |node: Script|
@backend.clean(node, nil)
processInferenceErrors(node, @context)
if @diagnostics.errorCount > 0
Expand Down

0 comments on commit 6a814e6

Please sign in to comment.