-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (52 loc) · 1.62 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"github.com/Jamlie/Jamlang/jamlang"
"github.com/Jamlie/Jamlang/runtimelang"
)
var (
env = runtimelang.CreateGlobalEnvironment()
)
func main() {
jamlang.CallMain(env)
}
/*
{
class := ClassValue{
Name: expr.Name,
Methods: make(map[string]FunctionValue),
}
for _, method := range expr.Body {
if method.Kind() == ast.FunctionDeclarationType {
method := method.(*ast.FunctionDeclaration)
if method.Name == "constructor" {
class.Constructor = FunctionValue{
Name: method.Name,
Parameters: method.Parameters,
Body: method.Body,
DeclarationEnvironment: *env,
}
continue
}
class.Methods[method.Name] = FunctionValue{
Name: method.Name,
Parameters: method.Parameters,
Body: method.Body,
DeclarationEnvironment: *env,
}
env.DeclareVariable(method.Name, class.Methods[method.Name], true)
} else if method.Kind() == ast.VariableDeclarationType {
method := method.(*ast.VariableDeclaration)
value, err := Evaluate(method.Value, *env)
if err != nil {
return MakeNullValue(), err
}
env.DeclareVariable(method.Identifier, value, true)
continue
} else {
return MakeNullValue(), fmt.Errorf("invalid method declaration")
}
}
env.DeclareVariable(expr.Name, class.Constructor, true)
return MakeNullValue(), nil
}
*/