* test/strings.hb: new file.
* test/stddef.hb: new file.
* test/errno.hb: new file.
* test/stdio.hb: add more decls.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3827 1b9489fe-b721-0410-924e-b54b9192deb8
* test/test.sh: test integer.cb.
* test/test.sh: test initializer.cb.
* test/test.sh: test test2.cb.
* test/test.sh: test test3.cb.
* test/test.sh: test test4.cb.
* test/test2.cb: long long is not supported now.
* test/test4.cb: f -> main to make compilable.
* test/list-untested.rb: new tool.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3820 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/ast/*Node.java: ditto.
* net/loveruby/cflat/ast/Location.java: new class.
* net/loveruby/cflat/ast/Dumper.java (printClass): show location.
* net/loveruby/cflat/type/*Ref.java: support Location.
* net/loveruby/cflat/parser/Parser.jj: pass location to nodes.
* net/loveruby/cflat/parser/Parser.jj: long long removed.
* net/loveruby/cflat/type/SignedLongLongRef.java: ditto.
* net/loveruby/cflat/type/UnsignedLongLongRef.java: ditto.
* net/loveruby/cflat/type/SignedLongLongType.java: ditto.
* net/loveruby/cflat/type/UnsignedLongLongType.java: ditto.
* net/loveruby/cflat/type/TypeTable.java: ditto.
* net/loveruby/cflat/ast/LiteralNode.java: introduce new superclass of all literal nodes.
* net/loveruby/cflat/ast/StmtNode.java: introduce new superclass of all statement nodes.
* net/loveruby/cflat/ast/Declaration.java: is subclass of Node.
* net/loveruby/cflat/ast/Dumpable.java: removed: Now declarations are subclass of Node.
* net/loveruby/cflat/ast/Dumper.java: follow new class hierarchy.
* net/loveruby/cflat/ast/DefinitionVisitor.java: removed: merge into ASTVisitor again.
* net/loveruby/cflat/compiler/Visitor.java: follow new class hierarchy.
* net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
* net/loveruby/cflat/compiler/TypeResolver.java: ditto.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3800 1b9489fe-b721-0410-924e-b54b9192deb8
* test/pointer4.cb: test derefering AddressNode.
* test/test.sh: run it.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3797 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: do not warn incompatible cast, if it is castable.
* net/loveruby/cflat/type/IntegerType.java (isCastable): allow array.
* net/loveruby/cflat/type/Type.java (isCastable): use isCompatible for default implementation.
* net/loveruby/cflat/type/PointerType.java: forgot to add #isCompatible.
* net/loveruby/cflat/type/PointerType.java: forgot to add #isCastable.
* net/loveruby/cflat/type/PointerType.java (equals): reject type alias by using instanceof.
* net/loveruby/cflat/ast/CastNode.java: forward #isAssignable to base expr.
* test/cast2.cb: test cast of pointer.
* test/Makefile: build it.
* test/test.sh: test it.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3796 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: reject void paramters.
* net/loveruby/cflat/compiler/TypeChecker.java: allow all type of arrays for RHS.
* net/loveruby/cflat/compiler/CodeGenerator.java (variableNode): generate address for allocated array on RHS.
* net/loveruby/cflat/compiler/CodeGenerator.java (ArefNode): expects expr generates pointer by compile().
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS/ArefNode): unallocated array is a pointer.
* net/loveruby/cflat/type/Type.java: new method #isPointerAlike.
* net/loveruby/cflat/type/ArrayType.java: implement it.
* net/loveruby/cflat/type/PointerType.java: implement it.
* net/loveruby/cflat/asm/Assembler.java: new method #comment, to add comment.
* test/array-semcheck2.cb: check assignment to unallocated array.
* test/array-semcheck2.cb: check dereference of unallocated array.
* test/Makefile: build it.
* test/test.sh: run it.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3794 1b9489fe-b721-0410-924e-b54b9192deb8
* test/union-semcheck10.cb: test union which contains void.
* test/array-semcheck1.cb: test array which contains void.
* test/test.sh: run them.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3786 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: check lvar initializer.
* net/loveruby/cflat/ast/DefinedVariable.java: new method #setInitializer.
* net/loveruby/cflat/type/PointerType.java (isSameType): all array is same type (allocated arrays are rejected by LHS check).
* test/block.cb: was wrong test.
* test/assign.cb: add tests.
* test/test.sh: adjust output for assign.cb.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3784 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/CodeGenerator.java (AssignNode): should not leave RHS value on stack (because of feature change).
* net/loveruby/cflat/compiler/CodeGenerator.java (VariableNode): load address for array, to support ptr = ary.
* net/loveruby/cflat/compiler/CodeGenerator.java (ArefNode): dereference pointer, to support ptr[0].
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS/ArefNode): ditto.
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS/ArefNode): support non-LHS expr.
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS/ArefNode): support non-constant index.
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS/DereferenceNode): support non-LHS expr.
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS/PtrMemberNode): support non-LHS expr.
* net/loveruby/cflat/compiler/CodeGenerator.java (PrefixIncNode, PrefixDecNode, SuffixIncNode, SuffixDecNode): support pointer inc/dec.
* net/loveruby/cflat/compiler/CodeGenerator.java: #size -> #allocSize.
* net/loveruby/cflat/type/Type.java: new method #allocSize, to support ptr = ary.
* net/loveruby/cflat/type/ArrayType.java: override #size and #allocSize.
* net/loveruby/cflat/ast/Entity.java: should define #allocSize, not #size.
* net/loveruby/cflat/asm/Register.java: should not handle AMD64 registers.
* net/loveruby/cflat/asm/Assembler.java: should not handle >4 size operators.
* test/pointer-semcheck1.cb: test ptr = ary; ptr[0].
* test/deref-semcheck4.cb: test 1->memb.
* test/deref-semcheck5.cb: test ptr->y where y is not a member.
* test/Makefile: build pointer-semcheck1.
* test/test.sh: run them.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3783 1b9489fe-b721-0410-924e-b54b9192deb8
* test/union-semcheck9.cb: test recursive struct whose member is user type.
* test/struct-semcheck9.cb: test recursive union whose member is user type.
* test/test.sh: run them.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3782 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: reject arguments which has invalid type (struct, union, allocated array).
* net/loveruby/cflat/type/Type.java: new method #isAllocatedArray.
* net/loveruby/cflat/type/ArrayType.java: override it.
* net/loveruby/cflat/type/ArrayType.java: new method #isAllocated.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3779 1b9489fe-b721-0410-924e-b54b9192deb8
* test/ptrmemb.cb: test (*ptr).x where ptr is a pointer to struct.
* test/ptrmemb.cb: test (*ptr).x where ptr is a pointer to union.
* test/ptrtostruct.cb: merged to ptrmemb.cb.
* test/test.sh: remove ptrtostruct.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3778 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: arrays and pointers are both dereferable (== indexable). We can dereference both.
* net/loveruby/cflat/type/Type.java: #isIndexable -> #isDereferable.
* net/loveruby/cflat/type/UserType.java: ditto.
* net/loveruby/cflat/type/ArrayType.java: ditto.
* net/loveruby/cflat/ast/ExprNode.java: ditto.
* net/loveruby/cflat/type/Type.java: #isReferable -> #isDereferable.
* 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: ptr[0] should be allowed. Use #isDereferable instead of explict pointer check.
* net/loveruby/cflat/ast/DereferenceNode.java: override #type.
* net/loveruby/cflat/ast/ArefNode.java: remove cast for Type.
* net/loveruby/cflat/ast/FuncallNode.java: #functionType should be called after checking isCallable, type check is not needed in #functionType.
* net/loveruby/cflat/ast/PtrMemberNode.java: #baseType -> #dereferedType.
* net/loveruby/cflat/ast/MemberNode.java: reduce cast for Type.
* net/loveruby/cflat/type/Type.java: define #baseType here.
* net/loveruby/cflat/type/ArrayType.java: override #baseType (#base -> #baseType).
* net/loveruby/cflat/type/PointerType.java: ditto.
* net/loveruby/cflat/type/UserType.java: ditto.
* net/loveruby/cflat/ast/Function.java: ditto.
* net/loveruby/cflat/type/PointerType.java: is not an integer. #isInteger removed.
* net/loveruby/cflat/type/ArrayTypeRef.java: #base -> #baseType.
* net/loveruby/cflat/type/PointerTypeRef.java: ditto.
* net/loveruby/cflat/type/TypeTable.java: do not use cast methods, use true cast, since the real type is required here.
* test/usertype.cb: test user type.
* test/Makefile: build it.
* test/test.sh: run it.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3776 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: check if argument type is valid.
* net/loveruby/cflat/compiler/TypeChecker.java: check if lhs is assignable.
* net/loveruby/cflat/compiler/TypeChecker.java: reduce cast.
* net/loveruby/cflat/ast/Function.java: define #address here.
* net/loveruby/cflat/ast/DefinedFunction.java: ditto.
* net/loveruby/cflat/ast/UndefinedFunction.java: ditto.
* net/loveruby/cflat/ast/BlockNode.java: fix type error by cast.
* test/test.sh: test funcptr2.
* test/funcptr2.cb: test a function pointer to local (defined) function.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3775 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/ast/DefinedFunction.java: #body is a BlockNode, not Node.
* net/loveruby/cflat/ast/BlockNode.java: new method #tailStmt.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3774 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/ast/Node.java: new generic method #isAssignable.
* net/loveruby/cflat/ast/VariableNode.java: is assignable.
* net/loveruby/cflat/ast/DereferenceNode.java: is assignable.
* net/loveruby/cflat/ast/ArefNode.java: is assignable.
* net/loveruby/cflat/ast/MemberNode.java: is assignable.
* net/loveruby/cflat/ast/PtrMemberNode.java: is assignable.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3772 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/type/TypeTable.java (semanticCheck): check duplicated member.
* test/test.sh: invoke following test cases.
* test/struct-semcheck7.cb: test duplicated member on struct.
* test/union-semcheck7.cb: test duplicated member on union.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3769 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/type/Type.java: new method #isComplexType.
* net/loveruby/cflat/type/ComplexType.java: override it.
* net/loveruby/cflat/compiler/LocalReferenceResolver.java: should resolve variable initializer.
* net/loveruby/cflat/ast/DefinedVariable.java: new method #hasInitializer.
* test/test.sh: run tests.
* test/struct-semcheck5.cb: check if member is valid on s.memb.
* test/struct-semcheck6.cb: check if member is valid on sptr->memb.
* test/union-semcheck5.cb: check if member is valid on u.memb.
* test/union-semcheck6.cb: check if member is valid on uptr->memb.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3766 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/CodeGenerator.java: accepts TypeTable and ErrorHandler.
* net/loveruby/cflat/compiler/TypeResolver.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: set type of AddressNode.
* net/loveruby/cflat/compiler/TypeChecker.java: warn incompatible cast.
* net/loveruby/cflat/compiler/ErrorHandler.java: modify message (error -> warning).
* net/loveruby/cflat/parser/Parser.jj: rename variable: handler -> errorHandler.
* net/loveruby/cflat/ast/AST.java: do not contain TypeTable.
* net/loveruby/cflat/ast/ComplexTypeDefinition.java: new method #type.
* net/loveruby/cflat/ast/StructNode.java: ditto.
* net/loveruby/cflat/ast/UnionNode.java: ditto.
* net/loveruby/cflat/ast/AddressNode.java: receive Type from TypeChcker.
* net/loveruby/cflat/type/TypeTable.java: new method #pointerTo.
* net/loveruby/cflat/type/IntegerType.java (isCompatible): check if self is compatible with other side (be able to cast to other implicitly).
* net/loveruby/cflat/type/IntegerType.java (isCastableTo): allow explicit cast if type of type is same (integer/pointer).
* net/loveruby/cflat/type/PointerType.java: implement #equals.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3763 1b9489fe-b721-0410-924e-b54b9192deb8
* net/loveruby/cflat/compiler/TypeChecker.java: check type (incomplete).
* net/loveruby/cflat/type/Type.java: new method #isCompatible, #isCastableTo.
* net/loveruby/cflat/type/IntegerType.java: override them.
* net/loveruby/cflat/type/UnsignedCharType.java: change textize result.
* net/loveruby/cflat/type/UnsignedLongType.java: ditto.
* net/loveruby/cflat/type/UnsignedIntType.java: ditto.
* net/loveruby/cflat/type/UnsignedShortType.java: ditto.
* net/loveruby/cflat/ast/AbstractAssignNode.java: new method #setRHS.
* net/loveruby/cflat/ast/AssignNode.java: is now an AbstractAssignNode.
* net/loveruby/cflat/ast/BinaryOpNode.java: new methods #setLeft, #setRight.
* net/loveruby/cflat/ast/FuncallNode.java (type): does not rely on #function (can get type of non-static function).
* net/loveruby/cflat/ast/CondExprNode.java: new methods #setThenBody, #setElseBody.
* net/loveruby/cflat/ast/TypeNode.java: new constructor by Type.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3762 1b9489fe-b721-0410-924e-b54b9192deb8
* test/test.sh: test op association.
* test/assoc.cb: new test case.
* test/Makefile: build it.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3758 1b9489fe-b721-0410-924e-b54b9192deb8