* net/loveruby/cflat/compiler/TypeChecker.java: an array for stmt value *is* valid because it is a pointer really.
* net/loveruby/cflat/compiler/CodeGenerator.java: st.x while st.x is an array should make a pointer.
* net/loveruby/cflat/type/Type.java: remove #isPointerAlike, there is only a Pointer and an Array already.
* net/loveruby/cflat/type/ArrayType.java: ditto.
* net/loveruby/cflat/type/PointerType.java: ditto.
* net/loveruby/cflat/type/UserType.java: ditto.
* net/loveruby/cflat/ast/ArefNode.java: ditto.
* net/loveruby/cflat/ast/Variable.java: ditto.
* net/loveruby/cflat/ast/ExprNode.java: ditto.
* test: check st.x[1] access.
* test: check pst->x[1] access.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4089 1b9489fe-b721-0410-924e-b54b9192deb8
* separate Label and Symbol.
* net/loveruby/cflat/compiler/CodeGenerator.java: use Symbol instead of Label for entity symbol.
* net/loveruby/cflat/asm/Symbol.java: new interface.
* net/loveruby/cflat/asm/BaseSymbol.java: new class.
* net/loveruby/cflat/asm/NamedSymbol.java: new class.
* net/loveruby/cflat/asm/SuffixedSymbol.java: new class.
* net/loveruby/cflat/asm/UnnamedSymbol.java: new class.
* net/loveruby/cflat/asm/SymbolTable.java: new class.
* net/loveruby/cflat/asm/*.java: Label -> Symbol.
* net/loveruby/cflat/asm/LabelRef.java: removed.
* net/loveruby/cflat/ast/*.java: Label -> Symbol.
* net/loveruby/cflat/parser/Parser.jj: does not pass a LabelPool anymore.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4072 1b9489fe-b721-0410-924e-b54b9192deb8
* lib/Makefile: should generate PIC for libcbc.o.
* net/loveruby/cflat/compiler/Compiler.java: pass CodeGeneratorOptions to CodeGenerator.
* net/loveruby/cflat/compiler/Options.java: new options -fpic, -fPIC.
* net/loveruby/cflat/compiler/CodeGenerator.java: use position independent address for global variables, common symbols, defined/undefined functions and string constants.
* net/loveruby/cflat/compiler/CodeGeneratorOptions.java: new class.
* net/loveruby/cflat/asm/ELFConstants.java: new interface to define ELF-related constants.
* net/loveruby/cflat/asm/Assembler.java: new method #hidden.
* net/loveruby/cflat/asm/Assembler.java: new overload #section(s,s,s,s,s).
* net/loveruby/cflat/asm/IndirectMemoryReference.java: offset may not long, but Literal.
* net/loveruby/cflat/asm/Literal.java: new method #isZero.
* net/loveruby/cflat/asm/IntegerLiteral.java: ditto.
* net/loveruby/cflat/asm/LabelRef.java: ditto.
* net/loveruby/cflat/ast/ExprNode.java: new method #shouldEvaluatedToAddres.
* net/loveruby/cflat/ast/VariableNode.java: override it.
* net/loveruby/cflat/ast/CastNode.java: override it.
* net/loveruby/cflat/ast/Entity.java: new method #cannotLoad, to implement #shouldEvaluatedToAddress.
* net/loveruby/cflat/ast/Variable.java: override it.
* net/loveruby/cflat/ast/Function.java: override it.
* net/loveruby/cflat/ast/ExprNode.java: rename method: #AsmLiteral -> #AsmValue because it now returns ImmediateValue instead of Literal.
* net/loveruby/cflat/ast/CastNode.java: override it.
* net/loveruby/cflat/ast/LiteralNode.java: rename method also.
* net/loveruby/cflat/ast/IntegerLiteralNode.java: ditto.
* net/loveruby/cflat/ast/StringLiteralNode.java: ditto.
* net/loveruby/cflat/ast/Variable.java: holds memref and address here, not in subclasses.
* net/loveruby/cflat/ast/DefinedVariable.java: ditto.
* net/loveruby/cflat/ast/UndefinedVariable.java: ditto.
* net/loveruby/cflat/ast/LiteralNode.java: new method #memref.
* net/loveruby/cflat/ast/IntegerLiteralNode.java: implement it.
* net/loveruby/cflat/ast/StringLiteralNode.java: implement it.
* net/loveruby/cflat/ast/ConstantEntry.java: holds memref and address.
* net/loveruby/cflat/ast/AST.java: new method #allFunctions, to access undefined functions from code generator.
* net/loveruby/cflat/ast/ToplevelScope.java: ditto.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4057 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/asm/PeepholeOptimizer.java: new optimization method: jump elimination.
* net/loveruby/cflat/asm/Assembler.java: refactoring: #string -> #toSource.
* net/loveruby/cflat/asm/Assembler.java: refactoring: list -> assemblies.
* net/loveruby/cflat/asm/Assembly.java: new method #isDirective and #isComment.
* net/loveruby/cflat/asm/Directive.java: implement it.
* net/loveruby/cflat/asm/AsmComment.java: implement it.
* net/loveruby/cflat/asm/Label.java: implement it.
* net/loveruby/cflat/asm/Label.java: new method #equals, #hashCode.
* net/loveruby/cflat/asm/Instruction.java: add jump related methods to analyze jump instruction.
* net/loveruby/cflat/asm/LabelRef.java: new method #label to allow extracting a Label.
* net/loveruby/cflat/asm/Register.java: new method #equals, #hashCode.
* net/loveruby/cflat/asm/AsmStatistics.java: use Object for map keys.
* net/loveruby/cflat/asm/AsmStatistics.java: new method #doesRegisterUsed.
* net/loveruby/cflat/utils/ClonableIterator.java: new utility.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4050 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/asm/Assembler.java: do not use Literals in instruction operand.
* net/loveruby/cflat/asm/ImmediateValue.java: accept only Literals.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4029 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/Options.java: new class forked from Compiler.java. Command option parser.
* net/loveruby/cflat/compiler/SourceFile.java: new class.
* net/loveruby/cflat/compiler/LdOption.java: new class.
* net/loveruby/cflat/compiler/LdArg.java: new interface.
* net/loveruby/cflat/exception/OptionParseError.java: new error class.
* test: test multiple input.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4016 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/CodeGenerator.java: show stmt line in assembly.
* net/loveruby/cflat/parser/Parser.jj: pass a Token to the Location.
* net/loveruby/cflat/ast/AST.java: use CflatToken.
* net/loveruby/cflat/ast/Location.java: use CflatToken.
* net/loveruby/cflat/ast/CflatToken.java: new file.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4015 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: reject array variable definition without length.
* net/loveruby/cflat/type/Type.java: remove #isAllocated.
* net/loveruby/cflat/type/UserType.java: ditto.
* net/loveruby/cflat/type/ArrayType.java: change #isAllocatedArray semantics. isAllocatedArray requires the all consecutive array types have its length, recursively.
* net/loveruby/cflat/type/ArrayType.java: new method #isIncompleteArray.
* net/loveruby/cflat/compiler/Compiler.java: new option --dump-asm.
* net/loveruby/cflat/compiler/Compiler.java: handle "--" on command line.
* test/run.sh: use bash.
* test/shunit.sh: show program name on core dump.
* test/syntax1.cb: int[][] is now invalid.
* cbci: print coredump and signal.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4010 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/CodeGenerator.java (compileStmt): output statement number and line number as comment.
* net/loveruby/cflat/ast/ArefNode.java: new method #isMultiDimension.
* net/loveruby/cflat/ast/ArefNode.java: new method #baseExpr.
* net/loveruby/cflat/ast/ArefNode.java: new method #elementSize.
* net/loveruby/cflat/ast/ArefNode.java: new method #length.
* net/loveruby/cflat/type/ArrayType.java: add comment.
* test: test multi-dimension array access.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4007 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/ast/PtrMemberNode.java: #dereferedType should return Type instead of ComplexType because DereferenceChecker checks derefered type by this method.
* test: test ptr->memb with complex pointer expression.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4002 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/Visitor.java: support SizeofTypeNode, SizeofExprNode.
* net/loveruby/cflat/compiler/TypeResolver.java: ditto.
* net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
* net/loveruby/cflat/ast/ASTVisitor.java: ditto.
* net/loveruby/cflat/ast/SizeofTypeNode.java: new file.
* net/loveruby/cflat/ast/SizeofExprNode.java: new file.
* net/loveruby/cflat/type/Type.java: default alignment equals to size, not allocSize (e.g. int[4] should be aligned on 4, not 16).
* net/loveruby/cflat/type/StructType.java: element offset calculation was wrong. Elements should be aligned on its own alignment.
* net/loveruby/cflat/type/StructType.java: size calculation was wrong. Struct size is align(last-offset, max-element-alignment).
* net/loveruby/cflat/type/UnionType.java: union's alignment equals to element's max alignment.
* net/loveruby/cflat/type/ComplexType.java: cache computed alignment.
* net/loveruby/cflat/type/ArrayType.java: array's alignment equals to elements' alignment.
* net/loveruby/cflat/ast/Slot.java: new method #allocSize, #alignment.
* net/loveruby/cflat/asm/Assembler.java: new method #align (moved from CodeGenerator).
* test
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3999 1b9489fe-b721-0410-924e-b54b9192deb8