Commit Graph

176 Commits

Author SHA1 Message Date
Minero Aoki 076d0dea13 * net/loveruby/cflat/compiler/Options.java: new option -O0, -O, -O1, -O2, -Os.
* net/loveruby/cflat/asm/AsmOptimizer.java: new interface to switch optimizer dynamicly.
* net/loveruby/cflat/compiler/PeepholeOptimizer.java -> asm/PeepholeOptimizer.java
* net/loveruby/cflat/compiler/CodeGenerator.java: parameterize AsmOptimizer.
* net/loveruby/cflat/ast/AST.java: holds a typeTable.
* net/loveruby/cflat/compiler/Compiler.java: follow AST change.
* net/loveruby/cflat/compiler/TypeResolver.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: ditto.
* net/loveruby/cflat/compiler/LocalReferenceResolver.java: ditto.
* net/loveruby/cflat/compiler/DereferenceChecker.java: ditto.
* net/loveruby/cflat/compiler/JumpResolver.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4039 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-20 15:13:09 +00:00
Minero Aoki c3bf6f1344 * net/loveruby/cflat/compiler/CodeGenerator.java: apply peep-hole optimization.
* net/loveruby/cflat/compiler/PeepholeOptimizer.java: new class.
* net/loveruby/cflat/asm/Assembler.java: export list (List<Assembly>).
* net/loveruby/cflat/asm/Instruction.java: new method #build to build an Instruction from the instruction object.
* net/loveruby/cflat/asm/OperandPattern.java: new interface.
* net/loveruby/cflat/asm/AsmOperand.java: impelements OperandPattern.
* net/loveruby/cflat/asm/Register.java: implements #isRegister.
* net/loveruby/cflat/asm/ImmediateValue.java: implement #equals to allow matching immediate integer value.
* net/loveruby/cflat/asm/IntegerLiteral.java: implement #equals.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4038 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-20 13:53:34 +00:00
Minero Aoki c335616a4c * net/loveruby/cflat/type/ComplexType.java -> CompositeType.java
* net/loveruby/cflat/ast/ComplexTypeDefinition.java -> CompositeTypeDefinition.java


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4037 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-20 10:30:54 +00:00
Minero Aoki b4d2e50529 * install.sh: check if jar and libcbc are built.
* install.sh: fix syntax error.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4035 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 18:53:09 +00:00
Minero Aoki 5c673e2b7d * net/loveruby/cflat/compiler/TypeChecker.java: reject statements whose type is struct/union/allocated array.
* test: test invalid statement expression.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4032 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 18:42:46 +00:00
Minero Aoki cc014500f8 * net/loveruby/cflat/asm: toString -> toSource.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4030 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 18:23:51 +00:00
Minero Aoki 47d4b13b1e * net/loveruby/cflat/asm/Literal.java: does not inherit AsmOperand.
* 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
2008-09-15 18:12:46 +00:00
Minero Aoki a95ad7b451 * net/loveruby/cflat/asm/Symbol.java -> LabelRef.java
* net/loveruby/cflat/asm/*.java: Symbol -> LabelRef.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4028 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 17:53:12 +00:00
Minero Aoki de82f43658 * net/loveruby/cflat/asm/AsmEntity.java -> AsmOperand.java
* net/loveruby/cflat/*/*.java: AsmEntity -> AsmOperand.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4027 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 17:49:29 +00:00
Minero Aoki 19ca32a89d * net/loveruby/cflat/asm/Address.java -> MemoryReference.java
* net/loveruby/cflat/asm/DirectAddress.java -> DirectMemoryReference.java
* net/loveruby/cflat/asm/IndirectAddress.java -> IndirectMemoryReference.java
* net/loveruby/cflat/compiler/CodeGenerator.java: Address -> MemoryReference.
* net/loveruby/cflat/asm/AsmEntity.java: ditto.
* net/loveruby/cflat/asm/AbsoluteAddress.java: ditto.
* net/loveruby/cflat/ast/Entity.java: ditto.
* net/loveruby/cflat/ast/Variable.java: ditto.
* net/loveruby/cflat/ast/DefinedVariable.java: ditto.
* net/loveruby/cflat/ast/UndefinedVariable.java: ditto.
* net/loveruby/cflat/ast/Function.java: ditto.
* net/loveruby/cflat/ast/ExprNode.java: ditto.
* net/loveruby/cflat/ast/VariableNode.java: ditto.
* net/loveruby/cflat/ast/CastNode.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4026 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 17:37:49 +00:00
Minero Aoki 9af6bc364f * net/loveruby/cflat/compiler/CodeGenerator.java: both of "puts" and "&puts" should be evaluated to its address.
* net/loveruby/cflat/compiler/CodeGenerator.java: address -> memref.
* net/loveruby/cflat/ast/Entity.java: ditto.
* net/loveruby/cflat/ast/Function.java: ditto.
* net/loveruby/cflat/ast/Variable.java: ditto.
* net/loveruby/cflat/ast/UndefinedVariable.java: ditto.
* net/loveruby/cflat/ast/DefinedVariable.java: ditto.
* net/loveruby/cflat/ast/ExprNode.java: ditto.: ditto.
* net/loveruby/cflat/ast/ArefNode.java: ditto.
* net/loveruby/cflat/ast/MemberNode.java: ditto.
* net/loveruby/cflat/ast/PtrMemberNode.java: ditto.
* net/loveruby/cflat/ast/VariableNode.java: ditto.
* net/loveruby/cflat/ast/CastNode.java: ditto.
* test: test "puts", "&puts", "myputs", "&myputs".


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4025 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 17:18:16 +00:00
Minero Aoki cb8b921931 * net/loveruby/cflat/ast/Function.java (address): should return $sym.
* net/loveruby/cflat/asm/Instruction.java: fix indent.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4024 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 15:59:57 +00:00
Minero Aoki 7314d4bf6f * net/loveruby/cflat/asm/Assembler.java: objectify instructions, directives, comments and labels.
* net/loveruby/cflat/asm/Label.java: inherits Assembly instead of AsmEntity.
* net/loveruby/cflat/asm/Address.java: new method #isAddress.
* net/loveruby/cflat/asm/ImmediateValue.java: accept Literals.
* net/loveruby/cflat/asm/AbsoluteAddress.java: new file.
* net/loveruby/cflat/asm/AsmComment.java: new file.
* net/loveruby/cflat/asm/Assembly.java: new file.
* net/loveruby/cflat/asm/Directive.java: new file.
* net/loveruby/cflat/asm/Reference.java -> DirectAddress.java: new file.
* net/loveruby/cflat/asm/SimpleAddress.java, CompositeAddress.java -> IndirectAddress.java
* net/loveruby/cflat/asm/Instruction.java: new file.
* net/loveruby/cflat/asm/IntegerLiteral.java: new file.
* net/loveruby/cflat/asm/Literal.java: new file.
* net/loveruby/cflat/asm/Symbol.java: new file.
* net/loveruby/cflat/compiler/CodeGenerator.java: follow asm changes.
* net/loveruby/cflat/ast/UndefinedVariable.java: 
* net/loveruby/cflat/ast/Function.java


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4022 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 15:21:14 +00:00
Minero Aoki ae0f46cee4 * net/loveruby/cflat/compiler/Compiler.java: link libcbc on making executables.
* Makefile: new file.
* lib/Makefile: new file to build libcbc.a.
* test: test varargs.
* install.sh: new file.
* README: change install.sh usage.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4021 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-15 12:19:11 +00:00
Minero Aoki 30433983ca * bin/cbc: allow overriding java runtime by setting JAVA environment variable.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4020 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-14 16:31:31 +00:00
Minero Aoki bdfd802a9c * bin/cbc: follow last directory tree change.
* test/test_cbc.sh: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4019 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-14 16:25:04 +00:00
Minero Aoki 97ff5aafe0 * cbc -> bin/cbc
* cbci -> bin/cbci.rb
* bin/cbci.sh: new file.
* lib/libcbc.cb: new file.
* build.properties: create jar file in lib/.
* install.sh: new file.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4018 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-14 16:19:44 +00:00
Minero Aoki 9a0bfed9f0 * net/loveruby/cflat/compiler/Compiler.java: handle multiple source files.
* 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
2008-09-14 15:51:46 +00:00
Minero Aoki 688d709302 * net/loveruby/cflat/compiler/Compiler.java: use CflatToken to dump token list.
* 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
2008-09-14 11:08:26 +00:00
Minero Aoki b79d20d4c3 * net/loveruby/cflat/ast/UndefinedVariable.java: should not append '$' for extern symbol address.
* import/stdio.hb: add va_list functions.
* import/stdarg.hb: new file.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4014 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-13 20:36:34 +00:00
Minero Aoki 09f1c83a3b * net/loveruby/cflat/compiler/TypeChecker.java: reject incomplete multi-dimension array for function parameters.
* 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
2008-09-13 17:28:00 +00:00
Minero Aoki 50c4f0ecd5 * cbci: new command. Simple Cflat interpriter.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4008 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-13 15:13:41 +00:00
Minero Aoki 3b0a50aaca * net/loveruby/cflat/compiler/CodeGenerator.java (arefNode): calculate element address of multi-dimension array correctly.
* 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
2008-09-13 13:15:38 +00:00
Minero Aoki 5b4def1bd7 * test: test void function without return.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4006 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-13 12:34:51 +00:00
Minero Aoki 50d605a369 * net/loveruby/cflat/compiler/Compiler.java: implement -o option.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4004 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 23:36:31 +00:00
Minero Aoki 9ea468d3db * net/loveruby/cflat/compiler/CodeGenerator.java: split compileLHS by using visitor pattern.
* net/loveruby/cflat/ast/ASTLHSVisitor.java: new interface.
* net/loveruby/cflat/ast/DereferenceNode.java: implement #acceptLHS.
* net/loveruby/cflat/ast/ArefNode.java: ditto.
* net/loveruby/cflat/ast/PtrMemberNode.java: ditto.
* net/loveruby/cflat/ast/MemberNode.java: ditto.
* net/loveruby/cflat/ast/Node.java: ditto.
* net/loveruby/cflat/ast/VariableNode.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4003 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 23:06:41 +00:00
Minero Aoki 633a249559 * net/loveruby/cflat/compiler/CodeGenerator.java: opassign should not spill DX because division uses DX.
* 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
2008-09-06 22:37:39 +00:00
Minero Aoki 0206623cad * net/loveruby/cflat/compiler/CodeGenerator.java: calculate LHS value on AX, not BX.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4001 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 21:50:59 +00:00
Minero Aoki 353ae35e8b fill missing text
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4000 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 20:11:17 +00:00
Minero Aoki 355873c1ea * net/loveruby/cflat/parser/Parser.jj: parse sizeof expr.
* 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
2008-09-06 20:10:49 +00:00
Minero Aoki a6c6112b29 * net/loveruby/cflat/utils/TextUtils.java (toUnsigned): simplify.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3998 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 17:57:27 +00:00
Minero Aoki 554e1e9f04 * net/loveruby/cflat/compiler/Compiler.java: use #dumpString.
* net/loveruby/cflat/compiler/Constants.java: new class.
* net/loveruby/cflat/compiler/Constants.java: define constant sourceEncoding.
* net/loveruby/cflat/parser/Parser.jj: get source encoding from Constant class.
* net/loveruby/cflat/ast/Dumper.java: use #dumpString.
* net/loveruby/cflat/asm/Assembler.java: use #dumpString.
* net/loveruby/cflat/utils/TextUtils.java: new method #dumpString, which dumps UTF-8 string correctly.
* test: test UTF-8 string literal.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3997 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 17:46:17 +00:00
Minero Aoki 960d30f461 * net/loveruby/cflat/asm/Register.java (lowerByteRegister): check wheather the register has lower-byte register or not.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3996 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 16:21:41 +00:00
Minero Aoki cd988128cc * net/loveruby/cflat/compiler/CodeGenerator.java: implement cast.
* net/loveruby/cflat/asm/Assembler.java: new method #movsx, #movzx.
* net/loveruby/cflat/type/PointerType.java: provide #isSigned for cast.
* net/loveruby/cflat/type/ArrayType.java: ditto.
* net/loveruby/cflat/type/UserType.java: ditto.
* test: test cast operation.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3995 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 15:59:02 +00:00
Minero Aoki 744e790e5d * net/loveruby/cflat/ast/Entity.java (alignment): fetch value from its type.
* net/loveruby/cflat/type/ArrayType.java: should compute allocated size from member's #allocSize, not #size.
* net/loveruby/cflat/type/StructType.java (alignment): do not depend on Entity#size.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3994 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-06 14:19:55 +00:00
Minero Aoki 7d6555c583 * test/test_cbc.sh: run tests for switch stmt.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3991 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 16:54:40 +00:00
Minero Aoki b99c2c277d * net/loveruby/cflat/parser/Parser.jj: pass location node to the CaseNode explicitly.
* net/loveruby/cflat/ast/CaseNode.java: default clause does not have value, we cannot extract location node from values.  Receive a location node as a first argument explicitly.
* net/loveruby/cflat/compiler/CodeGenerator.java: must define end label.
* net/loveruby/cflat/compiler/CodeGenerator.java: implement default clause.
* test: test switch stmt.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3990 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 16:49:26 +00:00
Minero Aoki c0b83c8998 * net/loveruby/cflat/compiler/CodeGenerator.java: static function should be local in the file.
* test: test it.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3988 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 16:27:08 +00:00
Minero Aoki 694891005c * net/loveruby/cflat/ast/CastNode.java: remove unused method #resolve.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3985 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 11:09:14 +00:00
Minero Aoki 21fdd60b8e * net/loveruby/cflat/compiler/Compiler.java: better help message.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3983 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 11:02:58 +00:00
Minero Aoki f041f5d296 * net/loveruby/cflat/ast/MemberNode.java: has always non-constant address.
* net/loveruby/cflat/asm/AsmEntity.java: remove method #add.
* net/loveruby/cflat/asm/Label.java: ditto.
* net/loveruby/cflat/asm/Reference.java: ditto.
* net/loveruby/cflat/asm/ImmediateValue.java: ditto.
* net/loveruby/cflat/asm/Register.java: ditto.
* net/loveruby/cflat/asm/SimpleAddress.java: ditto.
* net/loveruby/cflat/asm/CompositeAddress.java: ditto.
* test: test nested struct member access.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3982 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 10:59:40 +00:00
Minero Aoki ec7a3285fe * net/loveruby/cflat/ast/Function.java: reduce a warning using Reference.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3981 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 10:40:30 +00:00
Minero Aoki eca722f362 * net/loveruby/cflat/compiler/TypeChecker.java: transform pointer arithmetic to normal arithmetic (e.g. ptr+7 => ptr+(7*sizeof(*ptr))).
* net/loveruby/cflat/compiler/TypeChecker.java: int-ptr is invalid.
* net/loveruby/cflat/compiler/CodeGenerator.java: implement pointer arithmetic correctly (e.g. *(ptr+1) for various types work now).
* net/loveruby/cflat/ast/PrefixOpNode.java: inherit UnaryArithmeticOpNode.
* net/loveruby/cflat/ast/SuffixOpNode.java: ditto.
* net/loveruby/cflat/ast/UnaryArithmeticOpNode.java: new file.
* net/loveruby/cflat/ast/CastNode.java: is not assignable.
* net/loveruby/cflat/type/TypeTable.java: new method #pointerSize, #ptrDiffTypeRef.
* net/loveruby/cflat/type/ArrayType.java: fetch pointer size from a TypeTable.
* net/loveruby/cflat/type/ArrayType.java: we can cast any pointers to void*.
* net/loveruby/cflat/type/PointerType.java: ditto.
* net/loveruby/cflat/type/IntegerTypeRef.java (equals): check name equality by #equals, not ==.
* test: test pointer arithmetic.
* test: CastNode does not becomes LHS, do not check it.
* import/string.hb: add mem* functions.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3979 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 10:24:40 +00:00
Minero Aoki 0229e05728 * net/loveruby/cflat/ast/Declarations.java: reject duplicated symbols to support duplicated import.
* net/loveruby/cflat/compiler/LibraryLoader.java: should return previous loaded symbols for the same import file.
* test: test duplicated import.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3978 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-31 06:18:26 +00:00
Minero Aoki fae7f1e085 * net/loveruby/cflat/parser/Parser.jj: implement NULL.
* test: use it.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3977 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-30 11:21:49 +00:00
Minero Aoki 80651a70cc * net/loveruby/cflat/compiler/TypeChecker.java: ptr==ptr should work.
* net/loveruby/cflat/compiler/TypeChecker.java: ptr&&ptr should work.
* net/loveruby/cflat/compiler/TypeChecker.java: any==any should always returns int.
* net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
* test: test it.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3975 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-30 11:07:44 +00:00
Minero Aoki 7e39838625 * test/test_cbc.sh: test overrapped lvar.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3974 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-30 09:01:14 +00:00
Minero Aoki 737fb40fb5 * test/assign.cb: test case was wrong (caused SEGV). I don't know why this test case did not crash.
* test/test_cbc.sh: follow it.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3973 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-30 08:39:31 +00:00
Minero Aoki 01e51bf969 * cbc: surround path variables by double quotes.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3971 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-29 09:25:08 +00:00
Minero Aoki 4f50048234 * net/loveruby/cflat/compiler/CodeGenerator.java (allocateLocalVariables): refactoring: stackWordSize -> stackAlignment.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3970 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-29 08:18:15 +00:00