Refactored code structure
This commit is contained in:
19
src/build/core/CompileAssign.go
Normal file
19
src/build/core/CompileAssign.go
Normal file
@ -0,0 +1,19 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/build/ast"
|
||||
"git.akyoto.dev/cli/q/src/build/errors"
|
||||
)
|
||||
|
||||
// CompileAssign compiles an assign statement.
|
||||
func (f *Function) CompileAssign(node *ast.Assign) error {
|
||||
name := node.Name.Text()
|
||||
variable, exists := f.variables[name]
|
||||
|
||||
if !exists {
|
||||
return errors.New(&errors.UnknownIdentifier{Name: name}, f.File, node.Name.Position)
|
||||
}
|
||||
|
||||
defer f.useVariable(variable)
|
||||
return f.Execute(node.Operator, variable.Register, node.Value)
|
||||
}
|
Reference in New Issue
Block a user