montyscoconut / moco Goto Github PK
View Code? Open in Web Editor NEWThe Monty to LLVM compiler
Home Page: http://www.informatik.uni-bremen.de/monty/
License: GNU General Public License v3.0
The Monty to LLVM compiler
Home Page: http://www.informatik.uni-bremen.de/monty/
License: GNU General Public License v3.0
In many cases the exception classes do not receive an ASTNode object, therefore the error reporting can not provide a line number of the error (which is not very helpful in many cases):
ResolveVisitor caught error in null: ...
instead of
ResolveVisitor caught error in line 7, char 13: ...
The problem is that those exceptions are thrown inside the Scope class, which does not have any node objects associated, thus there is no node to pass to the exception object.
Any suggestions are appreciated.
Code generation for if-Statements seems broken. The following code produces the lli error
lli: C:\Users\Simon\Documents\Java\moco\target\test-classes\testPrograms\if.ll:110:1: error: expected instruction opcode
print(foo(true))
print(foo(false))
String foo(Bool cond):
if cond:
return "a"
else:
return "b"
Generated code:
define i8* @M.if.F.foo$M.std.C.String$M.Bool.C.Bool(%M.Bool.C.Bool* %M.if.V.cond$M.Bool.C.Bool) {
entry:
%_unnamed_0 = getelementptr inbounds %M.Bool.C.Bool* %M.if.V.cond$M.Bool.C.Bool, i32 0,i32 1
%_unnamed_1 = load i1* %_unnamed_0
br i1 %_unnamed_1, label %if0.true, label %if0.false
if0.true:
ret i8* getelementptr inbounds ([2 x i8]* @.0, i32 0, i32 0)
br label %if0.end
if0.false:
ret i8* getelementptr inbounds ([2 x i8]* @.1, i32 0, i32 0)
br label %if0.end
if0.end:
}
I'm not sure wether this applies to the current master but the code generation for if-statements seems not to have changed recently.
For some time now a new LLVM version is available: http://llvm.org/releases/.
We might need to update to that version (LLVM 3.7).
I started some time ago, but am not doing it actively right now. See https://github.com/lummax/moco/tree/llvm-upgrade.
I encountered a bug in the current master revision of the Monty compiler (although this also seems to be broken in earlier versions). The following Monty input program produces an EmptyStackException in the CodeGenerationVisitor:
class Person:
+ Int age():
return 8
Int x := Person().age()
While the following Monty program works fine:
class Person:
+ Int age():
return 8
Person p := Person()
Int x := p.age()
It seems like expressions which are not assigned to a variable are not correctly pushed to the stack. The corresponding stack trace looks like the following:
java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at java.util.Stack.pop(Stack.java:84)
at de.uni.bremen.monty.moco.visitor.CodeGenerationVisitor.visit(CodeGenerationVisitor.java:200)
at de.uni.bremen.monty.moco.ast.statement.Assignment.visit(Assignment.java:84)
at de.uni.bremen.monty.moco.visitor.BaseVisitor.visitDoubleDispatched(BaseVisitor.java:72)
at de.uni.bremen.monty.moco.visitor.CodeGenerationVisitor.visit(CodeGenerationVisitor.java:191)
at de.uni.bremen.monty.moco.ast.Block.visit(Block.java:106)
at de.uni.bremen.monty.moco.visitor.BaseVisitor.visitDoubleDispatched(BaseVisitor.java:72)
at de.uni.bremen.monty.moco.ast.declaration.ModuleDeclaration.visitChildren(ModuleDeclaration.java:99)
at de.uni.bremen.monty.moco.visitor.BaseVisitor.visit(BaseVisitor.java:128)
at de.uni.bremen.monty.moco.ast.Package.visitChildren(Package.java:77)
at de.uni.bremen.monty.moco.visitor.BaseVisitor.visit(BaseVisitor.java:425)
at de.uni.bremen.monty.moco.visitor.CodeGenerationVisitor.visit(CodeGenerationVisitor.java:179)
at de.uni.bremen.monty.moco.ast.Package.visitChildren(Package.java:74)
at de.uni.bremen.monty.moco.visitor.BaseVisitor.visit(BaseVisitor.java:425)
at de.uni.bremen.monty.moco.visitor.CodeGenerationVisitor.visit(CodeGenerationVisitor.java:174)
at de.uni.bremen.monty.moco.ast.Package.visit(Package.java:68)
at de.uni.bremen.monty.moco.visitor.BaseVisitor.visitDoubleDispatched(BaseVisitor.java:72)
at de.uni.bremen.monty.moco.Main.visitVisitors(Main.java:127)
at de.uni.bremen.monty.moco.Main.main(Main.java:246)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.