Commit Graph

18 Commits

Author SHA1 Message Date
Minero Aoki 3b29c039bd r4865@macbookpro: aamine | 2009-05-18 03:02:28 +0900
* net/loveruby/cflat/parser/Parser.jj: change function pointer syntax: int(*)(int,int) -> int(int,int)*.  Function type is int(int,int).
 * net/loveruby/cflat/parser/Parser.jj: function returns function type, not pointer to function.
 * net/loveruby/cflat/compiler/TypeResolver.java: resolve all function headers first, then resolve bodies.
 * net/loveruby/cflat/compiler/TypeResolver.java: generate a pointer for array-type expression.
 * net/loveruby/cflat/compiler/TypeResolver.java: isDereferable -> isPointer.
 * net/loveruby/cflat/compiler/TypeChecker.java: ditto.
 * net/loveruby/cflat/compiler/DereferenceChecker.java: ditto.
 * net/loveruby/cflat/compiler/IRGenerator.java: ditto.
 * net/loveruby/cflat/compiler/IRGenerator.java: shouldEvaluatedToAddress -> isLoadable (check arrays and functions, not only arrays).
 * net/loveruby/cflat/type/Type.java: remove #isDereferable.
 * net/loveruby/cflat/type/UserType.java: ditto.
 * net/loveruby/cflat/type/ArrayType.java: is not a scalar.
 * net/loveruby/cflat/type/ArrayType.java: is not dereferable itself.
 * net/loveruby/cflat/type/PointerType.java: is incompatible with arrays.
 * net/loveruby/cflat/type/IntegerType.java: ditto.
 * net/loveruby/cflat/type/FunctionType.java: is callable.
 * net/loveruby/cflat/type/ParamTypeRefs.java: x[] -> x* for param types.
 * net/loveruby/cflat/type/TypeTable.java: new method #getParamType.
 * net/loveruby/cflat/ast/ExprNode.java: new method #isLvalue.
 * net/loveruby/cflat/ast/ExprNode.java: new method #isAssignable.
 * net/loveruby/cflat/ast/ExprNode.java: new method #isLoadable.
 * net/loveruby/cflat/ast/CastNode.java: delegate them.
 * net/loveruby/cflat/ast/LHSNode.java: new super class of LHS nodes.
 * net/loveruby/cflat/ast/VariableNode.java: ditto.
 * net/loveruby/cflat/ast/DereferenceNode.java: 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/entity/Entity.java: remove #cannotLoad.
 * net/loveruby/cflat/entity/Function.java: ditto.
 * net/loveruby/cflat/entity/Variable.java: ditto.
 * net/loveruby/cflat/entity/Constant.java: ditto.
 * net/loveruby/cflat/ir/Addr.java: is not LHS node now.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4220 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-17 18:35:02 +00:00
Minero Aoki 0b3098612a * now IR nodes are separated from AST. Sources are compilable but not tested yet.
* ir/*: new classes.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4154 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 13:08:40 +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 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 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 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 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 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 cf1b3c39a8 * net/loveruby/cflat/ast/MemberNode.java: #name -> #member.
* net/loveruby/cflat/ast/PtrMemberNode.java: #name -> #member.
* net/loveruby/cflat/compiler/TypeChecker.java: follow changes.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3805 1b9489fe-b721-0410-924e-b54b9192deb8
2008-01-05 04:24:00 +00:00
Minero Aoki 8ca82908c1 * net/loveruby/cflat/ast/ExprNode.java: has all LHSNode methods.
* net/loveruby/cflat/ast/LHSNode.java: removed (methods merged into ExprNode).
* net/loveruby/cflat/ast/CastNode.java: should implement #isConstantAddress.
* net/loveruby/cflat/ast/DereferenceNode.java: does not implement LHSNode.
* 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/VariableNode.java: ditto.
* net/loveruby/cflat/ast/LiteralNode.java: ditto.
* net/loveruby/cflat/compiler/CodeGenerator.java: cast not needed.
* test/cast3.cb: test cast on LHS.
* test/test.sh: run it.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3802 1b9489fe-b721-0410-924e-b54b9192deb8
2008-01-05 03:52:41 +00:00
Minero Aoki 879738ba62 * net/loveruby/cflat/ast/Node.java: all nodes must contain Location.
* 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
2008-01-05 01:34:27 +00:00
Minero Aoki 132e4cbbb2 * net/loveruby/cflat/compiler/Compiler.java: implement command line option --dump-ast.
* net/loveruby/cflat/compiler/Compiler.java: implement command line option --dump-tokens.
* net/loveruby/cflat/ast/Dumper.java: new class; AST dumper.
* net/loveruby/cflat/ast/Dumpable.java: new interface; AST dumper interface.
* net/loveruby/cflat/ast/*.java: define #dump, #_dump.
* net/loveruby/cflat/asm/Assembler.java: fork utils/TextUtils.java.
* net/loveruby/cflat/utils/TextUtils.java: new file.
* test/stdlib.hb: new header file.
* test/unistd.hb: new header file.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3787 1b9489fe-b721-0410-924e-b54b9192deb8
2008-01-03 23:01:49 +00:00
Minero Aoki 5b61b2f529 * net/loveruby/cflat/compiler/TypeChecker.java: try semantic check and catch semantic errors (mainly thrown from *Node#type).
* net/loveruby/cflat/exception/SemanticError.java: new class.
* net/loveruby/cflat/type/ComplexType.java: throw SemanticError when no member found.
* net/loveruby/cflat/type/Type.java: #baseType throw SemanticError instead of Error.
* net/loveruby/cflat/ast/FuncallNode.java: convert ClassCastException to SemanticError.
* net/loveruby/cflat/ast/PtrMemberNode.java: ditto.
* net/loveruby/cflat/ast/MemberNode.java: ditto.
* net/loveruby/cflat/type/TypeTable.java: check recursive typedef.
* net/loveruby/cflat/type/TypeTable.java: validate array/struct/union does not contain void.
* net/loveruby/cflat/type/UserType.java: #real -> #realType.
* test/struct-semcheck8.cb: test 1.memb.
* test/union-semcheck8.cb: test (1+"str").memb.
* test/Makefile: build them.
* test/test.sh: run them.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3781 1b9489fe-b721-0410-924e-b54b9192deb8
2008-01-03 14:31:26 +00:00
Minero Aoki 9915a036dc * net/loveruby/cflat/compiler/TypeChecker.java: <<, >> does not require same type of integers. 2 types of integers are OK.
* 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
2008-01-03 11:26:07 +00:00
Minero Aoki e3282566a4 * introduce ExprNode class for all expression nodes.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3773 1b9489fe-b721-0410-924e-b54b9192deb8
2008-01-02 11:53:41 +00:00
Minero Aoki 16a2210512 * net/loveruby/cflat/compiler/TypeChecker.java: check &expr is assignable.
* 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
2008-01-02 10:46:28 +00:00
Minero Aoki dd209e191b import cbc from stdcompiler repository (rev185)
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3753 1b9489fe-b721-0410-924e-b54b9192deb8
2007-12-24 08:19:51 +00:00