Skip to content

Commit

Permalink
UniByteLiteralとUniCharacterLiteral追加
Browse files Browse the repository at this point in the history
  • Loading branch information
RYOSKATE committed Jul 15, 2016
1 parent 73cb694 commit d3d4c67
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 4 deletions.
4 changes: 3 additions & 1 deletion UniNodeGenerator/lib/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def write_equals(dsl, node, w)
"(#{name} ? 1 : 0)"
when /int/
name
when /byte|char/
"(int)#{name}"
when /long/
"(int)(#{name}^(#{name}>>32))"
when /double/
Expand Down Expand Up @@ -275,7 +277,7 @@ def write_merge(dsl, node, w)
w.block "if (that.#{name})" do
w << "this.#{name} = true;"
end
when /int|long|double|float/
when /int|long|double|float|byte|char/
w.block "if (that.#{name} != 0)" do
w << "this.#{name} = that.#{name};"
end
Expand Down
6 changes: 3 additions & 3 deletions UniNodeGenerator/node_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"Int" => :int,
"Long" => :long,
"Double" => :double,
"String" => String
# "Byte" => :byte,
# "Character" => :char
"String" => String,
"Byte" => :byte,
"Character" => :char
}.each do |name, type|
x.node "#{name}Literal" do |d|
d.mem "value", type
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/net/unicoen/generator/DolittleGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import net.unicoen.node.UniBlock;
import net.unicoen.node.UniBoolLiteral;
import net.unicoen.node.UniBreak;
import net.unicoen.node.UniByteLiteral;
import net.unicoen.node.UniCast;
import net.unicoen.node.UniCharacterLiteral;
import net.unicoen.node.UniClassDec;
import net.unicoen.node.UniContinue;
import net.unicoen.node.UniDoWhile;
Expand Down Expand Up @@ -397,5 +399,17 @@ public void traverseEnumConstant(UniEnumConstant node) {

}

@Override
public void traverseByteLiteral(UniByteLiteral node) {
// TODO Auto-generated method stub

}

@Override
public void traverseCharacterLiteral(UniCharacterLiteral node) {
// TODO Auto-generated method stub

}


}
14 changes: 14 additions & 0 deletions src/main/java/net/unicoen/generator/JavaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import net.unicoen.node.UniBlock;
import net.unicoen.node.UniBoolLiteral;
import net.unicoen.node.UniBreak;
import net.unicoen.node.UniByteLiteral;
import net.unicoen.node.UniCast;
import net.unicoen.node.UniCharacterLiteral;
import net.unicoen.node.UniClassDec;
import net.unicoen.node.UniContinue;
import net.unicoen.node.UniDoWhile;
Expand Down Expand Up @@ -630,5 +632,17 @@ public void traverseEnumConstant(UniEnumConstant node) {

}

@Override
public void traverseByteLiteral(UniByteLiteral node) {
// TODO Auto-generated method stub

}

@Override
public void traverseCharacterLiteral(UniCharacterLiteral node) {
// TODO Auto-generated method stub

}


}
14 changes: 14 additions & 0 deletions src/main/java/net/unicoen/generator/JavaToSwiftTreeConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import net.unicoen.node.UniBlock;
import net.unicoen.node.UniBoolLiteral;
import net.unicoen.node.UniBreak;
import net.unicoen.node.UniByteLiteral;
import net.unicoen.node.UniCast;
import net.unicoen.node.UniCharacterLiteral;
import net.unicoen.node.UniClassDec;
import net.unicoen.node.UniContinue;
import net.unicoen.node.UniDoWhile;
Expand Down Expand Up @@ -555,5 +557,17 @@ public void traverseEnumConstant(UniEnumConstant node) {

}

@Override
public void traverseByteLiteral(UniByteLiteral node) {
// TODO Auto-generated method stub

}

@Override
public void traverseCharacterLiteral(UniCharacterLiteral node) {
// TODO Auto-generated method stub

}


}
14 changes: 14 additions & 0 deletions src/main/java/net/unicoen/generator/SwiftCodeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import net.unicoen.node.UniBlock;
import net.unicoen.node.UniBoolLiteral;
import net.unicoen.node.UniBreak;
import net.unicoen.node.UniByteLiteral;
import net.unicoen.node.UniCast;
import net.unicoen.node.UniCharacterLiteral;
import net.unicoen.node.UniClassDec;
import net.unicoen.node.UniContinue;
import net.unicoen.node.UniDoWhile;
Expand Down Expand Up @@ -893,5 +895,17 @@ else if(num>=2){
}
}

@Override
public void traverseByteLiteral(UniByteLiteral node) {
// TODO Auto-generated method stub

}

@Override
public void traverseCharacterLiteral(UniCharacterLiteral node) {
// TODO Auto-generated method stub

}


}
10 changes: 10 additions & 0 deletions src/main/java/net/unicoen/node/Traverser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public abstract class Traverser {
public abstract void traverseLongLiteral(UniLongLiteral node);
public abstract void traverseDoubleLiteral(UniDoubleLiteral node);
public abstract void traverseStringLiteral(UniStringLiteral node);
public abstract void traverseByteLiteral(UniByteLiteral node);
public abstract void traverseCharacterLiteral(UniCharacterLiteral node);
public abstract void traverseIdent(UniIdent node);
public abstract void traverseArray(UniArray node);
public abstract void traverseFieldAccess(UniFieldAccess node);
Expand Down Expand Up @@ -61,6 +63,14 @@ public final void traverseExpr(UniExpr node) {
traverseStringLiteral((UniStringLiteral)node);
return;
}
if (node instanceof UniByteLiteral) {
traverseByteLiteral((UniByteLiteral)node);
return;
}
if (node instanceof UniCharacterLiteral) {
traverseCharacterLiteral((UniCharacterLiteral)node);
return;
}
if (node instanceof UniIdent) {
traverseIdent((UniIdent)node);
return;
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/net/unicoen/node/UniByteLiteral.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package net.unicoen.node;
import net.unicoen.node_helper.*;

public class UniByteLiteral extends UniExpr {
public byte value;

public UniByteLiteral() {
}

public UniByteLiteral(byte value) {
this.value = value;
}

@Override
public String toString() {
return "ByteLiteral(" + value + ")";
}

@Override
public int hashCode() {
int result = 17;
result = result * 31 + (int)value;
result = result * 31 + (comments == null ? 0 : comments.hashCode());
result = result * 31 + (codeRange == null ? 0 : codeRange.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof UniByteLiteral)) return false;
UniByteLiteral that = (UniByteLiteral)obj;
return this.value == that.value
&& (this.comments == null ? that.comments == null : this.comments.equals(that.comments))
&& (this.codeRange == null ? that.codeRange == null : this.codeRange.equals(that.codeRange));
}

@Override
public boolean isStatement() {
return false;
}

public void merge(UniByteLiteral that) {
if (that.value != 0) {
this.value = that.value;
}
if (that.comments != null) {
if (this.comments == null) {
this.comments = that.comments;
} else {
this.comments.addAll(that.comments);
}
}
if (that.codeRange != null) {
this.codeRange = that.codeRange;
}
}
}
57 changes: 57 additions & 0 deletions src/main/java/net/unicoen/node/UniCharacterLiteral.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package net.unicoen.node;
import net.unicoen.node_helper.*;

public class UniCharacterLiteral extends UniExpr {
public char value;

public UniCharacterLiteral() {
}

public UniCharacterLiteral(char value) {
this.value = value;
}

@Override
public String toString() {
return "CharacterLiteral(" + value + ")";
}

@Override
public int hashCode() {
int result = 17;
result = result * 31 + (int)value;
result = result * 31 + (comments == null ? 0 : comments.hashCode());
result = result * 31 + (codeRange == null ? 0 : codeRange.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof UniCharacterLiteral)) return false;
UniCharacterLiteral that = (UniCharacterLiteral)obj;
return this.value == that.value
&& (this.comments == null ? that.comments == null : this.comments.equals(that.comments))
&& (this.codeRange == null ? that.codeRange == null : this.codeRange.equals(that.codeRange));
}

@Override
public boolean isStatement() {
return false;
}

public void merge(UniCharacterLiteral that) {
if (that.value != 0) {
this.value = that.value;
}
if (that.comments != null) {
if (this.comments == null) {
this.comments = that.comments;
} else {
this.comments.addAll(that.comments);
}
}
if (that.codeRange != null) {
this.codeRange = that.codeRange;
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/net/unicoen/parser/blockeditor/BlockGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import net.unicoen.node.UniBlock;
import net.unicoen.node.UniBoolLiteral;
import net.unicoen.node.UniBreak;
import net.unicoen.node.UniByteLiteral;
import net.unicoen.node.UniCast;
import net.unicoen.node.UniCharacterLiteral;
import net.unicoen.node.UniClassDec;
import net.unicoen.node.UniContinue;
import net.unicoen.node.UniDoWhile;
Expand Down Expand Up @@ -1186,6 +1188,18 @@ public void traverseEnumConstant(UniEnumConstant node) {

}

@Override
public void traverseByteLiteral(UniByteLiteral node) {
// TODO Auto-generated method stub

}

@Override
public void traverseCharacterLiteral(UniCharacterLiteral node) {
// TODO Auto-generated method stub

}




Expand Down

0 comments on commit d3d4c67

Please sign in to comment.