Skip to content

Commit 6d840b9

Browse files
committed
improve code
1 parent 2deacd6 commit 6d840b9

75 files changed

Lines changed: 2062 additions & 3180 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/hulo-repl/exec/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"fmt"
88

99
"github.com/hulo-lang/hulo/internal/config"
10-
"github.com/hulo-lang/hulo/internal/transpiler/bash"
10+
transpiler "github.com/hulo-lang/hulo/internal/transpiler/vbs"
1111
"github.com/hulo-lang/hulo/internal/vfs"
1212
"github.com/hulo-lang/hulo/internal/vfs/memvfs"
1313
)

internal/compiler/compiler.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,23 @@ func Compile(cfg *config.Huloc, fs vfs.VFS) error {
8787

8888
for _, nodes := range transpiler.UnresolvedSymbols() {
8989
for _, node := range nodes {
90-
ld.Read(node.AST.Path)
91-
linkable := ld.Load(node.AST.Path)
92-
symbol := linkable.Lookup(node.AST.Symbol)
90+
err := ld.Read(node.Source())
91+
if err != nil {
92+
return err
93+
}
94+
linkable := ld.Load(node.Source())
95+
symbol := linkable.Lookup(node.Name())
9396
if symbol == nil {
94-
return fmt.Errorf("symbol %s not found in %s", node.AST.Symbol, node.AST.Path)
97+
return fmt.Errorf("symbol %s not found in %s", node.Name(), node.Source())
98+
}
99+
err = node.Link(symbol)
100+
if err != nil {
101+
return err
95102
}
96-
// node.Node.Val = symbol.Text()
97103
}
98104
}
99105

100-
// 写文件
106+
// 写文件,打包到 ouput_dir 里面,然后include exclude也要处理
101107
}
102108

103109
return nil

internal/config/bash.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// Copyright 2025 The Hulo Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package config
56

67
// BashOptions is the configuration for the Bash compiler.
78
type BashOptions struct {
8-
MultiString string `yaml:"multi_string"`
9-
BooleanFormat string `yaml:"boolean_format" validate:"oneof=number string command"`
9+
MultiString string `yaml:"multi_string"`
10+
BoolFormat string `yaml:"bool_format" validate:"oneof=number string command"`
1011
}
1112

1213
func DefaultBashOptions() *BashOptions {
1314
return &BashOptions{
14-
MultiString: "off",
15-
BooleanFormat: "number",
15+
MultiString: "off",
16+
BoolFormat: "number",
1617
}
1718
}

internal/config/batch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
// Copyright 2025 The Hulo Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package config
56

67
// BatchOptions is the configuration for the Batch compiler.
78
type BatchOptions struct {
89
CommentSyntax string `yaml:"comment_syntax" validate:"oneof=rem double_colon"`
910
BoolFormat string `yaml:"bool_format" validate:"oneof=number string cmd"`
11+
ExtFileName string `yaml:"ext_file_name" validate:"oneof=.bat .cmd"`
1012
}
1113

1214
func DefaultBatchOptions() *BatchOptions {
1315
return &BatchOptions{
1416
CommentSyntax: "rem",
1517
BoolFormat: "number",
18+
ExtFileName: ".bat",
1619
}
1720
}

internal/config/dependency.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2025 The Hulo Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package config
26

37
type Dependency struct {

internal/config/huloc.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2025 The Hulo Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package config
56

67
import "github.com/go-playground/validator/v10"
@@ -35,9 +36,10 @@ func (c *Huloc) Validate() error {
3536

3637
// CompilerOptions is the configuration for the compiler.
3738
type CompilerOptions struct {
38-
Bash *BashOptions `yaml:"bash"`
39-
Batch *BatchOptions `yaml:"batch"`
40-
VBScript *VBScriptOptions `yaml:"vbs"`
39+
Bash *BashOptions `yaml:"bash"`
40+
Batch *BatchOptions `yaml:"batch"`
41+
VBScript *VBScriptOptions `yaml:"vbs"`
42+
Pwsh *PowerShellOptions `yaml:"pwsh"`
4143
}
4244

4345
func DefaultCompilerOptions() CompilerOptions {

internal/config/huloc_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2025 The Hulo Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package config_test
56

67
import (

internal/config/hulorc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2025 The Hulo Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package config
56

67
const HuloRCFileName = "hulorc.yaml"

internal/config/package.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2025 The Hulo Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package config
56

67
const HuloPkgFileName = "hulo.pkg.yaml"

internal/config/pwsh.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2025 The Hulo Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package config
6+
7+
type PowerShellOptions struct{}
8+
9+
func DefaultPowerShellOptions() *PowerShellOptions {
10+
return &PowerShellOptions{}
11+
}

0 commit comments

Comments
 (0)