Commit Graph

273 Commits

Author SHA1 Message Date
Minero Aoki ecdfcff254 * new class Simplifier (it is really a IR generator). Passes compilation, but not tested.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4140 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 14:52:48 +00:00
Minero Aoki 1e80fec3ab * refactoring: rename class: compiler/Simplifier.java -> IRGenerator.java.
* compiler/Compiler.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4139 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 05:57:41 +00:00
Minero Aoki ae4073e7c3 revert r4136 (no IR)
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4138 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 05:50:16 +00:00
Minero Aoki 444c8e1bd9 * net/loveruby/cflat/compiler/IRGenerator.java: generates IR (intermediate representation) tree (work is still incomplete but commit for logging).
* net/loveruby/cflat/ir: new package to hold IR tree nodes.
* net/loveruby/cflat/ir/IRTree.java: new class.
* net/loveruby/cflat/ir/Stmt.java: new class.
* net/loveruby/cflat/ir/StmtKind.java: new enum.
* net/loveruby/cflat/ir/Expr.java: new class.
* net/loveruby/cflat/ir/ExprKind.java: new enum.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4136 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 16:53:28 +00:00
Minero Aoki 5a287a7b48 * net/loveruby/cflat/compiler/TypeChecker.java: split IRGenerator.
* net/loveruby/cflat/compiler/IRGenerator.java: new class.
* net/loveruby/cflat/compiler/Compiler.java: call IRGenerator.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4135 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 08:49:23 +00:00
Minero Aoki 8d208c36cc * net/loveruby/cflat/compiler/TypeChecker.java: simplify BinaryOp checking, utilizing destructive methods.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4134 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 07:48:17 +00:00
Minero Aoki f69902e1d7 * net/loveruby/cflat/compiler/Visitor.java: make destructive again.
* net/loveruby/cflat/compiler/TypeResolver.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: ditto.
* net/loveruby/cflat/compiler/LocalResolver.java: ditto.
* net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
* net/loveruby/cflat/compiler/DereferenceChecker.java: ditto.
* net/loveruby/cflat/compiler/JumpResolver.java: ditto.
* net/loveruby/cflat/ast/AbstractAssignNode.java: ditto.
* net/loveruby/cflat/ast/CondExprNode.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4133 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 07:37:18 +00:00
Minero Aoki d514300aef * net/loveruby/cflat/compiler/Visitor.java: make all return types generic.
* net/loveruby/cflat/compiler/TypeChecker.java: ditto.
* net/loveruby/cflat/ast/*.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4132 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 06:31:12 +00:00
Minero Aoki 33dcef983b * net/loveruby/cflat/compiler/Compiler.java: call JumpResolver at last.
* net/loveruby/cflat/compiler/TypeChecker.java: TypeChecker has required ReturnNode.function, provide "current function" by myself.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4131 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-05 22:04:35 +00:00
Minero Aoki 043859df0b * net/loveruby/cflat/ast/ASTVisitor.java: #visit returns a node which has same type with the argument, to allow non-destructive AST rewriting.
* net/loveruby/cflat/ast/*Node.java (#accept): ditto.
* net/loveruby/cflat/compiler/Visitor.java: ditto.
* net/loveruby/cflat/compiler/*.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: make non-destructive.
* net/loveruby/cflat/parser/Parser.jj: use StmtNode/ExprNode instead of Node.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4130 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-04 14:47:11 +00:00
Minero Aoki b09c3f044f * lib/sizeof_jmpbuf.c: new analysis program.
* lib/Makefile: add a rule to build sizeof_jmpbuf.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4115 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-23 18:43:17 +00:00
Minero Aoki 4cb2818d45 * import/setjmp.hb: new file to support setjmp.
* test: test setjmp.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4113 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-23 17:54:11 +00:00
Minero Aoki f6a1df9142 * introduce virtual stack again, for only local variables and tmp variables. Function arguments use true push & pop.
* --verbose-asm prints stack frame layout in detail.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4110 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-14 15:05:20 +00:00
Minero Aoki 73ecd8d50b * test: test alloca more.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4108 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-14 12:04:58 +00:00
Minero Aoki e0105bda01 * net/loveruby/cflat/compiler/CodeGenerator.java (compileFunctionBody): remove bp from saveRegs first.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4107 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-14 11:43:51 +00:00
Minero Aoki 76fd64dc52 * lib/alloca.s: alloca() implemeted.
* lib/Makefile: build it.
* import/alloca.hb: declare alloca.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4103 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 15:55:40 +00:00
Minero Aoki b598628af9 * net: revert r4100; implementing alloca() is too difficult for current architecture.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4102 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 14:26:56 +00:00
Minero Aoki 37476f6839 * lib/libcbc.cb -> lib/stdarg.cb
* lib/Makefile: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4101 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 14:25:31 +00:00
Minero Aoki e64c1373c0 * net/loveruby/cflat/compiler/CodeGenerator.java: manage stack offset by generator, instead of using machine push/pop.
* net/loveruby/cflat/asm/Assembler.java: new method relocatableMov.
* net/loveruby/cflat/asm/Assembly.java: allow fixing indirect memory access offset.
* net/loveruby/cflat/asm/Instruction.java: ditto.
* net/loveruby/cflat/asm/AsmOperand.java: ditto.
* net/loveruby/cflat/asm/IndirectMemoryReference.java: ditto.
* net/loveruby/cflat/asm/IntegerLiteral.java: ditto.
* net/loveruby/cflat/asm/Literal.java: ditto.
* net/loveruby/cflat/asm/BaseSymbol.java: ditto.
* net/loveruby/cflat/asm/SuffixedSymbol.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4100 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 13:27:54 +00:00
Minero Aoki 278c5bea47 * net/loveruby/cflat/compiler/LocalReferenceResolver.java -> LocalResolver.java
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4099 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 08:13:47 +00:00
Minero Aoki 545515b5e0 * net/loveruby/cflat/ast/ToplevelScope.java: use SemanticException instead of SemanticError for duplicated declarations/definitions.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4098 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 08:09:20 +00:00
Minero Aoki 1524d3d719 * test: test declaration override.
* test/run.sh: new option --help.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4096 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-07 07:56:00 +00:00
Minero Aoki 96fb88ec26 * net/loveruby/cflat/compiler/CodeGenerator.java: refactoring: reduce lvar.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4091 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-24 09:49:31 +00:00
Minero Aoki 234bd96642 * net/loveruby/cflat/compiler/TypeResolver.java: an array on the parameter list is a pointer really.
* 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
2008-11-16 14:57:11 +00:00
Minero Aoki 1f47ab6771 * net/loveruby/cflat/compiler/TypeResolver.java: "f = puts" implies "f = &puts", adjust type for such expressions.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4088 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-16 13:29:35 +00:00
Minero Aoki 3bf172e272 * net/loveruby/cflat/compiler/Compiler.java: make compiler mode enum.
* net/loveruby/cflat/compiler/Options.java: ditto.
* net/loveruby/cflat/compiler/SourceFile.java: ditto.
* net/loveruby/cflat/compiler/CompilerMode.java: new enum.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4086 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-16 12:28:02 +00:00
Minero Aoki 83dcd37243 * net/loveruby/cflat/compiler/DereferenceChecker.java: We do not need to check an OpAssignNode as operator, because this class only check references.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4085 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-16 11:20:19 +00:00
Minero Aoki 89c7decdad * net/loveruby/cflat/compiler/CodeGenerator.java (compileAST): should not generate .data section when no global variable is defined.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4083 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-16 11:11:01 +00:00
Minero Aoki aa030b42b7 * net/loveruby/cflat/compiler/CodeGenerator.java: should access file-local gvar directly (with @GOTOFF) in PIE.
* net/loveruby/cflat/ast/Entity.java: all entities should have memref or address.
* 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/DefinedFunction.java: ditto.
* import/stdlib.hb: add new declarations.
* import/unistd.hb: add new declarations.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4082 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-16 11:01:10 +00:00
Minero Aoki 6b24625a87 * net/loveruby/cflat/compiler/Options.java: new option --readonly-plt.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4076 1b9489fe-b721-0410-924e-b54b9192deb8
2008-11-02 09:27:05 +00:00
Minero Aoki 2d0babf4c4 * bin/cbc: resolve symbolic link to command file.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4074 1b9489fe-b721-0410-924e-b54b9192deb8
2008-10-25 22:04:56 +00:00
Minero Aoki dd5d3dd4f0 * name code symbols lazily.
* 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
2008-10-24 18:40:21 +00:00
Minero Aoki 11e6f1ab64 * net/loveruby/cflat/ast/*.java: minimize references to asm/*.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4071 1b9489fe-b721-0410-924e-b54b9192deb8
2008-10-24 14:03:31 +00:00
Minero Aoki cd37fb1f02 * convert all source codes to Java 5 using generics and foreach stmt.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4067 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-28 18:46:56 +00:00
Minero Aoki 9003c4fd72 * net/loveruby/cflat/compiler/Options.java (getOutputFileName): should use outputFileName always when linking, output file of linking is always 1 file.
* net/loveruby/cflat/compiler/Options.java: fixes compile error: new method #isGeneratingPIE.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4066 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-27 22:19:48 +00:00
Minero Aoki 1d35dd1665 * net/loveruby/cflat/compiler/Compiler.java: implement -shared.
* net/loveruby/cflat/compiler/Options.java: new option -shared.
* net/loveruby/cflat/compiler/CodeGeneratorOptions.java: ditto.
* net/loveruby/cflat/compiler/SourceFile.java: new method #linkedFileName.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4065 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-27 22:07:04 +00:00
Minero Aoki 69862827dc * implement PIC generation.
* 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
2008-09-27 20:07:49 +00:00
Minero Aoki f94faf7fde * net/loveruby/cflat/compiler/CodeGenerator.java: remove unused labels.
* net/loveruby/cflat/asm/AsmStatistics.java: collect label usage.
* net/loveruby/cflat/asm/DirectMemoryReference.java: support collectStatistics.
* net/loveruby/cflat/asm/Literal.java: ditto.
* net/loveruby/cflat/asm/LabelRef.java: ditto.
* net/loveruby/cflat/asm/IntegerLiteral.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4054 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-23 16:10:42 +00:00
Minero Aoki df96fa80c7 * net/loveruby/cflat/asm/PeepholeOptimizer.java: unify insn optimization and jump elimination.
* net/loveruby/cflat/utils/ClonableIterator.java -> Cursor.java
* net/loveruby/cflat/compiler/Options.java: use default optimization rule set for -O.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4052 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-23 15:48:39 +00:00
Minero Aoki 637fce5053 * net/loveruby/cflat/compiler/CodeGenerator.java: apply jump elimination.
* 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
2008-09-23 13:50:54 +00:00
Minero Aoki 9fcae829f5 * lib/Makefile: parameterize.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4047 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-23 13:45:03 +00:00
Minero Aoki 6a847efed7 * unit: new unit test suite.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4045 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-23 11:42:44 +00:00
Minero Aoki 6164216de3 * test/div.cb: test %esi usage.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4044 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-21 16:45:52 +00:00
Minero Aoki 8f3e39031a * net/loveruby/cflat/ast/Function.java: refactoring: new method #label.
* net/loveruby/cflat/compiler/CodeGenerator.java (prologue): omit loop when no-verboseAsm.
* test: check "puts = NULL" and "stdin = NULL" are compilable (of course "puts = NULL" causes segv).


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4043 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-21 09:14:34 +00:00
Minero Aoki 81bbba45af * net/loveruby/cflat/compiler/CodeGenerator.java: lhs.memref may be null when lhs is extern variable.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4042 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-21 08:22:48 +00:00
Minero Aoki 556d917fff * net/loveruby/cflat/compiler/CodeGenerator.java: optimize constant load.
* net/loveruby/cflat/asm/ImmediateValue.java: accept any Literal.
* net/loveruby/cflat/ast/LiteralNode.java: new method #asmLiteral.
* net/loveruby/cflat/ast/CastNode.java: is not constant when cast is effective.
* net/loveruby/cflat/compiler/Compiler.java: new option --verbose-asm.
* net/loveruby/cflat/compiler/Options.java: ditto.
* net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
* net/loveruby/cflat/asm/Assembler.java: new method #indentComment, #unindentComment.
* net/loveruby/cflat/asm/AsmComment.java: indent comments.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4041 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-20 20:43:34 +00:00
Minero Aoki 1668b72403 * net/loveruby/cflat/compiler/CodeGenerator.java: fix local variables offset after compiling function body, to allow saving really-used callee-saved registers only.
* net/loveruby/cflat/asm/IndirectMemoryReference.java: allow fixing offset out of consructor.
* net/loveruby/cflat/asm/AsmStatistics.java: new class.
* net/loveruby/cflat/asm/Assembly.java: support #collectStatistics.
* net/loveruby/cflat/asm/Instruction.java: ditto.
* net/loveruby/cflat/asm/AsmOperand.java: ditto.
* net/loveruby/cflat/asm/Register.java: ditto.
* net/loveruby/cflat/asm/AbsoluteAddress.java: ditto.
* net/loveruby/cflat/asm/DirectMemoryReference.java: ditto.
* net/loveruby/cflat/asm/ImmediateValue.java: ditto.
* net/loveruby/cflat/ast/Scope.java: refactoring: rename method: #allChildren -> #allScopes.
* net/loveruby/cflat/ast/Scope.java (allScopes): should include receiver scope itself.
* net/loveruby/cflat/ast/LocalScope.java (allVariables): did not wrongly included current scope's variables.
* net/loveruby/cflat/ast/LocalScope.java: refactoring: rename method: allVariables -> allLocalVariables.
* net/loveruby/cflat/ast/DefinedFunction.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4040 1b9489fe-b721-0410-924e-b54b9192deb8
2008-09-20 18:04:20 +00:00
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
Minero Aoki 14722b9d49 * build.xml: test entry point is now run.sh.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3969 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-29 08:12:21 +00:00
Minero Aoki 13e2116602 * test/Makefile: testing entry point is run.sh.
* test/shunit.sh: add "shunit_" prefix for all internal functions.
* test/run.sh: load test_*.sh to support multiple test case files.
* test/run.sh: accept command line arguments as test case files.
* test/test.sh -> test/test_cbc.sh
* test/test2.cb -> test/syntax1.cb
* test/test3.cb -> test/syntax2.cb
* test/test4.cb -> test/syntax3.cb


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3968 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-29 08:05:09 +00:00
Minero Aoki 40720e76cf * net/loveruby/cflat/compiler/CodeGenerator.java: should handle global string literal.
* net/loveruby/cflat/asm/Assembler.java (_long, _quad): should handle label.
* test/run.sh: new test runner.
* test/shunit.sh: library function name must not start with "test_" because they are treated as test case definition.
* test/test.sh: split tests in to multiple functions.
* test/initializer.cb: test string initializer.
* test/comm.cb: ditto.
* test/scomm.cb: ditto.
* test/slvar.cb: ditto.
* test/gvar.cb: ditto.
* test/sgvar.cb: ditto.
* test/slcomm.cb: : ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3967 1b9489fe-b721-0410-924e-b54b9192deb8
2008-08-29 07:35:31 +00:00